Repository navigation
refactor: drop mid-request authority re-checks in the last gateway, session and node-host refusals (R6d part 4) - #204191
Conversation
…ession and node-host refusals (R6d part 4) Delete role, scope, profile-version, access-revision, config and command-policy re-reads that refused started requests; keep Stop, disconnect and data fences and reword them to say what ended and the next step. Admission checks that sat inside a repeated closure now run once before it (factory GitHub proof, remote ingress). Co-authored-by: obviyus <[email protected]>
…on-facts refusal rows The remote ingress role compare retires the binding so the MCP relay rebinds with the current role; without it the next relay request fails as internal. Keep it, reworded. Drop session-facts rows that expect a started disclosure to be refused after a role, profile or config change (red on main since the R6d part 3 cut). 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. |
|
|
Codex review: needs changes before merge. What this changesThis PR removes permission rechecks from started Gateway operations while retaining admission, lifecycle, session, and identity checks. Example: Alice starts an agent turn while she is a channel owner, then an administrator removes her owner status.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-authored PR follows the approved admission contract, but a renamed Factory GitHub error breaks an existing rejection test. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway admission accepts authenticated requests; agent, mention, repository, and node owners execute them and return results under their retained lifecycle and target checks. flowchart TD
A[Authenticated request] --> B[Request start admission]
B --> C[Captured authority]
C --> D[Agent and Talk execution]
C --> E[Mention and repository operations]
D --> F[Lifecycle and target checks]
E --> F
F --> G[Result or actionable refusal]
Technical reviewBest possible solution: Keep the existing admission owners and retained lifecycle checks, and update the foreign-host rejection assertion to recognize the new diagnostic. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the repeated permission checks being removed, and exact-head CI independently demonstrates the remaining Factory GitHub assertion mismatch; no target code was executed during this review. Is this the best way to solve the issue? Removing repeated checks and their plumbing from existing owners is the smallest coherent implementation of the recorded admission policy. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e2973f933f10. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource -54, Tests -40, Other -1. Total -95 across 40 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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, 2:15 PM ET / 19:15 UTC. |
…update the factory proof text subagent-spawn.production-boundary still expects child dispatch to stop after the spawning owner is removed; that tree is owned by a parallel PR, so the check stays until that expectation is deleted. The factory identity fence test now matches the reworded message. Co-authored-by: obviyus <[email protected]>
|
Maintainer override: the only red job on head
The same file is red in main run 45238720546. The |
|
Stopped under the 2-CI-round rule. Not merged. CI round 2 on
Proposed split: one more push on this branch that deletes the |
The row cleared the client's scopes after ACK and expected the run to be refused; that mid-request scope re-check is gone from repository-dispatch. Co-authored-by: obviyus <[email protected]>
|
Withdrawn: |
…ssion parity Co-authored-by: obviyus <[email protected]>
|
Maintainer override: the only red job on head
The same file is red on main (runs 45238720546 and 45248844963). The |
|
Landed as 1596a12.
|
…4270) ## Result The 12 refusal-class test files that turned scheduled run 45259316971 (`cded11f8`) red pass again. Two one-time-admission PRs caused these reds. Nine files change here; the other three were already fixed on `main` (#204191, #204255, 4efdef5). Each changed case is deleted (it asserted a mid-run permission refusal that was removed on purpose) or keeps its condition with the new refusal text. There is no production change. ## Introducing PR per file I ran all 12 files at each suspect merge and at its parent (`ab24e714` → `8ea0f171`, `412df906` → `515a93c6`). The parent `ab24e714` is green. Every failure shows up at the merge named below. #204167 (`ef48c716`) adds no failure. | File | Introduced by | Action | Why | |---|---|---|---| | `src/agents/command/model-selection.configured.test.ts` | #204155 | deleted "rechecks operator authority after loading the thinking catalog" | #204155 removed the `authority.assertCurrent` composition from `createOperatorModelSelectionAssertion`. A started selection now finishes after the authority ends; the next request is admitted again | | `src/gateway/operator-run-authority.worker.test.ts` | #204155 | deleted the "role facts reader throws after abort" loop; cancellation of `assertCurrent` is kept | #204155 removed the `readCurrentRoleFacts` re-check wrapper. Role facts are the admitted snapshot | | `src/gateway/local-request-context.session-tools.test.ts` | #204155 | none: #204255 already changed it on `main` (the revoked participant now gets a structured denial) | The participant `assertCurrent` was removed in `session-controller.tool-authority.ts` | | `src/agents/tools/image-tool.runtime-abort.test.ts` | #204155 | deleted the 2 "retired after download" rows; the denied-override and permitted-fallback rows are kept | Same as the `pdf-tool` "retired after extraction" case that #204155 deleted | | `src/gateway/sessions-patch.operator-model-policy.test.ts` | #204155 | deleted the source-revocation steps (4 cases); the admitted model policy, the denied model, the wildcard family and the policy-tightening checks are kept | #204155 removed the source composition from `createOperatorModelSelectionAssertion` | | `src/gateway/server-methods/ui-command.test.ts` | #204155 | none: 4efdef5 already dropped the mid-turn revoke step on `main` | Same participant re-check | | `src/model-picker/apply-session-model-selection.operator-context.test.ts` | #204155 | deleted "rechecks caller authority after model preparation before mutation" and its `assertCurrent` fixture plumbing | Same composition | | `src/gateway/session-access-authority.test.ts` | #204134 | text only: `/could not start\|Session access changed/` | The refusal is still at admission, before route effects. The handler is not called and the leases are released. #204134 reworded `prepareGatewayOperatorRunAuthority` to "Gateway request could not start. Reconnect and try again." | | `src/gateway/server-plugins.panels.test.ts` | #204134 | text only, "caller revoked" and "requester disconnected" rows | The same admission refusal. No delivery happens (`broadcastToConnIds` is not called) | | `src/gateway/server-methods/users-personal-file.test.ts` | #204134 | text only: `/could not start\|connection/` | The change happens during operator-run preparation (admission). The request is still refused, and no `USER.md` is written (asserted after the refusal) | | `test/cli-message-authority.integration.test.ts` | #204134 | text only, registration row: `/was reloaded during/` | The plugin-reload fence is kept. #204134 reworded it to "Plugin discord was reloaded during alias resolution. Retry the action." | | `src/gateway/server-plugins.session-facts.test.ts` | #204134 | none: #204191 already rewrote it on `main` | See the leak check below | `server.chat-goal.test.ts` (small-4) is the known #204187 race. This PR does not change it. ## Leak check - `server-plugins.session-facts` "private cached snapshot": the consumer callback belongs to a request that was admitted before the grant, role or profile change. That request may finish (AGENTS.md "Check authority one time"). The next disclosure is refused at admission (`main` test, line 362). No snapshot goes to a caller who was refused at admission. **No leak.** - `users-personal-file`: the refusal still occurs at admission and nothing is written. Only the text changed. **No leak.** ## Evidence - Red on the scheduled run: 45259316971, shards large-8/19/20/22/28/32/37/41/42 and small-4. - Local attribution runs (12 files each): `ab24e714` green; `8ea0f171` and `412df906` show the 5 #204134 files red; `515a93c6` adds the 7 #204155 files. - Head: the 12 files pass locally (one unrelated `cli-message-authority` timeout under host load 66 passed on the rerun). CI on the head is green. Local ClawSweeper: patch is correct, no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
…ime ratchet (R6z) (#204249) ## Problem AGENTS.md says to check authority once, when work starts. The admitted operator authority (`AdmittedRunOperatorAuthority`) still carried a mid-run re-check member, `assertCurrent`, plus `onModelPolicyChanged`, a mid-run model-policy revocation hook. About 60 production readers called `assertCurrent()` in the middle of started runs, requests and queued work, and the constructor latched any failure into the run's signal. A started run could still be refused after a permission, role or profile change. The lifetime-check ratchet (`scripts/check-lifetime-check-ratchet.mts`) only kept the count from growing; it is now at zero and protects nothing. ## Fix This is the last one-admission PR (R6z). - `AdmittedRunOperatorAuthority` loses `assertCurrent` and `onModelPolicyChanged`. `createAdmittedRunOperatorAuthority` no longer composes or latches a re-check: its `signal` is the source signal (Stop) only. `bindOperatorModelExecution` keeps release and Stop, and no longer re-runs the policy on change. - Every reader the compiler listed is deleted. Stop reads its own signal (`signal.throwIfAborted()`). Data fences keep reading their own data: owner, generation, writer lease, run occurrence, released/closed flags, request lifetime, commit guards, the cron delivery fence (`scheduledAutomation.deliveryAttemptFence`) and the cron control-edit compare (`retainCronControlSource`). - `SessionControllerSourceAdapter.authority.assertCurrent` becomes optional. Non-operator producers keep their fence there. An operator authority passed there carries only Stop. - The retired-cron-delivery fence moves off the operator authority. A queued follow-up checks `scheduledAutomation.deliveryAttemptFence` before claim, in the same place where the removed `operatorAuthority.assertCurrent()` was. The follow-up runner withholds a run on `CronDeliveryAuthorityError` itself: it records the run and does not replay it. Before, it learned this only from the authority's latched signal. - The ratchet script, its test and its `ci-baseline-ratchets` entry are deleted. - New lint rule `openclaw-boundaries/no-operator-permission-read` (in `config/oxlint/boundary-guards.json`, which the `lint:no-chained-type-assertions` boundary lane runs over `src`, `extensions` and `packages`). Only the files named in `scripts/lib/no-operator-permission-read.mjs` may reference the live permission readers `resolveOperatorRolePolicy`, `resolveOperatorRolePolicyForAssignment`, `resolveOperatorRolePolicyForProfile`, `resolveOperatorRoleSelection`, `authorizeCurrentOperatorRoleScopes`, `onOperatorRolePolicyChanged` and `captureResidentUserProfileAccess`. The allowlist is the owners and the work-start files that use them today (63 files). It only shrinks: new code takes scopes, role and policy from the admitted operator authority. The planted fixture `test/fixtures/oxlint-boundary-guards/operator-permission-recheck-violation.ts` (named import, namespace member, lazy import) fails the rule (4 reports). - Parked item from R6c4a: the worktree publication message reads "The GitHub publication worktree changed" instead of "...authority changed". The test fixture URL that had fake credentials is now `https://example.test/repo?...`. - The last three refusal strings in production code are gone: - `agent-run-user-turn.ts`: the requester-owner re-read from live config (`assertRequesterCurrent`, "Requester owner authority changed") is deleted, along with its admission-phase and execution-phase plumbing. The owner decision is made once, when the turn starts. The `subagent-spawn.production-boundary` expectation "removing the spawning owner after admission must stop that dispatch" is deleted with it. - `acp/runtime/session-meta-resume-authorization.ts`: this is a data fence (the source session's facts changed). It is reworded to "The ACP resume source session changed". - `cron-creator-authority-grant.ts`: the run-scoped grant ends with its run, scope, operation or management deadline. It is reworded to "This run's MCP cron access has ended". - `scripts/perf/*-measure.ts`: removed the `assertCurrent` counters and the source-authority revocation proof, which measured the deleted mid-run re-check. Production code: 86 files, +82 / −313. Scripts, config and lint test: +138 / −242. ### Decisions - Lint rule shape (Fable 5.2): an import/reference boundary on the live readers, with exact files listed. A rule that bans the name `assertCurrent` would be wrong, because ~150 data-owner authorities use that name. The refusal-string ban would only bring the deleted ratchet back as a wording check. Accepted risk: an allowed work-start file can still call a reader twice. Review owns that. - `src/cron/service.restart-delivery.test.ts` "automation=false" row deleted. Only the fixture put the delivery fence on the operator authority. In production the queued authority comes from `decideOperatorAdmission`, whose `assertCurrent` was always a no-op. The real carrier is `scheduledAutomation.deliveryAttemptFence`, and that case stays. - Accepted edge: a queued chat input's `requesterProfile.isCurrent` is now `true` for the life of the dispatch. Before, it turned false after the admitted source was released. It only selects the requester attribution prefix. - Accepted edge: if a completion cohort settles between the steering preparation and the queue commit, the human correction now reports `failed` with the policy-mismatch error. Before, it reported `rejected: tool_authority_mismatch`. The message is still refused visibly, and the race window is a few milliseconds. - Known follow-up, not done here: a cron creator grant can still be refused when consumed after its issuing device or channel owner is revoked during the run, because the grant's `isCurrent` producers still read the device and owner lifetime. Only the wording changed in this PR. Removing those producers is a separate cut in the cron grant plumbing. ## User impact A started run, request, queued start, tool call, model execution or scheduled job finishes after a permission, role, profile or model-policy change. The next request uses the new permissions. Stop still cancels. Data fences still refuse stale writes. ## Tests Deleted, because each asserts a refusal after a mid-run permission, role, profile or model-policy change (full list in the PR comment). Stop, run-close and data-fence tests keep their condition. Test fixtures no longer pass `assertCurrent` or `onModelPolicyChanged`. ## Evidence - `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean. - oxfmt and oxlint on all changed files: clean. `pnpm lint:no-chained-type-assertions` (all focused guards, including the new rule) over the tree: 0 errors. `test/scripts/oxlint-boundary-guards.test.ts`: the planted re-check fixture fails the rule. - Pre-push `ocx test`: all 215 touched test files and the importers of every `*.test-support.ts` file. The direct-importer set is over the 150-file cap. Then the failed files, plus importers of `followup-runner.ts` and `reply-agent-turn-preparation.ts`, and after the rebase on #204191 its 17 test files. Final reruns are green. - E2E `one-admission-e2e/run.sh`: see the comment. Co-authored-by: Ayaan Zaidi <[email protected]>
* fix(subagents): settle cleaned child receipts and classify delivery notices * test(subagents): preserve notice classification assertion typing * test(subagents): build cleanup fixtures without map spread * chore(subagents): shrink identity allowance after guard removal * fix(subagents): separate receipt identity from continuation claims * test(subagents): retain main child notice classification after rebase * test(subagents): expect the ready cohort member to schedule settlement * fix(sessions): deduplicate yielded completion failure notices * test(subagents): preserve explicit claims and await terminal session state (cherry picked from commit cab76a6) Release adaptation: Preserved stable suspended-delivery sweeper; omitted main-only expiry and self-hold replacement fixtures; retained registry and Gateway yield-wait regression coverage. Identity ratchet prune clean. Companion audit: #204249 and #204191 not applicable (authority refactors); #204260 missing in lane, not a prerequisite. Co-authored-by: RomneyDa <[email protected]>
…ession and node-host refusals (R6d part 4) (openclaw#204191) ## Problem OpenClaw checks authority once, when work starts (AGENTS.md "Choose good compromises"). The last gateway, ACP, session and node-host files outside `src/agents/**` still re-read a role, scope, profile version, access revision, config or command policy during a request. A started request was then refused with "authority changed" or "authority is no longer active/current". Other checks in the same files are valid Stop, disconnect or data fences, but their text claimed authority. ## Change R6d part 4. Each string site was classified with one test: can it fire when only a permission, approval or config changes while nothing about the run or the data changes? - Yes: the check and its plumbing are deleted. - No (Stop, run close, disconnect, data fence): the check is kept and reworded. The text says what ended and what to do next. - Start-time checks (admission, made once before work begins) stay. In `factory-github-proof.ts` the role/scope check sat inside a repeated closure whose first call was the admission; it is now a one-time check before the closure. | Site | Old message | Kind | Action | |---|---|---|---| | `channel-avatar-http.ts` | Channel avatar session authority changed | data fence (session id, lifecycle revision, avatar ref) | reworded | | `managed-image-session-read.ts` | Managed media session authority changed | data fence (session id, lifecycle revision) | reworded | | `server-node-event-source.ts` | Node event session authority changed | data fence (harness, delivery) | reworded | | `human-mention-policy.ts` recipient selection | Committed mention recipients or sender authority changed | admission, repeated at involvement commit | kept once at the start, reworded; repeat removed | | `human-mention-policy.ts` involvement `assertCurrent` | Committed mention authority changed before involvement commit | mixed: recipient policy re-selection + policy closed | policy re-selection deleted; closed-policy fence kept, reworded | | `mention-inbox.ts` commit | Mention authority changed before commit | mixed: profile version, access revision, config + session revision | profile/access/config compares deleted; session-revision fence kept, reworded | | `node-claude-skill-runtime.ts` | Paired-node skill assignment or run authority changed | mixed: live node command allowlist + node/session/placement/claim fences | allowlist re-read deleted (still checked once at invocation start in `node-agent-cli-runtime.ts`); fences kept, reworded | | `node-mcp-elicitation.ts` | MCP elicitation authority changed | opaque callback (pairing lifecycle mixed with MCP config) | kept, reworded | | `cron-stream-sandbox-authority.ts` | Sandbox stream authority changed | session/resource fence | reworded | | `desktop/observe-bridge.ts` | Desktop observer authority is no longer current | opaque connection callback | kept, reworded | | `factory-github-proof.ts` | Factory GitHub caller authority changed. | mixed: role/scope/operator flag + connection/identity | role/scope/operator check moved to a one-time check at capture; connection/identity fence kept, reworded | | `repository-dispatch.ts` | Repository caller authority changed | mixed | role, scope, operator-flag and permission-callback re-checks deleted; connection, device-source and identity fences kept, reworded | | `repository-integration-identity.ts` | Repository operation authority changed | config re-read (integration, host, API URL) | deleted | | `http-auth-user-profile.ts` (2) | HTTP profile authority changed during acquisition | admission (one acquisition) | kept, reworded | | `openai-compatible-agent-run.ts` | Gateway requester authority changed | admission (`!admitted` only) | kept, reworded | | `session-sharing-read.ts` | Gateway requester authority changed | requester identity fence | kept, reworded | | `skill-library-session.ts` | OpenClaw ID owner authority changed | opaque owner-device callback (Stop fence of `SkillLibraryAuthority`) | kept, reworded | | `talk/client-run-authority.ts` (2) | Talk caller source authority is no longer active | mixed: release/device source + `hasCurrentClientAuthority` fallback | permission fallback deleted; release and device-source fences kept, reworded | | `remote-control-ui-ingress.ts` | Remote ingress principal authority changed; … | mixed: person auth policy + role compare + identity/alias/abort | **cut less:** kept, reworded. The role compare retires the binding so the MCP relay rebinds with the current role on the next request. Without it the next relay request fails downstream with `internal` and never rebinds (`remote-control-ui-ingress.integration` "shares real principal authority…" red). | | `ws-connection/authenticated-request-dispatch.ts` publication transport | publication transport authority changed | opaque token-identity callback | kept, reworded (telemetry reason code unchanged) | | `ws-connection/authenticated-request-dispatch.ts` expected profile | Gateway requester authority changed | permission re-check (`hasCurrentClientAuthority`) | callback argument deleted | | `ws-connection/connect-publication-transport.ts` (2) | publication transport authority changed | handshake admission | kept, reworded | | `server/ws-origin-policy.ts` | OpenClaw ID owner authority changed | opaque principal callback | kept, reworded | | `config/sessions/session-accessor.sqlite-reclamation-commit.ts` | SQLite reclamation authority is no longer current | reclamation-state fence | reworded | | `node-host/openclaw-id-connection.ts` | server authority changed | transport identity (server key) | reworded | Deleted tests (they asserted a mid-request permission refusal): - `server.sessions.create.repository-required.test.ts`: the `caller` row (client scopes cleared after ACK, run expected to be refused). - `mention-inbox.test.ts`: "refuses a pending mention write after the recipient loses access". - `server-plugins.session-facts.test.ts`: the `role`, `profile` and `same-object config` rows of "retains admitted grants but fences selected disclosure data". They expect a started disclosure to be refused after that change; openclaw#204134 removed that re-check, and the rows are red on main `d4ff1834c0ff` (3 failed locally). The `grant` row stays: a started disclosure finishes and the next one is refused. Stop and data-fence tests keep their conditions. Only their expected text changed. `config/session-identity-allowlist.txt` is pruned. Accepted edge cases: - A started mention write commits even if a recipient's role changes before commit. The next read applies the new role. - A started repository operation keeps its admitted role. The next request uses the new role. ## Not in this PR - `src/gateway/cron-creator-authority-grant.ts`, `src/acp/runtime/session-meta-resume-authorization.ts` and `src/gateway/agent-turn/agent-run-user-turn.ts` (`assertRequesterCurrent`, the requester-owner re-read from live config through the run): tests under `src/agents/**` pin them, and a parallel PR owns that tree. `subagent-spawn.production-boundary.test.ts` line 457 expects the child dispatch to stop after `commands.ownerAllowFrom` is cleared. Delete that expectation first, then the check and its admission/execution-phase plumbing. `src/agents/worktrees/errors.ts` stays parked for R6z. - Readers of `AdmittedRunOperatorAuthority.assertCurrent` outside `src/agents/**` and `src/auto-reply/**` (41 production files, listed by LSP references): `gateway/operator-role-policy.ts`, `sessions/session-controller.tool-authority.ts`, `gateway/operator-run-authority.ts`, `gateway/operator-admission.ts`, `security/dangerous-tools.ts`, `gateway/expected-profile.ts`, `gateway/session-sharing-policy.ts`, `gateway/session-sharing-read.ts`, `gateway/server-plugin-in-process-authority.ts`, `plugins/runtime/runtime-llm-isolated.ts`, `gateway/operator-invocation-authority.ts`, `plugins/runtime/runtime-llm-operator-authority.ts`, `gateway/github-publication-requester.ts`, `gateway/session-sharing-authorization-async.ts`, `gateway/session-create-existing-selection.ts`, `gateway/session-permission-authorization.ts`, `gateway/session-create-model-selection.ts`, `gateway/operator-session-run.ts`, `gateway/session-access-authority.ts`, `gateway/agent-turn/agent-run-user-turn.ts`, `gateway/agent-turn/agent-run-admission-phase.ts`, `gateway/agent-turn/agent-run-execution-phase.ts`, `gateway/cron-operator-source.ts`, `gateway/github-publication-actions.ts`, `gateway/session-companion-rpc.ts`, `talk/agent-run-control.ts`, `gateway/talk/client-run-authority.ts`, `gateway/question-session-access.ts`, `plugins/requester-models.ts`, `gateway/server-plugin-in-process-dispatch.ts`, `gateway/session-companion-ask.ts`, `gateway/session-activity-summary-authority.ts`, `gateway/cron-command-source.ts`, `gateway/plugin-command-scheduled-run.ts`, `cron/session-run.ts`, `gateway/cron-stream-sandbox-authority.ts`, `plugins/service-session-work.ts`, `gateway/openai-compatible-agent-run.ts`, `gateway/queued-chat-inputs.ts`, `gateway/session-restart-resume.ts`, `gateway/server-instance-runtime.ts`. `server-methods/**` has its own readers. Admission sites (`operator-admission.ts`, `operator-run-authority.ts` constructors) stay. - Opaque mixed callbacks kept here (MCP elicitation `current()`, desktop observer `isCurrent`, publication transport token check, OpenClaw ID owner principal, skill-library owner device) mix policy with lifecycle inside their producers. Splitting them needs the producer change in R6z. ## User impact A started request, mention write, repository operation, Talk run or ingress binding is no longer refused because a role, scope, profile, access revision or config changed. The change applies to the next request. Stop, disconnect, session changes and transport identity changes still end work, and the messages now say what ended and what to do next. ## Evidence - `pnpm tsgo:core`, `pnpm tsgo:test`: pass. oxfmt and oxlint on changed files: clean. Lifetime-check ratchet: 0 counted strings in changed production files, no per-file growth. - Production vs `main`: 23 files, +75/−107. - `ocx test` (continue-on-failure) on 140 files: every touched test file, every test file importing a changed source, and every importer of the 12 test-support files that import one. Ours fixed: Talk parity expected-text regex, the remote-ingress cut-less above, and the stale session-facts rows. Base comparison on `d4ff1834c0ff`: `server.operator-role-scope-matrix`, `server.sessions-send-resume` and `server.agent.gateway-server-agent-a` timed out at host load ~90 and pass on head and base at lower load (one head scope-matrix case failed on a transient `node_modules` module-not-found, file present after). Final reruns of every red or invalidated file: green. - CI round 1 (`29148535213c`): OURS = `project-github-identity.factory` expected text (fixed) and `local-request-context.session-tools` (passes after the requester-owner revert). Local review round 1 found `subagent-spawn.production-boundary.test.ts` pins the requester-owner mid-run check under `src/agents/**`: cut less, `agent-run-user-turn.ts` and its two phase files restored to `main`. - Local ClawSweeper review: round 1 (`29148535213c`) 1 real finding (fixed above); round 2 (`5dd4558144b8`) "patch is correct", no findings. - One-admission E2E on `5dd4558144b8`: verdict pass. R.running-turn-finishes, Q.queued-input-refused-visibly and S.stop-cancels all pass (`verdict.json`, `results.jsonl` kept in the proof directory). - CI round 2 (`5dd4558144b8`): OURS = `server.sessions.create.repository-required` `caller` row (deleted, test-only push `4ba022722a64`); not ours: `server.talk-consult-history` (openclaw#203507), `local-request-context.session-tools` (red on main run 45238720546). The E2E on `5dd4558144b8` covers `4ba022722a64`: production is identical. - CI round 3 (`4ba022722a64`): OURS = `server.talk-permission-parity.test-support.ts` regex still matching the old Talk wording (fixed, test-only push `711ba27c5b6f`); not ours: `local-request-context.session-tools` (main runs 45238720546 and 45248844963). Local review clean on `711ba27c5b6f`. Production is unchanged since `5dd4558144b8`, where the E2E passed. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#204134 (openclaw#204270) ## Result The 12 refusal-class test files that turned scheduled run 45259316971 (`7172fc1f`) red pass again. Two one-time-admission PRs caused these reds. Nine files change here; the other three were already fixed on `main` (openclaw#204191, openclaw#204255, 85559c3). Each changed case is deleted (it asserted a mid-run permission refusal that was removed on purpose) or keeps its condition with the new refusal text. There is no production change. ## Introducing PR per file I ran all 12 files at each suspect merge and at its parent (`28d97119` → `d4ff1834`, `f88a49de` → `8d86eea4`). The parent `28d97119` is green. Every failure shows up at the merge named below. openclaw#204167 (`941e90a3`) adds no failure. | File | Introduced by | Action | Why | |---|---|---|---| | `src/agents/command/model-selection.configured.test.ts` | openclaw#204155 | deleted "rechecks operator authority after loading the thinking catalog" | openclaw#204155 removed the `authority.assertCurrent` composition from `createOperatorModelSelectionAssertion`. A started selection now finishes after the authority ends; the next request is admitted again | | `src/gateway/operator-run-authority.worker.test.ts` | openclaw#204155 | deleted the "role facts reader throws after abort" loop; cancellation of `assertCurrent` is kept | openclaw#204155 removed the `readCurrentRoleFacts` re-check wrapper. Role facts are the admitted snapshot | | `src/gateway/local-request-context.session-tools.test.ts` | openclaw#204155 | none: openclaw#204255 already changed it on `main` (the revoked participant now gets a structured denial) | The participant `assertCurrent` was removed in `session-controller.tool-authority.ts` | | `src/agents/tools/image-tool.runtime-abort.test.ts` | openclaw#204155 | deleted the 2 "retired after download" rows; the denied-override and permitted-fallback rows are kept | Same as the `pdf-tool` "retired after extraction" case that openclaw#204155 deleted | | `src/gateway/sessions-patch.operator-model-policy.test.ts` | openclaw#204155 | deleted the source-revocation steps (4 cases); the admitted model policy, the denied model, the wildcard family and the policy-tightening checks are kept | openclaw#204155 removed the source composition from `createOperatorModelSelectionAssertion` | | `src/gateway/server-methods/ui-command.test.ts` | openclaw#204155 | none: 85559c3 already dropped the mid-turn revoke step on `main` | Same participant re-check | | `src/model-picker/apply-session-model-selection.operator-context.test.ts` | openclaw#204155 | deleted "rechecks caller authority after model preparation before mutation" and its `assertCurrent` fixture plumbing | Same composition | | `src/gateway/session-access-authority.test.ts` | openclaw#204134 | text only: `/could not start\|Session access changed/` | The refusal is still at admission, before route effects. The handler is not called and the leases are released. openclaw#204134 reworded `prepareGatewayOperatorRunAuthority` to "Gateway request could not start. Reconnect and try again." | | `src/gateway/server-plugins.panels.test.ts` | openclaw#204134 | text only, "caller revoked" and "requester disconnected" rows | The same admission refusal. No delivery happens (`broadcastToConnIds` is not called) | | `src/gateway/server-methods/users-personal-file.test.ts` | openclaw#204134 | text only: `/could not start\|connection/` | The change happens during operator-run preparation (admission). The request is still refused, and no `USER.md` is written (asserted after the refusal) | | `test/cli-message-authority.integration.test.ts` | openclaw#204134 | text only, registration row: `/was reloaded during/` | The plugin-reload fence is kept. openclaw#204134 reworded it to "Plugin discord was reloaded during alias resolution. Retry the action." | | `src/gateway/server-plugins.session-facts.test.ts` | openclaw#204134 | none: openclaw#204191 already rewrote it on `main` | See the leak check below | `server.chat-goal.test.ts` (small-4) is the known openclaw#204187 race. This PR does not change it. ## Leak check - `server-plugins.session-facts` "private cached snapshot": the consumer callback belongs to a request that was admitted before the grant, role or profile change. That request may finish (AGENTS.md "Check authority one time"). The next disclosure is refused at admission (`main` test, line 362). No snapshot goes to a caller who was refused at admission. **No leak.** - `users-personal-file`: the refusal still occurs at admission and nothing is written. Only the text changed. **No leak.** ## Evidence - Red on the scheduled run: 45259316971, shards large-8/19/20/22/28/32/37/41/42 and small-4. - Local attribution runs (12 files each): `28d97119` green; `d4ff1834` and `f88a49de` show the 5 openclaw#204134 files red; `8d86eea4` adds the 7 openclaw#204155 files. - Head: the 12 files pass locally (one unrelated `cli-message-authority` timeout under host load 66 passed on the rerun). CI on the head is green. Local ClawSweeper: patch is correct, no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
…ime ratchet (R6z) (openclaw#204249) ## Problem AGENTS.md says to check authority once, when work starts. The admitted operator authority (`AdmittedRunOperatorAuthority`) still carried a mid-run re-check member, `assertCurrent`, plus `onModelPolicyChanged`, a mid-run model-policy revocation hook. About 60 production readers called `assertCurrent()` in the middle of started runs, requests and queued work, and the constructor latched any failure into the run's signal. A started run could still be refused after a permission, role or profile change. The lifetime-check ratchet (`scripts/check-lifetime-check-ratchet.mts`) only kept the count from growing; it is now at zero and protects nothing. ## Fix This is the last one-admission PR (R6z). - `AdmittedRunOperatorAuthority` loses `assertCurrent` and `onModelPolicyChanged`. `createAdmittedRunOperatorAuthority` no longer composes or latches a re-check: its `signal` is the source signal (Stop) only. `bindOperatorModelExecution` keeps release and Stop, and no longer re-runs the policy on change. - Every reader the compiler listed is deleted. Stop reads its own signal (`signal.throwIfAborted()`). Data fences keep reading their own data: owner, generation, writer lease, run occurrence, released/closed flags, request lifetime, commit guards, the cron delivery fence (`scheduledAutomation.deliveryAttemptFence`) and the cron control-edit compare (`retainCronControlSource`). - `SessionControllerSourceAdapter.authority.assertCurrent` becomes optional. Non-operator producers keep their fence there. An operator authority passed there carries only Stop. - The retired-cron-delivery fence moves off the operator authority. A queued follow-up checks `scheduledAutomation.deliveryAttemptFence` before claim, in the same place where the removed `operatorAuthority.assertCurrent()` was. The follow-up runner withholds a run on `CronDeliveryAuthorityError` itself: it records the run and does not replay it. Before, it learned this only from the authority's latched signal. - The ratchet script, its test and its `ci-baseline-ratchets` entry are deleted. - New lint rule `openclaw-boundaries/no-operator-permission-read` (in `config/oxlint/boundary-guards.json`, which the `lint:no-chained-type-assertions` boundary lane runs over `src`, `extensions` and `packages`). Only the files named in `scripts/lib/no-operator-permission-read.mjs` may reference the live permission readers `resolveOperatorRolePolicy`, `resolveOperatorRolePolicyForAssignment`, `resolveOperatorRolePolicyForProfile`, `resolveOperatorRoleSelection`, `authorizeCurrentOperatorRoleScopes`, `onOperatorRolePolicyChanged` and `captureResidentUserProfileAccess`. The allowlist is the owners and the work-start files that use them today (63 files). It only shrinks: new code takes scopes, role and policy from the admitted operator authority. The planted fixture `test/fixtures/oxlint-boundary-guards/operator-permission-recheck-violation.ts` (named import, namespace member, lazy import) fails the rule (4 reports). - Parked item from R6c4a: the worktree publication message reads "The GitHub publication worktree changed" instead of "...authority changed". The test fixture URL that had fake credentials is now `https://example.test/repo?...`. - The last three refusal strings in production code are gone: - `agent-run-user-turn.ts`: the requester-owner re-read from live config (`assertRequesterCurrent`, "Requester owner authority changed") is deleted, along with its admission-phase and execution-phase plumbing. The owner decision is made once, when the turn starts. The `subagent-spawn.production-boundary` expectation "removing the spawning owner after admission must stop that dispatch" is deleted with it. - `acp/runtime/session-meta-resume-authorization.ts`: this is a data fence (the source session's facts changed). It is reworded to "The ACP resume source session changed". - `cron-creator-authority-grant.ts`: the run-scoped grant ends with its run, scope, operation or management deadline. It is reworded to "This run's MCP cron access has ended". - `scripts/perf/*-measure.ts`: removed the `assertCurrent` counters and the source-authority revocation proof, which measured the deleted mid-run re-check. Production code: 86 files, +82 / −313. Scripts, config and lint test: +138 / −242. ### Decisions - Lint rule shape (Fable 5.2): an import/reference boundary on the live readers, with exact files listed. A rule that bans the name `assertCurrent` would be wrong, because ~150 data-owner authorities use that name. The refusal-string ban would only bring the deleted ratchet back as a wording check. Accepted risk: an allowed work-start file can still call a reader twice. Review owns that. - `src/cron/service.restart-delivery.test.ts` "automation=false" row deleted. Only the fixture put the delivery fence on the operator authority. In production the queued authority comes from `decideOperatorAdmission`, whose `assertCurrent` was always a no-op. The real carrier is `scheduledAutomation.deliveryAttemptFence`, and that case stays. - Accepted edge: a queued chat input's `requesterProfile.isCurrent` is now `true` for the life of the dispatch. Before, it turned false after the admitted source was released. It only selects the requester attribution prefix. - Accepted edge: if a completion cohort settles between the steering preparation and the queue commit, the human correction now reports `failed` with the policy-mismatch error. Before, it reported `rejected: tool_authority_mismatch`. The message is still refused visibly, and the race window is a few milliseconds. - Known follow-up, not done here: a cron creator grant can still be refused when consumed after its issuing device or channel owner is revoked during the run, because the grant's `isCurrent` producers still read the device and owner lifetime. Only the wording changed in this PR. Removing those producers is a separate cut in the cron grant plumbing. ## User impact A started run, request, queued start, tool call, model execution or scheduled job finishes after a permission, role, profile or model-policy change. The next request uses the new permissions. Stop still cancels. Data fences still refuse stale writes. ## Tests Deleted, because each asserts a refusal after a mid-run permission, role, profile or model-policy change (full list in the PR comment). Stop, run-close and data-fence tests keep their condition. Test fixtures no longer pass `assertCurrent` or `onModelPolicyChanged`. ## Evidence - `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean. - oxfmt and oxlint on all changed files: clean. `pnpm lint:no-chained-type-assertions` (all focused guards, including the new rule) over the tree: 0 errors. `test/scripts/oxlint-boundary-guards.test.ts`: the planted re-check fixture fails the rule. - Pre-push `ocx test`: all 215 touched test files and the importers of every `*.test-support.ts` file. The direct-importer set is over the 150-file cap. Then the failed files, plus importers of `followup-runner.ts` and `reply-agent-turn-preparation.ts`, and after the rebase on openclaw#204191 its 17 test files. Final reruns are green. - E2E `one-admission-e2e/run.sh`: see the comment. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
OpenClaw checks authority once, when work starts (AGENTS.md "Choose good compromises"). The last gateway, ACP, session and node-host files outside
src/agents/**still re-read a role, scope, profile version, access revision, config or command policy during a request. A started request was then refused with "authority changed" or "authority is no longer active/current". Other checks in the same files are valid Stop, disconnect or data fences, but their text claimed authority.Change
R6d part 4. Each string site was classified with one test: can it fire when only a permission, approval or config changes while nothing about the run or the data changes?
factory-github-proof.tsthe role/scope check sat inside a repeated closure whose first call was the admission; it is now a one-time check before the closure.channel-avatar-http.tsmanaged-image-session-read.tsserver-node-event-source.tshuman-mention-policy.tsrecipient selectionhuman-mention-policy.tsinvolvementassertCurrentmention-inbox.tscommitnode-claude-skill-runtime.tsnode-agent-cli-runtime.ts); fences kept, rewordednode-mcp-elicitation.tscron-stream-sandbox-authority.tsdesktop/observe-bridge.tsfactory-github-proof.tsrepository-dispatch.tsrepository-integration-identity.tshttp-auth-user-profile.ts(2)openai-compatible-agent-run.ts!admittedonly)session-sharing-read.tsskill-library-session.tsSkillLibraryAuthority)talk/client-run-authority.ts(2)hasCurrentClientAuthorityfallbackremote-control-ui-ingress.tsinternaland never rebinds (remote-control-ui-ingress.integration"shares real principal authority…" red).ws-connection/authenticated-request-dispatch.tspublication transportws-connection/authenticated-request-dispatch.tsexpected profilehasCurrentClientAuthority)ws-connection/connect-publication-transport.ts(2)server/ws-origin-policy.tsconfig/sessions/session-accessor.sqlite-reclamation-commit.tsnode-host/openclaw-id-connection.tsDeleted tests (they asserted a mid-request permission refusal):
server.sessions.create.repository-required.test.ts: thecallerrow (client scopes cleared after ACK, run expected to be refused).mention-inbox.test.ts: "refuses a pending mention write after the recipient loses access".server-plugins.session-facts.test.ts: therole,profileandsame-object configrows of "retains admitted grants but fences selected disclosure data". They expect a started disclosure to be refused after that change; refactor: drop mid-request authority re-checks in gateway operator/plugin/MCP App paths, skill library, reclaim and channel reads (R6d part 3) #204134 removed that re-check, and the rows are red on main8ea0f17162ab(3 failed locally). Thegrantrow stays: a started disclosure finishes and the next one is refused.Stop and data-fence tests keep their conditions. Only their expected text changed.
config/session-identity-allowlist.txtis pruned.Accepted edge cases:
Not in this PR
src/gateway/cron-creator-authority-grant.ts,src/acp/runtime/session-meta-resume-authorization.tsandsrc/gateway/agent-turn/agent-run-user-turn.ts(assertRequesterCurrent, the requester-owner re-read from live config through the run): tests undersrc/agents/**pin them, and a parallel PR owns that tree.subagent-spawn.production-boundary.test.tsline 457 expects the child dispatch to stop aftercommands.ownerAllowFromis cleared. Delete that expectation first, then the check and its admission/execution-phase plumbing.src/agents/worktrees/errors.tsstays parked for R6z.AdmittedRunOperatorAuthority.assertCurrentoutsidesrc/agents/**andsrc/auto-reply/**(41 production files, listed by LSP references):gateway/operator-role-policy.ts,sessions/session-controller.tool-authority.ts,gateway/operator-run-authority.ts,gateway/operator-admission.ts,security/dangerous-tools.ts,gateway/expected-profile.ts,gateway/session-sharing-policy.ts,gateway/session-sharing-read.ts,gateway/server-plugin-in-process-authority.ts,plugins/runtime/runtime-llm-isolated.ts,gateway/operator-invocation-authority.ts,plugins/runtime/runtime-llm-operator-authority.ts,gateway/github-publication-requester.ts,gateway/session-sharing-authorization-async.ts,gateway/session-create-existing-selection.ts,gateway/session-permission-authorization.ts,gateway/session-create-model-selection.ts,gateway/operator-session-run.ts,gateway/session-access-authority.ts,gateway/agent-turn/agent-run-user-turn.ts,gateway/agent-turn/agent-run-admission-phase.ts,gateway/agent-turn/agent-run-execution-phase.ts,gateway/cron-operator-source.ts,gateway/github-publication-actions.ts,gateway/session-companion-rpc.ts,talk/agent-run-control.ts,gateway/talk/client-run-authority.ts,gateway/question-session-access.ts,plugins/requester-models.ts,gateway/server-plugin-in-process-dispatch.ts,gateway/session-companion-ask.ts,gateway/session-activity-summary-authority.ts,gateway/cron-command-source.ts,gateway/plugin-command-scheduled-run.ts,cron/session-run.ts,gateway/cron-stream-sandbox-authority.ts,plugins/service-session-work.ts,gateway/openai-compatible-agent-run.ts,gateway/queued-chat-inputs.ts,gateway/session-restart-resume.ts,gateway/server-instance-runtime.ts.server-methods/**has its own readers. Admission sites (operator-admission.ts,operator-run-authority.tsconstructors) stay.current(), desktop observerisCurrent, publication transport token check, OpenClaw ID owner principal, skill-library owner device) mix policy with lifecycle inside their producers. Splitting them needs the producer change in R6z.User impact
A started request, mention write, repository operation, Talk run or ingress binding is no longer refused because a role, scope, profile, access revision or config changed. The change applies to the next request. Stop, disconnect, session changes and transport identity changes still end work, and the messages now say what ended and what to do next.
Evidence
pnpm tsgo:core,pnpm tsgo:test: pass. oxfmt and oxlint on changed files: clean. Lifetime-check ratchet: 0 counted strings in changed production files, no per-file growth.main: 23 files, +75/−107.ocx test(continue-on-failure) on 140 files: every touched test file, every test file importing a changed source, and every importer of the 12 test-support files that import one. Ours fixed: Talk parity expected-text regex, the remote-ingress cut-less above, and the stale session-facts rows. Base comparison on8ea0f17162ab:server.operator-role-scope-matrix,server.sessions-send-resumeandserver.agent.gateway-server-agent-atimed out at host load ~90 and pass on head and base at lower load (one head scope-matrix case failed on a transientnode_modulesmodule-not-found, file present after). Final reruns of every red or invalidated file: green.29148535213c): OURS =project-github-identity.factoryexpected text (fixed) andlocal-request-context.session-tools(passes after the requester-owner revert). Local review round 1 foundsubagent-spawn.production-boundary.test.tspins the requester-owner mid-run check undersrc/agents/**: cut less,agent-run-user-turn.tsand its two phase files restored tomain.29148535213c) 1 real finding (fixed above); round 2 (5dd4558144b8) "patch is correct", no findings.5dd4558144b8: verdict pass. R.running-turn-finishes, Q.queued-input-refused-visibly and S.stop-cancels all pass (verdict.json,results.jsonlkept in the proof directory).5dd4558144b8): OURS =server.sessions.create.repository-requiredcallerrow (deleted, test-only push4ba022722a64); not ours:server.talk-consult-history(server.talk-consult-history 'isolates registered Talk replay' red on main after #203468 #203507),local-request-context.session-tools(red on main run 45238720546). The E2E on5dd4558144b8covers4ba022722a64: production is identical.4ba022722a64): OURS =server.talk-permission-parity.test-support.tsregex still matching the old Talk wording (fixed, test-only push711ba27c5b6f); not ours:local-request-context.session-tools(main runs 45238720546 and 45248844963). Local review clean on711ba27c5b6f. Production is unchanged since5dd4558144b8, where the E2E passed.