Repository navigation
refactor(gateway): drop remaining mid-request authority re-checks in server methods (R6b part 2) - #204024
Conversation
…server methods (R6b part 2) Delete the caller permission re-reads that ran after admission in the approval family, MCP and provider sign-in, Web Push, skill library, update parking, profile administration and session sharing/discovery/reactions/compaction handlers. Start-time admission, Stop, request close, run close and data fences stay, with messages that name what ended and the next step. 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. |
|
|
One-admission E2E on head b68690a (Q, R, S pass). verdict.json{
"pass": true,
"prefix": "HEAD",
"sessionKey": "agent:main:one-admission-737e7eb7",
"models": [
null,
"gpt-5.5-2026-04-23"
],
"relayStatuses": [
421,
200
],
"checks": [
{
"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,
"runIds": [
"9004f472-756d-435d-9627-f00a2653a0ac"
]
},
"state": "aborted",
"requestsWithStopMarker": 1
}
}
],
"elapsedMs": 64080
}```
</details>
<details><summary>results.jsonl (28 lines)</summary>
{"t":"2026-11-23T10:09:43.038Z","step":"admin#1.hello","data":{"scopes":["operator.admin","operator.approvals","operator.pairing","operator.read","operator.write"],"role":"operator"}} |
|
Codex review: needs changes before merge. What this changesRemoves mid-request permission checks from Gateway handlers while retaining admission, cancellation, and data ownership checks. Example: An administrator starts models.authLogin, then loses operator.admin before credentials are saved.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 4 items remain Keep open: this maintainer-authored PR follows the approved authority policy, but four affected consumer tests still enforce superseded behavior or messages. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Gateway router admits authenticated RPC requests, then handlers perform approval, sign-in, session, notification, and update operations through existing lifecycle and storage owners. flowchart LR
A[Authenticated RPC request] --> B[Router admission]
B --> C[Server method handler]
C --> D[Retained request lifetime]
D --> E[Storage or provider operation]
E --> F[Response and events]
Technical reviewBest possible solution: Keep the focused deletions and existing owners, and complete the affected consumer-test cutover without restoring mid-request permission checks. Do we have a high-confidence way to reproduce the issue? Current main contains explicit post-admission permission refusals, and current-head CI demonstrates the four consumer-test failures; no target code was executed during this read-only review. Is this the best way to solve the issue? The deletion-based approach fits the approved invariant and existing owners; the identified test repairs should follow the intended behavior rather than reinstate the old checks. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cff878276e9d. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -278, Tests -302, Other -6. Total -586 across 44 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. 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 23, 2026, 5:29 AM ET / 10:29 UTC. |
… check for now Delete tests that asserted a refusal after a permission change mid-request, update the panel admission text, and restore the MCP sign-in check: its forced-effects tests use revocation as their fault trigger and need their own rewrite. Co-authored-by: obviyus <[email protected]>
|
One-admission E2E on head be7d53f (Q, R, S pass). verdict.json{
"pass": true,
"prefix": "HEAD",
"sessionKey": "agent:main:one-admission-a44ee554",
"models": [
null,
"gpt-5.5-2026-04-23"
],
"relayStatuses": [
421,
200
],
"checks": [
{
"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,
"runIds": [
"fc1ceb1c-67fb-4159-86c2-e068a83d296e"
]
},
"state": "aborted",
"requestsWithStopMarker": 1
}
}
],
"elapsedMs": 63100
}```
</details>
<details><summary>results.jsonl (28 lines)</summary>
{"t":"2026-11-23T10:54:39.784Z","step":"admin#1.hello","data":{"scopes":["operator.admin","operator.approvals","operator.pairing","operator.read","operator.write"],"role":"operator"}} |
|
Stopped under the 2-CI-round rule. Not merging this head. CI round 2 (head
Local review: clean on both heads. One-admission E2E: Q/R/S pass on both heads. Proposed split:
|
… mid-wait test The approval-request policy re-check is gone, so no error carries "Approval requester authority changed" any more. Delete the matcher, its test row, and the integration case that asserted a refusal after a mid-wait access change. Co-authored-by: obviyus <[email protected]>
|
One-admission E2E on head c9aef79 (Q, R, S pass). verdict.json{
"pass": true,
"prefix": "HEAD",
"sessionKey": "agent:main:one-admission-1a1554c7",
"models": [
"gpt-5.5-2026-04-23",
null
],
"relayStatuses": [
200,
421
],
"checks": [
{
"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,
"runIds": [
"73b6a7fe-9939-4650-a3fd-fdc82ee6b1be"
]
},
"state": "aborted",
"requestsWithStopMarker": 1
}
}
],
"elapsedMs": 56500
}```
</details>
<details><summary>results.jsonl</summary>
{"t":"2026-11-23T11:50:13.456Z","step":"admin#1.hello","data":{"scopes":["operator.admin","operator.approvals","operator.pairing","operator.read","operator.write"],"role":"operator"}} |
|
Maintainer override: every red on head
Also proven with a local |
|
Landed as 620b710. A request that already started now finishes when the caller's role, scope, device or config changes during it; the change applies to the next request. Start-time admission, Stop, run end and record fences still refuse, and their messages now name what ended and the next step. Proof: one-admission E2E Q/R/S pass on c9aef79, local review clean, every CI red also fails on main (override above). Still open: update-admission.ts, mcp-auth-login.ts and the authority.assertCurrent readers. |
…server methods (R6b part 2) (openclaw#204024) ## Problem OpenClaw checks authority once, when a request starts (AGENTS.md "Choose good compromises"). After part 1 (openclaw#203991), `src/gateway/server-methods` still had 22 counted refusals; this PR clears 20 of them that re-read the caller's permission in the middle of a request. They are the approval family, provider sign-in, Web Push, the skill library, update parking, profile administration, and session sharing, discovery, reactions and compaction. They refused with "... authority changed" or "... authority is no longer active". A role, scope, device or config change could fail a request that was already admitted. The lifetime-check ratchet still counts these strings. ## Fix R6b, second half. This PR takes the counted strings (24 production files in `server-methods`); the ~65 `authority.assertCurrent` reader files follow in their own PR. I classified each check that throws one with this test: can it fire when only a permission, approval or config changes while nothing about the run or data changes? - Yes → deleted, with its plumbing (`hasCurrentClientAuthority` in the session-sharing `Pick<>` types and their callers, `bindSource` and the config observer in `approval-request-authority.ts`, unused imports). - Start-time admission (the first decision, before any work) → kept, reworded. - No (Stop, request close, run close, data fence) → kept, reworded to name what ended and the next step. | Site | Old message | Kind | Action | |---|---|---|---| | `approval-request-authority.ts:204` | Approval requester authority changed | authority + request close | role, scope, device, actor, profile, config and access-revision terms deleted with `bindSource`/config observer; `closed` kept: "The approval request ended. Start a new request to retry." | | `approval-shared.ts:644` | approval resolver authority is no longer active | authority + data fence | `invalidated`/visibility re-reads deleted at commit; record/source/custody fence kept: "The approval record changed. Look up the approval again." The invite-access check moved to the start of the resolve (it existed only at commit) | | `approval-visible-record.ts:126` | Approval lookup authority is no longer active | authority + data fence | permission re-read deleted; record/source fence kept, reworded as above. The start-time `canAccess` checks stay | | `approval.ts:395` | approval resolver authority is no longer active | authority + data fence | `invalidated`/`canAccessOperatorApproval` re-read deleted (start-time lookup visibility stays); record/custody fence kept, reworded | | `exec-approval.ts:148`, `plugin-approval.ts:103` | agent runtime approval authority is no longer active | run close (start-time) | kept: "The approval run ended. Start a new turn to request approval again." | | `system-agent-approval.ts:177` | The system-agent approval authority is no longer active. | Stop / session replaced | kept: "... The system-agent approval ended. Start a new turn to request approval again." | | `models-auth-login.ts:95` | Provider login authority is no longer active. | authority | deleted; owner and method fences kept | | `push.ts:95` | Web Push requester authority changed | authority | deleted (role/scope/device re-read); request and profile fences kept | | `skills-library.ts:87` | Skill library authority changed. Refresh and retry. | authority | deleted (owner-device re-read) | | `update.ts:496` | Foreground update authority changed before parking. | config + handoff claim | config term deleted; claim fence kept: "The update handoff ended. Start a new update to retry." | | `method-authorization.ts:117` | Gateway requester authority changed | start-time admission (`client.invalidated` at dispatch) | kept: "This connection lost access. Reconnect and try again." | | `request-authorization.ts:414` | Gateway requester authority changed | authority (scope re-read after async pre-dispatch preparation) | deleted; the scope decided at the start of the admission holds | | `personal-profile-authorization.ts:50` | Personal profile request connection is no longer current; ... | start-time admission | kept: "This personal profile connection lost access. Reconnect and try again." | | `session-discovery-access.ts:32`, `sessions-reactions-access.ts:35`, `sessions-sharing-authority.ts:129` | Session discovery authority changed. / reaction author or session authority changed / session ownership changed ... | authority + request close + projection | `hasCurrentClientAuthority`, `invalidated`, creator-id and run-authority terms deleted from `assertCaller`; connection-closed and projection-replaced kept: "... ended. Start a new request to retry." | | `sessions-suggestions-access.ts:240` | suggestion requester authority changed | Stop / data fence (fallback text) | kept: "suggestion request ended; retry the request" | | `sessions-compact.ts:274` | Gateway requester authority changed | authority (device re-read) | deleted; Stop kept | | `users-profile-access.ts:119` | Gateway requester authority changed | request fence (request client/context replaced) | kept: "The profile administration request ended. Start a new request to retry." | | `users-profile-access.ts:138` | Gateway administrator profile authority changed | authority | `role.isCurrent()` re-read deleted. The admin scope/role/config-policy checks now run once at start instead of on every `assertCurrent` | Production: 24 files under `server-methods` plus `src/agents/bash-tools.exec-host-shared.ts`, where the `"Approval requester authority changed"` classifier matched a message that no longer exists; it is deleted with its test case. Net negative (see diff stat). The lifetime ratchet reports 0 counted strings in every touched file. `config/session-identity-allowlist.txt` pruned (6296 → 6286 pins). Not in this PR (deferred): - `mcp-auth-login.ts:116` "Sign-in authority is no longer active." (authority): kept. About 10 forced-effects cases in `server.mcp-auth-login.test.ts` use revocation as their fault trigger for cleanup and rollback paths; deleting the check needs those cases rewritten on a different trigger, which is a separate change. - `update-admission.ts:213` "Update requester authority changed before parking.": `retainUpdateRequesterAuthority` feeds `src/infra/update-managed-service-handoff.ts`, which requires a requester assertion. - `custody.isCurrent()` mixes config identity with the delivery fence inside `src/gateway/approval-channel-custody.ts`; kept as is. - The `authority.assertCurrent` readers in this directory (~65 files) and `sessions-sharing-authority.ts` `readCurrent`: next PR. Deleted tests (they asserted a mid-request permission refusal): caller revocation and scope-downgrade cases in `approval.request-authority`, `approval.legacy-authority`, `models-auth-login*`, `push-authority`, `request-authorization`, `session-discovery.authority`, `sessions-reactions*`, `sessions-sharing.*`, `github-personal-authorization`, plus `setup-inference-credentials.authority` (native login after owner invalidation), `session-access-authority` (scope change during preparation) `session-sharing-store.worker` (profile swap during a membership read) and `cron-stream-approval.integration` (approved exec whose waiting authority changed). `server-methods.profile-authorization.test.ts` now asserts that a scope switch during pre-dispatch preparation keeps the admitted scope. Stop, close and data-conflict cases stay with updated text. ## User impact A request that already started finishes even if the caller's role, scopes, device or config changes meanwhile; the change applies to the next request. A connection that lost access is still refused at the start of its next request. Stop, disconnect, run end and record replacement still end work, with messages that say what ended and what to do next. ## Evidence - `node scripts/check-lifetime-check-ratchet.mts`: 0 counted strings in the changed production files; no per-file growth. - `pnpm tsgo:core`, `pnpm tsgo:test`: pass. oxfmt/oxlint on changed files: clean. `pnpm check:changed`: typecheck, ratchets and guards pass; its dead-export scan lists only exports that are also unused on main (the one this PR caused, `authorizeGatewayMethodScopes`, is now module-private). - Final head: one `ocx test` call on 122 files, every test under `src/gateway/**` and `src/agents/**` that imports a changed source by module path (directly or through a `*.test-support`/`*.test-utils` helper), plus every touched test (continue-on-failure): 6 shards, all pass. - First head: `ocx test` on the 133 touched and importer test files (continue-on-failure): all gateway files pass after the test updates (6 re-run files: 90/90). `extensions/reef/src/{channel,friends,state}.test.ts` fail with `SyntaxError: Cannot convert 0x… to a BigInt` in plugin-state storage; they import no changed file (picked up by basename match). - One-admission E2E: on head `c9aef791ef0c` (isolated scratch Gateway, real agent turn): `pass: true`, results.jsonl 28 lines (attached in a comment). | Journey | Result | Detail | |---|---|---| | R.running-turn-finishes | pass | `{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}` | | Q.queued-input-refused-visibly | pass | `{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}` | | S.stop-cancels | pass | `{"abort":{"ok":true,"aborted":true},"state":"aborted","requestsWithStopMarker":1}` | - Local ClawSweeper review on `c9aef791ef0c`: complete, "patch is correct", no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
OpenClaw checks authority once, when a request starts (AGENTS.md "Choose good compromises"). After part 1 (#203991),
src/gateway/server-methodsstill had 22 counted refusals; this PR clears 20 of them that re-read the caller's permission in the middle of a request. They are the approval family, provider sign-in, Web Push, the skill library, update parking, profile administration, and session sharing, discovery, reactions and compaction. They refused with "... authority changed" or "... authority is no longer active". A role, scope, device or config change could fail a request that was already admitted. The lifetime-check ratchet still counts these strings.Fix
R6b, second half. This PR takes the counted strings (24 production files in
server-methods); the ~65authority.assertCurrentreader files follow in their own PR. I classified each check that throws one with this test: can it fire when only a permission, approval or config changes while nothing about the run or data changes?hasCurrentClientAuthorityin the session-sharingPick<>types and their callers,bindSourceand the config observer inapproval-request-authority.ts, unused imports).approval-request-authority.ts:204bindSource/config observer;closedkept: "The approval request ended. Start a new request to retry."approval-shared.ts:644invalidated/visibility re-reads deleted at commit; record/source/custody fence kept: "The approval record changed. Look up the approval again." The invite-access check moved to the start of the resolve (it existed only at commit)approval-visible-record.ts:126canAccesschecks stayapproval.ts:395invalidated/canAccessOperatorApprovalre-read deleted (start-time lookup visibility stays); record/custody fence kept, rewordedexec-approval.ts:148,plugin-approval.ts:103system-agent-approval.ts:177models-auth-login.ts:95push.ts:95skills-library.ts:87update.ts:496method-authorization.ts:117client.invalidatedat dispatch)request-authorization.ts:414personal-profile-authorization.ts:50session-discovery-access.ts:32,sessions-reactions-access.ts:35,sessions-sharing-authority.ts:129hasCurrentClientAuthority,invalidated, creator-id and run-authority terms deleted fromassertCaller; connection-closed and projection-replaced kept: "... ended. Start a new request to retry."sessions-suggestions-access.ts:240sessions-compact.ts:274users-profile-access.ts:119users-profile-access.ts:138role.isCurrent()re-read deleted. The admin scope/role/config-policy checks now run once at start instead of on everyassertCurrentProduction: 24 files under
server-methodsplussrc/agents/bash-tools.exec-host-shared.ts, where the"Approval requester authority changed"classifier matched a message that no longer exists; it is deleted with its test case. Net negative (see diff stat). The lifetime ratchet reports 0 counted strings in every touched file.config/session-identity-allowlist.txtpruned (6296 → 6286 pins).Not in this PR (deferred):
mcp-auth-login.ts:116"Sign-in authority is no longer active." (authority): kept. About 10 forced-effects cases inserver.mcp-auth-login.test.tsuse revocation as their fault trigger for cleanup and rollback paths; deleting the check needs those cases rewritten on a different trigger, which is a separate change.update-admission.ts:213"Update requester authority changed before parking.":retainUpdateRequesterAuthorityfeedssrc/infra/update-managed-service-handoff.ts, which requires a requester assertion.custody.isCurrent()mixes config identity with the delivery fence insidesrc/gateway/approval-channel-custody.ts; kept as is.authority.assertCurrentreaders in this directory (~65 files) andsessions-sharing-authority.tsreadCurrent: next PR.Deleted tests (they asserted a mid-request permission refusal): caller revocation and scope-downgrade cases in
approval.request-authority,approval.legacy-authority,models-auth-login*,push-authority,request-authorization,session-discovery.authority,sessions-reactions*,sessions-sharing.*,github-personal-authorization, plussetup-inference-credentials.authority(native login after owner invalidation),session-access-authority(scope change during preparation)session-sharing-store.worker(profile swap during a membership read) andcron-stream-approval.integration(approved exec whose waiting authority changed).server-methods.profile-authorization.test.tsnow asserts that a scope switch during pre-dispatch preparation keeps the admitted scope. Stop, close and data-conflict cases stay with updated text.User impact
A request that already started finishes even if the caller's role, scopes, device or config changes meanwhile; the change applies to the next request. A connection that lost access is still refused at the start of its next request. Stop, disconnect, run end and record replacement still end work, with messages that say what ended and what to do next.
Evidence
node scripts/check-lifetime-check-ratchet.mts: 0 counted strings in the changed production files; no per-file growth.pnpm tsgo:core,pnpm tsgo:test: pass. oxfmt/oxlint on changed files: clean.pnpm check:changed: typecheck, ratchets and guards pass; its dead-export scan lists only exports that are also unused on main (the one this PR caused,authorizeGatewayMethodScopes, is now module-private).ocx testcall on 122 files, every test undersrc/gateway/**andsrc/agents/**that imports a changed source by module path (directly or through a*.test-support/*.test-utilshelper), plus every touched test (continue-on-failure): 6 shards, all pass.ocx teston the 133 touched and importer test files (continue-on-failure): all gateway files pass after the test updates (6 re-run files: 90/90).extensions/reef/src/{channel,friends,state}.test.tsfail withSyntaxError: Cannot convert 0x… to a BigIntin plugin-state storage; they import no changed file (picked up by basename match).c9aef791ef0c(isolated scratch Gateway, real agent turn):pass: true, results.jsonl 28 lines (attached in a comment).{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}{"abort":{"ok":true,"aborted":true},"state":"aborted","requestsWithStopMarker":1}c9aef791ef0c: complete, "patch is correct", no findings.