Repository navigation
refactor(agents): drop mid-run operator authority re-reads (R6c part 4c) - #204155
Conversation
…allbacks, compaction and spawn Start-time admission already decided. Stop, run close and data fences keep their own signals and flags (exec reads the operator signal directly). Co-authored-by: obviyus <[email protected]>
…un-close refusals Deleted: image fallback 'requester retires', CLI question 'source revoked', retained harness source 'source assertion', participant 'access changed'. Kept: Stop signal and lifecycle refusals (now triggered directly), turn close, run close (text only), next spawn start refusal (text only). 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. |
|
|
E2E
{
"pass": true,
"prefix": "HEAD",
"sessionKey": "agent:main:one-admission-d0c6f273",
"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": [
"b705619a-a086-487e-8498-54bed09a5caa"
]
},
"state": "aborted",
"requestsWithStopMarker": 1
}
}
],
"elapsedMs": 67415
} |
|
Codex review: needs changes before merge. What this changesThis PR removes repeated operator-authority checks during admitted agent work while preserving model restrictions, Stop signals, and lifecycle fences. Example: An operator's role changes while an agent turn is running.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep open: this maintainer-authored PR follows the approved admission policy, but three consumer tests still depend on the removed checks and fail on the reviewed head. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherGateway admission supplies host-issued operator authority to agent execution, which carries its restrictions through tools, fallback models, compaction, and child launches. flowchart TD
A[Incoming request] --> B[Gateway admission]
B --> C[Admitted run context]
C --> D[Tools and model fallbacks]
C --> E[Compaction and child launches]
F[Stop and lifecycle signals] --> D
F --> E
Technical reviewBest possible solution: Keep the focused production deletions and complete the consumer-test cutover without restoring mid-run permission checks. Do we have a high-confidence way to reproduce the issue? Current main retains authority assertions inside fallback and other admitted-work paths; source establishes the mismatch with the request-start policy, without local execution. Is this the best way to solve the issue? The deletions use existing admission and cancellation owners and introduce no parallel authority mechanism; the incomplete test cutover is the concrete repair needed. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e5dcfa009663. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -47, Tests -48. Total -95 across 21 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, 12:03 PM ET / 17:03 UTC. |
… cases - Restored the required `assertCurrent` on test operator fixtures. - Deleted model-fallback 'rechecks retained authority' and pdf 'retired after extraction'. - compaction.cancel source revocation now stops through the source signal. Co-authored-by: obviyus <[email protected]>
|
Round 2 ( |
|
Maintainer override: the three remaining reds on head ci-triage: The same failures, reproduced locally with no part of this PR:
None of these tests sets an operator authority. This PR only removes |
|
Landed as 515a93c. This removes the last |
…uting * test(gateway): drop the stale mid-turn revocation step from screen routing #204155 removed the mid-run authority re-read from reply-turn participants, so a started turn keeps routing screen requests after its owner's access changes. The screen-routing cases still expected the removed "access changed" refusal and fail on main. Remove that step; the cases keep asserting the turn-closed refusal after completion. * test(gateway): drop the stale mid-turn revocation step from screen routing OpenClaw-Publication: 41e1f4f7-8791-83f0-8c23-8784ac1977c5 --------- Co-authored-by: Patrick-Erichsen <[email protected]>
…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]>
…4c) (openclaw#204155) ## Problem Agent runs still re-read the admitted operator authority (`operatorAuthority.assertCurrent()`) in the middle of the work: before each model fallback candidate, at exec spawn, before each step of a queued compaction, at queued collector launches, at question binding, and when one participant of a steered turn reads or writes personal data. AGENTS.md says to check authority once, when work starts. These re-reads can refuse a started run after only a permission, approval or config change. ## Fix This removes the last `operatorAuthority.assertCurrent` readers in `src/agents/**` and `src/sessions/session-controller.tool-authority.ts` (R6c part 4c). Start-time admission does not change. Stop, run close and data fences keep working through their own signals or flags. | Site | Kind | Action | |---|---|---| | `admitted-run-context.ts` `readCurrentRoleFacts` wrapper | authority re-check | deleted; the role facts the producer captured are returned as they are | | `admitted-run-context.ts` `createOperatorModelSelectionAssertion` source composition | authority re-check | deleted; the admitted model-policy check stays | | `admitted-run-context.ts` `assertOperatorAccessProgramAllowed` | authority re-check | deleted; the admitted access-program check stays | | `admitted-run-context.ts` `getAdmittedRunOperatorProfileId` | authority re-check | deleted; the active-lease check stays (run close) | | `admitted-run-context.ts` `readOperatorAuthority` | authority re-check | deleted; the `closed` refusal stays (run close) | | `bash-tools.exec-runtime.ts` spawn `assertCurrent` + pre-retain read | authority re-check (Stop rode on it) | deleted; Stop now reads `operatorSignal.throwIfAborted()` directly | | `model-fallback-runner.ts` start + per-candidate (×2) | authority re-check | deleted; the admitted `modelPolicy.allows` filter stays; Stop is `abortSignal` | | `model-fallback-image.ts` start + attempt error | authority re-check | deleted; `abortSignal` stays | | `operator-run-recovery-source.ts` `captureScheduledOperatorSource` | authority re-check of the creating request | deleted; each scheduled run is still admitted at its own start (`restoreScheduledAutomationOperator`) | | `plugin-tool-execution.ts` plugin model execution | authority re-check | deleted; `callerSignal` already includes `authority.signal` (Stop) | | `plugin-native-subagent.ts` request runtime | authority re-check | deleted; guard, source, abort signal and Gateway binding stay | | `harness/host-source-authority.ts` `retainHarnessSource` native branch | authority re-check | deleted; `assertRetained` keeps the source signal (Stop) and the lifecycle generation | | `harness/host-source-authority.ts` `assertCompactionSource` | authority re-check | deleted; `assertActive` (session data) and the host-issued check stay | | `harness/selection.ts` `assertHarnessModelPolicySupport` | authority re-check | deleted | | `cli-runner/tool-authority.ts` question bind + `assertActive` | authority re-check | deleted; turn end, source and abort signal stay | | `embedded-agent-runner/compact.queued.ts` host `assertActive` composition | authority re-check after each await | deleted; the operator signal stays in `abortSignal` (Stop). The queued compaction starts inside a request that was admitted when it started | | `subagents/spawn/subagent-spawn.ts` collect retain | authority re-check | deleted; `retain` stays | | `subagents/spawn/subagent-spawn-collector.ts` queued launch | authority re-check | deleted; the registration-ownership fence stays; the queue item still cancels on `operatorAuthority.signal`; the child run is admitted by the Gateway `agent` start | | `sessions/session-controller.tool-authority.ts` participant `assertCurrent` | authority re-check | deleted; the turn-closed check and the retain failure at acceptance stay | No ratchet strings were in these files, so no counts change. The `AdmittedRunOperatorAuthority.assertCurrent` type field and its producers stay for R6z. ## User impact A started agent run, exec, fallback chain, compaction or steered-turn personal tool call finishes after a permission or role change. The next request uses the new permissions. Stop still cancels. ## Tests Deleted, because each asserts a mid-run permission refusal: - `model-fallback-image.operator-model-policy`: "stops the chain when the original requester retires". - `cli-runner/tool-authority`: the "refuses it after its source is revoked" half (the profile carry stays). - `harness/host-capability.source-lifetime`: the "source assertion" case. The Stop-signal and lifecycle cases stay. They now abort or rotate directly instead of inside the removed source read. - `session-controller.message-join`: the "access changed" step. It now asserts the kept turn-closed refusal. - `model-fallback.operator-model-policy`: "rechecks retained authority after asynchronous preparation before starting a model". - `tools/pdf-tool`: the "retired after extraction" case (the denied-override and permitted-fallback cases stay). - `harness/compaction.cancel` "source revocation" case: Stop now reaches the model binding through the source's `signal` (the kept path) instead of its `assertCurrent`. The refusal and its text stay the same. Text only, condition kept: - `gateway/openai-compatible-agent-run`, `gateway/tools-invoke-http.abort`: after run close the source still refuses, now with the producer's "Operator execution ended" run-close text. Two expectation lines outside `src/agents` changed because this PR changed what they observe. - `subagent-spawn.participants.test-support`: a new spawn for a revoked participant is still refused at its start, and nothing is written. The refusal now comes from the spawn's own start check. ## Evidence - Pre-push `ocx test`: 95 targeted files (operator-authority importers of the changed files, over the 150-file importer cap, plus nearby tests). Every red was fixed and rerun. Rerun result: all green except `subagent-spawn.production-boundary`. On the rerun that file cascaded from 120 s timeouts at host load 95. It passed 138/139 in the first run on the same production code, and its 1 red was the participant text fixed above. - `pnpm tsgo:core`, `pnpm tsgo:test`, oxfmt and oxlint on the changed files: clean. - E2E `one-admission-e2e/run.sh` on the head: see the comment. Co-authored-by: Ayaan Zaidi <[email protected]>
…uting * test(gateway): drop the stale mid-turn revocation step from screen routing openclaw#204155 removed the mid-run authority re-read from reply-turn participants, so a started turn keeps routing screen requests after its owner's access changes. The screen-routing cases still expected the removed "access changed" refusal and fail on main. Remove that step; the cases keep asserting the turn-closed refusal after completion. * test(gateway): drop the stale mid-turn revocation step from screen routing OpenClaw-Publication: 41e1f4f7-8791-83f0-8c23-8784ac1977c5 --------- Co-authored-by: Patrick-Erichsen <[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]>
Problem
Agent runs still re-read the admitted operator authority (
operatorAuthority.assertCurrent()) in the middle of the work: before each model fallback candidate, at exec spawn, before each step of a queued compaction, at queued collector launches, at question binding, and when one participant of a steered turn reads or writes personal data. AGENTS.md says to check authority once, when work starts. These re-reads can refuse a started run after only a permission, approval or config change.Fix
This removes the last
operatorAuthority.assertCurrentreaders insrc/agents/**andsrc/sessions/session-controller.tool-authority.ts(R6c part 4c). Start-time admission does not change. Stop, run close and data fences keep working through their own signals or flags.admitted-run-context.tsreadCurrentRoleFactswrapperadmitted-run-context.tscreateOperatorModelSelectionAssertionsource compositionadmitted-run-context.tsassertOperatorAccessProgramAllowedadmitted-run-context.tsgetAdmittedRunOperatorProfileIdadmitted-run-context.tsreadOperatorAuthorityclosedrefusal stays (run close)bash-tools.exec-runtime.tsspawnassertCurrent+ pre-retain readoperatorSignal.throwIfAborted()directlymodel-fallback-runner.tsstart + per-candidate (×2)modelPolicy.allowsfilter stays; Stop isabortSignalmodel-fallback-image.tsstart + attempt errorabortSignalstaysoperator-run-recovery-source.tscaptureScheduledOperatorSourcerestoreScheduledAutomationOperator)plugin-tool-execution.tsplugin model executioncallerSignalalready includesauthority.signal(Stop)plugin-native-subagent.tsrequest runtimeharness/host-source-authority.tsretainHarnessSourcenative branchassertRetainedkeeps the source signal (Stop) and the lifecycle generationharness/host-source-authority.tsassertCompactionSourceassertActive(session data) and the host-issued check stayharness/selection.tsassertHarnessModelPolicySupportcli-runner/tool-authority.tsquestion bind +assertActiveembedded-agent-runner/compact.queued.tshostassertActivecompositionabortSignal(Stop). The queued compaction starts inside a request that was admitted when it startedsubagents/spawn/subagent-spawn.tscollect retainretainstayssubagents/spawn/subagent-spawn-collector.tsqueued launchoperatorAuthority.signal; the child run is admitted by the Gatewayagentstartsessions/session-controller.tool-authority.tsparticipantassertCurrentNo ratchet strings were in these files, so no counts change. The
AdmittedRunOperatorAuthority.assertCurrenttype field and its producers stay for R6z.User impact
A started agent run, exec, fallback chain, compaction or steered-turn personal tool call finishes after a permission or role change. The next request uses the new permissions. Stop still cancels.
Tests
Deleted, because each asserts a mid-run permission refusal:
model-fallback-image.operator-model-policy: "stops the chain when the original requester retires".cli-runner/tool-authority: the "refuses it after its source is revoked" half (the profile carry stays).harness/host-capability.source-lifetime: the "source assertion" case. The Stop-signal and lifecycle cases stay. They now abort or rotate directly instead of inside the removed source read.session-controller.message-join: the "access changed" step. It now asserts the kept turn-closed refusal.model-fallback.operator-model-policy: "rechecks retained authority after asynchronous preparation before starting a model".tools/pdf-tool: the "retired after extraction" case (the denied-override and permitted-fallback cases stay).harness/compaction.cancel"source revocation" case: Stop now reaches the model binding through the source'ssignal(the kept path) instead of itsassertCurrent. The refusal and its text stay the same.Text only, condition kept:
gateway/openai-compatible-agent-run,gateway/tools-invoke-http.abort: after run close the source still refuses, now with the producer's "Operator execution ended" run-close text. Two expectation lines outsidesrc/agentschanged because this PR changed what they observe.subagent-spawn.participants.test-support: a new spawn for a revoked participant is still refused at its start, and nothing is written. The refusal now comes from the spawn's own start check.Evidence
ocx test: 95 targeted files (operator-authority importers of the changed files, over the 150-file importer cap, plus nearby tests). Every red was fixed and rerun. Rerun result: all green exceptsubagent-spawn.production-boundary. On the rerun that file cascaded from 120 s timeouts at host load 95. It passed 138/139 in the first run on the same production code, and its 1 red was the participant text fixed above.pnpm tsgo:core,pnpm tsgo:test, oxfmt and oxlint on the changed files: clean.one-admission-e2e/run.shon the head: see the comment.