Skip to content

Mode switch: off wins in every form, and the note names the real cause (T210, T212, T213, T214) - #106

Closed
erickb336 wants to merge 5 commits into
mainfrom
hook/t210-off-rules
Closed

erickb336 wants to merge 5 commits into
mainfrom
hook/t210-off-rules

Conversation

@erickb336

Copy link
Copy Markdown
Owner

Closes #105

The follow-ups of PR #104. Off now wins in each form that the reviews found, and the miss note names the real cause. The on rule keeps PR #104's strict phrase boundary. In this text, "the on phrase" is sage's on phrase and "the autopilot word" is the word autopilot.

Items and fixes

Item Problem on main Fix
T210 An off request a few words after the on phrase (please and stop; turn, it, all and off; can, go and off) turned the mode on. The off guard reads a short window: any gap, then at most 5 small words (please, turn, it, all, can, go, now, just and similar), then an off word. Any other word ends the window, so a request that names an off word later still turns the mode on.
T212 The table form of the on phrase with the autopilot word, then a comma and an off-meaning word, was no autopilot ask: no note. The autopilot ask is blocked only when the off word is the next word after the autopilot word, with spaces only. The note says that an off word won and names it.
T213 Only a comma, colon, semicolon or dash counted before an off word. Any run of spaces, punctuation, symbols and line breaks counts: a full stop, an exclamation mark, an ellipsis, a slash, an open parenthesis, U+2010 and a line break are tested.
T214 A mark or a format character joined to the phrase's last letter (U+0301, U+200B, U+00AD, U+2060, U+FE0F) hid an off word after it: autopilot stayed on. The off signal reads the whole message folded (NFKD, marks, format and invisible characters removed, look-alikes made plain). The on rule still reads the strict phrase.
Invisible letters and look-alikes (R733) U+3164, U+115F, U+2800 inside an off word, and the Cyrillic s, r and a, hid it. The fold removes every default-ignorable character and U+2800. The look-alike table covers each letter of the off words (Cyrillic, Greek, Armenian, small capitals).
Whole words (R733) A stopwatch app, end-to-end tests, a cancellation flow, a killer feature and no rush after the phrase blocked the on. After the phrase, off words match as whole words; a hyphen, a letter or an apostrophe after the stem makes it another word. The off word itself keeps its plain word boundary, so off with a hyphen still blocks the on, as the off line rule reads it.
"no" and "without" "no rush" blocked the on. Both count only alone (before punctuation or the end of the line) or before "more" or "longer". So "no rush" and "without asking" are requests; "no more", "no longer" and a bare "no." are off. The broad off rule anywhere in the owner's text is not changed.
Note: hidden character (R738) A mark or a zero-width space after the phrase gave "the words after the phrase match no rule". The note says that a hidden character, an accent or a look-alike letter is in the phrase or joined to it, and to retype it.
Note: the off word (R738) "an off word won" did not name the word. The note names it in parentheses, for example the stop word or the off word.
Note: autopilot reasons (R732) "and" before the autopilot word, and a word other than on after it, gave the full-stop advice. New reasons: "the word and comes before autopilot" and "autopilot needs the word on right after it".
Long s (R737) The phrase spelt with U+017F got the paste reason, and an off word after it left autopilot on. It gets the hidden-or-look-alike reason; the folded off signal turns autopilot off.
BOM (R737) START and SP read U+FEFF as a space, so a BOM before or after the phrase still switched the mode. A BOM is no space: the phrase with a BOM is no phrase, and it gets the note.
U+0345, U+037A, Arabic presentation forms (R737) Right after the phrase: no switch and no note. The mode word reads the folded text, and a character whose compatibility form starts with a space or a mark counts as joined: the note fires.

Tests

  • scripts/sage-hook.test.mjs: rows for each item in the mode table (on side and, with autopilot on before, the off side), the note table (each new reason, word for word), the noted table, and 5 new 1 MB padding rows (punctuation, small words, invisible letters, a joined mark with BOMs).
  • scripts/providers.test.mjs: the new signals (offWord, joined, autopilotGap) in both isolated bundles, so the Codex adapter reads the same signals.
  • On main (86e2421, a detached worktree, the new test files copied in), the 3 mode tests fail with the new rows and the padding test passes; on this branch all pass.

Every rule stays linear (T34): a probe of each new shape at 100 KB and 1000 KB gives a time ratio of 8.7 to 12.4.

🤖 Generated with Claude Code

erickb336 and others added 4 commits October 10, 2026 22:52
…e (T210, T212, T213, T214)

- T210: an off word after at most 5 small words (please, turn it all, can go) blocks the on rule and turns autopilot off.
- T212: the table form with the autopilot word, a comma and an off word asks for autopilot, so the note says the off word won.
- T213: any punctuation run or a line break between the phrase and an off word counts.
- T214: the off signal reads the whole text folded, so a mark or a format character joined to the phrase cannot hide it.
- Whole off words after the phrase; invisible letters removed; look-alikes for every letter of the off words; a BOM is no space.
- The note names the off word, a hidden character or look-alike at the phrase, "and" before autopilot, and a missing on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e new note reasons (T210)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…differential test (T210 round 1)

- F-R741-1, F-R741-3: the off words soon after the phrase are main's again: no or without and any word, an off word at the start of a longer word, with a hyphen or a typo, and do then not across a line break.
- F-R741-2: turn or switch, one word, then off, also after the small words.
- F-R741-4: the note names an off word only by a fixed name, found in the owner's own text; otherwise it says an off word.
- F-R740-1: a character that the fold removes or changes (default-ignorables, U+2800, symbols that fold into letters, control characters) joined to the phrase makes it no phrase; the off rule also reads it as a space, and a control character may come before the off word.
- The off rules keep main's start and space (a BOM is a space there), and the broad off rule reads the text as it is too.
- The mode tables move to module level; a differential test reads them, the repros of issue 105, the reviewers' forms and a generated set (124547 inputs) against main's rules in scripts/fixtures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…intent words before an off word (T210 round 1)

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

Copy link
Copy Markdown
Owner Author

Repair round 1 (run R743), head 0f982f0. Each finding, and what changed. The phrases are described, not quoted.

  1. F-R741-1 (high). After the on phrase, a word that starts with "no" or "without", followed by any word (for example a polite refusal in any letter case), is an off word again, as on main. The mode does not turn on, autopilot goes off, and the note names the word. A request that starts with "no" or "without" (no hurry, without asking) is now an off too; the note tells the owner. The numero sign (U+2116) joined to the phrase, then an off word, also turns autopilot off.
  2. F-R741-2 (high). "turn" or "switch", one word, then "off" soon after the phrase counts as off again, as on main, also after the small words of the window ("please").
  3. F-R741-3 (medium). The off rule after the phrase uses main's off-word list again: an off word with a hyphen, an apostrophe or a typo after it, joined to more letters, and "do" with a line break before "not", all count as off. A word such as stopwatch or end-to-end blocks the on again, as on main, and gets the note.
  4. F-R741-4 (medium). The note names an off word only by a fixed name from the off-word list (for example "stop", "don't", "kill"), and only when the owner's own text has it. An off word that only a queued message has (which an agent could write) gives "an off word", with no name. A long word gives its fixed stem name, never the typed text.
  5. F-R740-1 (medium) and the lows. A character that the fold removes (the default-ignorables, U+2800) or changes (a symbol that folds into letters: U+2116, U+2100, U+20A8, circled and parenthesized letters), and a control character, joined to the phrase make it no phrase for the on rule, and count as "joined" for the note. The off rule also reads such a character as a space, so an off word after it still turns autopilot off. A control character may come before the off word. A new row covers the broad off rule's fold: a look-alike off word in the middle of the message with the autopilot word turns autopilot off; the mutant without the fold fails it. The README says that intent words before an off word right after the phrase also block the on, and that the note names the word.
  6. The round rule, as a test. The off rules keep main's start and space (where a BOM is a space), and the broad off rule reads the text as it is too. A new differential test compares the shipped rules with main's rules at 86e2421 (byte-for-byte copy in scripts/fixtures/mode-policy-main-86e2421.mjs, so no git is needed at run time). The corpus: every row of the three mode tables, the repros of issue Mode switch: an off request a few words after the on phrase never turns the mode on (PR #104 follow-up) #105, the reviewers' forms, and a generated set (7 heads, 8 gaps, 1 to 3 words of off words, words that mean off, small words, requests and punctuation): 124,548 inputs, each as the owner's message, as an agent's text and as a frame. For each one: when main reads an autopilot off or a mode off, the head does too; and the head never turns the mode or autopilot on where main did not.

Evidence:

  • npm run build: built 228 files. npm run check: all checks pass.
  • node --test scripts/sage-hook.test.mjs (fake ps and kill first on PATH): tests 224, pass 224, fail 0. The 1 MB padding test passes.
  • node --test scripts/providers.test.mjs (fakes first): tests 91, pass 91, fail 0.
  • The same new tests on 1527403 (detached worktree): the 4 mode tests fail. The differential test reports 5,204 of 124,548 inputs where 1527403 is narrower or wider than main. Failing rows by finding: F-R741-1 18, F-R741-2 2, F-R741-3 8, F-R740-1 20, and the note rows for F-R741-4 (1527403 names the queued long word, and the owner's long word as typed).

Behaviour changes to know about: the earlier whole-word rule of this PR is gone. A request that starts with an off-word stem right after the on phrase now blocks the on and gets the note. The round rule decided this: never narrower than main.

🤖 Generated with Claude Code

Both rules hold after the merge:
- Only the owner's own text switches sage mode or autopilot (PR 110, T215):
  autopilotOff is ownOff only; unreadOff, the stray path, the unread note and
  the frame parser stay as on main.
- The owner's off is never narrower than before (PR 106): ownOff keeps the
  small-word window, the fold forms and the as-is form.
- The unread note reads the same wider off forms at the start of any line
  (offAtLines, which replaces OFF_AFTER_LINE), in linear time.
- The differential test against main 86e2421 applies to the owner's text.
  For agent text it now asserts that nothing switches, and that every off
  that main applied in an unreadable prompt still gives the unread note.

PR 106 rows dropped or changed, with the reason:
- providers.test.mjs, the F-R724-L2 row (an agent's off line turns
  autopilot off): replaced by main's T215 row, because agent text switches
  nothing now.
- sage-hook.test.mjs NOTE_TEXT_CASES, the row whose note reason is an off
  line in an agent's text: removed, because that reason no longer exists.
- sage-hook.test.mjs NOTE_CASES, the two F-R724-L2 rows (an agent's off line
  gives the miss note): now expect no note, as on main (T215).
- sage-hook.test.mjs MODE_CASES, the agent report row with off lines: now
  expects autopilot to stay on, as on main (T215).

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

Copy link
Copy Markdown
Owner Author

Closed by the owner's decision (2026-10-11): sage mode and autopilot switch only on an exact phrase, so the free-text off rules here are no longer needed. The replacement is task T240.

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.

Mode switch: an off request a few words after the on phrase never turns the mode on (PR #104 follow-up)

1 participant