Repository navigation
refactor(steering): gateway-owned atomic start-or-steer - #125808
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 10:26 AM ET / 14:26 UTC. ClawSweeper reviewWhat this changesCentralizes start-or-steer admission and captured message injection for Gateway, channel, and Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessThe prior Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway and channel inputs resolve a session’s direct reply operation, then either inject into that exact active run or continue as a normal turn. The shared registry enforces runtime capability and tool-authority checks before delivery. flowchart LR
A[Chat send or channel input] --> B[Gateway and reply admission]
B --> C{Direct active operation?}
C -->|Yes| D[Captured injection target]
C -->|No| E[Start or queue normal turn]
D --> F{Authority and runtime accept?}
F -->|Yes| G[Active run receives message]
F -->|No| E
G --> H[Transcript and audit finalization]
E --> H
Decision needed
Why: Repository policy requires direct Codex-source inspection when the PR explicitly depends on that contract, and the required checkout is unavailable to this review. Before merge
Agent review detailsSecurityNone. PR surfaceSource +47, Tests +55, Docs 0. Total +102 across 25 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared captured-operation lifecycle and verify the cited Codex revision plus exact-head CI before merge. Do we have a high-confidence way to reproduce the issue? No live reproduction was run in this read-only review; source and focused tests establish the targetless-steer and authority-fallback paths. Is this the best way to solve the issue? Unclear: the shared captured-operation owner is coherent and repairs the earlier authority finding, but its asserted Codex equivalence could not be directly checked. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2c5a694ccb1a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
2563203 to
5450880
Compare
…ration lifecycle chat.send with queue mode steer now atomically captures the selected session's current direct reply operation under the writer barrier and injects into exactly that operation; with no direct owner it starts a new run instead of failing with active-leaf-changed. Client-supplied expectedRunId keeps exact-match semantics; the transcript-branch CAS (expectedLeafEntryId) now guards only non-steer sends. All three steering paths (gateway chat.send, channel queue steering, server /steer) share one begin/finalize lifecycle on the reply-run registry, including the captured-instance abort from 5a15e1a. Deleted: the duplicate accepted/rejected/unconfirmed policy machine in steer adoption, the raw embedded /steer runtime path, the leaf-bound injection identity and reject-before-ack compat, and the dead target tool-authority fingerprint. messageInjectionAttempted becomes a typed messageInjectionDisposition (none | accepted | rejected); rejected injections take one visible followup fallback, so non-injectable runtimes queue instead of silently dropping. Deliberate semantics: a registry-less active embedded run is no longer steered by raw session id (correlation-only authority) - the message becomes a visible followup; /steer injects under its own command authorization instead of the inbound tool-authority gate it could never satisfy.
Targetless steer is no longer a leaf-bound compatibility path that can reject with active-leaf-changed; it targets the selected session's current state (inject into the direct run, else start a turn). expectedRunId stays an exact-run fence; expectedLeafEntryId is the non-steer transcript-branch CAS.
5450880 to
0c71b12
Compare
The authorized-sender command gate is weaker than tool-authority equality. Make /steer and gateway injection present the same projected evidence as channel steering so mismatches fall back to a normal prompt under the sender’s own authority.
|
Merged via squash.
|
) * refactor(steering): gateway-owned start-or-steer via one captured-operation lifecycle chat.send with queue mode steer now atomically captures the selected session's current direct reply operation under the writer barrier and injects into exactly that operation; with no direct owner it starts a new run instead of failing with active-leaf-changed. Client-supplied expectedRunId keeps exact-match semantics; the transcript-branch CAS (expectedLeafEntryId) now guards only non-steer sends. All three steering paths (gateway chat.send, channel queue steering, server /steer) share one begin/finalize lifecycle on the reply-run registry, including the captured-instance abort from 9a36324. Deleted: the duplicate accepted/rejected/unconfirmed policy machine in steer adoption, the raw embedded /steer runtime path, the leaf-bound injection identity and reject-before-ack compat, and the dead target tool-authority fingerprint. messageInjectionAttempted becomes a typed messageInjectionDisposition (none | accepted | rejected); rejected injections take one visible followup fallback, so non-injectable runtimes queue instead of silently dropping. Deliberate semantics: a registry-less active embedded run is no longer steered by raw session id (correlation-only authority) - the message becomes a visible followup; /steer injects under its own command authorization instead of the inbound tool-authority gate it could never satisfy. * docs(protocol): describe gateway start-or-steer contract for chat.send Targetless steer is no longer a leaf-bound compatibility path that can reject with active-leaf-changed; it targets the selected session's current state (inject into the direct run, else start a turn). expectedRunId stays an exact-run fence; expectedLeafEntryId is the non-steer transcript-branch CAS. * fix(steering): require matching tool authority for /steer injection The authorized-sender command gate is weaker than tool-authority equality. Make /steer and gateway injection present the same projected evidence as channel steering so mismatches fall back to a normal prompt under the sender’s own authority.
What Problem This Solves
The browser owned start-vs-steer and exact run targeting, producing failures like #125427 (landed mitigation #125428) and requiring beta-only
expectedRunIdwire state; three parallel steering state machines (gateway captured-op, channel steer adoption, server/steer) duplicated accepted/rejected/unconfirmed/fallback policy, and two of them addressed runs by session key or raw session id (correlation-only authority; successor-abort class fixed for one path in #125763).Why This Change Was Made
The Gateway session-work admission is the correct atomic owner of the start-or-steer decision (mirrors the upstream Codex contract: core
start_or_steerattempts steering with no expected turn under the active-turn lock and starts onNoActiveTurn— verified in sibling codex-rs at rev 4861236f06d0:core/src/session/turn_input.rs:195-249,478-564;protocol/src/turn_input.rs:115-124). One captured-operation lifecycle (resolveCurrentMessageInjectionTarget/beginReplyMessageInjectionTarget/finalizeReplyMessageInjectionAttempt) now serves all three paths with the #125763 captured-instance abort.User Impact
Steer-mode sends to an idle session start a run instead of failing with "active leaf changed"; rejected injections visibly queue as follow-ups (fixes the silent CLI-runtime steer drop class, #124731);
/steeractually injects into the active run under its command authorization. Deliberate semantics changes: (1) registry-less active embedded runs are no longer steered by raw session id — the message becomes a visible followup (fail-closed captured-authority rule); (2) the transcript-branch CAS (expectedLeafEntryId) now guards only non-steer sends — explicit steer intent targets the session's current state; (3)expectedRunIdexact-match behavior is unchanged when supplied (its removal is a follow-up PR).Evidence
Production LOC +285/−295 (net −10), tests +423/−418; deleted the duplicate policy machine,
commands-steer.runtime.ts, leaf-bound injection identity + reject-before-ack, deadtoolAuthorityFingerprinton targets, the booleanmessageInjectionAttempted; new gateway matrix tests (idle→start incl. active-descendant case, direct-run capture, successor never injected/aborted, non-injectable runtime visible fallback, idempotent retry) — the two targetless-steer regressions fail pre-change with active-leaf-changed; focused suites 298+379+25+7 passed; tsgo core lanes, check-changed, pnpm build (noINEFFECTIVE_DYNAMIC_IMPORT) green; codex autoreview clean on the final tree. Pending-user-input claim/cancel semantics moved verbatim fromembedded runs.ts:486-520into the shared primitive;runs.tskeeps its copy for its four non-steer callers (talk control, TUI backend, sessions-send tool, subagent announce) — consolidation follow-up noted. Known unrelated env-dependent local failure of the heartbeat usage test (CI-green on main; follow-up task filed).