Skip to content

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

Closed

Description

@erickb336

Owner: Claude (the sage). Context for Codex: do not build this; it changes the same lines as PR #104 (packages/sage-core/mode-policy.mjs), so it comes after #104 merges.

Found in PR #104's code review (run R724, finding L3). Size: small. Low; main behaves the same.

The problem

The off guard in the on rule's trailing-words branch (OFF_NEXT in mode-policy.mjs) reads only the word right after the phrase, and after "switch" or "turn" at most one word before the off word. So the on phrase followed by "please stop", "turn it all off" or "can go off now" turns sage mode on from off. When sage mode is already on, nothing changes and no note fires.

Goal

A message that starts with the on phrase and clearly asks for off within its first few words never turns the mode on, and gets the miss note. Off is the safe direction (owner rule).

Scope

  • Read a short window after the phrase (for example the first 6 words of the first line, after the tail folding of Hook: the miss note covers the autopilot half, says which rule failed, and describes the phrases (T200, T201) #104) for the off word or an off-meaning word, with "switch", "turn", "can go", "please" and similar fillers allowed before it. Keep it linear.
  • Keep real requests working: "offer", "office", "offline", "no rush" and a request that mentions "off" later in a long sentence must still turn the mode on. List the cases you checked.
  • Tests for each case. The README line about off words after the phrase says "within the first few words".

Acceptance

  • The new tests fail on main and pass on the branch; the 1 MB padding rows pass. npm run build, npm run check and npm test pass with fake ps, pgrep and kill first on PATH.

Activity

  1. added
    claude
    on Oct 11, 2026
  2. erickb336 commented on Oct 11, 2026

    @erickb336
    OwnerAuthor

    Added from PR #104's final-head QA (run R734, finding R734-1, sage task T212): the table form of the on phrase with the autopilot word, followed by a comma and an off-meaning word (for example 'dont stop until done' or 'stop when done'), turns sage mode on and leaves autopilot off with no note. AUTOPILOT_ASKED in packages/sage-core/mode-policy.mjs reads the comma and the off-meaning word as an autopilot off, so autopilotAsked is false and the fallback is false. Count the autopilot word as asked unless the off word is the next word of the phrase itself, and add tests for the comma forms. Build it together with this issue (sage task T210): same lines.

  3. erickb336 commented on Oct 11, 2026

    @erickb336
    OwnerAuthor

    More for this issue from PR #104's final-head security review (run R733). Build these together with the rest of this issue; sage tasks T210, T212 and T213 all change packages/sage-core/mode-policy.mjs.

    1. Medium, pre-existing (sage task T213): OFF_SOON accepts only a comma, colon, semicolon or dash before an off word. The phrase, then a full stop, an exclamation mark, an ellipsis, a slash, an open parenthesis, U+2010 or a line break, then the off word, turns the mode on with no note. Treat any punctuation run and a line break between the phrase and an off word as "off next" (the safe direction; the note tells the owner).
    2. Low, pre-existing: visible letters that the look-alike list misses (the Cyrillic s in the stop word, the Cyrillic r and a in the pause word) and invisible letters (U+3164, U+115F, U+2800 inside the off word) still hide an off word, so the mode turns on; with autopilot already on, autopilot also stays on with no note. Remove invisible letters from the tail before the off guard, and widen the look-alike list to every letter of the off-meaning words.
    3. Low, the safe direction: the stem matches in OFF_WORDS read some ordinary requests as off: "end-to-end tests", "stopwatch app" and "cancellation flow" after the phrase. The mode does not turn on, a running autopilot goes off, and the note tells the owner. Match whole words only.
  4. erickb336 commented on Oct 11, 2026

    @erickb336
    OwnerAuthor

    One more for this issue, from PR #104's final-head code review (run R732, finding F-R732-1, low):

    The autopilot note gives a reason that does not help in two cases: the on phrase then "and" then the autopilot word, and the autopilot word followed by a word other than "on" (for example "please"). For both, the note says that the autopilot phrase needs a full stop, a comma or a line break after it; an owner who adds a full stop gets the same miss and the same advice. Give the real reason, for example "the word after autopilot is not on" or "and comes before it", in packages/sage-claude/hooks/sage-hook.mjs (about line 178), and update the test rows at scripts/sage-hook.test.mjs about lines 1075 and 1076.

    Also decided for PR #104 (option a of the reviewer's question): the off-word list keeps blocking the on rule right after the phrase ("no rush", "end to end", "stopwatch"), because off wins and the note tells the owner. Whole-word matching (item 3 above) is the follow-up.

  5. erickb336 commented on Oct 11, 2026

    @erickb336
    OwnerAuthor

    Two more low points for this issue, from PR #104's round-2 QA (run R738). Both are about the note's wording; the state is right in both cases.

    1. A combining accent or a zero-width space right after the phrase gives the note "the words after the phrase match no rule". The real cause is a mark or hidden character that the owner cannot see, so the owner may retype the same text. Name it: for example "a hidden character or an accent is joined to the phrase; retype it".
    2. "An off word in the message won" does not name the word (for example "stop" in "dont stop until done"). Name the word the rule found.
  6. erickb336 commented on Oct 11, 2026

    @erickb336
    OwnerAuthor

    One more low point for this issue, from PR #104's round-2 code review (run R736, finding L-R736-1). Main behaves the same, so it is no regression; it is the unsafe direction, so it belongs here.

    With sage's mode on and autopilot on, these forms leave autopilot on (round 1's head turned it off):

    • the off word in full-width letters, or with a Cyrillic o, joined to the mode name with no space (no note at all);
    • a soft hyphen joined to the off word; or a zero-width space, a combining accent, U+2060 or U+FE0F, then a space or a comma, then an off word or the stop word (the note says the message switched nothing).

    The same off word in plain letters, joined, still turns autopilot off, so the rule is not consistent. Possible fix: compute the off-after signal from a fold that does not need the phrase's end boundary, while the on rule keeps the strict boundary (packages/sage-core/mode-policy.mjs, HEAD at about line 35, the fold at about lines 40 and 41, offNext at about line 87).

  7. erickb336 commented on Oct 11, 2026

    @erickb336
    OwnerAuthor

    From PR #104's round-2 security review (run R737). The medium is the same gap as the code review's L-R736-1 above, now sage task T214; the security review swept 4.3 million single-character cases and found 7,176 forms of it. Three low points too:

    1. Medium (T214): with autopilot on, the on phrase with a mark or format character joined to its last letter (U+0301, U+200B, U+00AD), then an off word ("off", "stop", "no more"), leaves autopilot on with only a "switched nothing" note. Compute the off-after signal from a fold that does not need the phrase's end boundary, and add tests on the off side.
    2. Low, pre-existing: START and SP count U+FEFF (a BOM) as white space, so the on phrase with a BOM before or after it switches the mode on, and the phrase, a BOM, a comma and the autopilot on phrase turns autopilot on. Owner text only.
    3. Low (from PR Hook: the miss note covers the autopilot half, says which rule failed, and describes the phrases (T200, T201) #104 round 1): the on phrase spelt with the long s (U+017F) gets the wrong note reason ("a pasted quote, bullet or indent"), because MODE_WORD has the u flag and PLAIN_WORD does not; with an off word next, autopilot stays on.
    4. Low, pre-existing, the safe direction: the on phrase followed at once by U+0345, U+037A or an Arabic presentation form switches nothing and gives no note.
  8. erickb336 commented on Oct 11, 2026

    @erickb336
    OwnerAuthor

    PR #106 is closed: the owner chose exact-phrase switches (task T240) over free-text off rules.

  9. erickb336 commented on Nov 9, 2026

    @erickb336
    OwnerAuthor

    Closing as decided. PR #106 was closed: the owner chose exact-phrase switches (T240) over free-text off rules. Owner decision 2026-11-09.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions