Repository navigation
Conversation
- 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.
|
🦞👀 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: blocked before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
Findings
Agent review detailsHow this fits togetherGateway 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
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 74e5127c0c3d. Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: Queued execution currently crosses the model-permission boundary using authority captured before the policy changed. EvidenceSecurity concerns:
What I checked:
PR surfaceSource -87, Tests +83, Docs +1, Other -5. Total -8 across 29 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 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.
- 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.
- 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.
|
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. |
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'sagent 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:
captureGatewayOperatorRunAuthoritysubscribed to device/profile/OCID/role changes (operator-run-authority.tsbase lines 558–590). A role assignment calledrevokeat 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).prepareAgentRunAdmissionthreads this assertion into the run source.agent-run-registry.ts:395rechecks that source; a failure retires the exact run claim at line 438.createAgentRuntimeApprovalAuthorityValidatorthen returns false for the delegated identity (agent-runtime-approval-authority.ts:23–24), producing T01 atagent-runtime-authority.ts:28or the router's equivalentsession-runtime-authority.ts:52.T05 is the receipt translation of the same source failure, not a separate role decision:
createAdmittedGatewayToolCallerIdentitycomposes the admitted-run assertion and supplied receipt predicate (gateway-caller-context.ts:286–290);composeReceiptAuthoritytranslates either predicate's exception/false to false (:190–195);captureGatewayToolReceiptAssertionthrows 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:425andsession-controller.steer.ts:138: already-accepted unqueued steering remains fixed; queued fallback/new custody reauthorizes through adoption. The hook is gated by canonicalcustody.enqueued.agent-runner-result.ts:248–255andfollowup-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–48andtranscript-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–304andcron/session-run.ts:81–108: each scheduled start restores current origin authority; no new per-effect check is added here.Change
createAgentRuntimeAuthorityGuard.commitGuard's live source-policy recheck with lifecycle-only validation. InitialensureActiveadmission and supplied caller/data guards remain; exact run/tool release, worker-claim loss, and message-turn capability closure still fence effects and returned results.admit()boundary, called for the accepted chat target insession-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.Whole-PR production delta against
1f03e2723b78is +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 includesassertCapturedRoleCurrent,assertRoleCurrent,resolveCurrentRole, and the subscriptionrecheckcallback. Source guards, reference owners, and channel/recovery constructors remain.Obsolete tests changed with their checks:
Refusal reachability after this cut
assertActiveAgentRuntimeAuthoritycallers remain.composeReceiptAuthoritycan still return false for a closed/replaced admitted execution, delegated tool lease release, explicit cancellation, or an independent supplied receipt/source assertion.captureGatewayToolCallerAssertionalso retains abort-signal checks. These mixed per-source inputs are the next S1 cut, not silently removed here.cron/active-jobs.tsoccurrence identity/removal/cancellation/source/standing-grant checks are unchanged. Cron occurrence admission/lifetime separation is a separate PR.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.sendfollow-up case also remains protected by an earlier transcript-persistence role guard, observed asuser transcript persistence failed: SessionMutationAuthorizationChangedError: Your operator role changed; reconnect before continuing.That guard already refuses the queued input on15e103909ce6, 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, andusers.setRole(writer → denied)during an admitted turn. Base is1f03e2723b78a4c66cdf34ce7863c0ac673a9dc8viaocx base --src; HEAD uses those pinned dependencies with the worktree's completesrcoverlaid in a disposable source snapshot.sessions.list, role changed while awaitingoperator-run-authority.ts:582; resumed SDK call refused; turn abortedS1_TURN_FINISHED,agent.wait.status=okmessage.action, role changed while its actual channel handoff awaitsTypeError: agent runtime authority is no longer activeatagent-runtime-authority.ts:28; no mailbox deliverye3a9cabeed0c: actual handoff succeeds (local_mailbox_delivered, receiptc23370bf-b924-4b03-acb0-f545caa540d4);agent.wait.status=ok, terminal replyS1_TURN_FINISHED; no runtime-authority-inactive errorFORBIDDEN: missing scope: operator.writee3a9cabeed0c:next_request_refused,FORBIDDEN: missing scope: operator.writemessage.actionhandoff, explicit Stop viachat.aborte3a9cabeed0c:aborted=true; handoff throwsSessionMutationAuthorizationChangedError: 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 settleserror,agent.wait.status=error,stopReason=rpc; no mailbox artifact/deliverychat.sendfollow-up; remove write while first turn is busy1f03e272: both turns abort;15e103909ce6: running turn finishes and queued input is already visibly refused by the earlier transcript-persistence guarda8e5504847bb: running turn finishesS1_QUEUED_RUNNING_FINISHED; queued input visibly errors once; fresh send isFORBIDDENThe message/Stop proofs observed on
e3a9cabeed0cuse 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
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 onlyreadCurrentfrom projection readers, not by adding a no-op admission method.send.state.test-support.tsafter 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.src extensions packages test scripts ui; LSP references covered changed exported owners and the prepared-profile type. The obsoleteauthority.roleperformance-counter consumer was removed.Tier
fullwas previously run for the policy cut:ocx build --dtsand 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.tsattempt timed out withrequires 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.sendon 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
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.operator-run-authority.tsshrinks 2 → 1.full:ocx build --dtsand the packed tarball installed into a clean prefix (CLI, doctor). Not rerun for the later CI consumer repair.CI consumer repair
src extensions packages test scripts ui.