Skip to content

Hook: the miss note covers the autopilot half, says which rule failed, and describes the phrases (T200, T201) - #104

Merged
erickb336 merged 4 commits into
mainfrom
hook/t200-miss-note
Oct 11, 2026
Merged

erickb336 merged 4 commits into
mainfrom
hook/t200-miss-note

Conversation

@erickb336

Copy link
Copy Markdown
Owner

Closes #64
Closes #65

The miss note now fires when a switch the owner asked for did not happen. It names the failed rule in one sentence, describes the phrases instead of quoting them, and ends with "Tell the user." The on rule's trailing-words branch closes the edge cases from the PR #54 reviews.

Finding Fix
QA R704 medium, R702-4 (autopilot half) Sage mode goes on, and the message names autopilot with its on word, but autopilot stays off: the note says autopilot did not switch on. An off word in the same message still wins, with no note.
R708-1, F-R706-2 The note fires when no rule changed the state. A rule that kept the state on purpose gives no note: the on phrase while sage mode is on, the off phrase while it is off, or an autopilot off while autopilot is off.
R702-3 (item 3) The note gives one reason: a question mark on the line; the autopilot phrase without a full stop, comma or line break after it; autopilot outside sage mode; else the words after the phrase match no rule.
QA R704 F4 (T200) The note ends with "Tell the user."
T201, standing order 8 The note describes the phrases (the on phrase, the off phrase and the autopilot phrases). A test checks that it quotes none.
F-R706-1 The off guard also holds after the optional "on" word.
F-R707-1 The question guard takes every question mark: also U+061F, U+2047, U+2048, U+2049, U+FE56 and U+037E.
F-R710-2 An off-meaning word after the phrase blocks the trailing branch: the shared off words, plus "switch" or "turn" followed by off. The on rule reads a folded text: with no format characters (soft hyphen, zero-width space) and no combining marks, and with the look-alikes of o and f read as those letters.
F-R710-1 Decision: the trailing-words branch accepts only a plain line (blank lines, then at most 3 spaces). A quote mark, bullet, tab or 4-space indent before the phrase refuses more words. The phrase alone keeps today's wider start.
F-R709-1 A no-note row: the mode phrase and a question mark, then a line with the hand-back marker. With the owner check removed (in core and the hook), only this row fails.
T34 The rule stays linear: the 1 MB padding test has 4 new rows, and they pass.

Codex parity: the Codex adapter reads the same sageOn and sageOff from sage-core, so the rule changes apply to it too. providers.test.mjs checks both bundles. Codex has no miss note, the same as before.

Checks: npm run build built 228 files, npm run check passes all checks, and npm test passes 784 of 784.

🤖 Generated with Claude Code

…, and describes the phrases (T200, T201)

The note fires when a switch the owner asked for did not happen: no rule changed the state, or autopilot named with its on word stayed off. It names the failed rule in one sentence, describes the phrases instead of quoting them, and ends with Tell the user. The on rule's trailing-words branch now refuses an off word after the optional on word, off-meaning words, a hidden or look-alike off, every question mark, and a Markdown quote, list item or indented line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ssed switch names its reason (T200, T201 round 1)

- F-R725-1, F-R724-L1: the on rule folds only the words after the phrase. A look-alike letter, a zero-width space or a combining mark inside the phrase makes it no phrase, as on main. The tail gets NFKD per word (not its punctuation), loses marks and format characters, and maps the Cyrillic and Greek look-alikes and the small capitals.
- F-R725-2: the phrase, then a comma, colon, semicolon or dash, then an off word, no longer turns the mode on.
- Reviewer question: the phrase with an off word next also switches autopilot off, and the note says so.
- F-R724-L2: an off line in an agent's frame no longer hides the autopilot note.
- F-R726-1: an autopilot ask with an off word, "autopilot please" and "and autopilot" get the autopilot note; the note names the reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336

Copy link
Copy Markdown
Owner Author

Repair round 1 (run R727), new head 4ac827d. This comment describes the phrases and does not quote them.

Finding Fix
F-R725-1 (security, medium) and F-R724-L1 (code review, low) The on rule now folds only the words after the phrase, never the phrase itself. A look-alike letter, a zero-width space or a combining mark inside the phrase (or before it) means "no phrase", as on main. The words after the phrase get their compatibility form per word (NFKD, so the marks come off too), then lose marks and format characters, then the Cyrillic and Greek look-alikes and the small capitals become plain letters. So mathematical-bold, circled, full-width and small-capital off words count as off words. The punctuation after the phrase keeps its form, so the full-width exclamation mark rule (F-T72-20) still holds. I chose NFKD over NFKC because NFKC joins a letter and its accent into one character that the mark removal then cannot remove.
F-R725-2 (security, medium) The phrase, then a comma, colon, semicolon or dash, then an off word, no longer turns sage's mode on. The off guard now sits in one place (OFF_AFTER) and covers both forms of the on rule.
Reviewer question (answered by the sage) The phrase with an off word next (in any of the forms above) also switches autopilot off, because off is the safe direction. The note says that sage's mode did not change and that autopilot is off. The exact off phrase keeps its own rules.
F-R724-L2 (code review, low) Only an off in the owner's own text counts as an off that won. An autopilot off line inside an agent's frame still turns autopilot off, but the owner now gets the note, with the reason "an off line in an agent's text won".
F-R726-1 (QA, medium) and the QA lows An autopilot ask that also holds an off word now gets the note "an off word in the message won". Autopilot at the start with another word, and the on phrase with "and autopilot", get the autopilot note. The note names the reason: an off word after the phrase, an off word in the message, an off line in an agent's text, a pasted quote, bullet or indent, a question mark on the line, the strict autopilot phrase, or autopilot outside sage's mode. The note no longer puts the bare mode name in a sentence. The README says "matches no rule, or asks for a switch that does not happen".

Proof: the new test cases fail on the old head ed073bb (4 of 4 tests fail, 38 failing case lines) and pass on the new head. Build, check, the hook and providers test files (314 of 314) pass; the 1 MB padding rows pass, with 4 new rows for the folded tail, the punctuation guard and the autopilot ask. The full npm test under a 900 s alarm passed 784 of 784 (301 s). Fakes for the process tools were first on PATH for every run.

Not merged.

erickb336 and others added 2 commits October 10, 2026 20:42
The on rule's phrase start had no end boundary, so a combining mark or an
invisible format character on the phrase's last letter fell into the folded
tail and was removed. Add a boundary that refuses a letter, a mark, a digit
or a format character next, as on main. Rows for probes A10 to A16 and D13.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336

Copy link
Copy Markdown
Owner Author

Repair round 2 (R735): this closes the last gap of F-R725-1, which the security review R733 found.

What was wrong: the rule that finds the start of the phrase did not check what came right after the last letter of the mode name. A combining accent, a zero-width space, a soft hyphen, a variation selector or a word joiner on that letter fell into the words after the phrase. The fold then removed it, so the on rule matched: the mode turned on and the owner got no note.

The fix: the phrase start now ends with a boundary. A letter, a mark, a digit or an invisible format character next means "not the phrase", as on main. The words after it are not folded, the mode does not turn on, and the owner gets the miss note. The change is one line in packages/sage-core/mode-policy.mjs, plus the rebuilt plugin copies.

Tests: 8 rows (probes A10 to A16 and D13). They cover the accent alone, the accent with more words, the accent in the form with "enter", the four invisible characters, and the accent followed by a comma and the autopilot request. The rows are in the modes table and the note table of scripts/sage-hook.test.mjs, and in scripts/providers.test.mjs for both bundles. They fail on 9d5fdad and pass on ae693a0. The 1 MB padding rows still pass.

Checks: npm run build (228 files) and npm run check (all pass). With a fake ps, pgrep and kill: sage-hook tests 223 of 223, providers tests 91 of 91.

🤖 Generated with Claude Code

@erickb336
erickb336 merged commit 86e2421 into main Oct 11, 2026
1 check passed
@erickb336
erickb336 deleted the hook/t200-miss-note branch October 11, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T201: The miss note describes the phrases instead of quoting them T200: The miss note covers the autopilot half and names the failed rule

1 participant