Skip to content

chore(test): align latent-red tests with one-time admission and no-auto-disable cron - #203560

Merged
obviyus merged 3 commits into
mainfrom
codex/red-main-one-admission-tests
Nov 23, 2026
Merged

obviyus merged 3 commits into
mainfrom
codex/red-main-one-admission-tests

Conversation

@steipete

@steipete steipete commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Related: #203488, #203516, #204024, #204037, #204048, #204081

What Problem This Solves

Scheduled main CI (run 45184109257, head 4ff5ebd) is red in the 7 test files below. Each red case asserts a refusal after the requester was revoked while the request was already running. One-time admission removed that refusal on purpose (root AGENTS.md: "Check authority one time, when work starts"; a started request may finish, and the revocation applies to the next request). This PR changes tests only.

Rebased onto main after the one-admission test cleanup (#204024, #204037, #204048, #204081). Dropped from the original scope because main no longer needs them:

  • doctor-health.legacy-update.test.ts: fixed on main by fix: restore two OpenClaw regression suites #203569; this PR takes main's version.
  • server.roles-allowlist-update.test.ts (update.run handoff fixture) and server.sessions.create.projects.test.ts: not red on the latest scheduled run.

Why This Change Was Made

File Action Why
src/commands/models/auth-api-key.test.ts deleted 1 case "writes no binding or allowlist once the requester is revoked": mid-request revocation of a started save (#203516).
server-methods/exec-approvals.test.ts updated 3 cases, deleted 1 native commit keeps the write of an admitted requester; legacy get/set prove a started mutation finishes after revocation; the revoke-while-reading case is deleted (the set case covers it).
server-methods/sessions-create-device-folder.test.ts updated requester revocation while the node validates no longer refuses; the device data fence (node connection goes away) stays.
server-methods/sessions-diff.test.ts updated per-caller mid-poll authority removed; still proves polls share preparation and metadata stays per session.
server-methods/system-changes.test.ts updated "does not disclose a delayed revoked read" removed; the delayed rejected-read case stays.
server.sessions.create.lifecycle.test.ts deleted 1 variant durable replay "requester" revocation after authorization. The membership data-fence variant stays.
server.sessions.create.durability.test.ts deleted 1 row "permission-revoked-at-commit": device revoked while the started create commits its initial input. It hung the fixture, so the later cases in the file timed out in their hooks. Commit-refused, transaction-refused and Stop rows stay.

User Impact

None. Test-only.

Evidence

  • Red on main: scheduled run 45184109257, every case named above.
  • Head: PR CI on this branch; local vitest-source run of the 7 files (see comment).
  • oxfmt and oxlint clean on changed files.

@clawsweeper

clawsweeper Bot commented Nov 22, 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 size: M labels Nov 22, 2026
@steipete
steipete marked this pull request as ready for review November 22, 2026 17:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T17:26:32.867264Z 56bd31f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR removes or updates Gateway tests that still expect requester revocation to interrupt an already admitted request.

Example: An exec.approvals.set request saves defaults.security="deny" after its requester is revoked during commit.

  • Before: The test expects an UNAVAILABLE response and an unchanged policy snapshot.
  • After: The test expects successful completion and a changed policy snapshot.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused test migration supported by production-source inspection and passing exact-head CI; proof is through test harnesses, with no shipped-behavior proof required.
Proof confidence 🦐 gold shrimp (3/6) This PR changes tests without changing shipped behavior; focused test results and successful exact-head CI provide the applicable validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Unrelated PRs encounter failing Gateway tests whose expected requester-revocation behavior has been retired.
Reason: The maintainer-authored direction matches root policy and the merged admission decision, with all introduced hunks serving the test migration.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR aligns obsolete tests with the approved one-time admission contract while retaining independent data fences; no actionable patch defect was found.

Priority: P2
Reviewed head: 45db34b19b0c6d693a95db64b811896df83a6cc9

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway dispatch admits RPC requests, then handlers perform reads and writes under cancellation and operation-specific data fences; these tests exercise those handlers and their storage owners.

flowchart TD
  A[Authenticated RPC] --> B[Request admission]
  B --> C[Gateway handler]
  C --> D[Cancellation and data fences]
  D --> E[Storage or node operation]
  E --> F[RPC response]
  G[Gateway tests] --> C
Loading

Technical review

Best possible solution:

Merge the focused test migration while preserving the existing admission owner, cancellation checks, and independent data fences.

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

Current-main tests still expect requester-change refusals that the shared request-authority owner no longer produces; the reported bisect supports that source trace, without a new local execution.

Is this the best way to solve the issue?

Updating the obsolete expectations is the smallest complete repair because restoring runtime rechecks would contradict the approved admission contract.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native and legacy exec-approval requester expectations changes intended behavior with a stated reason (9324ed6: Worker offloading retained requester checks before policy writes; dcaf3d9 subsequently exercised native shared-policy commits.)
  • Shared diff preparation changes intended behavior with a stated reason (57751ab: Keep diff polls responsive during metadata stalls while separating session data and caller disclosure checks.)
  • Delayed changes-history reads changes intended behavior with a stated reason (718f9b7: Worker-based history reads retained requester checks before disclosure; the patch preserves reader rejection while retiring that requester variant.)
  • Existing folders on paired devices changes intended behavior with a stated reason (2c87e33: Validate the selected device folder before persisting a device-bound session; the node-connection fence remains covered.)
  • Durable creation replay changes intended behavior with a stated reason (d40aa7c: Replay persisted creation receipts without duplicate preparation while retaining access and incarnation checks; membership and lifecycle coverage remain.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 57751ab adds src/gateway/server-methods/sessions-diff.test.ts:248 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 57751abcca1d; files: src/gateway/server-methods/sessions-diff.test.ts)
  • Ayaan Zaidi: Raw commit 2c87e33 adds src/gateway/server-methods/sessions-create-device-folder.test.ts:32 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2c87e3339901; files: src/gateway/server-methods/sessions-create-device-folder.test.ts)

PR surface

Tests -89. Total -89 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 192 281 -89
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 192 281 -89

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: Obsolete Gateway expectations cause unrelated PR test selections to fail and warrant a focused test repair.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Obsolete Gateway expectations cause unrelated PR test selections to fail and warrant a focused test repair.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 22, 2026, 12:15 PM ET / 17:15 UTC.

steipete and others added 3 commits November 23, 2026 19:51
… by one-time admission

#203488 (6ff7a06) made Gateway requests check the caller's authority
once at admission, so a requester revoked while a request runs no longer
gets a mid-request refusal. Eight tests in five files still asserted the
retired refusal and have failed on main since then (main push CI does not
select them).

Keep the contracts these tests still prove: shared poll preparation and
per-session metadata (sessions.diff), a delayed rejected read (changes
list), device and membership data fences (sessions.create), and the
admitted native/legacy exec-approvals writes. The legacy get/set case now
proves a started mutation finishes after the requester is revoked.
…anded policy

Three more test files fail on main but are not selected by main push CI:

- doctor-health.legacy-update: the notification heartbeat-owner variants
  expected the 10th failure to auto-disable the job and send a safety
  notice. #203106 (8bdaed5) removed run-failure auto-disable, so
  Doctor now settles the interrupted run and the job keeps its schedule.
- auth-api-key: asserted a mid-request requester-revocation refusal that
  one-time admission retired (#203516, cc7b482).
- server.sessions.create.projects: the repository-child revocation phases
  asserted the same retired refusal; keep the parent-reassigned data fence.
…oject fixture edits

Deletes the permission-revoked-at-commit row in server.sessions.create.durability.test.ts: it revoked the device while a started create committed its input, which one-time admission no longer refuses, and the hung fixture made later cases time out. Restores server.sessions.create.projects.test.ts to main, where it is green.

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

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Rebased onto main after the one-admission test cleanup (#204024, #204037, #204048, #204081). Resolved conflicts and dropped hunks already fixed on main (doctor-health.legacy-update by #203569). Landing to get main CI green.

@obviyus
obviyus force-pushed the codex/red-main-one-admission-tests branch from 206f693 to ce37dcf Compare November 23, 2026 14:39
@obviyus
obviyus merged commit 6a8b47c into main Nov 23, 2026
124 of 132 checks passed
@obviyus
obviyus deleted the codex/red-main-one-admission-tests branch November 23, 2026 14:49
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Landed as 6a8b47c. All 7 files were red on main (scheduled run 45184109257) and pass in PR CI run 45196616090. Thanks @steipete for the original cleanup.

obviyus added a commit that referenced this pull request Nov 23, 2026
…ugin/MCP App paths, skill library, reclaim and channel reads (R6d part 3) (#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 #203560), `users-personal-file` text (open #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
… by one-time admission (openclaw#203560)

Deletes or updates test cases that expect a refusal after the requester is revoked while a request is already running (auth-api-key, exec-approvals, sessions-create-device-folder, sessions-diff, system-changes, server.sessions.create lifecycle and durability). One-time admission lets a started request finish; data fences stay. Tests only.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants