Repository navigation
fix: preserve operator authority through queued and child runs - #153989
Conversation
|
🦞👀 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. |
ashishsinghbora
left a comment
There was a problem hiding this comment.
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.
| export function createAdmittedRunOperatorAuthority( | ||
| source: AdmittedRunOperatorAuthority, | ||
| ): AdmittedRunOperatorAuthority { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
|
Codex review: blocked before merge. Reviewed September 21, 2026, 1:29 AM ET / 05:29 UTC (Revision 7). ClawSweeper reviewWhat this changesPreserves 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 Review scores
Verification
How this fits togetherThe 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]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
c73b316 to
7ad858a
Compare
c86d6e4 to
92630e8
Compare
…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.
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.