Repository navigation
Conversation
- Share policy and retryable dispatch classification between follow-up custody and mailbox claim release. - Preserve the exact controller input through temporary policy failures; keep definite revocations terminal. - Reproduce with an installed SDK file-access policy on an isolated real Gateway; the built-in policy does not exercise file-store outages.
|
🦞👀 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. What this changesThis PR preserves queued messages through temporary authority-check failures so the existing drain can retry them. Example: A second message is queued while an agent runs a 20-second command, and the access-policy service becomes unavailable for 30 seconds.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a current queued-message loss path, and no definite introduced regression was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe session mailbox retains queued user input, the follow-up runner prepares agent turns, and authority admission determines whether execution may start. flowchart TD
A[Queued user message] --> B[Session mailbox]
B --> C[Follow-up runner]
C --> D[Authority admission]
D --> E[Agent execution]
D --> F[Temporary refusal]
F --> B
E --> G[Source reply]
Technical reviewBest possible solution: Distinguish temporary failures in both existing custody owners while preserving FIFO ordering, successful admission checks, and terminal revocation. Do we have a high-confidence way to reproduce the issue? Current source establishes both discard paths, and the body describes a concrete base/head Gateway reproduction; this read-only review executed no target code. Is this the best way to solve the issue? The change repairs both independent custody checks through one reused classifier without introducing another queue, retry mechanism, or state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b4254cb2f6fa. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +12, Tests +67. Total +79 across 5 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, 12:00 AM ET / 05:00 UTC. |
|
Closing in favor of a fix at the owner layer. This PR teaches two queue readers which The real-Gateway reproduction and outage matrix from this PR are reused for the replacement. |
## 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 #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. ## 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 `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]>
## 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)
Problem
A message queued while a turn is running is dropped when a Gateway access policy is briefly unavailable.
The authority contract says an unavailable policy evaluation is temporary: "An unavailable evaluation returns UNAVAILABLE with
details.code: OPERATOR_ACCESS_UNAVAILABLE; before dispatch, it is retryable and does not authorize the failed operation" (docs/plugins/sdk-runtime/gateway-and-nodes.md). Two readers of queued-input custody did not follow it. Both treated any exception fromassertCurrent()as a revocation:isFollowupOperatorAuthorityCurrent(auto-reply/reply/queue/types.ts), made the single rule by fix(auto-reply): show revoked queued input as a withheld failure instead of a silent cancel #200213: the queued input was consumed and the chat showedwithheld: Gateway access policy is unavailable; retry the operation.releaseSessionControllerClaim(sessions/session-controller.mailbox-claim.ts): a second, older reader. On release it marked the claim's authority as not current, so the drain dropped the input even when the first reader kept it.Affected installs: those with an access-policy plugin (
registerGatewayAccessPolicy) whose evaluation can fail. No built-in policy reaches this path.Fix
infra/operator-authority-error.tsgetsisOperatorAuthorityRetryableError, next to the existingisOperatorAuthorityUnavailable: a policy outage (also nested) or a retryableGatewayDispatchUnavailableError.Production code: +16 / −4.
Accepted edge: while an outage lasts, the input is retried on the drain's existing cadence (observed about 1.4 refused attempts per second, each refused before any model call, with one log line each). A policy that never recovers keeps the input owed until the policy is fixed or the chat is stopped. This replaces silently losing the message.
User impact
withheld.Not changed: when a grant is revoked while the input is queued, it is cancelled without a visible
withheldnotice (same as before this PR).Evidence
Regression tests, red on the merge base
941ae776, green on this head:followup-runner.test.ts: retains queued input after a temporary admission refusal (direct policy error, nested policy error, retryable dispatch error); ordinary revocation and non-retryable dispatch still withhold visibly. Base 3 failed; head 33 passed.session-controller.mailbox.test.ts: the exact controller input survives a temporary run/adapter policy failure through real reservation, claim deferral, release and reclaim. Base 2 failed (consumed instead of waiting); head 29 passed.Real Gateway from source (
ocx src, isolated state, real model), base vs head. A test access-policy plugin, loaded throughplugins.load.pathsand using only the documented plugin SDK, reads its grant from a file. A non-owner sends a second message while the agent runs a 20 s command; once the queue receipt shows the input queued, the grant file is renamed away for 30 s and back:941ae776withheld; never answeredReader audit: the predicate's callers (
followup-runner.ts,queue/drain.ts,agent-runner-execute.ts,goal-continuation-return.ts) and every other authority assertion on the queued-input path (queue/delivery-context.ts,queue/lifecycle.ts,queue/enqueue.ts,queue/drain.ts) were checked; only the two readers above treated a temporary failure as revocation.