Repository navigation
Conversation
|
🦞👀 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: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
beb496c to
2efe63f
Compare
|
E2E (ocx src, isolated scratch Gateway, real model through the cliproxy Claude route)Base: merge base
Logs and state per run: |
…s, queued input and cron Detached work restores its authority from origin facts saved at launch or enqueue, through the existing operator-recovery restore path, at turn admission. The in-memory completion custody, the restart owner-authority rebuild, the cron per-check occurrence closures and the follow-up liveness probe are deleted. A refused origin is withheld visibly and its result stays readable; temporary outages retry. Co-authored-by: obviyus <[email protected]>
6e18a6b to
b4ef253
Compare
…efusals Co-authored-by: obviyus <[email protected]>
|
Hold from the coordinator: the production diff is net −7 after the rebase, below the net-negative bar. This PR is set to draft until the cuts in the handoff notes land. The PR owner marks it ready again when the numbers are clearly negative. |
|
Coordinator decision on the local-review P1 (rows written before origin facts existed): do not recover them through the session owner, because that widens authority, and do not rerun the review. Overriding this finding is a maintainer decision for the morning. Until then: keep this PR as a draft, make the cuts in the handoff notes, and add an "Upgrade behaviour" section to the PR body. It must state that old rows without facts are withheld with the result text readable. |
… refusal classifier Drop withheldOnRefusal and the session-principal refusal constructor. A completion or queued input whose origin cannot be restored is withheld with the reason; the parent chat reuses the withheld: <reason> notice with the result text. Co-authored-by: obviyus <[email protected]>
…agnostics Co-authored-by: obviyus <[email protected]>
…ch outage An outage is not a revocation. toTurnWithheld passes GatewayOperatorAccessUnavailableError and retryable GatewayDispatchUnavailableError through; the completion maps them to the existing preparation retry and queued input keeps its normal retry. Co-authored-by: obviyus <[email protected]>
E2E on head a14999e (ocx src, isolated scratch Gateways, real model through the cliproxy Claude route)
New unit proof: Logs and state: |
## 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)
Scope
Authority from saved facts, slice B (slice A: #200176). Detached work (a subagent completion, a queued follow-up, a cron occurrence) now restores its authority from saved origin facts and current policy at turn admission. The existing operator-recovery restore path (
restoreGatewayQueuedOperatorRecovery) is the only path;authorizeTurnis a thin entry on that owner, not a new module.What Problem This Solves
completionAuthorities). The closure was lost on every restart and released when its source signal fired, although nobody revoked access. The result then failed with "Subagent completion authority is no longer active" (986 and 480 production occurrences on two hosts before slice A).isFollowupOperatorAuthorityCurrent) at three call sites.Why This Change Was Made
subagent_runs.payload_jsongetsoriginFacts(additive JSON, no table, column or migration):gatewayorchannelrecovery snapshot (the existing codec);{ kind: "session", profileId }when the spawning turn ran as the session principal (restart resume, system turns), restored throughprepareSessionPrincipalRunAuthority;{ kind: "system", scopes }for a launch without an operator principal;{ kind: "none" }for a launch without a Gateway authority, which delivers in its caller's scope as before.originFacts(written by an older build), anunavailableorigin, or a restore that current policy refuses. It never widens to the session owner. A withheld completion settles as a permanent failure, and the parent chat shows the samewithheld: <reason>notice that fix(auto-reply): show revoked queued input as a withheld failure instead of a silent cancel #200213 ships for queued input, followed by the result text, so the result stays readable. There is no second renderer and no refusal classifier. The one exception intoTurnWithheld: a policy outage (GatewayOperatorAccessUnavailableError) or a retryable dispatch outage is not a revocation. The completion stays owed through the existing preparation retry, and queued input keeps its normal retry.{ kind: "session" }. Removing the rest needs a codec change and is left for a follow-up.requiredCompletionEntries, bind, release, transfer authority, batch identity comparison, the settle pass, andsubagent-registry-memory.types.ts;restoreCronOperatorSource,captureCronJobTurnTarget(including itssessionIdcomparison) andprepareCronStreamSourceAuthority;isFollowupOperatorAuthorityCurrentand its uses in the drain, the stalled-turn handoff and goal continuation.chat.sendstill fails on the live source before follow-up admission (operator-run-cancellationand the steering path), so it shows no notice. That is the next A-auth slice.retireCompletionAuthority, fix: keep child notifications out of replaced session stores #152828 / [Bug]: Session-store reload sends queued heartbeat context into another store #152288) and requester-turn accounting, which is not authority. The accounting now lives in aWeakMapthat needs no settle pass.Upgrade behaviour
subagent_runsrow written by an older build has nooriginFacts. After the upgrade its completion is withheld: the parent chat showswithheld: the origin of this child run was not savedfollowed by the result text, so the result stays readable.originFactsis additive JSON on the existing row payload. Rows written by this build carry it.{ kind: "session" }facts (Upgrade journey in the E2E table).Security model
withheld: <reason>. Cancel is explicit: Stop, cron disable or removal. The end of the parent turn, an edit, an abort plus a new message, or a cron job edit no longer revokes anything.User Impact
withheldnotice that keeps the result readable, instead of a silent drop or a generic "couldn't be delivered" message.Evidence
Production diff: net −42 (+476/−518, tests excluded) against merge base
726a8dd4. E2E table posted below (ocx src, scratch Gateway, real model on the cliproxy route).