Skip to content

refactor(agents): drop mid-run operator authority re-reads (R6c part 4c) - #204155

Merged
obviyus merged 3 commits into
mainfrom
refactor/agents-assert-current-2
Nov 23, 2026
Merged

obviyus merged 3 commits into
mainfrom
refactor/agents-assert-current-2

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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.

obviyus and others added 2 commits November 23, 2026 20:56
…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]>
@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S labels Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 2c91febf7a9d3fd974ae441b3796a653cdc58c6b
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/cli-runner/tool-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/harness/host-source-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

E2E one-admission-e2e/run.sh on head a4e7e1794e71 (scratch Gateway, real agent turn): pass.

  • Q queued input refused visibly: pass (0 provider requests with the queued marker; refusal in transcript)
  • R running turn finishes after revoke: pass
  • S Stop cancels: pass (state aborted)

verdict.json:

{
  "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
}

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This 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.

  • Before: A later fallback or personal-tool operation can reject the already admitted work.
  • After: The admitted work can finish; subsequent requests use current permissions, and Stop still cancels.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused production simplification with relevant Gateway proof, but the consumer-test cutover is incomplete and compiler failures remain unattributed.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The author supplied output from an isolated Gateway and real agent turn on the reviewed head demonstrating admitted completion after revocation, visible refusal of queued input before provider work, and explicit Stop cancellation.
Patch quality 🦐 gold shrimp (3/6) 3 actionable review findings remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Permission changes can interrupt work that the Gateway already admitted.
Reason: The maintainer-authored direction matches root policy and earlier merged simplification work.

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
Reviewed head: a4e7e1794e713905d342d91dbc62eac3afd1cdfe

Before merge

  • Remove the obsolete fallback revocation expectation (P2) - The author needs to remove this mid-run revocation case and its unused setup while retaining the denied-model cases. It retires the source during prepareCandidateChain and expects rejection through assertions this PR deliberately removes; current-head CI instead completes the fallback and fails at line 84.
  • Remove the PDF matrix's obsolete retirement case (P2) - The author needs to remove the retired-after-extraction row and its retirement-only setup while preserving denied overrides, permitted fallback, and cancellation coverage. This case changes source authority after the PDF invocation starts and still expects rejection; current-head CI correctly receives the allowed PDF answer, leaving the suite red.
  • Pass the explicit cancellation signal to the compaction fixture (P2) - The author needs to supply source.signal on this operator-authority fixture if the case is intended to preserve explicit cancellation coverage. The controller currently reaches execution only through assertCurrent, whose invocation this PR removes; aborting it therefore leaves compaction successful and fails current-head CI at line 273. Keep the model-ceiling and host-close assertions.

Findings

  • [P2] Remove the obsolete fallback revocation expectation — src/agents/model-fallback.operator-model-policy.test.ts:84-85
  • [P2] Remove the PDF matrix's obsolete retirement case — src/agents/tools/pdf-tool.test.ts:528
  • [P2] Pass the explicit cancellation signal to the compaction fixture — src/agents/harness/compaction.cancel.test.ts:229-231
Agent review details

How this fits together

Gateway 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
Loading

Technical review

Best 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:

  • [P2] Remove the obsolete fallback revocation expectation — src/agents/model-fallback.operator-model-policy.test.ts:84-85
    The author needs to remove this mid-run revocation case and its unused setup while retaining the denied-model cases. It retires the source during prepareCandidateChain and expects rejection through assertions this PR deliberately removes; current-head CI instead completes the fallback and fails at line 84.
    Confidence: 1
  • [P2] Remove the PDF matrix's obsolete retirement case — src/agents/tools/pdf-tool.test.ts:528
    The author needs to remove the retired-after-extraction row and its retirement-only setup while preserving denied overrides, permitted fallback, and cancellation coverage. This case changes source authority after the PDF invocation starts and still expects rejection; current-head CI correctly receives the allowed PDF answer, leaving the suite red.
    Confidence: 1
  • [P2] Pass the explicit cancellation signal to the compaction fixture — src/agents/harness/compaction.cancel.test.ts:229-231
    The author needs to supply source.signal on this operator-authority fixture if the case is intended to preserve explicit cancellation coverage. The controller currently reaches execution only through assertCurrent, whose invocation this PR removes; aborting it therefore leaves compaction successful and fails current-head CI at line 273. Keep the model-ceiling and host-close assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e5dcfa009663.

Provenance checked

  • Retained operator authority changes intended behavior with a stated reason (715077a: Preserve the initiating operator and permission ceiling across queued and delegated work, originally including current-authority checks.)
  • Model fallback and native model policy changes intended behavior with a stated reason (6b4ebc0: Apply role model ceilings throughout model selection and fallback, originally including mid-run revocation.)
  • Retained native harness sources changes intended behavior with a stated reason (17d2faf: Keep original and current operator policy attached to native delegation and retained model execution.)
  • Exec source lifetime changes intended behavior with a stated reason (08f5fb8: Retain a command's original source through process finalization and cancel its exact managed work on revocation.)
  • Scheduled operator-source capture changes intended behavior with a stated reason (961f5c0: Carry authenticated operator facts through restart recovery instead of granting privileged System authority.)
  • Personal turn participants changes intended behavior with a stated reason (bf3a182: Support steering between people with equivalent permissions while preserving each participant's personal authority.)
  • Requester-bound plugin delegation changes intended behavior with a stated reason (46d7d89: Reuse finalized native tools and collector ownership while retaining requester identity, model policy, and sandbox restrictions.)
  • Plugin model execution changes intended behavior with a stated reason (24ed521: Allow restricted host reviewer execution through the existing caller authority and model-policy owner.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/model-fallback.operator-model-policy.test.ts --maxWorkers=1
  • pnpm test src/agents/tools/pdf-tool.test.ts --maxWorkers=1
  • pnpm test src/agents/harness/compaction.cancel.test.ts --maxWorkers=1
  • pnpm tsgo:core:test
  • git diff --check

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit d979dba adds src/agents/admitted-run-context.ts:68 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d979dba02457; files: src/agents/admitted-run-context.ts)
  • Peter Steinberger: Raw commit 5d3d341 adds src/agents/admitted-run-context.ts:71 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5d3d341eda21; files: src/agents/admitted-run-context.ts)
  • Shakker: Raw commit 715077a adds src/agents/admitted-run-context.ts:53 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 715077a3befb; files: src/agents/admitted-run-context.ts)

PR surface

Source -47, Tests -48. Total -95 across 21 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 14 16 63 -47
Tests 7 16 64 -48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 32 127 -95

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: This is a bounded improvement to admitted-run behavior with concrete consumer-test repairs, without evidence of an urgent production outage.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a bounded improvement to admitted-run behavior with concrete consumer-test repairs, without evidence of an urgent production outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

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]>
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Round 2 (2c91febf7a9d) changes tests only: production code is the same as on a4e7e1794e71, where the E2E above passed Q/R/S. Round-1 OURS reds fixed: test fixture types (assertCurrent is still required on the type until R6z), plus the mid-run retirement cases in model-fallback.operator-model-policy and pdf-tool (deleted) and compaction.cancel (Stop now goes through the source signal).

@THE-NAVVV THE-NAVVV left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

​

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the three remaining reds on head 2c91febf7a9d also fail on main. Each failed again on one CI rerun. The same files were green on the round-1 head a4e7e1794e71, whose production code is the same. Round 2 changed tests only. The difference is the newer CI merge base ab24e714bdc2, which includes #204111 (compact from the warm prompt cache).

ci-triage:

# PR #204155 head 2c91febf7a9d; main run 45216550182
checks-node-changed-2	test/gateway-restart-resume.e2e.test.ts	OURS
checks-node-changed-compact-large-21	src/agents/embedded-agent-runner.prompt-cache.test.ts	OURS
checks-node-changed-compact-large-24	src/auto-reply/reply/agent-runner-required-maintenance.pending-input.test.ts	OURS

The same failures, reproduced locally with no part of this PR:

  • embedded-agent-runner.prompt-cache (×4: expected 16 to be 15) and agent-runner-required-maintenance.pending-input "two archives" (expected +0 to be 1) fail on origin/main 9a39176f4d7e. Both pass on this PR's own commit.
  • test/gateway-restart-resume.e2e "restart markers survive graceful shutdown (blocked store: false)" fails on the exact merge base ab24e714bdc2.

None of these tests sets an operator authority. This PR only removes operatorAuthority.assertCurrent reads.

@obviyus
obviyus merged commit 515a93c into main Nov 23, 2026
213 of 223 checks passed
@obviyus
obviyus deleted the refactor/agents-assert-current-2 branch November 23, 2026 18:20
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 515a93c. This removes the last operatorAuthority.assertCurrent re-reads in agents and in the session participants. A started run, exec, fallback chain, compaction or spawn now finishes after a permission change. Stop, run close and data fences are kept. Proof: E2E Q/R/S pass, local review clean (2 rounds), and the remaining reds are MAIN-ALSO (override comment above).

Patrick-Erichsen added a commit that referenced this pull request Nov 23, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 23, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants