Classifier outputs only the shared pose set
All checks were successful
Build pull request / Build pull request (pull_request) Successful in 3m30s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Void 2026-11-11 12:18:31 +00:00
commit 7c97b79956
2 changed files with 6 additions and 7 deletions

View file

@ -3,14 +3,13 @@ import { classifyPose, messagePose } from './sentiment';
describe('classifyPose', () => {
it.each([
['concerned', 'Sorry, that build failed with an error'],
['annoyed', 'ugh, this again'],
['surprised', 'wow, no way'],
['determined', "on it, I'll fix that"],
['amused', 'hahaha that is funny'],
['happy', 'thanks, great work'],
['thinking', 'should we ship it?'],
['neutral', 'Merged the branch.'],
['neutral', 'sorry, that failed with an error'],
])('%s', (label, text) => expect(classifyPose(text)).toBe(label));
it('is neutral for empty or non-string text', () => {
expect(classifyPose('')).toBe('neutral');
@ -33,9 +32,8 @@ describe('messagePose', () => {
'neutral'
);
});
it('classifies when there is no label, and drops labels the Mind lacks', () => {
it('classifies when there is no label, and never outputs a signature label', () => {
expect(messagePose('aqua', { body: 'thanks!' })).toBe('happy');
expect(messagePose('aqua', { body: 'sorry' })).toBe('concerned');
expect(messagePose('kiko', { body: 'sorry' })).toBe('neutral');
expect(messagePose('aqua', {})).toBe('neutral');
});

View file

@ -1,11 +1,12 @@
import { POSE_KEY, NEUTRAL, resolvePose } from './poses';
// catalogue.json beside this file is a vendored copy of /opt/commons/cast-art/poses/catalogue.json
// (npm run sync:poses); nothing else publishes it to the browser.
// Local sentiment -> pose label. A lexicon over the message text, no network, no model: the
// same text always gives the same pose. Rules are tried in order and the first hit wins, so a
// message that says "sorry" and "thanks" reads as concerned. Labels outside a Mind's art fall
// back to neutral in resolvePose, so 'concerned' and 'determined' need no per-Mind table.
// message that says "wow" and "thanks" reads as surprised. Only the shared labels (identical art
// for all eight Minds, catalogue.json) are ever output; signature labels are explicit-only.
const RULES: [string, RegExp][] = [
['concerned', /\b(errors?|sorry|apolog\w+|oops|fail(ed|s|ure)?|broke(n)?|crash\w*|bug)\b/i],
['annoyed', /\b(annoy\w*|ugh+|argh+|frustrat\w*|again\?|why won'?t|stop it)\b/i],
['surprised', /\b(wow|whoa|woah|omg|no way|unexpected\w*|surpris\w*|wait,? what)\b|[?!]{2,}/i],
[