Skip to content

Codex mode hook: an on that sage cannot see start a turn does not count (T896) - #460

Merged
erickb336 merged 2 commits into
mainfrom
sage/t896-joined-on-unreadable
Nov 8, 2026
Merged

erickb336 merged 2 commits into
mainfrom
sage/t896-joined-on-unreadable

Conversation

@erickb336

Copy link
Copy Markdown
Owner

What this is

The last narrow exception to the owner's rule (option A: an on phrase counts only from the owner's message that starts a turn). Finding F-T896-1 (was F-T823-2), low, security class.

The problem

After an off phrase from another thread (a fork, a subagent's thread, a side conversation), an on phrase that joined the main thread's running turn could still turn merges on again when the Codex mode hook could not read Codex's record at that moment: no record (no transcript_path), or a last line that Codex still writes (about 150 ms of re-reads). The hook then accepted the on and saved the same turn that the gate counts.

The change

  • packages/sage-codex/hooks/sage-codex-hook.mjs: joins now gives the reason why an on cannot count. An unreadable record, or a turn that already holds the saved on (state.onTurn equals turn_id), joins: the on switches nothing and saves no turn. The chief's note says why, and tells the user to send the on phrase alone as a new message while Codex is idle. The comments match.
  • docs/guide/codex.md: two limit lines. An on phrase queued with Tab in the terminal UI counts when it starts the next turn, and it still fires after an off phrase sent before that turn starts; to cancel it, remove it from the queue or queue the off phrase after it. An on phrase counts for nothing when the hook cannot read Codex's record at that moment.
  • changes/T896.md: the change log entry.

Tests

  • scripts/codex-mode-hook.test.mjs: two new tests. (1) No record, and a record with a partial last line after an off from a fork: the on switches nothing, autopilot stays off (or stays on from the earlier on), and the saved turn does not change. (2) A second on in the turn that holds the saved on, before Codex records the first: it switches nothing and saves nothing new. Both fail on the base 5bc9422 and pass here.
  • The old case that expected an on with no record to switch is replaced by test (1).
  • The test sessions in codex-mode-hook.test.mjs and the Codex sessions in branch-protection.test.mjs now start a new turn for each prompt (and the latter keep Codex's record), as a message sent while Codex is idle does. Before, every prompt of a session shared one turn id, which the new saved-turn rule correctly refuses.

The gate (gate-hook.mjs) does not change.

🤖 Generated with Claude Code

erickb336 and others added 2 commits November 7, 2026 23:10
…e turn of the saved on (T896)

F-T896-1: after an off from another thread, an on that joined the same
running turn could turn merges on again when the hook could not read
Codex's record (no record, or a partial last line). The hook now treats
an unreadable record, or a turn that already holds the saved on, as
joined: the on does not count, no turn is saved, and the chief's note
says why and asks for a new message while Codex is idle.

The test sessions now start a new turn for each prompt and keep Codex's
record, as a message sent while Codex is idle does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336
erickb336 merged commit 45af586 into main Nov 8, 2026
1 check passed
@erickb336
erickb336 deleted the sage/t896-joined-on-unreadable branch November 8, 2026 07:57
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.

1 participant