Skip to content

refactor(subagents): restore completion authority from saved origin facts - #200231

Open
obviyus wants to merge 5 commits into
mainfrom
obviyus/identity-pr4d
Open

obviyus wants to merge 5 commits into
mainfrom
obviyus/identity-pr4d

Conversation

@obviyus

@obviyus obviyus commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

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; authorizeTurn is a thin entry on that owner, not a new module.

What Problem This Solves

  • Completion custody. A child result held a live closure over the request that spawned it (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).
  • Owner widening after restart. After a restart, the custody was rebuilt from the requester session owner. In a shared session, a guest's child result then ran as the owner.
  • Cron edits killed runs. A running occurrence re-checked its job definition and occurrence marker on every authority check, so editing a job (for example its name) ended a run that was already in progress.
  • Queued input on a live closure. A queued follow-up ran on its request's live authority and needed separate liveness probes (isFollowupOperatorAuthorityCurrent) at three call sites.

Why This Change Was Made

  • Saved origin on the run row. subagent_runs.payload_json gets originFacts (additive JSON, no table, column or migration):
    • a gateway or channel recovery snapshot (the existing codec);
    • { kind: "session", profileId } when the spawning turn ran as the session principal (restart resume, system turns), restored through prepareSessionPrincipalRunAuthority;
    • { 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.
  • Refusals are visible; outages are not refusals. A completion or queued input whose origin cannot be authorized is withheld: a row without originFacts (written by an older build), an unavailable origin, 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 same withheld: <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 in toTurnWithheld: 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.
  • Accepted fallback: origins beyond the recovery codec bounds. Slice A's fallback to live authority now covers only origins the recovery codec cannot serialize (for example a role with more than 256 deny wildcards, or a channel model policy that has no snapshot). Those children run on their live authority and their completions are withheld visibly; queued input from such an origin keeps its live authority check at admission. Session-principal turns no longer use the fallback: they save { kind: "session" }. Removing the rest needs a codec change and is left for a follow-up.
  • Deleted:
    • the completion custody: map, requiredCompletionEntries, bind, release, transfer authority, batch identity comparison, the settle pass, and subagent-registry-memory.types.ts;
    • the restart owner-authority rebuild (restart now readmits owed rows by key);
    • the cron per-check occurrence and definition closures in restoreCronOperatorSource, captureCronJobTurnTarget (including its sessionId comparison) and prepareCronStreamSourceAuthority;
    • isFollowupOperatorAuthorityCurrent and its uses in the drain, the stalled-turn handoff and goal continuation.
  • Not in this PR: revoked input queued through chat.send still fails on the live source before follow-up admission (operator-run-cancellation and the steering path), so it shows no notice. That is the next A-auth slice.
  • Kept: the physical store-switch boundary (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 a WeakMap that needs no settle pass.

Upgrade behaviour

  • A subagent_runs row written by an older build has no originFacts. After the upgrade its completion is withheld: the parent chat shows withheld: the origin of this child run was not saved followed by the result text, so the result stays readable.
  • These rows are not recovered through the session owner. Restoring them as the session owner would widen authority: in a shared session a guest's child result would run as the owner.
  • No schema, stored-row or protocol change: originFacts is additive JSON on the existing row payload. Rows written by this build carry it.
  • A child still running at upgrade time is re-steered by the restart-resumed parent, which saves { kind: "session" } facts (Upgrade journey in the E2E table).

Security model

  • Authority is saved origin facts intersected with current policy, checked at turn admission. Restart, queued input, cron and completions all use the same restore path.
  • Revoked by a policy change: device revoked, shared token rotated, role or profile changed, channel link removed, or the session principal losing access to the chat. The restore refuses, and the chat shows 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.
  • Ceiling: facts come only from the host-issued authority at launch or enqueue (the capture asserts the live authority first, and snapshot scopes are intersected at capture). A session origin restores exactly the principal its spawning turn ran as. Nothing falls back to the session owner or to a live closure.

User Impact

  • A child result reaches its parent after a parent edit, a Gateway restart or an upgrade, under the authority of the person (or session principal) that spawned it.
  • Editing a cron job no longer kills its running occurrence.
  • A revoked origin shows a visible withheld notice 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).

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: XL labels Nov 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 997070932e1501eafaf830c235a238460ff713e4, but the PR head is now a14999e3b6b65d5f92999dba800d5969e97fa348. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-16T20:04:39.186Z sha 9970709 :: blocked before merge. :: [P2] Record origin refusals through the completion failure owner | [P2] Stop expecting released launch authority to remain active | [P2] Supply recoverable origins and row resolvers in delivery fixtures

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 16, 2026
@obviyus
obviyus force-pushed the obviyus/identity-pr4d branch from beb496c to 2efe63f Compare November 16, 2026 20:33
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: a14999e3b6b65d5f92999dba800d5969e97fa348
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/admitted-run-operator-authority.types.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/cron-stream-source-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-sharing-authorization-async.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

E2E (ocx src, isolated scratch Gateway, real model through the cliproxy Claude route)

Base: merge base 869734209368. Head: this PR.

Journey Base Head
J1 edit while a child runs (parent yielded; second message, then sessions.rewind and a third message) (fixed by slice A) Child finishes; the parent replies parent-got child-final; row origin=gateway, delivery=delivered
Upgrade child row written by the base Gateway; SIGTERM mid-child; the head Gateway starts on the same state n/a The restart-resumed parent re-steers its child; the head row saves origin=session; the parent replies parent-got child-final; delivery=delivered
J2 shared Gateway token rotated while a yielded child runs (child sleeps 150 s) (custody revoked) The completion is refused at restore: withheld: Restart recovery authentication owner changed; start a new user turn.. At the time of that run the parent chat showed the generic copy; the yielded-batch notice now uses the same withheld renderer (unit-covered, not re-run end to end)
J4 a cron occurrence's job is edited mid-run Run continues (cron-done) Run continues (cron-done). The edit no longer reaches the run's authority checks
Queued revoke input A queued behind a busy turn; token rotated before A runs A is cancelled silently (chat pending input aborted: authority-revoked); no transcript entry Not fixed in this PR. A is still refused without a transcript notice: the chat.send queue path checks the live source (steering followup unavailable: source authority lost) before the follow-up queue sees the saved origin. Follow-up slice

Logs and state per run: runs/<label>/ (proxy ledger, gateway log, scratch state).

…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]>
@obviyus
obviyus force-pushed the obviyus/identity-pr4d branch from 6e18a6b to b4ef253 Compare November 16, 2026 23:33
@obviyus
obviyus marked this pull request as draft November 16, 2026 23:35
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

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.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

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]>
obviyus and others added 2 commits November 17, 2026 05:55
…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]>
@obviyus
obviyus marked this pull request as ready for review November 17, 2026 00:41
@obviyus

obviyus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on head a14999e (ocx src, isolated scratch Gateways, real model through the cliproxy Claude route)

Journey Result
J1 edit while a yielded child runs (second message, sessions.rewind, third message) The child finishes; the parent replies parent-got child-final; row origin=gateway, delivery=delivered
Upgrade the child row was written by the base build (8697342); SIGTERM mid-child; the head Gateway starts on the same state The restart-resumed parent gets the child result: parent-got child-final
J2 shared Gateway token rotated while a yielded child runs The settle wake is refused at restore. The parent chat shows withheld: Restart recovery authentication owner changed; start a new user turn. (run-failed-before-reply). Nothing is widened

New unit proof: subagent-registry.completion-authority.test.ts (policy-outage, policy-refusal). A policy outage keeps the completion owed, and the next attempt delivers it under the original profile. A policy refusal is withheld. The outage case fails on 5148de7 and passes on a14999e.

Logs and state: runs/{h4-jrw,up4-base-head,h4-jrevoke2}.

obviyus added a commit that referenced this pull request Nov 17, 2026
## 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
## 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]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
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)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. security-sensitive-changed size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant