Repository navigation
fix(queue): end queued input only on a recorded cause - #200433
Conversation
- Publish latched revocation through authority-owner signals and preserve the terminal reason. - Remove assertion-derived input retirement from queue and mailbox custody, including direct steering callers. - Cover policy outages, internal refusals, ingress-owner replacement, and recorded cancellation; document the custody contract. - Pinned-base real Gateway outage loses the queued input; source-tier head matrix retains and answers it with no queued-attempt failure notice.
- The deleted authority diagnostic was its only reader before reassignment.
|
🦞👀 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 changes before merge. What this changesThis PR preserves queued input through failed authority checks and makes authority owners publish terminal revocation through abort signals. Example: A message waits behind an active turn during a 30-second access-policy outage.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep open: this maintainer-authored PR addresses a current message-loss path, but stalled-turn recovery now throws on revoked authority and affected sibling tests fail. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe session controller retains accepted input, queue adapters schedule its execution, and operator-authority owners determine whether a new attempt may start. flowchart TD
A[Accepted message] --> B[Session mailbox]
B --> C[Turn admission]
C --> D[Authority owner]
D --> E[Agent execution]
D --> F[Temporary refusal]
F --> B
D --> G[Recorded cancellation]
Technical reviewBest possible solution: Retain owner-recorded revocation and FIFO custody, handle refused recovery enqueue without escaping dispatch, and migrate affected sibling tests. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the discard paths, and the PR describes a concrete base/head Gateway reproduction; this read-only review ran no target code. Is this the best way to solve the issue? Publishing revocation at its existing owners and removing inferred custody endings is a focused repair, but the stalled-recovery callback and sibling tests need adaptation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 81d8ceeaad93. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -69, Tests +237, Docs +5. Total +173 across 21 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 17, 2026, 1:02 AM ET / 06:02 UTC. |
- Refuse stalled continuation admission without ending queued-input custody. - Deliver the prepared preflight failure notice for its recorded source revocation while keeping explicit Stop and supersession silent. - Update consumer assertions to test revocation propagation and accepted-turn independence rather than upstream signal identity. - Verified 41 focused consumer files, 1008 tests, across 9 Vitest shards; full runtime-alias inventory retained for hosted CI.
…rded-cause # Conflicts: # src/gateway/operator-run-cancellation.test.ts
- The test typecheck rejected a possibly undefined reply operation.
|
Landed as d979dba. A queued message now ends only for a recorded cause (revocation, Stop, delete, consumption). A failed or unavailable access check refuses that attempt and keeps the message queued; it runs when the policy returns. Proof: regression tests red on the merge base and green here, a real-Gateway base vs head matrix in the description, and green CI on efc3df6. |
## Problem A message queued while a turn runs could be dropped because a check failed, not because anything ended it. The custody contract (`docs/concepts/session-controller.md`) lets an accepted input end only as consumed, deliberately dropped, cancelled or interrupted, and requires every accepted input to stay accounted for. The access-policy contract (`docs/plugins/sdk-runtime/gateway-and-nodes.md`) says an owner aborts its signal when a source is revoked, and that an internal assertion error "refuses the operation without revoking the person or their admitted runs". The code did the opposite in two places: - The authority owners latched a revocation they found inside `assertCurrent()` without aborting their signal (`operator-run-authority.ts`, `admitted-run-context.ts`). Revocations found by event rechecks were recorded; ones found by a direct check were not. - Seven queue and mailbox readers ended custody when `assertCurrent()` threw: `isFollowupOperatorAuthorityCurrent` and its four callers (followup runner, drain retry filter, stalled-turn handoff, goal return), mailbox claim release, early injection and steer admission, `reserveSteerCandidate`, and the channel steer caller. Each re-derived the owner's decision from the thrown error with its own rule. On a real Gateway with an access-policy plugin, a 30 s policy outage while a message was queued dropped it as `withheld`; it never ran after the policy returned. ## Fix - Owners record revocation: `assertCurrent` in `operator-run-authority.ts` uses its existing `revoke()`, and `createAdmittedRunOperatorAuthority` aborts a local revocation signal, composed with the upstream one, instead of keeping a private latch. A policy outage stays non-terminal. - Queue and mailbox custody end only on recorded facts: the input's abort signal (which already includes the source authority's signal), retirement, cancellation, or consumption. A failed check now only refuses that attempt; the input stays queued and the drain retries it. - Deleted `isFollowupOperatorAuthorityCurrent` and every inferred custody end listed above. The deletions in `drain.ts`, `agent-runner-execute.ts` and `goal-continuation-return.ts` match openclaw#200231. - Notices survive the owner's new revocation signal. The stalled-turn handoff refuses a continuation while the source authority is aborted or refusing, without ending custody, so the original dispatch keeps its fallback notice. `runReplyAgent` still returns a prepared preflight failure notice when the operation was aborted by the source authority's own revocation; an explicit Stop, supersession or restart stays silent. No new helper, flag, retry, backoff, schema or config. Production code: net −43 lines. Replaces openclaw#200413, which taught two of these readers a wider "temporary" rule; that rule disagreed with the owner on remote-ingress "owner changed" errors and would have retried such an input forever. ## User impact - A message queued during a temporary access-policy outage runs after the policy recovers. - An internal policy error no longer silently drops a queued message. - Revocation, Stop, delete and graceful restart behave as before: revoked, stopped and deleted messages are cancelled with zero model calls. Affected installs: those using an access-policy plugin whose evaluation can fail. No built-in policy reaches the outage path. ## Evidence - Regression tests, red on the merge base `20a8025c`, green on this head: - mailbox: the exact controller input survives a refusing run or adapter authority (base: consumed); - followup runner: policy outage and an unsignaled internal assertion error keep the input (base: dropped); - authority owners: a revocation found by `assertCurrent` aborts the owner's signal, including remote-ingress owner replacement (base: signal not aborted); - steering: early and guarded steer assertions, `reserveSteerCandidate`, and the channel steer caller keep the source after an unsignaled failure and still end it on recorded cancellation (base: retired). - Real Gateway from source (`ocx src`, isolated state, real model, a test access-policy plugin loaded through `plugins.load.paths` that reads its grant from a file; non-owner sender), base vs head, with the message confirmed queued before each event: | Event | Base `20a8025c` | Head | |---|---|---| | 30 s policy outage (grant file moved away and back) | withheld; never answered | same queued run answered after restore; 0 model calls during the outage; no failure notice for the queued message | | Grant revoked | cancelled, 0 model calls, socket 4001 `grant-revoked` | same | | Outage, then grant revoked | already withheld during the outage | kept through the outage, then cancelled; 0 model calls | | Stop | cancelled, 0 model calls | same | | Delete | removed, 0 model calls | same | | Graceful restart | resumed and answered | same | During the outage the head logs 14 refused attempts in 30 s (peak 2/s), each refused before any model call. - Accepted edge: a long outage keeps the message queued on the drain's existing retry cadence. Co-authored-by: Ayaan Zaidi <[email protected]>
A message queued while a turn runs could be dropped because a check failed, not because anything ended it. The custody contract (`docs/concepts/session-controller.md`) lets an accepted input end only as consumed, deliberately dropped, cancelled or interrupted, and requires every accepted input to stay accounted for. The access-policy contract (`docs/plugins/sdk-runtime/gateway-and-nodes.md`) says an owner aborts its signal when a source is revoked, and that an internal assertion error "refuses the operation without revoking the person or their admitted runs". The code did the opposite in two places: - The authority owners latched a revocation they found inside `assertCurrent()` without aborting their signal (`operator-run-authority.ts`, `admitted-run-context.ts`). Revocations found by event rechecks were recorded; ones found by a direct check were not. - Seven queue and mailbox readers ended custody when `assertCurrent()` threw: `isFollowupOperatorAuthorityCurrent` and its four callers (followup runner, drain retry filter, stalled-turn handoff, goal return), mailbox claim release, early injection and steer admission, `reserveSteerCandidate`, and the channel steer caller. Each re-derived the owner's decision from the thrown error with its own rule. On a real Gateway with an access-policy plugin, a 30 s policy outage while a message was queued dropped it as `withheld`; it never ran after the policy returned. - Owners record revocation: `assertCurrent` in `operator-run-authority.ts` uses its existing `revoke()`, and `createAdmittedRunOperatorAuthority` aborts a local revocation signal, composed with the upstream one, instead of keeping a private latch. A policy outage stays non-terminal. - Queue and mailbox custody end only on recorded facts: the input's abort signal (which already includes the source authority's signal), retirement, cancellation, or consumption. A failed check now only refuses that attempt; the input stays queued and the drain retries it. - Deleted `isFollowupOperatorAuthorityCurrent` and every inferred custody end listed above. The deletions in `drain.ts`, `agent-runner-execute.ts` and `goal-continuation-return.ts` match #200231. - Notices survive the owner's new revocation signal. The stalled-turn handoff refuses a continuation while the source authority is aborted or refusing, without ending custody, so the original dispatch keeps its fallback notice. `runReplyAgent` still returns a prepared preflight failure notice when the operation was aborted by the source authority's own revocation; an explicit Stop, supersession or restart stays silent. No new helper, flag, retry, backoff, schema or config. Production code: net −43 lines. Replaces #200413, which taught two of these readers a wider "temporary" rule; that rule disagreed with the owner on remote-ingress "owner changed" errors and would have retried such an input forever. - A message queued during a temporary access-policy outage runs after the policy recovers. - An internal policy error no longer silently drops a queued message. - Revocation, Stop, delete and graceful restart behave as before: revoked, stopped and deleted messages are cancelled with zero model calls. Affected installs: those using an access-policy plugin whose evaluation can fail. No built-in policy reaches the outage path. - Regression tests, red on the merge base `b4254cb2`, green on this head: - mailbox: the exact controller input survives a refusing run or adapter authority (base: consumed); - followup runner: policy outage and an unsignaled internal assertion error keep the input (base: dropped); - authority owners: a revocation found by `assertCurrent` aborts the owner's signal, including remote-ingress owner replacement (base: signal not aborted); - steering: early and guarded steer assertions, `reserveSteerCandidate`, and the channel steer caller keep the source after an unsignaled failure and still end it on recorded cancellation (base: retired). - Real Gateway from source (`ocx src`, isolated state, real model, a test access-policy plugin loaded through `plugins.load.paths` that reads its grant from a file; non-owner sender), base vs head, with the message confirmed queued before each event: | Event | Base `b4254cb2` | Head | |---|---|---| | 30 s policy outage (grant file moved away and back) | withheld; never answered | same queued run answered after restore; 0 model calls during the outage; no failure notice for the queued message | | Grant revoked | cancelled, 0 model calls, socket 4001 `grant-revoked` | same | | Outage, then grant revoked | already withheld during the outage | kept through the outage, then cancelled; 0 model calls | | Stop | cancelled, 0 model calls | same | | Delete | removed, 0 model calls | same | | Graceful restart | resumed and answered | same | During the outage the head logs 14 refused attempts in 30 s (peak 2/s), each refused before any model call. - Accepted edge: a long outage keeps the message queued on the drain's existing retry cadence. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit d979dba) Release adaptation: preserve both baseline occurrence-retirement and session-replacement cases; expect permanent authority failures to record cancellation in each. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit fb38fcadada62aadc8d0b94265dd9123df11f8c6)
Align the accepted-turn cancellation regression with #200433: permanent assertion failure records source abortion. Check the pre-assert signal separately and retain child liveness and subsequent device-revocation assertions. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 9d26cccaeb2be66f0e186d1574a2b1324fda9a39)
Problem
A message queued while a turn runs could be dropped because a check failed, not because anything ended it.
The custody contract (
docs/concepts/session-controller.md) lets an accepted input end only as consumed, deliberately dropped, cancelled or interrupted, and requires every accepted input to stay accounted for. The access-policy contract (docs/plugins/sdk-runtime/gateway-and-nodes.md) says an owner aborts its signal when a source is revoked, and that an internal assertion error "refuses the operation without revoking the person or their admitted runs".The code did the opposite in two places:
assertCurrent()without aborting their signal (operator-run-authority.ts,admitted-run-context.ts). Revocations found by event rechecks were recorded; ones found by a direct check were not.assertCurrent()threw:isFollowupOperatorAuthorityCurrentand its four callers (followup runner, drain retry filter, stalled-turn handoff, goal return), mailbox claim release, early injection and steer admission,reserveSteerCandidate, and the channel steer caller. Each re-derived the owner's decision from the thrown error with its own rule.On a real Gateway with an access-policy plugin, a 30 s policy outage while a message was queued dropped it as
withheld; it never ran after the policy returned.Fix
assertCurrentinoperator-run-authority.tsuses its existingrevoke(), andcreateAdmittedRunOperatorAuthorityaborts a local revocation signal, composed with the upstream one, instead of keeping a private latch. A policy outage stays non-terminal.isFollowupOperatorAuthorityCurrentand every inferred custody end listed above. The deletions indrain.ts,agent-runner-execute.tsandgoal-continuation-return.tsmatch refactor(subagents): restore completion authority from saved origin facts #200231.runReplyAgentstill returns a prepared preflight failure notice when the operation was aborted by the source authority's own revocation; an explicit Stop, supersession or restart stays silent.No new helper, flag, retry, backoff, schema or config. Production code: net −43 lines.
Replaces #200413, which taught two of these readers a wider "temporary" rule; that rule disagreed with the owner on remote-ingress "owner changed" errors and would have retried such an input forever.
User impact
Affected installs: those using an access-policy plugin whose evaluation can fail. No built-in policy reaches the outage path.
Evidence
Regression tests, red on the merge base
b4254cb2, green on this head:assertCurrentaborts the owner's signal, including remote-ingress owner replacement (base: signal not aborted);reserveSteerCandidate, and the channel steer caller keep the source after an unsignaled failure and still end it on recorded cancellation (base: retired).Real Gateway from source (
ocx src, isolated state, real model, a test access-policy plugin loaded throughplugins.load.pathsthat reads its grant from a file; non-owner sender), base vs head, with the message confirmed queued before each event:b4254cb2grant-revokedDuring the outage the head logs 14 refused attempts in 30 s (peak 2/s), each refused before any model call.
Accepted edge: a long outage keeps the message queued on the drain's existing retry cadence.