Repository navigation
refactor(steering): make active-run admission exact and atomic - #120285
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 7:46 PM ET / 23:46 UTC. ClawSweeper reviewWhat this changesThis PR makes Control UI steering select an exact active run and inject user input into that operation before normal reply hydration and dispatch. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open for maintainer review. Current main confirms the leaf-only admission and delayed-dispatch gap, and the proposed exact operation/run boundary is well-directed, but exact-head core blobs and the required sibling Codex checkout could not be materialized in this environment. Priority: P1 Review scores
Verification
How this fits togetherControl UI sends chat and steering requests to Gateway, which either injects them into a live provider run or starts normal reply dispatch. Gateway reports terminal status back to the UI so durable queued steering can be resolved safely. flowchart LR
UI[Control UI steer request] --> Admission[Gateway admission]
Admission --> Target[Exact active operation and run]
Target --> Inject[Provider message injection]
Inject --> Terminal[Terminal outcome]
Terminal --> UIState[Durable UI queue state]
Admission --> Fallback[Normal dispatch after definite rejection]
Decision needed
Why: The current environment cannot materialize the final core blobs or inspect the mandatory sibling Codex source, so this cannot safely be decided from the available partial evidence. Before merge
Agent review detailsSecurityNone. PR surfaceSource +526, Tests +1290, Docs 0, Other +6. Total +1822 across 65 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Have a maintainer with the exact branch and sibling Codex checkout verify the final hydration-to-injection path and its native turn contract before merging. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main admits steering by leaf identity and performs reply hydration after acknowledgement, while the UI has no exact-run precondition. No independent live reproduction was run in this read-only environment. Is this the best way to solve the issue? Unclear: capturing an opaque operation and exact run before delayed work is the best owner-boundary direction, but the final implementation and upstream Codex contract could not be independently inspected here. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 621efa4f5fe4. LabelsLabel 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 (4 earlier review cycles)
|
|
@clawsweeper re-review Exact-head review requested for |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review Exact-head review requested for |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Exact-head review requested for |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review Exact-head review requested for The prior P1 is repaired at the session-suggestion owner: |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
ac99c24 to
8c65684
Compare
|
@clawsweeper re-review Exact-head review requested for The branch was rebased only after GitHub reported a real merge conflict. The sole conflict was test-only in the Gateway queue-mode fixture: the resolution preserves latest main's compressed The modern Control UI/Codex pre-ACK injection path remains patch-identical to live-6: one outer run, one native turn, one |
d46a8f3 to
4f98126
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head ClawSweeper disposition for
No ClawSweeper Rank-up move is being skipped. Native review artifacts and prepare gates are complete on this exact head. |
Unblocks the check-lint gate broken by #120285's max-lines overflow.
…x symlinked state-dir lock blindness (#120362) * fix(agents): canonicalize managed worktree paths * test(qa): cover managed worktree owner lifecycles * test(agents): split worktree canonical-path regression into focused file * fix(doctor): canonicalize persisted managed-worktree paths for symlinked state dirs * fix(doctor): keep worktree path migration detection read-only * test(doctor): bound managed-worktree migration product proof * fix(doctor): keep worktree path detection from creating state dirs * test(doctor): allow state migration detection under CI load * test(agents): split embedded-runner steering runs into focused file Unblocks the check-lint gate broken by #120285's max-lines overflow.
…law#120285) * refactor(steering): make admission exact and atomic * fix(steering): bind targets by run identity * fix(steering): inject before reply dispatch * fix(steering): preserve backend injection modes * fix(steering): target session suggestions * fix(steering): preserve sibling delivery contracts * style(steering): satisfy exact-head lint * fix(steering): preserve targetless protocol compatibility * fix(steering): preserve exact targets through replies
…x symlinked state-dir lock blindness (openclaw#120362) * fix(agents): canonicalize managed worktree paths * test(qa): cover managed worktree owner lifecycles * test(agents): split worktree canonical-path regression into focused file * fix(doctor): canonicalize persisted managed-worktree paths for symlinked state dirs * fix(doctor): keep worktree path migration detection read-only * test(doctor): bound managed-worktree migration product proof * fix(doctor): keep worktree path detection from creating state dirs * test(doctor): allow state migration detection under CI load * test(agents): split embedded-runner steering runs into focused file Unblocks the check-lint gate broken by openclaw#120285's max-lines overflow.
Related: #120083
What Problem This Solves
Active-run steering was coupled to the wrong signals and the wrong lifecycle. It inferred injectability from token streaming, then delayed the actual backend queue call until normal reply dispatch had performed plugin, context, skill, model, and auth work. A tool-running native turn could therefore be correctly selected at Gateway admission yet disappear before
turn/steerwas invoked.Root Cause and Architecture
Message injection is now an explicit capability owned by the active reply operation. Gateway admission captures an opaque operation target plus the active native run ID. The Control UI persists only that immutable run ID with durable retry state; advancing transcript leaves are context, not run identity. Modern steering uses operation + run identity, while the shipped legacy targetless seam retains exact origin-leaf fencing.
The queue operation now begins at the owner boundary. After attachment preparation and final abort/routing checks,
handleChatSendsynchronously prepares the exact user-turn recorder and media options and callsbeginReplyMessageInjectionTargetbefore sending the started ACK. The backend queue is therefore already running before reply dispatch, context resolution, plugin binding, or agent-reply hooks can delay it.The detached continuation awaits a typed result:
before_dispatch,reply_dispatch,before_agent_reply, follow-up policy, cancellation, and transcript ownership remain unchanged.Accepted steering no longer runs
before_agent_reply: injection adds user input to the current native turn; it is not a new OpenClaw model/reply turn. Talk,/steer, and activesessions_sendalready follow the same direct-queue contract.Token streaming is no longer an injection gate. Embedded, Codex, and Copilot producers expose
messageInjection; CLI-only backends expose cancellation but cannot claim steering support. Codex and Copilot replacement handles preserve the negotiatedtaskSuggestionDeliveryMode. Explicit wirequeueMode: "steer"fails closed withoutexpectedRunId.Session-suggestion compatibility is preserved without weakening that contract.
sendtargets the sole authoritative active Gateway run withexpectedRunId, sends an ordinary immediate turn when idle, and fails visibly while keeping the suggestion pending when active work has zero or multiple authoritative run IDs.queueremains a follow-up.Upstream Codex confirms this boundary at
openai/codex@57f42a81131ccf5933e7ec5dc659c381eeb5d72b:TurnSteerParams.expected_turn_id,turn_steer_inner, and the atomic active-turn check plus pending-input append inSession::steer_input.Best-Fix Decision
This is the owner-boundary fix, not a consumer workaround. Keeping token streaming was rejected because output progress does not imply input capability. Targetless delivery-time discovery was rejected because stale retry could hit a successor run and Codex requires an exact active-turn precondition. Delayed injection inside reply dispatch was rejected by live evidence: context/plugin work can outlive the selected native turn.
Live Evidence
f5e8d07c4facorrected modern targeting to operation + run identity and kept leaf equality only for the legacy targetless seam.turn/steerRPC occurred. That trace motivated the pre-ACK synchronous begin path in451128b175b.7e73f1a7345preserves that mode on both owner backends.7e73f1a7345795910f26217807b0510614d9a63c: one outer run (ea29d8ac…232c), one native turn (019fdd92-202f…), oneturn/start, oneturn/steer503 ms after ACK, matching steered-user completion in the same native turn, one nativetask_started, zero successor run, finalSTEER_ACCEPTED, noWAIT_FINISHED, aborted=false. Source-blind UI verification passed after refresh with no Retry, uncertainty, queue, waiting, steering, or error residue.The exact-head follow-up
9e1a4a62b2a5d3e17eef94a74826d9b47c9d0d33changes onlysessions-suggestions.tsand its focused test, so the core injection/Control UI/backend path exercised by live-6 is patch-identical.Verification
src/gateway/server-methods/sessions-suggestions.test.tspasses 22/22, including active exact targeting, idle immediate send, and zero/multiple-identity visible failures.origin/main: clean, no accepted/actionable findings (gpt-5.6-sol, high reasoning, confidence 0.96; 193,269-byte bundle in one pass).git diff --checkand targeted formatting pass.scripts/pr prepare-runremain required before merge.Compatibility and User Impact
The public queue-mode shape remains additive. Shipped legacy handle fields remain only as a structural Plugin SDK compatibility seam; the queue operation, not token streaming, is authoritative. No protocol version, config, persistence, SQLite schema, auth, or setup surface changes.
Steering now reaches the native turn while it still owns the work, including non-streaming tool execution. Retry cannot silently jump to a later run. Definite rejection falls back once; irreversible acceptance cannot become a duplicate follow-up. Session-suggestion send/queue behavior remains intact.
Production LOC: +866/-443 (net +423), justified by the explicit injection capability, exact operation/run fencing, Gateway-owned pre-ACK begin/typed terminalization boundary, and session-suggestion compatibility owner. Tests: +1071/-186 (net +885). Generated Swift protocol: +6/-0.
No changelog entry is included; release generation owns changelog updates.
Unrelated follow-up: the selected-agent sidebar auth state observed during live setup is outside this PR's injection lifecycle and did not affect the steering proof.
Exact-head CI Repair
Head
ac99c24d43d5f67ca1f1f17657b5d2c16ad9df8dpreserves sibling delivery contracts without weakening exact steering. Modern backends use explicitmessageInjection; only legacy embedded handles retain their shippedisStopped/isStreamingeligibility adapter. CLI backends remain cancellation-only. Restored Control UI steering now proves exact run and leaf identity, and Copilot cleanup retains the concrete backend-handle type.Focused exact-head proof: agent/session suites 88/88, Gateway suites 286/286, Control UI mocked browser E2E 9/9, targeted type-aware lint clean,
git diff --checkclean, and fresh Codex autoreview clean with no actionable findings (confidence 0.97). The exact local full type/package setup is blocked before the changed surfaces by the unrelated sibling-checkout baseline atpackages/terminal-core/src/ansi.ts:194; the remote changed-gate router was unavailable because no Crabbox provider passed readiness. Hosted exact-head CI remains the authoritative static/package proof.Repair delta: production +11/-14 (net -3); tests +68/-157 (net -89).
Targetless Protocol Compatibility Disposition
Head
b8dd16baefbresolves the remaining ClawSweeper P1 without a protocol bump.expectedRunIdremains the preferred modern/durable retry contract, and Control UI plus session suggestions continue to send it. Older targetless wirequeueMode: "steer"requests now pass normalization only to enter a leaf-bound compatibility path: Gateway requires a supplied immutableexpectedLeafEntryId(including deliberatenull), resolves one running/fresh injectable operation, captures that opaque operation, and revalidates it before invoking the backend. Missing/mismatched ownership returns typedactive-leaf-changed; queue-time ABA replacement rejects before ACK, never dispatches normally, and never reaches the successor. Internal current-operation injection remains separate because it already holds the opaque owner.Direct upstream verification used
openai/codex@57f42a81131ccf5933e7ec5dc659c381eeb5d72b:codex-rs/app-server-protocol/src/protocol/v2/turn.rs:175-196requiresexpectedTurnId;codex-rs/app-server/src/request_processors/turn_processor.rs:910-1017forwards and maps the exact-turn precondition;codex-rs/core/src/session/mod.rs:3983-4066atomically checks the active turn and appends pending input under the active-turn lock. OpenClaw legacy compatibility therefore resolves to one exact operation before it reaches that backend contract.Exact-head proof: Gateway 204/204; reply registry 60/60; modern Control UI exact-ID E2E 25/25; protocol schema 64/64; full docs formatting/lint/MDX/link checks; targeted type-aware lint and
git diff --check; fresh Codex autoreview clean with no actionable findings (confidence 0.98). Delta: production +57/-31 (net +26), justified by the public compatibility identity and restart-safe pre-ACK rejection owner; tests +262/-9; docs +1/-1.Exact Targets Through Reply Hydration
Head
d46a8f36cd2resolves both exact-head ClawSweeper P1s./steernow requires exactly one authoritativeactiveRunId, always sends it asexpectedRunId, and treatsactiveLeafEntryIdas optional context; zero or multiple run IDs still refuse visibly. ForreplyToIdsteering, Gateway carries the admission-captured opaque target through asynchronous reply hydration, adds the hydrated quote to the direct-injection prompt, begins injection only against that captured operation, and marks the attempt so the runner cannot rediscover a successor. If A ends and B replaces it during hydration, the accepted Gateway claim terminalizes as typedactive-run-changed; neither backend queue nor normal/followup dispatch reaches B. UI terminal handling retires the rejected steer chip.Exact-head proof: focused reply/command Gateway+UI 416/416; broad Gateway 124/124, registry 60/60, UI chat-send 272/272, exact-ID UI E2E 25/25, and agent-runner dispatch E2E 142/142; final focused Gateway/UI 405/405; targeted type-aware lint plus
git diff --check; Codex autoreview clean with no actionable findings (confidence 0.98). Production delta +111/-48 (net +63), justified by the exact-target reply-hydration owner and typed terminal projection; tests +243/-2. No live rerun was performed: this authorized follow-up explicitly excluded live work, and it changes only deterministicreplyToIdplus client/steerpaths while the previously live-proven ordinary steering path remains unchanged.