Repository navigation
refactor(gateway): check HTTP request authority once at admission - #203590
Conversation
- Delete captureHttpRequestAuthority, bindHttpResponseAuthority, assertGatewayHttpRequestCurrent and the device-token and plugin-cookie revalidate overrides. HTTP auth results no longer carry assertCurrent or revalidate; route handlers stop re-checking authority after admission. - Keep request abort and data fences (session lifecycle, row generation, record replacement). - Keep the optional hasCurrentClientAuthority pass-through for agent-turn and plugin-runtime scopes, where its presence still selects behavior. - Drop both names from LIFETIME_CHECK_CALLS; delete tests that assert a refusal after admission. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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. |
|
…ty-check-once # Conflicts: # scripts/check-lifetime-check-ratchet.mts
- Delete provider-icon device-token revalidation, the embeddings provider-acquisition revocation row and the revoked post-deploy session-entry handoff; prune the timeout-race baseline. Co-authored-by: obviyus <[email protected]>
|
Codex review: needs changes before merge. What this changesThis PR removes repeated HTTP authority checks so admitted requests can finish after credentials or policy change. Example: A request to /secure-hook authenticates with test-token before the Gateway rotates to rotated-token.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep open: this maintainer-authored PR implements the documented admission contract, but its test migration leaves concrete CI failures. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway HTTP authentication admits callers and supplies scopes to route handlers, which perform operations and return responses under request cancellation and operation-specific data fences. flowchart TD
A[HTTP request] --> B[Credential and scope admission]
B --> C[Gateway route handler]
C --> D[Cancellation and data fences]
D --> E[Operation owner]
E --> F[HTTP response]
Technical reviewBest possible solution: Retain the existing admission and cancellation owners, finish migrating affected consumer tests, and regenerate the reduced timeout baseline. Do we have a high-confidence way to reproduce the issue? Base source shows the repeated snapshot checks, and exact-head CI demonstrates the changed responses; no target code was executed during this review. Is this the best way to solve the issue? Removing the redundant checks at their existing owner is a focused implementation of the approved contract; the documented retained callbacks serve downstream consumers outside this cutover. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 34ce936db81e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -457, Tests -1549, Other -2. Total -2008 across 69 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. 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 22, 2026, 1:56 PM ET / 18:56 UTC. |
|
One-admission E2E (
Evidence: Plugin HTTP routes are outside this journey. They are covered through the real HTTP router by:
|
|
One-admission E2E on the exact head |
|
Maintainer override: the only red job on head ci-triage: |
|
Landed as f1a6dbd. HTTP routes now check authority once, at admission. An admitted request finishes, and revocation, rotation and policy changes apply to the next request. Request abort and data fences stay. Proof: a new plugin-route integration test (red on base, green on head), one-admission E2E Q/R/S pass on the exact head, local review clean. The only CI red is the MAIN-ALSO |
…ttle-batch receipts (#203892) ## Problem R2 of the one-admission receipt cluster. After #203760 (R1c), two receipt producers still returned a boolean, and the receipt boolean itself (`ReceiptAuthority = () => boolean | void`, the `composeReceiptAuthority` check loop, `assertAllowed` in `captureGatewayToolReceiptAssertion`) still hid permission re-checks from the lifetime-check ratchet: - **MCP loopback grant receipt** (`mcp-http.ts`, `isGrantAndLineageCurrent` as `receiptAuthority`): every effect inside a started tool call re-checked the CLI grant row and the requester lineage. - **Settle-batch receipt** (`agent-tools.caller.ts`, `settleBatch.isCurrent` as `receiptAuthority`): every effect inside a started tool call re-checked the subagent settle batch. Both answer "may this requester still act?" in the middle of a call. R1c showed that turning them into throws is a new mid-request re-check (both ratchets went red), so they are deleted. ## Change - **Deleted** the MCP grant receipt and the settle-batch receipt. The grant row and lineage are still checked once at each tool-call dispatch (`authorizeToolCall`); the settle batch is still checked at handoff admission (`subagent-announce-handoff.ts`). Stop still reaches the call through the grant's `abortSignal` and the run signal. - **Deleted the receipt boolean:** the `ReceiptAuthority` type, the boolean check loop in `composeReceiptAuthority`, `captureGatewayToolReceiptAssertion` (and its lifetime-ratchet entry), and the `approvalAuthorityCheck` field (a duplicate of the receipt). `receiptAuthority` is now a plain `SessionSourceAssertion`: it throws or returns. `composeReceiptAuthority` only de-duplicates sources into `composeSessionSourceAssertion` and keeps its existing `assertScopeCurrent` forwarding. - Readers that compared `receiptAuthority() === false` now call it and let it throw (or catch where the reader already returns `false`): before-tool-call decision receipt, cron tool, sessions access, terminal tool, session event target, node skill runtime, delegated approval, skill authoring, question broker, plugin hooks, cron management/owner bindings, harness host source and embedded tool authority. - The "no delegated run" receipt `() => false` becomes a throw with the same message the boolean path already produced ("agent tool caller authority is no longer active"). Production: 17 files, +55/−173 (plus one session-identity allowlist entry pruned: `cron-tool.ts` lost its "no longer active" refusal string). No new export, name, hook, flag, guard, timer or state. ## Tests - **Deleted (obsolete):** `mcp-http.test.ts` "fences caller authority when the grant is replaced during tool execution". It asserts that a started MCP tool call is refused at its commit after the grant row is replaced mid-call, i.e. the mid-call permission re-check this PR removes. Replacement is still refused at the next dispatch. - About 60 test fixtures returned `false` from `receiptAuthority` to mean "run closed / revoked" (`() => validateAgentRunDelegatedAuthority(a)`, `() => current`, `() => !signal.aborted`, `() => false`). TypeScript accepts `() => boolean` as `() => void`, so these would silently stop refusing. Each now throws on the same condition (or uses `signal.throwIfAborted()`), so every refusal test keeps its meaning. Assertions on the boolean (`receiptAuthority()).toBe(false)`) became `toThrow`. The `hooks.before-tool-call.test.ts` "authority reports stale" row is gone (no boolean to report); both settlements now run with a throwing authority. - `server.visible-spawn-fallback.product-proof.test.ts` no longer passes `currentGrant.isCurrent` as a receipt, matching production `mcp-http.ts`. - Run-instance, claim, disconnect and stale-writer refusal tests keep their assertions. Two only changed the expected wording, because the refusal now comes from the run's own assertion instead of the deleted receipt wrapper: `session-event-handoff.test.ts` "rejects invocation retirement" (`no longer owns its invocation` → `no longer active`) and the retained-receipt check in `tool-authority.runtime.retention.test-support.ts` (`=== false` → throws). ## What users see A tool call already running through a CLI (MCP loopback) or a subagent settle turn finishes when the grant or batch is replaced mid-call. The next call is refused before it starts, as before. Stop still cancels a running call. Error text for a closed run inside some tools (terminal, skill authoring, session events) now comes from the run's own assertion instead of the caller-specific wording. ## Evidence - **Typecheck / lint / ratchets:** `pnpm tsgo:core`, `pnpm tsgo:test` clean on the head; oxfmt and oxlint clean on changed files; lifetime-check ratchet OK, session-identity ratchet OK (after prune). - **Tests (pre-push):** importer set of every changed source and test-support file (816 files) with `OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1`, run in lanes (the runner aborted once on a vitest resource-claim error after the gateway lanes, so the rest ran in a second call), then a focused rerun of every repaired file and a post-merge rerun after merging `main` for a ratchet-list conflict with #203847. Remaining reds, all not ours: red on the base locally (`dd56cf3d6457` / `49795c31df01`): `slack-download-read-authority` (claim at result), `github-pr-workspace-preparation`, `server.sessions.create.{durability,lifecycle,projects}`, `sessions-create-device-folder`, `provider-destroy-authority`, `service.pr-automation{,-feedback}`, `openclaw-tools.subagents.sessions-spawn.lifecycle`, `mcp-http.personal-authority`; known main reds from #203664/#203590/#203516: `server-cron-failure-repair.final-effect`, `cron.scheduled-policy-adoption`, `github-publication-imported-actions`, `question.communication`/`.recovery`, `mcp-http.async-scope`, `agent.test`, `plugin-reload-send-revocation.product`. - **Local ClawSweeper review** on exact head `eb077c177329`: `review_status: complete`, "patch is correct", 0 findings. - **One-admission E2E** (isolated Gateway, real model, exact head `eb077c177329`, `ocx build --dist`): `pass: true`. `results.jsonl` (28 rows) kept with the task proof. `verdict.json` checks: ```json [{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true},"state":"aborted","requestsWithStopMarker":1}}] ``` Co-authored-by: Ayaan Zaidi <[email protected]>
…enclaw#203590) ## What problem this solves HTTP routes checked the caller's authority when the request was admitted, then checked it again during the request. `captureHttpRequestAuthority` took a snapshot of auth policy, role policy, role revision, profile alias revision and shared auth generation. `bindHttpResponseAuthority` then made `assertCurrent()`, `revalidate()` and `hasCurrentClientAuthority()` compare against that snapshot, and against operator access and profile authority, at many points inside each route. Device-token routes re-verified the token in `revalidate()`. Plugin-cookie routes re-read the cookie grants and role policy. Because of this, an admitted request could stop halfway with 401/403 after an unrelated settings save or role edit. The one-admission rule is: check authority once, when the request starts. A started request finishes. Revocation, removal and reload apply to the next request. ## What changed - `src/gateway/http-request-authority.ts`: deleted `captureHttpRequestAuthority`, `bindHttpResponseAuthority`, `assertGatewayHttpRequestCurrent`, `GatewayHttpRequestAuthorityError` and the `GatewayHttp{Request,Response}Authority` types. `runGatewayHttpRequest` (request abort scope) and `finishGatewayHttpAuthorityError` stay. - `http-auth-utils.ts`: HTTP auth results no longer carry `assertCurrent` or `revalidate`. The admission-time early refusals that compared against the snapshot are gone. The device-token `revalidate` overrides are gone. - `http-auth-plugin-cookie.ts`: deleted `bindControlUiPluginCookieRequestAuthority` (the cookie/role re-check). `control-ui-plugin-assets.ts` authorizes the cookie one time. - Route handlers no longer call those methods: Control UI bootstrap/avatar/session entry, channel/plugin/provider/workspace/project icons, managed media, user profile avatars and backgrounds, session kill, models, embeddings, OpenAI and OpenResponses, tools invoke, and plugin routes. `rememberResponseSession` lost its authority `assertCurrent` parameter (its only production caller passed the request guard). - Removed both names from `LIFETIME_CHECK_CALLS`. Kept: - Request abort (Stop / client disconnect). The `runGatewayHttpRequest` scope signal and `finishGatewayHttpAuthorityError` still end the response. Response-ended checks (`res.writableEnded || res.destroyed`) stay where routes had them. - Data fences: session lifecycle revision and avatar reference (channel avatars), session row generation (workspace icons), image replacement (`prepared.isCurrent()`), assistant media policy, managed-media grant and ingress-session reads, and session actor readability for session kill. Production code: 29 files, +65 / −524. ## Decisions (recorded per the program rules) - **Cut less at the WebSocket seam.** `AuthorizedGatewayHttpRequest.hasCurrentClientAuthority` stays as an optional field (profile + operator access only). The OpenAI, OpenResponses and tools-invoke routes pass it to the agent-turn and plugin-runtime scopes. There, *whether the field is present* changes behavior: `operator-run-authority` `isHttpOwner` needs `=== true`, and in-process approval dispatch checks presence. Removing it here would change owner attribution for OpenClaw ID HTTP callers. The session-mutation-guard and run-authority PRs remove it together with those readers. Plugin route scopes keep presence `requestAuth || operatorAccessAuthority || ingress`, so for gateway-auth routes the field is present whether the request came in by bearer or by cookie, as before. - Not in scope, left for later PRs: `sessions-history-http` re-authenticates on each SSE publish through `checkGatewayHttpRequestAuth`. `tools-invoke-http` still adds `operatorAccessAuthority.signal` to the request signal. `operator-access-policy` aborts that signal on revocation (PR 7/8). ## Tests deleted (they assert a refusal after admission) - `http-request-authority.test.ts` (role-policy fence on the snapshot) - `http-auth-utils.openclaw-id-tunnel.test.ts` (device removed or role changed after admission → refusal) - `channel-avatar-http`: "rejects revoked authority while channel avatar bytes are loading" - `managed-image-attachments.authority`: revoked worker ownership read and revoked media authority after preparation - `plugin-icon-http`: revoked authority during normalization or favicon fetch - `workspace-icon-http`: changed authority during icon preparation (the workspace replacement case, a data fence, stays) - `http-endpoint-helpers`: "does not admit a parsed body after its authority was revoked while reading" - `http-utils.authorize-request`: trusted-proxy override revalidation - `tools-invoke-http.abort`: "rejects a tool when policy authority changes during its awaited hook" - `control-ui-assistant-media-metadata`: reader authority recheck variants - `server-http.authority-outcomes`: nine client-expired / role / operator-revoked / unavailable variants. The disconnect and unexpected-error variants stay, and still prove Stop through the real HTTP router - `openresponses-session-store` and the OpenResponses continuation support: revoked caller before commit / during the continuation lookup - `control-ui-assistant-media-policy`, `control-ui-plugin-assets`, `control-ui-session-entry(.real-auth.e2e)`, `control-ui.response-authority`, `http-auth-utils.paired-device`, `http-session-control.incognito` (revoked=true rows), `server.plugin-http-role-scopes`, `server/plugins-http` (re-check before the next matched route), `session-kill-http` (policy-revocation and credential-rotation rows), `sessions-history-http.revocation` (ingress-policy row), `user-background-http.authority`, `user-profiles-http.auth` (credential rotation and device revocation during preparation), `team-reports-http.gateway` (expiry, generation and role change before delivery). Data-fence, admission-time and abort cases in those files stay. ## Evidence - **Plugin HTTP route, through the real HTTP router (new test):** `server.plugin-http-auth.test.ts` › "finishes an admitted gateway-auth plugin request after its credential rotates". The plugin handler is blocked, the Gateway token rotates, then the handler calls the scope's `revalidate()`. The admitted request gets 200, and the next request with the old token gets 401. The same test copied onto base `c57ad28ba9b6` fails with `expected 401 to be 200`: base `revalidate()` re-checks the shared generation and refuses the admitted request. Stop through the real router: `server-http.authority-outcomes` › "cancels disconnected plugin reads without logging a handler failure". The one-admission E2E journey does not reach plugin HTTP routes, so this integration test is the plugin-route proof. - **Pre-push tests (vitest-source):** one `ocx test` call over the 291 importer test files, with `OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1`. It hit the 1 h tool deadline, so the 17 files it did not reach and every failed file ran again in two more calls. Everything passes except files that also fail on base `c57ad28ba9b6`: `cron/service.pr-automation` (13), `server-methods/question.own-run` (4), `server.config-security-policy` (3-4, timeouts), `server.sessions.create.projects` (1), and `operator-admission.table` › `token > principal > before-start`. - `pnpm tsgo:core` and `pnpm tsgo:test` are clean. oxfmt and oxlint are clean on the changed files. The lifetime-check ratchet passes. - E2E (`one-admission-e2e/run.sh`): Q, R and S pass on `1d9bc6d06222` and on the final head `33a643a42c77`. The live Gateway pid did not change. Co-authored-by: Ayaan Zaidi <[email protected]>
…ttle-batch receipts (openclaw#203892) ## Problem R2 of the one-admission receipt cluster. After openclaw#203760 (R1c), two receipt producers still returned a boolean, and the receipt boolean itself (`ReceiptAuthority = () => boolean | void`, the `composeReceiptAuthority` check loop, `assertAllowed` in `captureGatewayToolReceiptAssertion`) still hid permission re-checks from the lifetime-check ratchet: - **MCP loopback grant receipt** (`mcp-http.ts`, `isGrantAndLineageCurrent` as `receiptAuthority`): every effect inside a started tool call re-checked the CLI grant row and the requester lineage. - **Settle-batch receipt** (`agent-tools.caller.ts`, `settleBatch.isCurrent` as `receiptAuthority`): every effect inside a started tool call re-checked the subagent settle batch. Both answer "may this requester still act?" in the middle of a call. R1c showed that turning them into throws is a new mid-request re-check (both ratchets went red), so they are deleted. ## Change - **Deleted** the MCP grant receipt and the settle-batch receipt. The grant row and lineage are still checked once at each tool-call dispatch (`authorizeToolCall`); the settle batch is still checked at handoff admission (`subagent-announce-handoff.ts`). Stop still reaches the call through the grant's `abortSignal` and the run signal. - **Deleted the receipt boolean:** the `ReceiptAuthority` type, the boolean check loop in `composeReceiptAuthority`, `captureGatewayToolReceiptAssertion` (and its lifetime-ratchet entry), and the `approvalAuthorityCheck` field (a duplicate of the receipt). `receiptAuthority` is now a plain `SessionSourceAssertion`: it throws or returns. `composeReceiptAuthority` only de-duplicates sources into `composeSessionSourceAssertion` and keeps its existing `assertScopeCurrent` forwarding. - Readers that compared `receiptAuthority() === false` now call it and let it throw (or catch where the reader already returns `false`): before-tool-call decision receipt, cron tool, sessions access, terminal tool, session event target, node skill runtime, delegated approval, skill authoring, question broker, plugin hooks, cron management/owner bindings, harness host source and embedded tool authority. - The "no delegated run" receipt `() => false` becomes a throw with the same message the boolean path already produced ("agent tool caller authority is no longer active"). Production: 17 files, +55/−173 (plus one session-identity allowlist entry pruned: `cron-tool.ts` lost its "no longer active" refusal string). No new export, name, hook, flag, guard, timer or state. ## Tests - **Deleted (obsolete):** `mcp-http.test.ts` "fences caller authority when the grant is replaced during tool execution". It asserts that a started MCP tool call is refused at its commit after the grant row is replaced mid-call, i.e. the mid-call permission re-check this PR removes. Replacement is still refused at the next dispatch. - About 60 test fixtures returned `false` from `receiptAuthority` to mean "run closed / revoked" (`() => validateAgentRunDelegatedAuthority(a)`, `() => current`, `() => !signal.aborted`, `() => false`). TypeScript accepts `() => boolean` as `() => void`, so these would silently stop refusing. Each now throws on the same condition (or uses `signal.throwIfAborted()`), so every refusal test keeps its meaning. Assertions on the boolean (`receiptAuthority()).toBe(false)`) became `toThrow`. The `hooks.before-tool-call.test.ts` "authority reports stale" row is gone (no boolean to report); both settlements now run with a throwing authority. - `server.visible-spawn-fallback.product-proof.test.ts` no longer passes `currentGrant.isCurrent` as a receipt, matching production `mcp-http.ts`. - Run-instance, claim, disconnect and stale-writer refusal tests keep their assertions. Two only changed the expected wording, because the refusal now comes from the run's own assertion instead of the deleted receipt wrapper: `session-event-handoff.test.ts` "rejects invocation retirement" (`no longer owns its invocation` → `no longer active`) and the retained-receipt check in `tool-authority.runtime.retention.test-support.ts` (`=== false` → throws). ## What users see A tool call already running through a CLI (MCP loopback) or a subagent settle turn finishes when the grant or batch is replaced mid-call. The next call is refused before it starts, as before. Stop still cancels a running call. Error text for a closed run inside some tools (terminal, skill authoring, session events) now comes from the run's own assertion instead of the caller-specific wording. ## Evidence - **Typecheck / lint / ratchets:** `pnpm tsgo:core`, `pnpm tsgo:test` clean on the head; oxfmt and oxlint clean on changed files; lifetime-check ratchet OK, session-identity ratchet OK (after prune). - **Tests (pre-push):** importer set of every changed source and test-support file (816 files) with `OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1`, run in lanes (the runner aborted once on a vitest resource-claim error after the gateway lanes, so the rest ran in a second call), then a focused rerun of every repaired file and a post-merge rerun after merging `main` for a ratchet-list conflict with openclaw#203847. Remaining reds, all not ours: red on the base locally (`d6b84a4c90a1` / `2f6261e2a4ec`): `slack-download-read-authority` (claim at result), `github-pr-workspace-preparation`, `server.sessions.create.{durability,lifecycle,projects}`, `sessions-create-device-folder`, `provider-destroy-authority`, `service.pr-automation{,-feedback}`, `openclaw-tools.subagents.sessions-spawn.lifecycle`, `mcp-http.personal-authority`; known main reds from openclaw#203664/openclaw#203590/openclaw#203516: `server-cron-failure-repair.final-effect`, `cron.scheduled-policy-adoption`, `github-publication-imported-actions`, `question.communication`/`.recovery`, `mcp-http.async-scope`, `agent.test`, `plugin-reload-send-revocation.product`. - **Local ClawSweeper review** on exact head `eb077c177329`: `review_status: complete`, "patch is correct", 0 findings. - **One-admission E2E** (isolated Gateway, real model, exact head `eb077c177329`, `ocx build --dist`): `pass: true`. `results.jsonl` (28 rows) kept with the task proof. `verdict.json` checks: ```json [{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true},"state":"aborted","requestsWithStopMarker":1}}] ``` Co-authored-by: Ayaan Zaidi <[email protected]>
What problem this solves
HTTP routes checked the caller's authority when the request was admitted, then checked it again during the request.
captureHttpRequestAuthoritytook a snapshot of auth policy, role policy, role revision, profile alias revision and shared auth generation.bindHttpResponseAuthoritythen madeassertCurrent(),revalidate()andhasCurrentClientAuthority()compare against that snapshot, and against operator access and profile authority, at many points inside each route. Device-token routes re-verified the token inrevalidate(). Plugin-cookie routes re-read the cookie grants and role policy. Because of this, an admitted request could stop halfway with 401/403 after an unrelated settings save or role edit.The one-admission rule is: check authority once, when the request starts. A started request finishes. Revocation, removal and reload apply to the next request.
What changed
src/gateway/http-request-authority.ts: deletedcaptureHttpRequestAuthority,bindHttpResponseAuthority,assertGatewayHttpRequestCurrent,GatewayHttpRequestAuthorityErrorand theGatewayHttp{Request,Response}Authoritytypes.runGatewayHttpRequest(request abort scope) andfinishGatewayHttpAuthorityErrorstay.http-auth-utils.ts: HTTP auth results no longer carryassertCurrentorrevalidate. The admission-time early refusals that compared against the snapshot are gone. The device-tokenrevalidateoverrides are gone.http-auth-plugin-cookie.ts: deletedbindControlUiPluginCookieRequestAuthority(the cookie/role re-check).control-ui-plugin-assets.tsauthorizes the cookie one time.rememberResponseSessionlost its authorityassertCurrentparameter (its only production caller passed the request guard).LIFETIME_CHECK_CALLS.Kept:
runGatewayHttpRequestscope signal andfinishGatewayHttpAuthorityErrorstill end the response. Response-ended checks (res.writableEnded || res.destroyed) stay where routes had them.prepared.isCurrent()), assistant media policy, managed-media grant and ingress-session reads, and session actor readability for session kill.Production code: 29 files, +65 / −524.
Decisions (recorded per the program rules)
AuthorizedGatewayHttpRequest.hasCurrentClientAuthoritystays as an optional field (profile + operator access only). The OpenAI, OpenResponses and tools-invoke routes pass it to the agent-turn and plugin-runtime scopes. There, whether the field is present changes behavior:operator-run-authorityisHttpOwnerneeds=== true, and in-process approval dispatch checks presence. Removing it here would change owner attribution for OpenClaw ID HTTP callers. The session-mutation-guard and run-authority PRs remove it together with those readers. Plugin route scopes keep presencerequestAuth || operatorAccessAuthority || ingress, so for gateway-auth routes the field is present whether the request came in by bearer or by cookie, as before.sessions-history-httpre-authenticates on each SSE publish throughcheckGatewayHttpRequestAuth.tools-invoke-httpstill addsoperatorAccessAuthority.signalto the request signal.operator-access-policyaborts that signal on revocation (PR 7/8).Tests deleted (they assert a refusal after admission)
http-request-authority.test.ts(role-policy fence on the snapshot)http-auth-utils.openclaw-id-tunnel.test.ts(device removed or role changed after admission → refusal)channel-avatar-http: "rejects revoked authority while channel avatar bytes are loading"managed-image-attachments.authority: revoked worker ownership read and revoked media authority after preparationplugin-icon-http: revoked authority during normalization or favicon fetchworkspace-icon-http: changed authority during icon preparation (the workspace replacement case, a data fence, stays)http-endpoint-helpers: "does not admit a parsed body after its authority was revoked while reading"http-utils.authorize-request: trusted-proxy override revalidationtools-invoke-http.abort: "rejects a tool when policy authority changes during its awaited hook"control-ui-assistant-media-metadata: reader authority recheck variantsserver-http.authority-outcomes: nine client-expired / role / operator-revoked / unavailable variants. The disconnect and unexpected-error variants stay, and still prove Stop through the real HTTP routeropenresponses-session-storeand the OpenResponses continuation support: revoked caller before commit / during the continuation lookupcontrol-ui-assistant-media-policy,control-ui-plugin-assets,control-ui-session-entry(.real-auth.e2e),control-ui.response-authority,http-auth-utils.paired-device,http-session-control.incognito(revoked=true rows),server.plugin-http-role-scopes,server/plugins-http(re-check before the next matched route),session-kill-http(policy-revocation and credential-rotation rows),sessions-history-http.revocation(ingress-policy row),user-background-http.authority,user-profiles-http.auth(credential rotation and device revocation during preparation),team-reports-http.gateway(expiry, generation and role change before delivery). Data-fence, admission-time and abort cases in those files stay.Evidence
server.plugin-http-auth.test.ts› "finishes an admitted gateway-auth plugin request after its credential rotates". The plugin handler is blocked, the Gateway token rotates, then the handler calls the scope'srevalidate(). The admitted request gets 200, and the next request with the old token gets 401. The same test copied onto base3cd3a3118668fails withexpected 401 to be 200: baserevalidate()re-checks the shared generation and refuses the admitted request. Stop through the real router:server-http.authority-outcomes› "cancels disconnected plugin reads without logging a handler failure". The one-admission E2E journey does not reach plugin HTTP routes, so this integration test is the plugin-route proof.ocx testcall over the 291 importer test files, withOPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1. It hit the 1 h tool deadline, so the 17 files it did not reach and every failed file ran again in two more calls. Everything passes except files that also fail on base3cd3a3118668:cron/service.pr-automation(13),server-methods/question.own-run(4),server.config-security-policy(3-4, timeouts),server.sessions.create.projects(1), andoperator-admission.table›token > principal > before-start.pnpm tsgo:coreandpnpm tsgo:testare clean. oxfmt and oxlint are clean on the changed files. The lifetime-check ratchet passes.one-admission-e2e/run.sh): Q, R and S pass on1d9bc6d06222and on the final head33a643a42c77. The live Gateway pid did not change.