Skip to content

Hook: the on phrase may have words after it, and a missed phrase gets a note (T194) - #54

Merged
erickb336 merged 2 commits into
mainfrom
hook/t194-on-phrase
Oct 6, 2026
Merged

erickb336 merged 2 commits into
mainfrom
hook/t194-on-phrase

Conversation

@erickb336

@erickb336 erickb336 commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Finding

Spike R694 (T181) found that this session's installed hook state stayed {"given":false,"autopilot":false} since 2026-10-04 22:52 UTC. The owner's first message was the on phrase followed by more words in the same sentence. The on rule's end test asked for punctuation or a line end right after the phrase, so no rule applied, and nothing told the chief for two days.

Design choice

  • The mode phrase accepts trailing words. The on phrase at the start of a message may go on with a space and more words, as long as its line has no "?" and the next word is not "off". On is the safe direction for the file rules: a wrong on only stops the chief from editing files. "sage mode?" and "sage mode online: is it a thing?" still switch nothing (the "?" stop keeps a question from switching).
  • The autopilot rules are unchanged. "autopilot on" must still stand alone or end at punctuation or its line, so "autopilot on main" switches nothing. The off rules (the off phrase, the off line and the broad off rule) are unchanged, and off still wins over on: "sage mode off continue" turns the mode off.
  • A miss is never silent. When the owner's message starts with "sage mode" or "autopilot" and no rule read it, the hook adds one note to the chief that says so and names the phrases. Only the owner's own text gets the note, never text inside a frame. A message that a rule read and that kept the state as it was gets no note.

Docs

The hook's header comment, the README's "What to say" paragraph and "What's new" list, and the sage-help skill's sentence on the phrases.

Evidence

  • The new tests fail on main's hook (1e64e63) in a detached scratch worktree with fake ps and kill on PATH: "sage mode continue on sage project with remote control on" gives "sage mode off, autopilot off", not "sage mode on, autopilot off", and the six note cases do not get the note.
  • On the branch: npm run build (built 30 files), npm run check (all checks pass), npm test (449 tests, 449 pass, 0 fail).

🤖 Generated with Claude Code

Closes #63 (sage task T194).

erickb336 and others added 2 commits October 6, 2026 04:19
… a note (T194)

The on phrase at the start of a message may go on with a space and more
words, as long as its line has no "?" and the next word is not "off".
"autopilot on" and the off rules are unchanged. When the owner's message
starts with a mode word and no rule reads it, the hook adds one note for
the chief that names the phrases, so a miss is never silent: this
session's hook state stayed off for two days after such a miss.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…e answer for one or two spaces, full-width question mark (T194 round 1)

Fixes the four findings of cycle 1 on PR 54:
- F-R703-2 / R702-1: the question guard after the greedy space run re-scanned the line at each backtrack step
  (quadratic: the mode phrase + 1 MB of spaces + "x?" held the hook over 100 s). Both lookaheads now sit before
  the run. Probe: 16 ms on the branch, 14.5 ms on the parent, for 1 MB of spaces; 2.8 ms and 2.7 ms for 1 MB of words.
- F-R703-1 / R702-2: the off guard sat after the run, so two spaces + "off-topic" turned the mode on while one space
  did not. The guard before the run gives one answer. Only the exact off word blocks; "offline" turns the mode on,
  and the comment says so.
- F-R703-3: the question guard reads the full-width "?" too (G68).
- R702-5: the "off-topic" test row's reason now says why it passes; rows added for two spaces + "off-topic",
  "offline", the full-width "?" and the exact off word after two spaces. The 1 MB padding test gets two owner
  first-line cases.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@erickb336

Copy link
Copy Markdown
Owner Author

Repair round 1 (R705), commit bec5e2f: the four cycle-1 findings, one commit, two files (sage-hook.mjs, sage-hook.test.mjs).

  • F-R703-2 / R702-1 (quadratic tail): both lookaheads of the on rule's trailing-words branch now sit before the space run, so the run never backtracks into a re-scan of the line. Timing probe, one handle() call, CPU ms: the mode phrase + 1 MB of spaces + x?: branch 16.3 ms, parent (1e64e63) 14.5 ms; the phrase + 1 MB of words + ?: branch 2.8 ms, parent 2.7 ms. The old head (9d4a9d3) took 490 ms at only 64 KB of spaces. The 1 MB padding test has two new owner first-line cases; they fail on the old head (1.3 s for 100 KB, 5.4 s for 200 KB).
  • F-R703-1 / R702-2 (off guard position): the off guard before the run gives one answer for one or two spaces. Only the exact off word blocks the match; a longer word that starts with off turns the mode on, and the comment above the rule says so.
  • F-R703-3 (full-width question mark): the question guard reads [??], as the board rule does (G68).
  • R702-5 (test row passes for the wrong reason): the row's reason now says the off line rule reads the hyphenated off as an autopilot off and the on rule's guard blocks it too. New rows: two spaces + the hyphenated off, the longer off word with one and two spaces, the full-width mark twice, the exact off word after two spaces.

Checks (fake ps/kill first on PATH): hook test file 141/141; npm run build ok; npm run check ok; npm test 449/449.

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.

T194: The on phrase may have words after it, and a missed phrase gets a note (PR #54)

1 participant