Repository navigation
fix(gateway): steering during worktree creation still runs as a follow-up after the task - #165537
Conversation
Park incoming steering in the existing FIFO owner while its exact reply operation prepares. Publish first-backend readiness from that operation, then revalidate ownership and current tool authority before injection. Settle waits on source cancellation, owner retirement, or rekey without following a replacement. The Gateway regression now uses real dispatch and reply preparation instead of manufacturing a ready owner. It fails on current main and passes with the repair; unavailable and rejected injection retain existing follow-up acknowledgement and execution behavior. Keep backend readiness internal and retire precomputed steering authority parameters.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 7:42 AM ET / 11:42 UTC (Revision 3). ClawSweeper reviewWhat this changesSteering messages wait for the original turn’s runtime to become ready, then join that turn if still authorized or remain queued for a follow-up. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still misses steering during backend preparation. The prior synchronization finding is repaired, and no additional blocking code defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway passes incoming steering messages to the reply queue and active-turn registry. Those owners decide whether the runtime consumes the message during the current turn or executes it later. flowchart TD
A[Incoming steering message] --> B[Ordered reply queue]
B --> C[Original turn preparing]
C --> D[Runtime readiness signal]
D --> E[Check current owner and permissions]
E --> F[Inject into active turn]
E --> G[Execute queued follow-up]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +45, Tests +83, Docs +1. Total +129 across 11 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep startup steering in the existing FIFO owner until the original runtime can accept it, while preserving current authority checks and once-only follow-up delivery. Do we have a high-confidence way to reproduce the issue? Yes: current-main source captures an unavailable injection target during backend preparation, and the supplied live comparison exercises that window through sessions.create and chat.send. Reviewer execution was not performed. Is this the best way to solve the issue? Yes: extending the existing reply operation’s readiness lifecycle preserves queue ownership and avoids a parallel steering mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d4940e8bf63e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…#165788) Keep source reservations as completion barriers without using them as steering targets. The parked steering change in #165537 retained strict target selection but dropped the separate source-owned drain barrier. Preserve the existing ordering and image-delivery regression assertions, and update the authority-mismatch assertion to the parked fallback owner.
…w-up after the task (openclaw#165537) * fix(gateway): retain pre-start steering until the reply backend is ready Park incoming steering in the existing FIFO owner while its exact reply operation prepares. Publish first-backend readiness from that operation, then revalidate ownership and current tool authority before injection. Settle waits on source cancellation, owner retirement, or rekey without following a replacement. The Gateway regression now uses real dispatch and reply preparation instead of manufacturing a ready owner. It fails on current main and passes with the repair; unavailable and rejected injection retain existing follow-up acknowledgement and execution behavior. Keep backend readiness internal and retire precomputed steering authority parameters. * test(gateway): wait for runtime entry in prestart steering proof
…openclaw#165788) Keep source reservations as completion barriers without using them as steering targets. The parked steering change in openclaw#165537 retained strict target selection but dropped the separate source-owned drain barrier. Preserve the existing ordering and image-delivery regression assertions, and update the authority-mismatch assertion to the parked fallback owner.
Related: #165462
What Problem This Solves
Fixes: a message sent with Steer right after starting a New Session with a new worktree (while it shows "Creating worktree…") still runs as a separate follow-up turn after the task finishes, instead of reaching the task. #165462 fixed a later point in that window; live, the steer usually arrives while the first turn's reply operation exists but its backend is still preparing.
User Impact
User impact: steering during worktree creation now joins the first turn as soon as its runtime is ready, on both the built-in and the Codex runtime. If that turn ends, is replaced, or its authority changes first, the message still runs once as a follow-up. The queued-follow-up acknowledgement semantics are unchanged.
Why This Change Was Made
runActiveReplySteerresolved the injection target and the steering authority when the steer was admitted. During preparation the active reply operation has no ready backend yet, so there was no target and the steer fell back to the follow-up queue immediately. The steering owner now parks the input in its FIFO custody, waits for that exact reply operation's backend to become ready (new readiness signal on the reply-run registry), then re-verifies the same operation object, resolves tool/pending-input authority at that moment, and injects. Cancellation, retirement, and rekeying release the wait and fall back. Authority is revalidated after the wait and immediately before injection rather than captured beforehand.Evidence
Live (dev Gateway, OpenAI provider, fresh state):
sessions.create {worktree: true, message}thenchat.send {queueMode: "steer", message: "…put the word PINEAPPLE<n>…"}~2 s later, while the worktree was being created.The regression now drives real
sessions.create+chat.senddispatch and reply preparation (only model execution is synthetic):Six affected test files: 68 passed (includes
reply-run-registry.backend-ready.test.ts, handoff adoption, media carrier/paths). Production and test types, scoped lint, formatting, ratchets pass. Deslop and branch autoreview clean (a rekey concern was ruled out by the existing queued-only guard).Production +75/−30 (readiness signal + post-wait revalidation; the pre-captured authority parameters are removed); tests +236/−157; docs +4/−3.
CI follow-through
CI run 37300380552, attempt 1, exposed a synchronization race in
chat-send-prestart-steer.test.ts: steering admission can park the message before reply preparation enters the runtime fixture, so the test readinitialOperation.phasebefore the fixture assigned that operation. The same three-file Gateway selection reproduced the failure locally (1 failed, 20 passed; 61.74 s).The test now waits for an explicit runtime-entry signal before the existing phase assertion. No assertion was removed or weakened, and production code is unchanged. The repaired selection passes all 21 tests in 34.76 s; the focused file passes all 3 cases with
--maxWorkers=1in 34.30 s. This public-RPC regression uses real session/worktree creation, reply preparation, and transcript persistence, which accounts for its runtime. The original CI failure took 10.57 s in the failing test; its three-file invocation took 22.60 s. Codex autoreview of the four-line repair is scoped-clean through P2.Formatting, scoped lint, core test types, and changed-scope contract guards pass. The local changed-file command remains red solely on unrelated dead exports in
extensions/google-meet/src/transports/types.ts,extensions/memory-wiki/src/compiled-cache.ts,extensions/workboard/src/gateway-helpers.ts, andsrc/meeting-bot/runtime-facade-types.ts. The same scan independently fails for all of those exports on main6b37a39aa10; those four files are identical between the PR and that baseline. This is local baseline evidence, not a claim of passing CI.The corrected head
ceca71960713965814217b9e70e6ac17bad2b46apassed all three prestart-steering cases in CI run 37303089262 (accepted 10.684 s, unavailable 2.741 s, rejected 3.997 s). That run remains failed/cancelled becausecheck-guardsjob111740773333found an inherited Madge import cycle among migration and state-reader files, fromsrc/infra/deferred-plugin-migrations.tsthroughsrc/state/openclaw-state-read.types.ts.Inherited-failure qualification: CI checked merge
0be42ce7d59a188c41429310e0e8db999b6183db, whose ordered parents are main83b743ac7141882378a821db5beacd14a7222745and this exact PR head. Its tree matches Git's merge of those parents. Every cycle node and the scanner/config/workflow inputs are identical to the baseline; the same guard independently fails with the identical cycle on current maind4940e8bf63. The PR changes none of those cycle files. This qualifies for the native inherited-failure admin route; it is not a passing-CI claim.security-fastpassed. The successful fail-fast monitor cancelled jobs111740773615,111740773949, and111741290757; no additional failed step was found, and cancelled coverage remains incomplete. The native evidence retains the complete checkout, failure, aggregate, and cancellation logs.