Repository navigation
fix(reply): register composed upstream abort signal sources for identity lookups - #118057
pacocartones wants to merge 1 commit into
Conversation
…ity lookups
The chat.abort gate asks isReplyRunAbortableForSignal with the raw
controller signal (chat-send-admission.ts:287), but followup admission
registers the operation under a fresh AbortSignal.any() composite
(followup-turn-admission.ts:152 -> queue/types.ts:219 ->
reply-run-registry.ts:1059). The WeakMap lookup misses by identity and
returns true (abortable) even when the operation is frozen/finalizing,
so chat.abort reports {aborted: true} while delivery continues.
Register the composite's source signals as aliases of the same
operation; the abort listener stays on the composite, so cancellation
semantics are unchanged.
Refs openclaw#118028.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 2:01 PM ET / 18:01 UTC. ClawSweeper reviewWhat this changesThis PR registers the raw cancellation signals behind a queued follow-up’s composed abort signal as aliases of the same reply operation, allowing Gateway abort checks to respect finalizing delivery. Merge readinessNo blocking correctness or security finding surfaced. Current Priority: P2 Review scores
Verification
How this fits togetherQueued follow-up admission combines the original chat-run signal with a queue-lifecycle signal before creating a reply operation. Later, the Gateway’s flowchart LR
A[Chat send controller] --> B[Queued follow-up]
Q[Queue lifecycle controller] --> B
B --> C[Composed cancellation signal]
C --> D[Reply operation registry]
A --> E[Gateway abort gate]
E --> D
D --> F[Abortability result]
F --> G[Abort broadcast or final delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +18, Tests +24. Total +42 across 4 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the reply registry as the single owner of signal-to-operation identity, register only the known queued-follow-up source signals there, and land after normal exact-head checks confirm the clean merge result. Do we have a high-confidence way to reproduce the issue? Yes: current-main source establishes the mismatch between a fresh queued-follow-up composite and the raw signal used by the Gateway abort gate, and the PR supplies a focused regression plus a claimed before/after runtime chain. Is this the best way to solve the issue? Yes: aliasing the two sources at the only admission point that knows both source identities and the created operation is narrower than adding Gateway-specific fallback logic or changing cancellation semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eef59b572b8f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Closing without landing because the patch repairs a real signal-identity mismatch at a lookup the production On current The canonical fix belongs at queued cancellation retirement: retire Gateway cancellation ownership through the existing Thanks for isolating the identity mismatch. No code from this PR was landed. |
|
Understood — thank you for the precise read. I re-verified it against the dispatcher: for a queued runId the handler takes the queued fork and calls Agreed the canonical fix is at queued cancellation retirement ( |
What Problem This Solves
chat.abortcan report a run as aborted while its reply operation is actually still finalizing and delivering. The abort gate resolves abortability by signal identity, but the followup-admission path registers operations under a freshAbortSignal.any()composite — so the gate's lookup always misses and defaults to "abortable".Refs #118028 (the
reply-run-registrysite of the signal-identity class; same class as #117884, different site and path).Root cause
queueAbortSignal(queue/enqueue.ts:189), so admission always composes:followup-turn-admission.ts:152→resolveFollowupAbortSignal(queue/types.ts:219) →AbortSignal.any(...)— a new object per admission.reply-run-registry.ts:1059(WeakMap<AbortSignal, ReplyOperation>).chat.abortgate asks with the raw controller signal:gateway/server-methods/chat-send-admission.ts:287→chat-abort.ts:488-494,530-533→isReplyRunAbortableForSignal(reply-run-registry.ts:398-401), which returnstrueon a WeakMap miss.freezeAbort→ non-abortable), the gate should sayfalsebut saystrue;abortChatRunByIdthen marks the run aborted and broadcasts it while the operation keeps finalizing and delivering. A direct (non-followup)chat.sendregisters the raw signal and is not affected.Fix
createReplyOperationacceptsupstreamAbortSignalAliasesand registers each source signal as an alias key to the same operation; the followup admission passes the composite's two sources through. The abort listener stays on the composite, so cancellation semantics are unchanged — identity lookups made with either the composite or any raw source now resolve to the same operation.4 files, +42/−0.
Evidence
Runtime proof — real chain, no mocks
Loopback harness driving the real production path on this head and on
main— no mocks of the logic under test, no fake timers (Windows, Node v24.14.1):Declared simplifications: minimal
FollowupRunliteral;broadcast/nodeSendToSessioncaptured in arrays; no SQLite session store (blocked on this Node by the repo's own WAL guard,node-sqlite.ts:81); no real model turn — "delivery" is the operation's real lifecycle (freezeAbort→complete), exactly the span the bug desynchronizes from the chat run.Run 1 — pre-fix (the three touched source files reverted to
upstream/mainfor the run, restored after):Bug reproduced end to end: the composite answers correctly (
composed=false), but the gate asks with the raw signal — unregistered onmain— so it misses and returnstrue; the gateway marks the run aborted and broadcasts it (partial draft included) while the frozen operation keeps going and completes delivery afterwards.Run 2 — post-fix (this head
f1f170a8839):Fix verified: both identities agree, the gate closes, no abort broadcast, no controller abort, and finalization completes delivery intact.
Run 3 — post-fix control (live, non-frozen operation):
Control verified: a genuinely abortable run still aborts through the composite (
aborted_by_user, own signal aborted) — the fix does not over-block.Unit coverage and local gates
New regression test in
reply-run-registry.test.tsmirroring the admission path (AbortSignal.anycomposite as the registry key, gate asking with the raw signal):AssertionError: expected true to be falseatisReplyRunAbortableForSignal(upstreamAbort.signal)(51/52 passing, only the new test failing).Verification:
vitest run(area):reply-run-registry52/52 ✅ ·followup-turn-admission36/36 ✅ ·chat-abort126/126 ✅reply-turn-admission.test.ts: 27 failures also present on cleanmainon this machine — the repo's SQLite runtime guard rejects Node 24.14.1's embedded SQLite 3.51.2 (node-sqlite.ts:81); verified identical viagit stash. Unrelated to this diff.oxlint: 0 errors ✅ ·oxfmt --check✅ ·tsgo -p tsconfig.core.json✅AI-assisted: the defect was found and the fix drafted with AI assistance; every link of the causal chain above was opened and verified against
main(38a5d39b), and both the red→green unit cycle and the three harness runs were executed locally (and re-executed by the author) before this update. I understand the change and stand by it.