Skip to content

fix: preserve operator authority through queued and child runs - #153989

Merged
shakkernerd merged 4 commits into
mainfrom
fix/queued-operator-authority
Sep 21, 2026
Merged

shakkernerd merged 4 commits into
mainfrom
fix/queued-operator-authority

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Queued and delegated agent work needs to keep the operator who authorized it. A request can return, a client can disconnect, or a later message can arrive before the accepted work reaches its next Gateway action. The original scope ceiling and current authorization checks must remain attached across those transitions.

This change carries that source through the existing admission, reply queue, and child-run owners. A write-scoped operator's queued input cannot borrow a later maintainer's permissions or become a system request when its request context is no longer present.

User Impact

Accepted work and ordinary child delegation continue after normal request completion and socket closure. Subsequent actions still observe device revocation, shared-auth rotation, and permissions removed by the operator's current named role. Merging the original profile retires its captured source, while unrelated profiles and fresh requests keep working. Compatible inputs from the same original source can still collect or steer; incompatible sources drain in FIFO order. Nested plugin SDK requests keep their authenticated caller and any narrower permissions. A retained source cannot restore write or admin access that the current request does not have, and accepted work retains that narrower ceiling.

Failed child creation and launch settle through cleanup bound to the exact child session, lifecycle, and accepted run. That cleanup remains available when the initiating operator's authority has ended. Saved output from already accepted filesystem work is preserved while handles and source holds are released. Requester resumes use their existing live child cohort after the spawning tool finishes, while retaining the original operator restriction.

The change uses existing roles, scopes, queue modes, and runtime owners. It adds no configuration, database migration, or wire representation. Live visitor-grant policy and durable recovery authorization remain separate consumers of the source contract.

Why This Change Was Made

The ambient request context is deliberately released for autonomous execution and queued reply drains. Attribution fields and a run ID cannot replace the original authorization source. Admission now retains a host-issued capability with the original profile, scope ceiling, and currentness check, while each execution keeps its own run lifetime.

Queue collection, overflow summaries, steering, delivery retries, memory preparation, and child admission carry that same source. Native policy retained after a foreground run closes owns an independent source hold. The carrier stays in process: model/RPC payloads cannot create it, and installed plugin code retains the existing host-process trust model. Worker preparation passes the complete request guard into its existing final admission callback, so source loss during asynchronous preparation cannot create a durable worker intent.

The existing tool-invocation owner remains in the dispatcher, and child cleanup uses the existing Gateway lifecycle dispatcher with its exact session and accepted-run checks. Preparation and fixture extraction is limited to existing owner boundaries where needed to keep the repository's line limits intact. The queue documentation explains the resulting lifetime and batching behavior.

Evidence

Remote validation uses the registered Gateway agent method, real command admission, and later Gateway tool dispatch. On unchanged base 9d150631709a, the write-scoped operator and maintainer cases both fail because the later tool receives a system actor; the trusted system control passes. With the change, all three controls pass. The same flow covers request return and socket closure, device and shared-auth invalidation, and an unrelated later ambient principal.

Focused queue, admission, public reply ingress, role-policy, and memory-file checks exercise source retention, forged-carrier rejection, revocation after awaited work, compatible batching, and cleanup. The child fixture exercises the registered spawn path, six delayed-collector lifetime cases, and ordinary preparation/registration rollback. Rollback must leave a terminal receipt and no active child before fixture teardown; execution that started must be cancelled and drained.

The registered plugin RPC → public SDK → in-process Gateway path now has passing read/write controls for original and narrower request permissions, inherited recapture, and original-source revocation. Worker-preparation controls follow the original source through registered Gateway dispatch, the actual service, and SQLite. The allowed case creates an intent and reaches the provider; revocation during preparation leaves no stored intent and makes no provisioning call. With the exact pre-fix handler from f5aeb9e3671fc, the revoked case incorrectly returns a created environment while the allowed control passes. The complete child production-boundary suite and queued cleanup controls pass after reusing the existing lifecycle and registration owners. The correction group passes 207 child, queue, and preparation cases; the requester-wake group passes 115 cases, including the full visible-yield flow and refusal after source/cohort retirement. Typed lint and production core type checking pass on the same corrected tree.

Compatibility controls preserve ordinary queued fallback only for unsupported injection before acceptance. Positive acceptance, uncertain submission, and authority refusal remain non-replayable. Automatic compaction also checks cancellation after credential lookup and provider auth preparation before publishing runtime auth; its allowed and canceled controls pass.

The registered source and SDK regressions have before/after proof. Production and test type graphs, lint, and affected behavior checks pass on final head 92630e8eaff2. The CI run retains two failures from existing test fixtures: inherited runtime policy in the sparse Node runner, and cancellation before the worker launch handoff. The former reproduced unchanged on the CI base; the latter has the identical failure in main CI, with the relevant producer, fixture, and runtime conditions verified. Their repairs are already on main (runner fixture, worker handoff). The combined result is qualified with those repairs and with current profile, child, and shutdown contracts; the original failed CI statuses remain unchanged.

The complete contribution changes no configuration defaults, serialized authority, dependency declaration, or stored-data schema. The SQLite cases exercise existing worker-intent storage. This PR has not been deployed to a live Gateway.

@clawsweeper

clawsweeper Bot commented Sep 20, 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 agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 20, 2026

@ashishsinghbora ashishsinghbora left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one security-boundary concern in the new operator-authority capability.

"createAdmittedRunOperatorAuthority()" is documented as host-only, but it is exported and acts as the authority minting primitive. Since it accepts the profile, scopes, source, and currentness callback from its caller, "assertAdmittedRunOperatorAuthority()" only proves that the value passed through this factory, not that it originated from a trusted Gateway admission path.

Please either make the minting path non-exported/internal or add an explicit trusted issuer boundary so extensions/internal callers cannot manufacture arbitrary operator capabilities.

Aside from that, the PR has good coverage around queue retention, revocation, FIFO authority separation, overflow cleanup, and child-run cleanup. The capability lifetime/cleanup handling is also substantially exercised by the new tests.

Comment on lines +50 to +52
export function createAdmittedRunOperatorAuthority(
source: AdmittedRunOperatorAuthority,
): AdmittedRunOperatorAuthority {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This factory is described as “Host-only construction”, but it is exported and accepts caller-controlled "profileId", "scopes", "source", and "assertCurrent". "assertAdmittedRunOperatorAuthority()" only verifies that the object was created by this factory, so any code that can import this module could manufacture a new authority with arbitrary operator scopes.

Can we make the minting primitive non-exported/internal, or otherwise enforce that only the Gateway admission boundary can issue these capabilities? The sanitizer prevents the capability from arriving directly through public reply options, but that does not protect the capability boundary if an extension/internal caller can reach this factory.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installed extensions share the Gateway process trust described in Trusted Plugins. This marker checks runtime-object provenance; it does not isolate code that can import core internals. operator-run-authority.ts is the only production issuer, and the constructor is not exported by the plugin SDK. Gateway capture supplies the validated original profile, permission ceiling, and live source check; public RPC/reply input cannot manufacture that issued carrier. I clarified this boundary in the PR body.

@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 92630e8eaff2932d747920945807c8e2dad75424
  • Maintainer: @shakkernerd
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/cli-runner/tool-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/harness/tool-authority.runtime.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/device-revocation.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.caller-authority.test-utils.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-reload-managed-secrets.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/server-secrets-reload.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/server-shared-auth-generation.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/authenticated-request-dispatch.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 21, 2026, 1:29 AM ET / 05:29 UTC (Revision 7).

ClawSweeper review

What this changes

Preserves the initiating operator’s permissions and revocation checks through queued replies, child runs, later Gateway actions, and failed-spawn cleanup.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, unmerged fix. The prior scoped-dispatch and steering findings are resolved; the previous generic config/default blocker is unsupported by the pinned diff. No new blocking defect was established.

Priority: P2
Reviewed head: 92630e8eaff2932d747920945807c8e2dad75424

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent authority repair with meaningful positive and negative boundary coverage and resolved prior findings.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The captured body reports remote before/after runs through registered Gateway admission and SDK dispatch, including denied writes and revoked-source rejection before worker-intent storage or provisioning. Inspected boundary coverage supports those claims and child cleanup settlement; no live deployment or reviewer execution is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured body reports remote before/after runs through registered Gateway admission and SDK dispatch, including denied writes and revoked-source rejection before worker-intent storage or provisioning. Inspected boundary coverage supports those claims and child cleanup settlement; no live deployment or reviewer execution is claimed.
Evidence reviewed 10 items Pinned introduction and live identity: Reviewed the merge-base-to-head changes. The raw test-merge record has the supplied base followed by the exact PR head as parents. REST inspection confirms the PR remains open, unmerged, assigned to shakkernerd, and at the reviewed head.
Still necessary on main: Fetched main still uses the earlier admitted-run structure without the operator carrier, and its in-process dispatcher lacks the new retained-source composition. The new operator authority module is absent from both fetched main and v2026.9.5. No supplied related PR is a merged replacement.
Scoped SDK finding resolved: Dispatch preserves a matching authenticated client and intersects its scopes with the retained source. Recapture preserves that narrower ceiling. Registered plugin SDK cases cover both intersection directions, reject unauthorized writes before their handler, and reject subsequent calls after original-source revocation.
Findings None None.
Security None None.

How this fits together

The Gateway authenticates operator requests and admits agent work that can outlive the original connection. This change carries that authorization source through queues and delegation so later actions retain the original permission ceiling.

flowchart TD
  A[Authenticated operator request] --> B[Gateway admission]
  B --> C[Retained operator source]
  C --> D[Queued reply or child run]
  D --> E[Current authority and scope checks]
  E --> F[Gateway action]
  E --> G[Reject revoked or excessive access]
  D --> H[Exact child cleanup]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +1,291 lines; tests and test support net +2,016 lines The body justifies production growth through source custody across existing owners and explains the supporting owner-boundary extractions.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep authorization attached to its original source while queues, child lifetimes, and exact-target cleanup remain with their existing owners.

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

Yes, through registered Gateway admission followed by tool dispatch after request completion; the supplied before/after results and current-main source establish the path. This read-only review did not execute it.

Is this the best way to solve the issue?

Yes. Carrying a host-issued source restriction through existing admission and dispatch owners addresses the lost-authority boundary while preserving narrower SDK permissions and bounded cleanup.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 90a39a0547e8.

Labels

Label justifications:

  • P2: This repairs operator permission continuity in queued and delegated work without evidence of an active emergency.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured body reports remote before/after runs through registered Gateway admission and SDK dispatch, including denied writes and revoked-source rejection before worker-intent storage or provisioning. Inspected boundary coverage supports those claims and child cleanup settlement; no live deployment or reviewer execution is claimed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports remote before/after runs through registered Gateway admission and SDK dispatch, including denied writes and revoked-source rejection before worker-intent storage or provisioning. Inspected boundary coverage supports those claims and child cleanup settlement; no live deployment or reviewer execution is claimed.

Evidence

What I checked:

  • Pinned introduction and live identity: Reviewed the merge-base-to-head changes. The raw test-merge record has the supplied base followed by the exact PR head as parents. REST inspection confirms the PR remains open, unmerged, assigned to shakkernerd, and at the reviewed head. (92630e8eaff2)
  • Still necessary on main: Fetched main still uses the earlier admitted-run structure without the operator carrier, and its in-process dispatcher lacks the new retained-source composition. The new operator authority module is absent from both fetched main and v2026.9.5. No supplied related PR is a merged replacement. (src/agents/admitted-run-context.ts:32, 90a39a0547e8)
  • Scoped SDK finding resolved: Dispatch preserves a matching authenticated client and intersects its scopes with the retained source. Recapture preserves that narrower ceiling. Registered plugin SDK cases cover both intersection directions, reject unauthorized writes before their handler, and reject subsequent calls after original-source revocation. (src/gateway/server-plugin-in-process-dispatch.ts:399, 92630e8eaff2)
  • Steering finding resolved: Compatibility uses profile, normalized scopes, and opaque original-source identity without including the signal identity. Queue and steering coverage accepts a fresh signal for the same source while separating different principals, scope ceilings, and sources. (src/auto-reply/reply/reply-tool-authority.ts:323, 92630e8eaff2)
  • Authority proof and final effects: The supplied body at sourceRevision 4768877a35fabddae3ced557ac64b69011e13af22d72143f2ad8548436de6d8f records before/after registered Gateway and SDK validation, including allowed controls and revoked-source denial. Source inspection corroborates the worker-preparation scenario: it uses registered dispatch, the actual service and SQLite, asserting no stored intent or provisioning call after revocation. The reported child-boundary results additionally cover delayed launch and cleanup before fixture teardown. These are contributor-reported remote executions, not executions performed by this review. (src/gateway/worker-environments/service-prepare.test.ts:253, 92630e8eaff2)
  • Cleanup remains narrowly owned: Failed-spawn cleanup uses the existing lifecycle dispatcher, permits only session deletion and chat abort, and checks the captured Gateway, child session identity, lifecycle revision, and accepted run. Rollback coverage checks terminal settlement and preservation of the parent session after source revocation. (src/agents/subagents/spawn/subagent-spawn-cleanup.ts:16, 92630e8eaff2)

Likely related people:

  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-20T19:48:21.233Z sha c73b316 :: needs real behavior proof before merge. :: [P1] Preserve scoped SDK dispatch when retaining operator authority
  • reviewed 2026-09-20T21:34:40.069Z sha c73b316 :: needs real behavior proof before merge. :: [P1] Preserve scoped SDK dispatch when retaining operator authority
  • reviewed 2026-09-20T22:28:03.820Z sha c73b316 :: needs real behavior proof before merge. :: [P1] Preserve scoped SDK dispatch when retaining operator authority
  • reviewed 2026-09-21T01:09:47.485Z sha c73b316 :: needs real behavior proof before merge. :: [P1] Preserve scoped SDK dispatch when retaining operator authority
  • reviewed 2026-09-21T02:54:50.643Z sha 7ad858a :: needs real behavior proof before merge. :: [P2] Treat a new signal on the same source as compatible steering
  • reviewed 2026-09-21T04:29:57.896Z sha 92630e8 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 20, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 20, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 20, 2026
@shakkernerd
shakkernerd force-pushed the fix/queued-operator-authority branch from c73b316 to 7ad858a Compare September 21, 2026 02:38
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 21, 2026
@shakkernerd
shakkernerd force-pushed the fix/queued-operator-authority branch from c86d6e4 to 92630e8 Compare September 21, 2026 04:16
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 21, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…law#153989)

Keep accepted queued and delegated work bound to the originating operator's permission ceiling and current authorization, including narrower nested requests and cleanup for the exact accepted child.
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants