Skip to content

refactor: drop mid-request authority re-checks in the last gateway, session and node-host refusals (R6d part 4) - #204191

Merged
obviyus merged 5 commits into
mainfrom
refactor/rest-refusals-part4
Nov 23, 2026
Merged

obviyus merged 5 commits into
mainfrom
refactor/rest-refusals-part4

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"). 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; refactor: drop mid-request authority re-checks in gateway operator/plugin/MCP App paths, skill library, reclaim and channel reads (R6d part 3) #204134 removed that re-check, and the rows are red on 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 (server.talk-consult-history 'isolates registered Talk replay' red on main after #203468 #203507), local-request-context.session-tools (red on main run 45238720546). The E2E 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.

obviyus and others added 2 commits November 23, 2026 23:05
…ession and node-host refusals (R6d part 4)

Delete role, scope, profile-version, access-revision, config and command-policy
re-reads that refused started requests; keep Stop, disconnect and data fences and
reword them to say what ended and the next step. Admission checks that sat inside
a repeated closure now run once before it (factory GitHub proof, remote ingress).

Co-authored-by: obviyus <[email protected]>
…on-facts refusal rows

The remote ingress role compare retires the binding so the MCP relay rebinds with
the current role; without it the next relay request fails as internal. Keep it,
reworded. Drop session-facts rows that expect a started disclosure to be refused
after a role, profile or config change (red on main since the R6d part 3 cut).

Co-authored-by: obviyus <[email protected]>
@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.

@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: 711ba27c5b6fa2f574240af590d99dcacafed200
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/cron-stream-sandbox-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/http-auth-user-profile.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/authenticated-request-dispatch.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-publication-transport.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-origin-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/talk/client-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@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. 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 started Gateway operations while retaining admission, lifecycle, session, and identity checks.

Example: Alice starts an agent turn while she is a channel owner, then an administrator removes her owner status.

  • Before: The running turn can fail with “Requester owner authority changed.”
  • After: The admitted turn may finish, and subsequent work uses the updated authority.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The product direction and simplification are supported, but a confirmed assertion failure remains and supplied behavior proof is test-only.
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 fail because permissions change before it finishes.
Reason: The maintainer-authored direction matches repository policy, documents the accepted completion semantics, and removes redundant checks without adding another authority owner.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR follows the approved admission contract, but a renamed Factory GitHub error breaks an existing rejection test.

Priority: P2
Reviewed head: 29148535213cd5295cc12612a7f6f7b16b59f8fc

Before merge

  • Update the Factory GitHub foreign-host rejection assertion (P2) - A caller whose authenticated principal names another Enterprise host still correctly fails this identity check, but project-github-identity.factory.test.ts:326 expects “caller authority changed.” The replacement message no longer contains that substring, and exact-head CI reproduces the failure in checks-node-changed-compact-large-40-2. Update the existing assertion to recognize the new identity diagnostic while preserving its rejection and no-broker-request checks.

Findings

  • [P2] Update the Factory GitHub foreign-host rejection assertion — src/gateway/factory-github-proof.ts:65-67

Tests

  • Missing end-to-end proof: Supply redacted real-Gateway output showing an affected operation completing after a permission change and a subsequent request using the new authority; the supplied validation is test-only.
Agent review details

How this fits together

Gateway admission accepts authenticated requests; agent, mention, repository, and node owners execute them and return results under their retained lifecycle and target checks.

flowchart TD
  A[Authenticated request] --> B[Request start admission]
  B --> C[Captured authority]
  C --> D[Agent and Talk execution]
  C --> E[Mention and repository operations]
  D --> F[Lifecycle and target checks]
  E --> F
  F --> G[Result or actionable refusal]
Loading

Technical review

Best possible solution:

Keep the existing admission owners and retained lifecycle checks, and update the foreign-host rejection assertion to recognize the new diagnostic.

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

Current-main source exposes the repeated permission checks being removed, and exact-head CI independently demonstrates the remaining Factory GitHub assertion mismatch; no target code was executed during this review.

Is this the best way to solve the issue?

Removing repeated checks and their plumbing from existing owners is the smallest coherent implementation of the recorded admission policy.

Full review comments:

  • [P2] Update the Factory GitHub foreign-host rejection assertion — src/gateway/factory-github-proof.ts:65-67
    A caller whose authenticated principal names another Enterprise host still correctly fails this identity check, but project-github-identity.factory.test.ts:326 expects “caller authority changed.” The replacement message no longer contains that substring, and exact-head CI reproduces the failure in checks-node-changed-compact-large-40-2. Update the existing assertion to recognize the new identity diagnostic while preserving its rejection and no-broker-request checks.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Requester owner checks across agent admission and execution changes intended behavior with a stated reason (fd2a6ca: Preserved requester identity and current permissions across delegated and recovered execution; fix(agents): channel owner's subagent keeps native runtime access after the owner is removed #185796 subsequently extended owner checks into running child dispatch.)
  • Committed mention involvement and Inbox commit checks changes intended behavior with a stated reason (62a982b: Mention invitations and notification delivery retained recipient and sender policy checks; worker-backed Inbox commits also guarded profile, access, configuration, and session changes.)
  • Paired-node skill runtime changes intended behavior with a stated reason (bc60cd9: Worker-prepared session facts were carried to effects with live authority and target validation; this PR deliberately leaves command policy at invocation admission while retaining assignment and run checks.)
  • Factory GitHub proof changes intended behavior with a stated reason (4579af0: Bound private GitHub App reads to an authenticated operator, exact actor, session, and issuer; this PR preserves initial scope admission and identity binding while removing repeated scope checks.)
  • Repository dispatch and integration identity changes intended behavior with a stated reason (a4b07c6: Retained caller-bound repository admission through worker preparation and recovery; this PR explicitly replaces repeated policy comparisons with admitted operation facts.)
  • Talk retained run authority changes intended behavior with a stated reason (f4f4868: Aligned voice requests with ordinary permissions and retained caller security; later work allowed accepted consultations to finish after revocation, while this change removes the remaining opaque permission fallback.)
  • Publication transport and retained refusal diagnostics keeps the original intent (39bcc3c: Restricted publication requests pass admission individually; this PR retains those conditions and changes diagnostics to identify the connection, session, or lifecycle condition that ended work.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/gateway/project-github-identity.factory.test.ts --maxWorkers=1
  • git diff --check

What I checked:

PR surface

Source -54, Tests -40, Other -1. Total -95 across 40 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 26 76 130 -54
Tests 13 30 70 -40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 2 -1
Total 40 107 202 -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 restores the established request-admission contract and has a focused diff-caused test failure, without evidence of an urgent production outage.
  • 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 the established request-admission contract and has a focused diff-caused test failure, without evidence of an urgent production outage.
  • 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, 2:15 PM ET / 19:15 UTC.

…update the factory proof text

subagent-spawn.production-boundary still expects child dispatch to stop after the
spawning owner is removed; that tree is owned by a parallel PR, so the check stays
until that expectation is deleted. The factory identity fence test now matches the
reworded message.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the only red job on head 5dd4558144b8 is not caused by this PR.

ci-triage 204191:

# PR #204191 head 5dd4558144b8; main run 45238720546
checks-node-changed-compact-large-23	src/gateway/local-request-context.session-tools.test.ts	MAIN-ALSO

The same file is red in main run 45238720546. The agent-turn files it exercises are identical to main on this head.

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Stopped under the 2-CI-round rule. Not merged.

CI round 2 on 5dd4558144b8 (ci-triage 204191):

  • server.sessions.create.repository-required.test.ts, row caller: OURS. After ACK it clears the client's scopes and expects the repository session run to be refused. This PR deleted that mid-request scope compare from repository-dispatch.ts, so the row is obsolete. Confirmed locally: only caller fails; allowed, policy, source and stop pass.
  • server.talk-consult-history.test.ts: known main red (server.talk-consult-history 'isolates registered Talk replay' red on main after #203468 #203507).
  • local-request-context.session-tools.test.ts: MAIN-ALSO (red in main run 45238720546).

Proposed split: one more push on this branch that deletes the caller row (line 53 list entry and the scenario === "caller" block at lines 300-302), then land with an override for the two not-ours reds. Local review (round 2, clean) and the E2E (Q/R/S pass) on 5dd4558144b8 cover the unchanged production code. Nothing else changes.

The row cleared the client's scopes after ACK and expected the run to be refused;
that mid-request scope re-check is gone from repository-dispatch.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Withdrawn: server.talk-consult-history on 4ba022722a64 is ours (expected-text regex in server.talk-permission-parity.test-support.ts still matches the old Talk wording). Fixed in the next push; a new override follows for the not-ours red only.

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the only red job on head 711ba27c5b6f is not caused by this PR.

ci-triage 204191:

# PR #204191 head 711ba27c5b6f; main run 45248844963
checks-node-changed-compact-large-38	src/gateway/local-request-context.session-tools.test.ts	MAIN-ALSO

The same file is red on main (runs 45238720546 and 45248844963). The agent-turn files it exercises are identical to main on this head. The Talk consult shard is green on this head.

@obviyus
obviyus merged commit 1596a12 into main Nov 23, 2026
151 of 154 checks passed
@obviyus
obviyus deleted the refactor/rest-refusals-part4 branch November 23, 2026 21:16
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 1596a12.

  • Change: the last gateway, ACP-session and node-host refusal strings outside src/agents/** are now classified. Mid-request role, scope, profile, access, config and command-policy re-reads are deleted. Stop, disconnect and data fences stay, with text that says what ended and what to do next.
  • Production: 23 files, +75/−107. The lifetime-check ratchet counts 0 strings in the changed files.
  • Proof: one-admission E2E Q/R/S pass (production unchanged since that head), local review clean on the merged head, CI green except local-request-context.session-tools (red on main; override above).
  • Left for later: agent-run-user-turn, cron-creator-authority-grant and acp/.../session-meta-resume-authorization (pinned by src/agents tests); the AdmittedRunOperatorAuthority.assertCurrent readers (R6z).

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]>
obviyus added a commit that referenced this pull request Nov 24, 2026
…ime ratchet (R6z) (#204249)

## Problem

AGENTS.md says to check authority once, when work starts. The admitted operator authority (`AdmittedRunOperatorAuthority`) still carried a mid-run re-check member, `assertCurrent`, plus `onModelPolicyChanged`, a mid-run model-policy revocation hook. About 60 production readers called `assertCurrent()` in the middle of started runs, requests and queued work, and the constructor latched any failure into the run's signal. A started run could still be refused after a permission, role or profile change. The lifetime-check ratchet (`scripts/check-lifetime-check-ratchet.mts`) only kept the count from growing; it is now at zero and protects nothing.

## Fix

This is the last one-admission PR (R6z).

- `AdmittedRunOperatorAuthority` loses `assertCurrent` and `onModelPolicyChanged`. `createAdmittedRunOperatorAuthority` no longer composes or latches a re-check: its `signal` is the source signal (Stop) only. `bindOperatorModelExecution` keeps release and Stop, and no longer re-runs the policy on change.
- Every reader the compiler listed is deleted. Stop reads its own signal (`signal.throwIfAborted()`). Data fences keep reading their own data: owner, generation, writer lease, run occurrence, released/closed flags, request lifetime, commit guards, the cron delivery fence (`scheduledAutomation.deliveryAttemptFence`) and the cron control-edit compare (`retainCronControlSource`).
- `SessionControllerSourceAdapter.authority.assertCurrent` becomes optional. Non-operator producers keep their fence there. An operator authority passed there carries only Stop.
- The retired-cron-delivery fence moves off the operator authority. A queued follow-up checks `scheduledAutomation.deliveryAttemptFence` before claim, in the same place where the removed `operatorAuthority.assertCurrent()` was. The follow-up runner withholds a run on `CronDeliveryAuthorityError` itself: it records the run and does not replay it. Before, it learned this only from the authority's latched signal.
- The ratchet script, its test and its `ci-baseline-ratchets` entry are deleted.
- New lint rule `openclaw-boundaries/no-operator-permission-read` (in `config/oxlint/boundary-guards.json`, which the `lint:no-chained-type-assertions` boundary lane runs over `src`, `extensions` and `packages`). Only the files named in `scripts/lib/no-operator-permission-read.mjs` may reference the live permission readers `resolveOperatorRolePolicy`, `resolveOperatorRolePolicyForAssignment`, `resolveOperatorRolePolicyForProfile`, `resolveOperatorRoleSelection`, `authorizeCurrentOperatorRoleScopes`, `onOperatorRolePolicyChanged` and `captureResidentUserProfileAccess`. The allowlist is the owners and the work-start files that use them today (63 files). It only shrinks: new code takes scopes, role and policy from the admitted operator authority. The planted fixture `test/fixtures/oxlint-boundary-guards/operator-permission-recheck-violation.ts` (named import, namespace member, lazy import) fails the rule (4 reports).
- Parked item from R6c4a: the worktree publication message reads "The GitHub publication worktree changed" instead of "...authority changed". The test fixture URL that had fake credentials is now `https://example.test/repo?...`.
- The last three refusal strings in production code are gone:
  - `agent-run-user-turn.ts`: the requester-owner re-read from live config (`assertRequesterCurrent`, "Requester owner authority changed") is deleted, along with its admission-phase and execution-phase plumbing. The owner decision is made once, when the turn starts. The `subagent-spawn.production-boundary` expectation "removing the spawning owner after admission must stop that dispatch" is deleted with it.
  - `acp/runtime/session-meta-resume-authorization.ts`: this is a data fence (the source session's facts changed). It is reworded to "The ACP resume source session changed".
  - `cron-creator-authority-grant.ts`: the run-scoped grant ends with its run, scope, operation or management deadline. It is reworded to "This run's MCP cron access has ended".
- `scripts/perf/*-measure.ts`: removed the `assertCurrent` counters and the source-authority revocation proof, which measured the deleted mid-run re-check.

Production code: 86 files, +82 / −313. Scripts, config and lint test: +138 / −242.

### Decisions

- Lint rule shape (Fable 5.2): an import/reference boundary on the live readers, with exact files listed. A rule that bans the name `assertCurrent` would be wrong, because ~150 data-owner authorities use that name. The refusal-string ban would only bring the deleted ratchet back as a wording check. Accepted risk: an allowed work-start file can still call a reader twice. Review owns that.
- `src/cron/service.restart-delivery.test.ts` "automation=false" row deleted. Only the fixture put the delivery fence on the operator authority. In production the queued authority comes from `decideOperatorAdmission`, whose `assertCurrent` was always a no-op. The real carrier is `scheduledAutomation.deliveryAttemptFence`, and that case stays.
- Accepted edge: a queued chat input's `requesterProfile.isCurrent` is now `true` for the life of the dispatch. Before, it turned false after the admitted source was released. It only selects the requester attribution prefix.
- Accepted edge: if a completion cohort settles between the steering preparation and the queue commit, the human correction now reports `failed` with the policy-mismatch error. Before, it reported `rejected: tool_authority_mismatch`. The message is still refused visibly, and the race window is a few milliseconds.
- Known follow-up, not done here: a cron creator grant can still be refused when consumed after its issuing device or channel owner is revoked during the run, because the grant's `isCurrent` producers still read the device and owner lifetime. Only the wording changed in this PR. Removing those producers is a separate cut in the cron grant plumbing.

## User impact

A started run, request, queued start, tool call, model execution or scheduled job finishes after a permission, role, profile or model-policy change. The next request uses the new permissions. Stop still cancels. Data fences still refuse stale writes.

## Tests

Deleted, because each asserts a refusal after a mid-run permission, role, profile or model-policy change (full list in the PR comment). Stop, run-close and data-fence tests keep their condition. Test fixtures no longer pass `assertCurrent` or `onModelPolicyChanged`.

## Evidence

- `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean.
- oxfmt and oxlint on all changed files: clean. `pnpm lint:no-chained-type-assertions` (all focused guards, including the new rule) over the tree: 0 errors. `test/scripts/oxlint-boundary-guards.test.ts`: the planted re-check fixture fails the rule.
- Pre-push `ocx test`: all 215 touched test files and the importers of every `*.test-support.ts` file. The direct-importer set is over the 150-file cap. Then the failed files, plus importers of `followup-runner.ts` and `reply-agent-turn-preparation.ts`, and after the rebase on #204191 its 17 test files. Final reruns are green.
- E2E `one-admission-e2e/run.sh`: see the comment.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
* fix(subagents): settle cleaned child receipts and classify delivery notices

* test(subagents): preserve notice classification assertion typing

* test(subagents): build cleanup fixtures without map spread

* chore(subagents): shrink identity allowance after guard removal

* fix(subagents): separate receipt identity from continuation claims

* test(subagents): retain main child notice classification after rebase

* test(subagents): expect the ready cohort member to schedule settlement

* fix(sessions): deduplicate yielded completion failure notices

* test(subagents): preserve explicit claims and await terminal session state

(cherry picked from commit cab76a6)

Release adaptation: Preserved stable suspended-delivery sweeper; omitted main-only expiry and self-hold replacement fixtures; retained registry and Gateway yield-wait regression coverage. Identity ratchet prune clean.

Companion audit: #204249 and #204191 not applicable (authority refactors); #204260 missing in lane, not a prerequisite.

Co-authored-by: RomneyDa <[email protected]>
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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…ime ratchet (R6z) (openclaw#204249)

## Problem

AGENTS.md says to check authority once, when work starts. The admitted operator authority (`AdmittedRunOperatorAuthority`) still carried a mid-run re-check member, `assertCurrent`, plus `onModelPolicyChanged`, a mid-run model-policy revocation hook. About 60 production readers called `assertCurrent()` in the middle of started runs, requests and queued work, and the constructor latched any failure into the run's signal. A started run could still be refused after a permission, role or profile change. The lifetime-check ratchet (`scripts/check-lifetime-check-ratchet.mts`) only kept the count from growing; it is now at zero and protects nothing.

## Fix

This is the last one-admission PR (R6z).

- `AdmittedRunOperatorAuthority` loses `assertCurrent` and `onModelPolicyChanged`. `createAdmittedRunOperatorAuthority` no longer composes or latches a re-check: its `signal` is the source signal (Stop) only. `bindOperatorModelExecution` keeps release and Stop, and no longer re-runs the policy on change.
- Every reader the compiler listed is deleted. Stop reads its own signal (`signal.throwIfAborted()`). Data fences keep reading their own data: owner, generation, writer lease, run occurrence, released/closed flags, request lifetime, commit guards, the cron delivery fence (`scheduledAutomation.deliveryAttemptFence`) and the cron control-edit compare (`retainCronControlSource`).
- `SessionControllerSourceAdapter.authority.assertCurrent` becomes optional. Non-operator producers keep their fence there. An operator authority passed there carries only Stop.
- The retired-cron-delivery fence moves off the operator authority. A queued follow-up checks `scheduledAutomation.deliveryAttemptFence` before claim, in the same place where the removed `operatorAuthority.assertCurrent()` was. The follow-up runner withholds a run on `CronDeliveryAuthorityError` itself: it records the run and does not replay it. Before, it learned this only from the authority's latched signal.
- The ratchet script, its test and its `ci-baseline-ratchets` entry are deleted.
- New lint rule `openclaw-boundaries/no-operator-permission-read` (in `config/oxlint/boundary-guards.json`, which the `lint:no-chained-type-assertions` boundary lane runs over `src`, `extensions` and `packages`). Only the files named in `scripts/lib/no-operator-permission-read.mjs` may reference the live permission readers `resolveOperatorRolePolicy`, `resolveOperatorRolePolicyForAssignment`, `resolveOperatorRolePolicyForProfile`, `resolveOperatorRoleSelection`, `authorizeCurrentOperatorRoleScopes`, `onOperatorRolePolicyChanged` and `captureResidentUserProfileAccess`. The allowlist is the owners and the work-start files that use them today (63 files). It only shrinks: new code takes scopes, role and policy from the admitted operator authority. The planted fixture `test/fixtures/oxlint-boundary-guards/operator-permission-recheck-violation.ts` (named import, namespace member, lazy import) fails the rule (4 reports).
- Parked item from R6c4a: the worktree publication message reads "The GitHub publication worktree changed" instead of "...authority changed". The test fixture URL that had fake credentials is now `https://example.test/repo?...`.
- The last three refusal strings in production code are gone:
  - `agent-run-user-turn.ts`: the requester-owner re-read from live config (`assertRequesterCurrent`, "Requester owner authority changed") is deleted, along with its admission-phase and execution-phase plumbing. The owner decision is made once, when the turn starts. The `subagent-spawn.production-boundary` expectation "removing the spawning owner after admission must stop that dispatch" is deleted with it.
  - `acp/runtime/session-meta-resume-authorization.ts`: this is a data fence (the source session's facts changed). It is reworded to "The ACP resume source session changed".
  - `cron-creator-authority-grant.ts`: the run-scoped grant ends with its run, scope, operation or management deadline. It is reworded to "This run's MCP cron access has ended".
- `scripts/perf/*-measure.ts`: removed the `assertCurrent` counters and the source-authority revocation proof, which measured the deleted mid-run re-check.

Production code: 86 files, +82 / −313. Scripts, config and lint test: +138 / −242.

### Decisions

- Lint rule shape (Fable 5.2): an import/reference boundary on the live readers, with exact files listed. A rule that bans the name `assertCurrent` would be wrong, because ~150 data-owner authorities use that name. The refusal-string ban would only bring the deleted ratchet back as a wording check. Accepted risk: an allowed work-start file can still call a reader twice. Review owns that.
- `src/cron/service.restart-delivery.test.ts` "automation=false" row deleted. Only the fixture put the delivery fence on the operator authority. In production the queued authority comes from `decideOperatorAdmission`, whose `assertCurrent` was always a no-op. The real carrier is `scheduledAutomation.deliveryAttemptFence`, and that case stays.
- Accepted edge: a queued chat input's `requesterProfile.isCurrent` is now `true` for the life of the dispatch. Before, it turned false after the admitted source was released. It only selects the requester attribution prefix.
- Accepted edge: if a completion cohort settles between the steering preparation and the queue commit, the human correction now reports `failed` with the policy-mismatch error. Before, it reported `rejected: tool_authority_mismatch`. The message is still refused visibly, and the race window is a few milliseconds.
- Known follow-up, not done here: a cron creator grant can still be refused when consumed after its issuing device or channel owner is revoked during the run, because the grant's `isCurrent` producers still read the device and owner lifetime. Only the wording changed in this PR. Removing those producers is a separate cut in the cron grant plumbing.

## User impact

A started run, request, queued start, tool call, model execution or scheduled job finishes after a permission, role, profile or model-policy change. The next request uses the new permissions. Stop still cancels. Data fences still refuse stale writes.

## Tests

Deleted, because each asserts a refusal after a mid-run permission, role, profile or model-policy change (full list in the PR comment). Stop, run-close and data-fence tests keep their condition. Test fixtures no longer pass `assertCurrent` or `onModelPolicyChanged`.

## Evidence

- `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean.
- oxfmt and oxlint on all changed files: clean. `pnpm lint:no-chained-type-assertions` (all focused guards, including the new rule) over the tree: 0 errors. `test/scripts/oxlint-boundary-guards.test.ts`: the planted re-check fixture fails the rule.
- Pre-push `ocx test`: all 215 touched test files and the importers of every `*.test-support.ts` file. The direct-importer set is over the 150-file cap. Then the failed files, plus importers of `followup-runner.ts` and `reply-agent-turn-preparation.ts`, and after the rebase on openclaw#204191 its 17 test files. Final reruns are green.
- E2E `one-admission-e2e/run.sh`: see the comment.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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