Repository navigation
refactor(gateway): keep operator authority fixed per request - #201334
Conversation
- Capture operator policy once and reauthorize queued and returned-result starts. - Preserve lifecycle and physical-source fences and publish refused returned inputs. - Compare effective source-agent model membership at queued admission.
- Admit prepared chat/run profile policy facts without dropping identity or physical-source fences. - Preserve the requester snapshot for admitted work and reject fresh restricted reads. - Keep native merge refusals and explicit Gateway disposal coverage.
|
🦞👀 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 freezes Gateway operator permissions during an admitted request and rechecks them when queued or returned-result work starts. Example: A writer loses operator.write while an admitted message action awaits delivery.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain Keep open: this maintainer-authored PR addresses interrupted turns, but one returned-result path misses reauthorization, and consumer tests and documentation still require updates. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway admission converts authenticated caller identity and policy into authority carried through agent turns, queued inputs, child results, and runtime effects. flowchart TD
A[Authenticated operator] --> B[Gateway admission]
B --> C[Captured authority]
C --> D[Running turn]
C --> E[Queued adoption]
C --> F[Returned result admission]
E --> G[Model and tool effects]
F --> G
D --> G
Technical reviewBest possible solution: Keep admitted permissions fixed, route every returned-result start through existing reauthorization, and align consumer tests and operator documentation. Do we have a high-confidence way to reproduce the issue? Current-main policy subscriptions explain the reported interruption, and the supplied paired Gateway observations exercise it; this review ran no target code. Is this the best way to solve the issue? The existing authority and adoption owners are appropriate, but returned-result classification must cover the one-way child path before removing its former lifetime check. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 24c2e742bb0f. Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: Returned-result admission has a reachable gap for revoked retained in-memory operator sources. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +52, Tests +398. Total +450 across 40 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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, 11:35 AM ET / 16:35 UTC. |
- Check incumbent and incoming grants against committed source policy at new-input admission. - Keep socket liveness separate and preserve different-profile and grant-closure refusals. - Correct continuation lifetime expectations and include canonical agent fixture and ratchet fixes.
) Problem: a running cron occurrence was aborted when its owner's role, device or membership changed (base: "Session event execution aborted"), because the restored operator authority subscribed to those changes and the occurrence re-checked its marker on every effect. Fix: a cron occurrence checks its owner's authority once when it is restored and starts; the running occurrence keeps that authority until it ends. Each new occurrence, queued child and replayed follow-up re-checks once at its own start (`reauthorize`, the person's current authority, never socket liveness). Job removal, explicit Stop, cancellation and release still end the occurrence. Refusals keep their specific reason instead of a generic "abandoned"/sign-in message. User impact: editing a job or the owner's role while an occurrence runs applies to the next occurrence instead of killing the current one; a revoked owner's next occurrence is refused with a clear reason. Proof: real Gateway from source with a real model: owner demoted while the occurrence's exec sleeps aborts it on base and finishes it on head; the next occurrence is refused on both. Regression tests cover first-start reauthorization, closed-connection starts, Stop, revocation, refusal reasons and the rewritten in-flight expectations. Builds on #201334. Co-authored-by: Ayaan Zaidi <[email protected]>
Keep role changes scoped to the next request as established by #197557 and #201334. Prove admitted guest writes and checkpoint settlement, next-request refusal, and explicit source cancellation across late committed receipts. Credit @obviyus for the admission contract; production behavior is unchanged.
The old rejection expectation predates #201334. Assert that the admitted inventory completes with its captured role and that a fresh inventory applies the edited role without returning the other owner’s transcript. No production authority change. Co-authored-by: vincentkoc <[email protected]>
…w#201334) Problem: a role edit during an admitted Gateway operator turn aborted that turn. The operator authority subscribed to role, profile, device and membership changes and revoked the running request, so downstream effects failed with "agent runtime authority is no longer active" (25 logged on one host in four days). Fix: operator authority is checked once when a request starts and stays fixed for that request (role, scopes, model ceiling, session-sharing policy facts). Role, device, membership and policy changes apply to the next request. Every new start re-checks once through `reauthorize`: queued input at adoption, a returned child result at admission, and input injected into a running turn; it checks the person's current authority and committed source, never socket liveness. A refused queued or returned input stops once with a visible notice. Explicit Stop, release, Gateway shutdown, profile-merge identity, credential and data fences are unchanged. User impact: a turn that started finishes even if the operator's role changes meanwhile; the next request reflects the change. Work that starts later (queued, returned, injected) is refused if authority was revoked. Proof: real Gateway from source: role change during a real message.action handoff fails with the logged error on base and delivers on head; explicit Stop still refuses; the next fresh request is refused. Regression tests cover queued, returned-result and injected starts, model-policy and sourceAgent changes, profile switches and socket-close-only reconnects. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#201377) Problem: a running cron occurrence was aborted when its owner's role, device or membership changed (base: "Session event execution aborted"), because the restored operator authority subscribed to those changes and the occurrence re-checked its marker on every effect. Fix: a cron occurrence checks its owner's authority once when it is restored and starts; the running occurrence keeps that authority until it ends. Each new occurrence, queued child and replayed follow-up re-checks once at its own start (`reauthorize`, the person's current authority, never socket liveness). Job removal, explicit Stop, cancellation and release still end the occurrence. Refusals keep their specific reason instead of a generic "abandoned"/sign-in message. User impact: editing a job or the owner's role while an occurrence runs applies to the next occurrence instead of killing the current one; a revoked owner's next occurrence is refused with a clear reason. Proof: real Gateway from source with a real model: owner demoted while the occurrence's exec sleeps aborts it on base and finishes it on head; the next occurrence is refused on both. Regression tests cover first-start reauthorization, closed-connection starts, Stop, revocation, refusal reasons and the rewritten in-flight expectations. Builds on openclaw#201334. Co-authored-by: Ayaan Zaidi <[email protected]>
…aw#201473) Keep role changes scoped to the next request as established by openclaw#197557 and openclaw#201334. Prove admitted guest writes and checkpoint settlement, next-request refusal, and explicit source cancellation across late committed receipts. Credit @obviyus for the admission contract; production behavior is unchanged.
…aw#201527) Apply the request-start authority contract from openclaw#197557 and @obviyus’s openclaw#201334. Remove the obsolete per-effect source check while preserving next-consult denial and explicit Stop. Follow openclaw#201473 for the stale in-process session-read expectation.
…continue_work wakes Upstream openclaw#201334 (04cb817) keeps operator authority fixed for the request that admitted it: role, device, membership and policy changes no longer revoke a running holder, and each later start (queued input at adoption, a returned child result, injected input) re-checks once through the authority's `reauthorize`. The fork's continue_work wake is such a later start, but it only called `custody.assertCurrent()`, which no longer sees a role change. After the absorb, a wake whose operator was revoked (or whose email moved to another profile) ran a turn under the retained authority instead of failing closed. The wake now calls the retained authority's `reauthorize` once before it runs. A refusal ends the work row "Retained operator authority revoked" as before, and system (non-operator) work is unchanged. The request type names the one member the wake uses (`Pick<AdmittedRunOperatorAuthority, "reauthorize">`) instead of `unknown`. Regression (real Gateway, real wake): server.continuation-finished-child- wake.product "keeps a restricted operator's agent-RPC continue_work custody through its wake": green at chain head fa212db (3/3), red at 8e63e3d (revoked: wake-prepared, one hop-two turn), green here; the durable-7 operator-wake cases and sibling suites stay green (5 files, 36 tests). Carried to the pure candidate (stage 2): the pure wake path is the same code, and openclaw#201334 (04cb817) arrives with the 41bdde2 merge. Reproduced on the merged head ddd0ec7: the "revoked" gate runs a turn (hopTwoTurns 1, order run-ended + wake-prepared). With the fix, the product file is 3/3. (cherry picked from commit 429cb8b) Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem: a role edit during an admitted Gateway operator turn aborted that turn. The operator authority subscribed to role, profile, device and membership changes and revoked the running request, so downstream effects failed with "agent runtime authority is no longer active" (25 logged on one host in four days). Fix: operator authority is checked once when a request starts and stays fixed for that request (role, scopes, model ceiling, session-sharing policy facts). Role, device, membership and policy changes apply to the next request. Every new start re-checks once through `reauthorize`: queued input at adoption, a returned child result at admission, and input injected into a running turn; it checks the person's current authority and committed source, never socket liveness. A refused queued or returned input stops once with a visible notice. Explicit Stop, release, Gateway shutdown, profile-merge identity, credential and data fences are unchanged. User impact: a turn that started finishes even if the operator's role changes meanwhile; the next request reflects the change. Work that starts later (queued, returned, injected) is refused if authority was revoked. Proof: real Gateway from source: role change during a real message.action handoff fails with the logged error on base and delivers on head; explicit Stop still refuses; the next fresh request is refused. Regression tests cover queued, returned-result and injected starts, model-policy and sourceAgent changes, profile switches and socket-close-only reconnects. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 04cb817) Co-authored-by: RomneyDa <[email protected]>
Apply the request-start authority contract from #197557 and @obviyus’s #201334. Remove the obsolete per-effect source check while preserving next-consult denial and explicit Stop. Follow #201473 for the stale in-process session-read expectation. (cherry picked from commit ac17452) Co-authored-by: RomneyDa <[email protected]>
Release adaptation: extract the independent mixed-requester repair and its queue regression. Stable already strips display/owner flags but copies requester origin and the private owner capability. The wider saved-requester cutover needs the newer fixed-request and Cron occurrence authorities and the durable queue owner; do not replace the stable custody or restart contract. Companions: #203468 and #203521 are separate selected start-grant repairs. #201334, #201377, #200533 and #202318 are missing full-cutover prerequisites; #203516, #202522 and #202520 are later distinct lifetime refactors, not needed by the isolated mixed-requester repair. (cherry picked from commit 3ad2cce) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a26e1e7b02425b94d31c3e6bc6add8d417dc3fda)
Problem
A role edit during an admitted Gateway operator turn aborts the turn through
operator-run-authority's policy subscription. The failed source assertion then retires its run claim and downstream runtime effects reportagent runtime authority is no longer active(T01).Rule
Check the original person's authority when a request starts, and keep its captured role, scopes and effective model ceiling until that request ends. Role, device, membership and policy changes govern the next request. Ordinary socket closure is not revocation. Explicit cancellation, release, exact run/turn/claim closure, independent source assertions, data fences and secret boundaries remain effective.
Queued work starts another request: reauthorize once at adoption against the original person's current authority, never socket liveness. Refuse a changed effective model-policy membership, narrowing or widening, rather than mutating the captured ceiling. This includes
sourceAgentmodel changes even when the role's configured policy object is unchanged.Change
reauthorizethrough the existing admitted-authority contract and invoke it at canonical queued adoption. Permanent refusals retire only that input through the existing pending-input and abandonment owners; transient unavailability remains retryable.withheld:), keeps the child's result in the cancelled input record, and never starts parent inference. Only host-bound private-completion or returned-delivery facts select this path.Production: +232 / −148 (net +84) across eleven files. Deleting the implicit lifetime revocation checks requires explicit queued, returned-result and injected-input admission, plus a terminal refusal for the affected input. The live T01 failure also requires fixing prepared-sharing policy facts at admission while preserving their identity/source fences. Runtime effect, registry and approval validation are not changed.
Threat model
A captured grant never widens, switches person or adopts a replacement membership. A revoked identity cannot start another queued request. Finishing already-admitted work after a role/device/policy change is intentional. Caller-supplied assertions and abort signals remain opaque and enforced; this does not remove physical-session, credential, plugin lifecycle or exact claim fences.
Prepared-sharing admission freezes policy facts, not the physical store or person. Consumption still checks requester identity, source settlement and the identity-only profile selection; a merge cannot redirect the admitted authority.
Deferred: separate subsystem PRs
No schema, stored-row, configuration or protocol change. Two-way door: reverting restores the former operator lifetime behavior; no persisted migration is involved. Blast radius is Gateway operator-derived turns and their queued starts, not all authority owners.
Tests
sourceAgentregressions: refused after the source agent's model membership narrows or widens; both fail on the previous head.withheld:notice; the child's result stays in the cancelled input record.subagent-spawn.production-boundary"consumed-*" Stop cases also fail locally on basec2ca162a9230(and in CI on unrelated fix: avoid repeated model setup before fallback attempts #201216); the session-notify allowed-path case and native-facade explicit-empty-scopes case also fail on that base.full:ocx build --dtsand the packed tarball installed into a clean prefix (CLI, doctor).Evidence
This is a new cut initially tested against
c2ca162a9230, then rebased onto mainc4549b7f5596; the broader branch remains untouched. Live proof on2cadbe5521e6showed that the operator owner alone was insufficient: a profile-verification refusal aborted the turn before the resumed adapter's canonical runtime check. Prepared sharing still vetoed its captured policy revision. The repair now admits those policy facts explicitly, but keeps source and identity checks; the runtime guard and run registry retain their existing validators. The same real message handoff succeeds ona73eded68c45, and explicit Stop still refuses it.readSourcecontractGateway disposal remains a resource fence: an unavailable captured resolver refuses effects, while replacing a context object alone does not revoke the request's admitted policy. Explicit Stop and child-command lifetime proof use the existing production-boundary tests unchanged.
Source-tier live-provider observations on frozen
a73eded68c45, using real isolated Gateways (ocx src), a real model, synthetic operators, and task-owned adapters/latches; no substituted authority predicate or Gateway handler. All task processes, state, and disposable snapshots were removed. These are not full-build claims.a73eded68c45message→ realmessage.action;users.setRole(writer → denied)while channel handoff awaitsmessage_action_entered,hasHandoff=true,hasPlatformDispatch=true; after role mutation:local_mailbox_delivered, receipt3ed50fb6-a3a2-4a57-8791-849e95509b4b; tool settlessuccess;agent.wait.status=ok, terminal replyS1_TURN_FINISHED; mailbox containsS1_LOCAL_DELIVERY. Next fresh request:FORBIDDEN: missing scope: operator.write.message.actionhandoff, explicitchat.abortwhile awaitingchat.abort:ok=true,aborted=true; resumed handoff:TypeError: agent runtime authority is no longer active; tool settleserror;agent.wait.status=error,stopReason=rpc; no mailbox artifact/delivery.chat.sendfollow-up; lose write while first turn is busystate=final,S1_QUEUED_RUNNING_FINISHED. Queued run: onestate=error,seq=1event per observer,Your operator role changed; reconnect before continuing.;queuedToolStarted=false; no queued-tool start/retry observed before cleanup. Fresh send:FORBIDDEN: missing scope: operator.write. Gateway diagnostic:user transcript persistence failed: SessionMutationAuthorizationChangedError: Your operator role changed; reconnect before continuing.withheld:notice or queued-adoption refusal was observed.CI consumer repair
src/gateway/server/ws-connection/authenticated-request-dispatch.ts:289–315;src/gateway/server/ws-policy-close.ts:33–58,110–127publishes committed invalidation. The socket'sconnectionSignalis a separate argument at dispatcher line 257. Reauthorization reads only classified committed-source authority; the raw transport fallback is never consulted. A socket-close-only control remains accepted.startTurnmock stops at dispatch, so real returned-turn refusal remains covered by the ACP custody regression. Gateway disposal still prevents dispatch and settles the flow.agents.entries.sourcefixture correction and reduced session-identity allowance are included unchanged.tsgo:core:testshards pass. Test-line ratchet: +400/400, no allocation credit.90ae7f2c6621935930d8d948d215cc2b5af794e7. The admission check and existing lifecycle assertion share the existing inbound-authority module, keeping the caller-policy module within its line cap without weakening any guard.