Skip to content

refactor(gateway): keep admitted agent authority fixed - #201070

Closed
obviyus wants to merge 5 commits into
mainfrom
refactor/check-once-agent-authority
Closed

obviyus wants to merge 5 commits into
mainfrom
refactor/check-once-agent-authority

Conversation

@obviyus

@obviyus obviyus commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Started agent work can lose its authority after admission. The logged families include github_publish failed: agent runtime authority is no longer active (T01, 25 events) and preflight compaction's agent tool caller authority is no longer active (T05, 19 events). These are matched log events, not unique requests, and their text alone does not identify the historical invalidation.

The source path is concrete: captureGatewayOperatorRunAuthority subscribed to device/profile/OCID/role changes (operator-run-authority.ts base lines 558–590). A role assignment called revoke at line 582, aborting the authority signal; config/profile changes rechecked captured policy at lines 568/587. Subsequent assertions also reread device source (485), Gateway context identity (492), OCID membership (500), and role (518). prepareAgentRunAdmission threads this assertion into the run source. agent-run-registry.ts:395 rechecks that source; a failure retires the exact run claim at line 438. createAgentRuntimeApprovalAuthorityValidator then returns false for the delegated identity (agent-runtime-approval-authority.ts:23–24), producing T01 at agent-runtime-authority.ts:28 or the router's equivalent session-runtime-authority.ts:52.

T05 is the receipt translation of the same source failure, not a separate role decision: createAdmittedGatewayToolCallerIdentity composes the admitted-run assertion and supplied receipt predicate (gateway-caller-context.ts:286–290); composeReceiptAuthority translates either predicate's exception/false to false (:190–195); captureGatewayToolReceiptAssertion throws the caller-inactive message (:213,216–217). Preflight compaction retains that caller/source across its awaited compaction operation. Run-claim closure, Stop, and independent supplied receipts can also make this predicate false.

Rule

Check authority when the request starts. A Gateway operator run keeps its admitted profile, role, scopes, and model-policy ceiling until it finishes. Revocation, reconnect, assignment changes, and policy reload affect the next request. A model-policy reload does not change or abort a running Gateway operator run. Explicit user model selection remains a user action: the model-selection owner still persists the chosen model and applies the captured ceiling; this change does not freeze the session's selected model. Queued, retried, and replayed work still checks current authority at its own start.

Queued work starts a new request. A queued, replayed, or retried input reauthorizes once at source adoption against the original person's current admission facts. A permission/model-policy refusal retires only that input through the existing abandonment/withheld-notice path, including its pending-input cancellation; it is not retried and never aborts shared authority or a running turn. Transient authority unavailability retains preparation retry behavior. Accepted edge case: any edit to the role's configured model-policy object while input waits, widening included, refuses the queued input. The user re-sends for a fresh ceiling; the frozen authority is not mutated.

Queued work: start-site decisions

  • agent-runner-execute.ts:79: only prepares stalled recovery; rebuilt recovery clears source custody and re-enqueues, so its new check is at lifecycle adoption; normal execution already adopts at :236.
  • agents/command/post-run.ts:277: the same admitted command records its final-delivery marker; no reauthorization.
  • agents/command/post-run.ts:301: the same command reads its original delivery target under session/write fences; no reauthorization.
  • agents/command/post-run.ts:391: foreground CLI compaction retains the original command budget/custody; no reauthorization.
  • subagents/spawn/subagent-spawn.ts:153: a child inherits its parent's fixed authority under S2; no reauthorization.
  • plugin-native-subagent.ts:84: native child work uses the already-admitted parent source, with plugin/resource/Stop guards retained; no reauthorization.
  • channel-run-admission.ts:125–179: runtime preparation reuses source admission (or an already-authorized native child request); no second policy check during preparation/fallback.
  • queue/drain.ts:186–203: collect and summary drains adopt every queued source, each checked once before custody commits; authority-copying helpers do not check.
  • agent-runner-steer-adoption.ts:425 and session-controller.steer.ts:138: already-accepted unqueued steering remains fixed; queued fallback/new custody reauthorizes through adoption. The hook is gated by canonical custody.enqueued.
  • agent-runner-result.ts:248–255 and followup-delivery.ts:453–475: stranded-final retries clear controller input/claim and enqueue fresh custody, so they reauthorize at the retry's adoption.
  • stalled-turn-recovery.ts:37–48 and transcript-followup-run.ts:17–39: stalled/goal transcript continuations clear prior admission and enqueue a new source, so adoption checks current authority.
  • gateway/queued-chat-inputs.ts:86–95: restart replay already restores current original-person authority and checks sender identity; the separate restoration owner remains its admission.
  • plugin-command-scheduled-run.ts:291–304 and cron/session-run.ts:81–108: each scheduled start restores current origin authority; no new per-effect check is added here.
  • In-turn model/provider retries, compaction, and resumed effects that retain an already-adopted source remain the same request and keep its fixed authority.

Change

  • Delete the operator run owner's device/profile/role/OCID subscriptions and its post-capture device/Gateway/membership/role checks.
  • Capture the named role and prepared model policy once. Return captured role facts rather than resolving the same person's role against reloaded config.
  • Replace createAgentRuntimeAuthorityGuard.commitGuard's live source-policy recheck with lifecycle-only validation. Initial ensureActive admission and supplied caller/data guards remain; exact run/tool release, worker-claim loss, and message-turn capability closure still fence effects and returned results.
  • Keep prepared profile policy facts only after their explicit admit() boundary, called for the accepted chat target in session-sharing.ts, or when carrying an existing admitted run. Admission validates currentness before marking; requester and physical/settled-source checks still run during consumption. Other non-admitted callers retain the prior revision refusal.
  • Keep references, release, use-after-release, explicit cancellation, and the supplied source/ingress/invocation assertions and abort signals. Those opaque callbacks include exact session and physical-store fences and cannot be deleted as one generic policy check.
  • Replace obsolete mid-request-revocation/model-refresh expectations with admitted-work survival and fresh-admission refusal. Retain independent Stop, release, pending-admission, and recovery-owner coverage.

Whole-PR production delta against 1f03e2723b78 is +167 / −174 lines (net −7), including queued-start admission and retained lifecycle fencing. The initial policy cut alone was net −92. The constructors remain; deleted per-effect machinery includes assertCapturedRoleCurrent, assertRoleCurrent, resolveCurrentRole, and the subscription recheck callback. Source guards, reference owners, and channel/recovery constructors remain.

Obsolete tests changed with their checks:

  • Operator/role/reload/reconnect/WS cases now keep captured grants and model choices; fresh capture/request admission sees the new restrictions.
  • Reset cases retain already-admitted policy. Send/Slack/Matrix/Teams cases still refuse publication after explicit run/turn/claim/plugin closure, preserve provider-I/O boundaries, and reject later use. Resource disposal and artifact replacement are not policy revocation.
  • Own-run questions remain open after demotion and cancel on exact run closure; the separate native browser-waiter limitation is recorded below.
  • Prepared-sharing coverage changes only admitted-run policy revision behavior; non-run requester checks remain intact, and release still refuses later use.
  • Model-picker coverage explicitly applies an allowed manual selection, rather than freezing the selected model with its policy.

Refusal reachability after this cut

Logged family Removed path Paths that can still refuse
T01: agent runtime inactive Operator owner's own role/profile/device/Gateway/membership changes no longer retire the admitted run. The runtime guard's commit callback checks lifecycle ownership without rerunning its source policy. Initial admission of a closed runtime remains refused. Exact delegated claim/tool closure, explicit abort, worker placement claim loss, message-action capability closure/expiry, supplied source/ingress/invocation assertions, router runtime assertions, and direct assertActiveAgentRuntimeAuthority callers remain.
T05: agent tool caller inactive A receipt no longer becomes false because this operator owner's own captured policy/source identity changed. composeReceiptAuthority can still return false for a closed/replaced admitted execution, delegated tool lease release, explicit cancellation, or an independent supplied receipt/source assertion. captureGatewayToolCallerAssertion also retains abort-signal checks. These mixed per-source inputs are the next S1 cut, not silently removed here.
Cron occurrence source inactive Only an operator-source failure originating in the deleted owner predicates is eliminated. cron/active-jobs.ts occurrence identity/removal/cancellation/source/standing-grant checks are unchanged. Cron occurrence admission/lifetime separation is a separate PR.
Admitted run inactive Deleted operator-owner policy predicates no longer fail the run's source assertion. Foreground closure, exact run/claim replacement or release, explicit Stop/abort, and other supplied run-source assertions still refuse. Transcript/session source fences remain unchanged.

Native question waiters still compose the separate captureGatewayRequestOperatorGuard (session-mutation-guards.ts:393–399) into settlement; that router-owned role recheck can refuse an already-waiting browser even while the underlying admitted question survives until its exact run closes. Splitting that request/waiter owner, the restored continuation owner, and the opaque source adapters is next; this PR does not claim those distinct lifetimes are migrated.

The real chat.send follow-up case also remains protected by an earlier transcript-persistence role guard, observed as user transcript persistence failed: SessionMutationAuthorizationChangedError: Your operator role changed; reconnect before continuing. That guard already refuses the queued input on 15e103909ce6, before the new queue check is reached. It is a remaining lifetime check for a later S1 source-specific cut, not removed or bypassed to manufacture a live regression.

Threat model

Role assignment/config subscription and per-effect assertRoleCurrent: row 2 explicitly accepts finishing one already-admitted request after demotion. The captured role, scopes, and agents/session/sandbox restrictions never widen. New requests still resolve current role grants, including after asynchronous profile preparation; row 5's new queued/replayed starts are unchanged. No sandbox or command-approval decision (row 4) is removed.

Profile-change subscription and repeated profile lookup: row 2 remains bound to the originally admitted profile and its copied role facts; a merge cannot switch this run to another person's authority. Row 1's authenticated identity admission remains. Prepared-profile retention/release is unchanged, and independent exact-session/credential fences are not removed.

Device-source subscription and per-effect source-identity check: row 1 still authenticates and checks the device at admission, including the final check after profile preparation. A revoked device does not admit another request. Row 2 permits the existing person's started request to finish; device revocation retention and use-after-release checks remain. No credential content or secret-egress control (row 3) changes.

Gateway context identity recheck: comparing the resolver's current object to its originally observed object was not a data-write fence. Row 2's admitted identity and ceiling stay captured; request admission still requires the correct Gateway owner. References, supplied source/ingress/invocation guards and abort signals preserve actual cleanup, physical-data, and cancellation ownership. Row 5's replay admission is unchanged.

OCID membership subscription and repeated membership-current check: row 2 permits the admitted membership's captured restriction to last for that request, without adopting a later role or another member. Row 1's verified OCID principal and current membership admission remain; row 5's future starts still check current membership. Other consumers' independent OCID checks are outside this cut and remain reachable.

Session-sharing policy-revision veto for admitted work: a role edit invalidated prepared facts belonging to an already-accepted chat source captured before its run authority existed. The chat-target owner now calls profiles.admit(), which validates currentness once before fixing the policy facts; existing admitted run authority also qualifies. Requester identity and physical/settled-source checks remain on consumption. Unadmitted clients retain their old revision refusal. Row 2 stays bound to the original person's facts; fresh admission sees current policy. Rows 1 and 5, transcript/session/write fences, and rows 3–4 are unchanged.

Live model-policy refresh and change notification: this is the model-policy portion of row 2, not a new route to another person's data or credentials. The run retains its original allowed-model ceiling; reload cannot widen it. The next request gets the updated ceiling, and queued/replayed starts retain row 5's current admission. Explicit model selection does not bypass the captured policy. Secret selection, sandbox decisions, and command approvals (rows 3–4) are unchanged.

Runtime source-policy recheck inside commitGuard: source policy is checked at initial runtime admission (rows 1–2), not again at effect settlement. The canonical validator's lifecycle-only path retains exact run/tool claims, explicit abort, worker placement claims, and the message-action turn capability. The supplied caller assertion also remains, preserving mixed session/physical-write fences. No transcript writer binding, plugin lifecycle lease, expected-id/CAS, secret control (row 3), command approval (row 4), or queued/replayed start check (row 5) is removed.

Queued-work admission (row 5): retained running authority is not permission to start a later queued input. Canonical enqueued custody invokes reauthorize() once before adoption commits, checking the person's current profile, role/scopes, device revocation, membership, and configured model policy. Ordinary socket closure/reconnect is not revocation; transport checks remain capture-time only. Permanent admission refusal cancels that input's pending record and retires only its exact source, producing the existing withheld/abandonment outcome once; transient authority unavailability and failed custody adoption can retry with a fresh start check. Already-adopted work and unqueued accepted steering remain fixed. Rows 1–2 retain original-person ceilings; rows 3–4, cancellation, release, and data fences are unchanged.

Evidence

Source tier: real isolated Gateways launched with ocx src, real model calls, synthetic operator identities, separate loopback ports/state, and users.setRole(writer → denied) during an admitted turn. Base is 1f03e2723b78a4c66cdf34ce7863c0ac673a9dc8 via ocx base --src; HEAD uses those pinned dependencies with the worktree's complete src overlaid in a disposable source snapshot.

Flow Base Head
Real model → task-owned awaiting tool → real sessions.list, role changed while awaiting Original role-subscription error at operator-run-authority.ts:582; resumed SDK call refused; turn aborted The same SDK call succeeds before and after the role change; final S1_TURN_FINISHED, agent.wait.status=ok
Real model → builtin message tool → real message.action, role changed while its actual channel handoff awaits Actual handoff throws TypeError: agent runtime authority is no longer active at agent-runtime-authority.ts:28; no mailbox delivery Observed on e3a9cabeed0c: actual handoff succeeds (local_mailbox_delivered, receipt c23370bf-b924-4b03-acb0-f545caa540d4); agent.wait.status=ok, terminal reply S1_TURN_FINISHED; no runtime-authority-inactive error
Next fresh request from the demoted operator FORBIDDEN: missing scope: operator.write Observed on e3a9cabeed0c: next_request_refused, FORBIDDEN: missing scope: operator.write
Same awaiting real message.action handoff, explicit Stop via chat.abort Not rerun Observed on e3a9cabeed0c: aborted=true; handoff throws SessionMutationAuthorizationChangedError: operator execution authority is no longer active. Reconnect to the Gateway, then resend your message. If access is denied, ask an administrator to restore it.; tool settles error, agent.wait.status=error, stopReason=rpc; no mailbox artifact/delivery
Queued chat.send follow-up; remove write while first turn is busy 1f03e272: both turns abort; 15e103909ce6: running turn finishes and queued input is already visibly refused by the earlier transcript-persistence guard Runtime fix a8e5504847bb: running turn finishes S1_QUEUED_RUNNING_FINISHED; queued input visibly errors once; fresh send is FORBIDDEN

The message/Stop proofs observed on e3a9cabeed0c use a task-owned local channel adapter and its real production handoff callbacks, never a substituted authority predicate or Gateway handler. No live Gateway was modified.

Proof limit: T01's exact literal is reproduced in the paired message boundary; T05's exact literal was not separately reproduced. These traces establish the observed source/handler mechanisms, not which unrecorded invalidation caused each historical production log event. Remaining refusal paths are enumerated above. Earlier intermediate HEAD artifacts are retained as diagnostic history, not final proof.

Checks

  • Aggregate check:baseline-ratchets: all ten component checks pass (the first aggregate attempt timed out under host load and was rerun).
  • tsgo:core:test: all 29 shards pass; tsgo:core: pass. A structural reader consumer exposed by the new admission method was fixed by requiring only readCurrent from projection readers, not by adding a no-op admission method.
  • Oxfmt and Oxlint cover all 29 changed files: pass, zero warnings/errors, including boundary declaration preparation. The send state/store fixtures were moved unchanged into send.state.test-support.ts after the pre-commit growth cap rejected the larger test file; the line-cap gate and all eight focused fixture/canonical-send cases pass without removing coverage.
  • Final affected source/channel rerun: 54 passed across prepared-sharing, Slack, and Matrix. Focused reset/caller-custody handler cases: 6 passed. Other owner/model runs observed 181 Gateway and 11 model-policy cases passing; their wrapper was interrupted by an in-flight source-generation change, so the affected files were rerun after freezing source.
  • Consumer sweeps covered src extensions packages test scripts ui; LSP references covered changed exported owners and the prepared-profile type. The obsolete authority.role performance-counter consumer was removed.

Tier full was previously run for the policy cut: ocx build --dts and the packed tarball installed into a clean prefix (CLI, doctor). This is prior-revision evidence, not a full-build claim for the later CI repair.

One broader, earlier agent.test.ts attempt timed out with requires image understanding for a non-ACP session with acpTurnSource. Attribution is unproven; the focused authority cases pass, and CI runs the full file.

Queued-start proof scope

Live chat.send on the previous head did not expose the unsafe queued execution, because an earlier transcript-persistence role guard (user transcript persistence failed… role changed) refused the queued input first. On this head the running turn finishes and the queued input is refused visibly. The unit regression below isolates the new start check; this is not a three-way live reproduction. That transcript-persistence guard is a remaining lifetime check for a later PR. The proof run's final wake hit a model-side policy refusal; it was not retried.

Queued-start validation

  • Regression on the previous head (15e103909ce6): four before-start cases are red, because queued work runs instead of being refused after write loss, agent-policy restriction, model-policy narrowing, or model-policy widening.
  • This head: 108 tests pass across eight authority/queue suites, including terminal retirement of the refused input, one abandonment notice, unchanged running authority/signal/ceiling, single-flight adoption, retry after a transient adoption failure, and no reauthorization for unqueued or already-adopted work.
  • All ten baseline sub-ratchets, line-cap, core typecheck, oxfmt and oxlint pass. The session-identity allowance for operator-run-authority.ts shrinks 2 → 1.
  • Prior queued-start revision, tier full: ocx build --dts and the packed tarball installed into a clean prefix (CLI, doctor). Not rerun for the later CI consumer repair.

CI consumer repair

  • Feishu/Slack allowed-path failures came from a missing commit callback, not provider permission changes. The callback now retains lifecycle-only validation while omitting repeated source policy checks. Existing Teams turn-token/run-response negatives and restored send/Slack/Matrix closure negatives retain resource-release/cancellation fences.
  • Profile merges change whose data is addressed (row 2), not just the person's policy. Prepared-sharing consumption now retains the identity-only selection assertion bound to its original physical source; role-only edits remain tolerated after admission, but profile identity replacement still refuses.
  • The native mailbox merge test still requires a visible refusal, no native enqueue/inbound dispatch, and preserved original transcript ownership; only its obsolete operator-owner diagnostic is updated to the prepared-profile fence's actual refusal.
  • The repair's core typecheck, all 29 test-type shards, line-cap, session-identity, and eleven-file format/lint checks pass. The nine other baseline components (including database-worker) passed in the aggregate attempt; its sole session-identity failure was then fixed and that component passed separately. Consumer sweep: 471 references across src extensions packages test scripts ui.
  • Vitest-source: all 274 distinct consumer/regression cases pass across the nine requested boundary suites after the diagnostic-only steering correction (the complete steering file's nine cases pass on its focused rerun). Another 58 delegated/worker lifecycle cases pass. No production source changed after these boundary results.

- Capture operator role and model policy once instead of revoking admitted work on policy or source changes.
- Admit accepted-chat profile policy facts explicitly while preserving requester, physical-source, cancellation and write fences.
- Remove runtime identity rechecks from effect commits and update obsolete revocation tests and operator docs.
@clawsweeper

clawsweeper Bot commented Nov 18, 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 docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 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: e3a9cabeed0ced70fc5c4e86bcacc4e9651ff09e
  • 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/agent-runtime-approval-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-role-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/agent-runtime-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@obviyus
obviyus marked this pull request as draft November 18, 2026 07:41
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR captures Gateway operator permissions once so admitted agent work can finish after role, device, or policy changes.

Example: An operator is demoted from writer to denied while an admitted message action awaits its channel handoff.

  • Before: The handoff fails with “agent runtime authority is no longer active.”
  • After: The admitted handoff completes, while a fresh request is refused.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful simplification with production-entry-point evidence, held by a concrete queued-start authorization defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The body records paired isolated-Gateway runs with real model calls through sessions.list and builtin message.action: admitted work finishes after demotion on head, while a fresh request remains forbidden; it explicitly limits attribution of historical errors.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An agent turn that was already accepted can fail when its operator's permissions change during execution.
Reason: The maintainer-authored direction matches the repository's check-at-start rule and removes a demonstrated source of interrupted work.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this maintainer-authored PR addresses admitted turns losing authority, but it also lets queued turns start with an outdated model-policy ceiling.

Priority: P2
Reviewed head: 15e103909ce67cc2b8f2f9c2552b44e66f86b0a8

Before merge

  • [P1] Recheck current model permissions when queued work starts (P1) - Queue a Gateway operator message while another turn is running, then remove fixture/a from that role's modelPolicy.allow before the queued turn begins, leaving its scopes, agents, and session permissions unchanged. The queued turn retains this captured modelPolicy: prepareReplyAgentTurn reuses queued.operatorAuthority, admitFollowupRunLifecycle only calls its now policy-independent assertCurrent(), and prepareReplySystemPrincipalAuthority skips callers already carrying authority. createOperatorModelSelectionAssertion therefore still permits fixture/a, allowing a new provider request after permission was removed. Previously the live policy intersection rejected it. Apply current restrictions once at the existing queued-start boundary, bounded by the original ceiling, without reinstating checks during an executing turn.
  • Resolve security concern: Removed model permission survives queued-start admission - The affected principal is an operator whose waiting turn was captured under an older model allowlist; its later provider request must satisfy the policy in force when that queued execution starts.

Findings

  • [P1] [P1] Recheck current model permissions when queued work starts — src/gateway/operator-run-authority.ts:555-559
  • [medium] Removed model permission survives queued-start admission — src/gateway/operator-run-authority.ts:555
Agent review details

How this fits together

Gateway admission turns authenticated operator identity and policy into authority carried through agent execution, queued turns, and tool effects.

flowchart TD
  A[Authenticated operator request] --> B[Gateway admission]
  B --> C[Captured operator authority]
  C --> D[Active agent turn]
  C --> E[Queued turn admission]
  D --> F[Model and tool effects]
  E --> F
Loading

Technical review

Best possible solution:

Keep active-turn authority fixed, but have the existing queued-turn admission owner apply current restrictions within the original ceiling before starting execution.

Do we have a high-confidence way to reproduce the issue?

Current main revokes captured authority on role changes, and the supplied paired Gateway results demonstrate the resulting active-turn failure; this review executed no target code.

Is this the best way to solve the issue?

Capturing authority at the existing admission owner is appropriate, but queued execution also needs a current-policy decision at its own start.

Full review comments:

  • [P1] [P1] Recheck current model permissions when queued work starts — src/gateway/operator-run-authority.ts:555-559
    Queue a Gateway operator message while another turn is running, then remove fixture/a from that role's modelPolicy.allow before the queued turn begins, leaving its scopes, agents, and session permissions unchanged. The queued turn retains this captured modelPolicy: prepareReplyAgentTurn reuses queued.operatorAuthority, admitFollowupRunLifecycle only calls its now policy-independent assertCurrent(), and prepareReplySystemPrincipalAuthority skips callers already carrying authority. createOperatorModelSelectionAssertion therefore still permits fixture/a, allowing a new provider request after permission was removed. Previously the live policy intersection rejected it. Apply current restrictions once at the existing queued-start boundary, bounded by the original ceiling, without reinstating checks during an executing turn.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 74e5127c0c3d.

Provenance checked

Testing

Proof path: shipped entry point.

Security

Needs attention: Queued execution currently crosses the model-permission boundary using authority captured before the policy changed.

Evidence

Security concerns:

  • [medium] Removed model permission survives queued-start admission — src/gateway/operator-run-authority.ts:555
    The affected principal is an operator whose waiting turn was captured under an older model allowlist; its later provider request must satisfy the policy in force when that queued execution starts.
    Confidence: 0.96

What I checked:

PR surface

Source -87, Tests +83, Docs +1, Other -5. Total -8 across 29 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 58 145 -87
Tests 22 387 304 +83
Docs 1 14 13 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 5 -5
Total 29 459 467 -8

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +58/−150; tests/support +387/−304 The change removes repeated authority machinery and updates distinct admission, cancellation, recovery, and transport contracts.

Labels

Label changes:

  • add P2: The change addresses interrupted admitted turns with a limited trigger involving authority or policy changes.
  • add merge-risk: 🚨 security-boundary: A queued turn can begin provider work using a model permission removed before that turn starts.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The change addresses interrupted admitted turns with a limited trigger involving authority or policy changes.
  • merge-risk: 🚨 security-boundary: A queued turn can begin provider work using a model permission removed before that turn starts.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 18, 2026, 2:58 AM ET / 07:58 UTC.

- Recheck current admission once at queued start without revoking running authority.
- Refuse queued starts after configured model-policy edits without mutating the captured ceiling.
- Reauthorize only canonical queued custody, preserving accepted unqueued steering.
- Cancel and retire only the refused input through existing source ownership; keep transient admission retries.
- Cover role and configured model-policy changes, source retirement, and unchanged running authority; document proof limits and shrink the ratchet.
@obviyus
obviyus marked this pull request as ready for review November 18, 2026 10:08
@obviyus
obviyus marked this pull request as draft November 18, 2026 10:13
- Keep transport identity checks at capture-time admission only.
- Recheck held person, device-revocation, membership, role and model-policy facts at queued starts.
- Cover an owner dashboard reload and genuine device revocation through queue adoption.
@obviyus
obviyus marked this pull request as ready for review November 18, 2026 11:15
@obviyus obviyus closed this Nov 18, 2026
@obviyus obviyus reopened this Nov 18, 2026
@obviyus
obviyus marked this pull request as draft November 18, 2026 11:41
- Retain exact run/tool/worker/turn closure checks without repeating admitted source policy.
- Restore read/publication closure regressions and bind prepared profiles to their original identity.
- Keep allowed channel reads working and refuse profile-merged steering visibly.
@obviyus
obviyus marked this pull request as ready for review November 18, 2026 12:16
@obviyus

obviyus commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #201334: this branch grew into five subsystems and kept breaking consumers. The replacement keeps only the operator-authority cut (plus queued-start reauthorization and prepared-sharing admission), proven on a real Gateway; the deferred pieces become their own PRs.

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant