Skip to content

refactor: drop mid-request authority re-checks in gateway operator/plugin/MCP App paths, skill library, reclaim and channel reads (R6d part 3) - #204134

Merged
obviyus merged 2 commits into
mainfrom
refactor/rest-refusals-part3
Nov 23, 2026
Merged

obviyus merged 2 commits into
mainfrom
refactor/rest-refusals-part3

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

OpenClaw checks authority once, when work starts (AGENTS.md "Choose good compromises"). Gateway operator, approval, plugin and MCP App paths, the skill library, worker reclaim and channel message reads still re-read a permission, role, scope, trust or config mid-request and refused started work with "authority changed" / "authority is no longer active/current". Other checks in the same files are valid Stop, run-close or data fences whose text claimed authority.

Change

R6d part 3, first half (split rule). Each check was classified with one test: can it fire when only a permission, approval or config changes while nothing about the run or data changes?

  • Yes → deleted, with its plumbing.
  • No (Stop, run close, disconnect, data fence) → kept, reworded to say what ended and the next step.
  • Start-time checks (admission, made before work begins) stay.
Site Old message Kind Action
skills/library/store-access.ts assertCurrent Skill library authority changed mixed: config roles, role subject and scopes re-read + authority.assertCurrent() (run close, claim loss, disconnect) role/scope/config compares deleted; Stop (authority.assertCurrent) and the database admission fence kept
skills/library/store-access.ts read Profile authority changed during library access / Skill library profile authority changed profile-row change (includes role) after admission refusals deleted; a profile change now only keeps the reply out of the read cache (no stale cached role)
server-worker-placement-reclaim.ts grant callback refusal (assertWorkerGrant) grant re-check during reclaim preparation deleted; lifetime + target-generation fences kept
worker-environments/placement-dispatch.ts reclaimOnce Gateway recovery disabled by required worker profile config re-read inside the repeated source check checked once at entry; reclaimSource/preparation get the existing assertWorkerLifetime branch
channels/plugins/message-action-dispatch.ts Plugin X read/alias authority is no longer active registration lifetime + trustedOfficialInstall downgrade trust term moved to capture time in plugins/registry-registrars-network.ts (admission); registration fence kept: "…was reloaded during the read. Retry the action."
shared/channel-read-authority.ts Channel read authority is no longer active. Stop (closed read scope) reworded: "Channel read ended. Retry the action."
agent-runtime-identity-token.ts agent runtime approval authority is no longer active run/claim fence reworded
device-revocation.ts Gateway caller authority is no longer active. mixed permission callback re-check deleted; closed-owner / released-lifetime fences kept
exec-approval-authority.ts + exec-approval-manager.ts approval resolver authority is no longer active mixed repeated caller assertion and its plumbing deleted; store/binding fences kept, reworded
exec-approval-resolution-authority.ts approval standing grant authority is no longer active Stop (run abort) + tool-owner data reworded
operator-approval-session-events.ts Operator approval replay authority is no longer current mixed reviewer-permission and scope re-reads deleted; runtime, connection and device fences kept, reworded
operator-invocation-authority.ts Gateway caller authority is no longer active. mixed caller-permission re-checks deleted; signals and context identity kept
operator-role-policy.ts OpenClaw ID membership authority changed authority membership re-reads for admitted runs deleted; admission checks kept, reworded
operator-run-authority.ts prepareGatewayOperatorRunAuthority Gateway caller authority is no longer active. admission (before the run starts) kept: "Gateway request could not start. Reconnect and try again."
question-manager.ts the question's resolution authority is no longer active Stop / question lifecycle reworded
openclaw-id/node-pairing.ts OpenClaw ID node authority changed mixed membership check moved to admission; connect-policy callback kept (opaque, mixes lifecycle), reworded
openclaw-id/tunnel-principal.ts OpenClaw ID membership authority changed admission / recovery reworded
server-plugin-github-account.ts, server-plugin-user-profile.ts, server-plugin-session-facts.ts (callerAuthorityError) … caller authority is no longer active request lifetime reworded (helper has callers outside this PR)
server-plugin-session-facts.ts assertAuthority Session read authority changed; retry the request mixed caller/config/policy/access/profile re-checks deleted; projection replacement fence kept, reworded
server-plugin-in-process-session-read.ts Session read authority changed before inference. mixed repeated visibility authorization deleted; projection/session/store/generation fences kept, reworded
server-plugin-in-process-authority.ts Gateway continuation authority is no longer active Stop (release, cancellation, Gateway lifetime) reworded
server-plugins-node-runtime.ts Plugin Gateway runtime authority is no longer current. mixed plugin permission/config reader deleted; lifecycle signal, binding and run/claim checks kept, reworded
mcp-app-form-resources.ts Form upload workspace authority changed; MCP App runtime is unavailable data fence; config (apps disabled) mid-operation workspace/session fence reworded; mid-operation enabled/upload-policy re-checks deleted (upload admission kept)
mcp-app-host-files.ts App file workspace authority changed; 3 subscription "authority changed" closes mixed permission/config/grant re-checks and revocation-retention plumbing deleted; connection, requester, view, session, workspace fences kept, reworded
mcp-app-tool-approval.ts MCP App tool approval authority changed authority (post-consumption re-check) deleted; admission, decision and allow-once consumption kept

Deleted tests (they asserted a mid-request permission refusal): skill library role change after preparation (skill-library-authoring, selection-authority), reclaim "caller changes at transaction/commit completion admission", message-action registry trust-downgrade row, form upload "upload policy"/"apps disabled", host-file synchronous grant revocation, fork "session visibility", linked-owner membership revocation for an admitted run, replay waiting-client scope revocation and revoked-requester variant, device-retention permission revocation. Stop and data-fence tests keep their conditions; only their expected text changed. The 21 channel read assertions that matched the generic "no longer active" text were first split so each matches its own producer.

Lifetime-check ratchet: 0 counted strings in every touched production file. config/session-identity-allowlist.txt pruned.

Accepted edge cases:

  • A started skill-library read or prepared selection keeps its result if the profile role changes; the next request admits the new role. The worker-side publication check is unchanged.
  • A started reclaim finishes even if the caller's grant is revoked; Stop and session lifetime still end it.
  • A channel read that started keeps going if the plugin install trust drops; the next read is admitted with the new trust.

Not in this PR (part 4)

  • Remaining src/gateway/** string files: agent-turn/agent-run-user-turn.ts, channel-avatar-http.ts, cron-creator-authority-grant.ts, cron-stream-sandbox-authority.ts, desktop/observe-bridge.ts, factory-github-proof.ts, http-auth-user-profile.ts, human-mention-policy.ts, managed-image-session-read.ts, mention-inbox.ts, node-claude-skill-runtime.ts, node-mcp-elicitation.ts, openai-compatible-agent-run.ts, remote-control-ui-ingress.ts, repository-dispatch.ts, repository-integration-identity.ts, server-node-event-source.ts, server/ws-connection/authenticated-request-dispatch.ts, server/ws-connection/connect-publication-transport.ts, server/ws-origin-policy.ts, session-sharing-read.ts, skill-library-session.ts, talk/client-run-authority.ts.
  • Reclaim: sessions.reclaim passes the unsplit SessionMutationAuthorization.assertCurrent (grant + session lifetime) and Move's composed callback reads config policy + signal. Removing the grant there needs the producer to expose its lifetime part (R6z type change).
  • Approval replay visibility (canAccessInvitedApprovalSession) mixes session-sharing data with role/scope reads; node-pairing's connect-policy callback mixes lifecycle and policy. Both kept.

User impact

A started read, reclaim, approval replay, plugin or MCP App request is no longer refused because a role, scope, trust or config changed mid-request; the change applies to the next request. Stop, disconnect, plugin reload and data changes still end work, with messages that 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; session-identity ratchet OK after prune (6257 → 6239 pins).
  • ocx test (continue-on-failure) on 204 files: every touched test file, every test importing a changed source or test-support file except the 3 widest modules (operator-role-policy, operator-run-authority, tunnel-principal: 200 importers; CI runs them), plus every test pinning a changed message. OURS reds fixed and rerun. Remaining local reds are not ours: mcp-http.async-scope, agent.test (2), question.communication, question.recovery (base-red, see earlier R6 PRs), server.sessions.create.lifecycle requester row + server.sessions.create.durability (rewritten on main by chore(test): align latent-red tests with one-time admission and no-auto-disable cron #203560), users-personal-file text (open test: expect current run-close and restart-admission refusal text #204110).
  • Production vs main: 27 files, +120/−228.
  • CI round 1: OURS = 6 text/permission test pins (message-action registry + alias, Telegram history plugin row, skill-library role/alias seed rows, runtime-llm replaced caller), fixed in 8519761ded. Round 2: only not-ours reds (see the Maintainer override comment).
  • Local ClawSweeper review: round 1 6db0ccd7d01d and round 2 8519761ded13 both "patch is correct", no findings.
  • One-admission E2E on 6db0ccd7d01d (production is the same at 8519761ded13; that diff is test-only): verdict pass; R.running-turn-finishes, Q.queued-input-refused-visibly and S.stop-cancels all pass. verdict.json and results.jsonl are kept in the proof directory.

…ary, reclaim and channel reads (R6d part 3)

Authority is checked once when work starts. Delete permission, role, scope, trust and config re-reads after admission in gateway operator/approval/plugin/MCP App paths, the skill library store access, worker reclaim preparation and channel message reads. Keep Stop, run-close and data fences and reword their messages to name what ended and the next step.

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: L 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: 8519761ded139f4924f5b7be1a8bdd0af440a449
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/device-revocation.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/exec-approval-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/exec-approval-manager.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/gateway/exec-approval-resolution-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/openclaw-id/node-pairing.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-invocation-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-role-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/agent.caller-authority.test-utils.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-plugin-in-process-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@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. labels Nov 23, 2026

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

​

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 permission rechecks from admitted Gateway operations while retaining cancellation, lifetime, and target checks.

Example: An official Slack plugin starts reading messages before its installation trust changes.

  • Before: The admitted read can fail when trust changes before completion.
  • After: The admitted read finishes, and the next read checks the updated trust.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The direction and simplification are supported, but behavior proof is test-only and a diff-caused assertion failure remains.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: An operation that already started can be refused when permission changes before it finishes.
Reason: The maintainer-authored direction matches the repository contract and removes redundant checks while explicitly retaining Stop and data fences.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR follows the one-time admission contract, but its message change breaks a remaining test assertion.

Priority: P2
Reviewed head: 8519761ded139f4924f5b7be1a8bdd0af440a449

Before merge

  • Update the remaining owner-admission error assertion (P2) - The new message no longer matches /authority|connection/ in users-personal-file.test.ts:441. Exact-head CI reports this failure for owner-admission refusal cases. The linked text-fix PR updates the separate released-execution assertion, and fetched main still contains this regex. Update the admission assertion to recognize the new refusal while preserving its rejection checks.

Findings

  • [P2] Update the remaining owner-admission error assertion — src/gateway/operator-run-authority.ts:426

Tests

  • Missing end-to-end proof: Supply redacted real-Gateway output showing a changed request path completing after a permission change, with the next request refused and explicit Stop preserved; remove credentials, IPs, and private endpoints.
Agent review details

How this fits together

Gateway admission authorizes operator and plugin requests; downstream approval, session, file, skill-library, and worker owners execute them and return results.

flowchart TD
  A[Operator or plugin request] --> B[Gateway admission]
  B --> C[Captured request authority]
  C --> D[Approval and session owners]
  C --> E[Files skills and workers]
  D --> F[Result or lifecycle refusal]
  E --> F
Loading

Technical review

Best possible solution:

Keep permission decisions at admission, preserve lifecycle and target fences, and update the remaining admission-error test assertion.

Do we have a high-confidence way to reproduce the issue?

Source exposes the post-admission refusals being removed, and exact-head CI independently reproduces the remaining assertion mismatch; no target code was executed during this review.

Is this the best way to solve the issue?

Removing repeated policy checks from existing owners is the smallest coherent approach; the reviewed changes retain admission and lifecycle boundaries without adding replacement machinery.

Full review comments:

  • [P2] Update the remaining owner-admission error assertion — src/gateway/operator-run-authority.ts:426
    The new message no longer matches /authority|connection/ in users-personal-file.test.ts:441. Exact-head CI reports this failure for owner-admission refusal cases. The linked text-fix PR updates the separate released-execution assertion, and fetched main still contains this regex. Update the admission assertion to recognize the new refusal while preserving its rejection checks.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Operator admission, membership, and continuation checks keeps the original intent (04cb817: Fixed authority per request after observed role changes aborted running turns; later starts still require admission.)
  • Approval resolver checks keeps the original intent (refactor(gateway): check exec approval authority once at request start #201812: Earlier approval work separated initial authority from record, expiry, consumption, and manager-lifetime checks.)
  • MCP App file interaction and subscription checks changes intended behavior with a stated reason (feat: use MCP plugin apps across conversations and workspace files #161747: Interactive file access retained requester, workspace, and approval boundaries; fix(mcp): keep app forms, file updates and context in sync after live testing #164277 subsequently retained subscription revocation custody.)
  • Skill-library role and profile checks changes intended behavior with a stated reason (a06f24e: Worker-backed library reads retained profile-authority checks; this PR explicitly separates admitted results from cache invalidation.)
  • Placement reclaim preparation changes intended behavior with a stated reason (perf(gateway): reduce redundant approval and placement queries #168995: Earlier placement simplification retained effect-time authority and exact completion predicates; this PR deliberately removes grant rechecks while keeping lifetime and target checks.)
  • Channel trust capture and lifecycle diagnostics changes intended behavior with a stated reason (unknown: Current and base source show combined trust and registration checks; incomplete historical blobs prevented complete introduction tracing with follow-history and blame.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a06f24e adds src/skills/library/store-access.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a06f24e1edb6; files: src/skills/library/store-access.ts)

PR surface

Source -108, Tests -114, Other -10. Total -232 across 63 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 27 120 228 -108
Tests 35 214 328 -114
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 14 -10
Total 63 338 570 -232

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 restores an established request-lifetime contract and has a focused test repair, without evidence of an urgent user-facing regression.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 restores an established request-lifetime contract and has a focused test repair, without evidence of an urgent user-facing regression.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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:01 PM ET / 17:01 UTC.

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: every remaining red on head 8519761ded13 (CI run 45219585379) is not caused by this PR.

ci-triage 204134:

checks-node-changed-11	src/gateway/worker-environments/destination-authority.e2e.test.ts	OURS
checks-node-changed-compact-large-23-2	src/gateway/server-methods/users-personal-file.test.ts	MAIN-ALSO
checks-node-changed-compact-large-41	src/gateway/server.chat-goal.test.ts	MAIN-ALSO
  • destination-authority.e2e is tagged OURS only because it imports a changed module. It fails the same way on the merge base 59ae4e0f760f locally: all 3 cases fail with "No model is configured". CI shows the same error. It was also red on base during R6a.
  • users-personal-file: main-also. Its text update is in the open test: expect current run-close and restart-admission refusal text #204110.
  • server.chat-goal: main-also.
  • openclaw/ci-gate is red only because of the jobs above.

@obviyus
obviyus merged commit 8ea0f17 into main Nov 23, 2026
165 of 170 checks passed
@obviyus
obviyus deleted the refactor/rest-refusals-part3 branch November 23, 2026 17:11
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 8ea0f17. R6d part 3: mid-request permission, role, scope, trust and config re-checks are deleted in gateway operator/approval/plugin/MCP App paths, the skill library, reclaim preparation and channel reads. Stop, run-close and data fences stay, with messages that say what ended. Proof: E2E Q/R/S pass, local review clean on both rounds, remaining CI reds are not ours (override above). Part 4 (23 gateway files) is listed in the body.

obviyus added a commit that referenced this pull request Nov 23, 2026
…ession and node-host refusals (R6d part 4) (#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; #204134 removed that re-check, and the rows are red on main `8ea0f17162ab` (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 `8ea0f17162ab`: `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` (#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]>
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
…ugin/MCP App paths, skill library, reclaim and channel reads (R6d part 3) (openclaw#204134)

## Problem

OpenClaw checks authority once, when work starts (AGENTS.md "Choose good compromises"). Gateway operator, approval, plugin and MCP App paths, the skill library, worker reclaim and channel message reads still re-read a permission, role, scope, trust or config mid-request and refused started work with "authority changed" / "authority is no longer active/current". Other checks in the same files are valid Stop, run-close or data fences whose text claimed authority.

## Change

R6d part 3, first half (split rule). Each check was classified with one test: can it fire when only a permission, approval or config changes while nothing about the run or data changes?

- Yes → deleted, with its plumbing.
- No (Stop, run close, disconnect, data fence) → kept, reworded to say what ended and the next step.
- Start-time checks (admission, made before work begins) stay.

| Site | Old message | Kind | Action |
|---|---|---|---|
| `skills/library/store-access.ts` `assertCurrent` | Skill library authority changed | mixed: config roles, role subject and scopes re-read + `authority.assertCurrent()` (run close, claim loss, disconnect) | role/scope/config compares deleted; Stop (`authority.assertCurrent`) and the database admission fence kept |
| `skills/library/store-access.ts` `read` | Profile authority changed during library access / Skill library profile authority changed | profile-row change (includes role) after admission | refusals deleted; a profile change now only keeps the reply out of the read cache (no stale cached role) |
| `server-worker-placement-reclaim.ts` | grant callback refusal (`assertWorkerGrant`) | grant re-check during reclaim preparation | deleted; lifetime + target-generation fences kept |
| `worker-environments/placement-dispatch.ts` `reclaimOnce` | Gateway recovery disabled by required worker profile | config re-read inside the repeated source check | checked once at entry; `reclaimSource`/preparation get the existing `assertWorkerLifetime` branch |
| `channels/plugins/message-action-dispatch.ts` | Plugin X read/alias authority is no longer active | registration lifetime + `trustedOfficialInstall` downgrade | trust term moved to capture time in `plugins/registry-registrars-network.ts` (admission); registration fence kept: "…was reloaded during the read. Retry the action." |
| `shared/channel-read-authority.ts` | Channel read authority is no longer active. | Stop (closed read scope) | reworded: "Channel read ended. Retry the action." |
| `agent-runtime-identity-token.ts` | agent runtime approval authority is no longer active | run/claim fence | reworded |
| `device-revocation.ts` | Gateway caller authority is no longer active. | mixed | permission callback re-check deleted; closed-owner / released-lifetime fences kept |
| `exec-approval-authority.ts` + `exec-approval-manager.ts` | approval resolver authority is no longer active | mixed | repeated caller assertion and its plumbing deleted; store/binding fences kept, reworded |
| `exec-approval-resolution-authority.ts` | approval standing grant authority is no longer active | Stop (run abort) + tool-owner data | reworded |
| `operator-approval-session-events.ts` | Operator approval replay authority is no longer current | mixed | reviewer-permission and scope re-reads deleted; runtime, connection and device fences kept, reworded |
| `operator-invocation-authority.ts` | Gateway caller authority is no longer active. | mixed | caller-permission re-checks deleted; signals and context identity kept |
| `operator-role-policy.ts` | OpenClaw ID membership authority changed | authority | membership re-reads for admitted runs deleted; admission checks kept, reworded |
| `operator-run-authority.ts` `prepareGatewayOperatorRunAuthority` | Gateway caller authority is no longer active. | admission (before the run starts) | kept: "Gateway request could not start. Reconnect and try again." |
| `question-manager.ts` | the question's resolution authority is no longer active | Stop / question lifecycle | reworded |
| `openclaw-id/node-pairing.ts` | OpenClaw ID node authority changed | mixed | membership check moved to admission; connect-policy callback kept (opaque, mixes lifecycle), reworded |
| `openclaw-id/tunnel-principal.ts` | OpenClaw ID membership authority changed | admission / recovery | reworded |
| `server-plugin-github-account.ts`, `server-plugin-user-profile.ts`, `server-plugin-session-facts.ts` (`callerAuthorityError`) | … caller authority is no longer active | request lifetime | reworded (helper has callers outside this PR) |
| `server-plugin-session-facts.ts` `assertAuthority` | Session read authority changed; retry the request | mixed | caller/config/policy/access/profile re-checks deleted; projection replacement fence kept, reworded |
| `server-plugin-in-process-session-read.ts` | Session read authority changed before inference. | mixed | repeated visibility authorization deleted; projection/session/store/generation fences kept, reworded |
| `server-plugin-in-process-authority.ts` | Gateway continuation authority is no longer active | Stop (release, cancellation, Gateway lifetime) | reworded |
| `server-plugins-node-runtime.ts` | Plugin Gateway runtime authority is no longer current. | mixed | plugin permission/config reader deleted; lifecycle signal, binding and run/claim checks kept, reworded |
| `mcp-app-form-resources.ts` | Form upload workspace authority changed; MCP App runtime is unavailable | data fence; config (apps disabled) mid-operation | workspace/session fence reworded; mid-operation enabled/upload-policy re-checks deleted (upload admission kept) |
| `mcp-app-host-files.ts` | App file workspace authority changed; 3 subscription "authority changed" closes | mixed | permission/config/grant re-checks and revocation-retention plumbing deleted; connection, requester, view, session, workspace fences kept, reworded |
| `mcp-app-tool-approval.ts` | MCP App tool approval authority changed | authority (post-consumption re-check) | deleted; admission, decision and allow-once consumption kept |

Deleted tests (they asserted a mid-request permission refusal): skill library role change after preparation (`skill-library-authoring`, `selection-authority`), reclaim "caller changes at transaction/commit completion admission", message-action registry `trust-downgrade` row, form upload "upload policy"/"apps disabled", host-file synchronous grant revocation, fork "session visibility", linked-owner membership revocation for an admitted run, replay waiting-client scope revocation and revoked-requester variant, device-retention permission revocation. Stop and data-fence tests keep their conditions; only their expected text changed. The 21 channel read assertions that matched the generic "no longer active" text were first split so each matches its own producer.

Lifetime-check ratchet: 0 counted strings in every touched production file. `config/session-identity-allowlist.txt` pruned.

Accepted edge cases:
- A started skill-library read or prepared selection keeps its result if the profile role changes; the next request admits the new role. The worker-side publication check is unchanged.
- A started reclaim finishes even if the caller's grant is revoked; Stop and session lifetime still end it.
- A channel read that started keeps going if the plugin install trust drops; the next read is admitted with the new trust.

## Not in this PR (part 4)

- Remaining `src/gateway/**` string files: `agent-turn/agent-run-user-turn.ts`, `channel-avatar-http.ts`, `cron-creator-authority-grant.ts`, `cron-stream-sandbox-authority.ts`, `desktop/observe-bridge.ts`, `factory-github-proof.ts`, `http-auth-user-profile.ts`, `human-mention-policy.ts`, `managed-image-session-read.ts`, `mention-inbox.ts`, `node-claude-skill-runtime.ts`, `node-mcp-elicitation.ts`, `openai-compatible-agent-run.ts`, `remote-control-ui-ingress.ts`, `repository-dispatch.ts`, `repository-integration-identity.ts`, `server-node-event-source.ts`, `server/ws-connection/authenticated-request-dispatch.ts`, `server/ws-connection/connect-publication-transport.ts`, `server/ws-origin-policy.ts`, `session-sharing-read.ts`, `skill-library-session.ts`, `talk/client-run-authority.ts`.
- Reclaim: `sessions.reclaim` passes the unsplit `SessionMutationAuthorization.assertCurrent` (grant + session lifetime) and Move's composed callback reads config policy + signal. Removing the grant there needs the producer to expose its lifetime part (R6z type change).
- Approval replay visibility (`canAccessInvitedApprovalSession`) mixes session-sharing data with role/scope reads; node-pairing's connect-policy callback mixes lifecycle and policy. Both kept.

## User impact

A started read, reclaim, approval replay, plugin or MCP App request is no longer refused because a role, scope, trust or config changed mid-request; the change applies to the next request. Stop, disconnect, plugin reload and data changes still end work, with messages that 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; session-identity ratchet OK after prune (6257 → 6239 pins).
- `ocx test` (continue-on-failure) on 204 files: every touched test file, every test importing a changed source or test-support file except the 3 widest modules (`operator-role-policy`, `operator-run-authority`, `tunnel-principal`: 200 importers; CI runs them), plus every test pinning a changed message. OURS reds fixed and rerun. Remaining local reds are not ours: `mcp-http.async-scope`, `agent.test` (2), `question.communication`, `question.recovery` (base-red, see earlier R6 PRs), `server.sessions.create.lifecycle` requester row + `server.sessions.create.durability` (rewritten on main by openclaw#203560), `users-personal-file` text (open openclaw#204110).
- Production vs `main`: 27 files, +120/−228.
- CI round 1: OURS = 6 text/permission test pins (message-action registry + alias, Telegram history plugin row, skill-library role/alias seed rows, runtime-llm replaced caller), fixed in `8519761ded`. Round 2: only not-ours reds (see the Maintainer override comment).
- Local ClawSweeper review: round 1 `6db0ccd7d01d` and round 2 `8519761ded13` both "patch is correct", no findings.
- One-admission E2E on `6db0ccd7d01d` (production is the same at `8519761ded13`; that diff is test-only): verdict pass; R.running-turn-finishes, Q.queued-input-refused-visibly and S.stop-cancels all pass. `verdict.json` and `results.jsonl` are kept in the proof directory.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…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]>
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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: L 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