Repository navigation
refactor: drop mid-run authority re-checks in infra, state, plugins and GitHub publication - #204037
Conversation
… in infra, state, plugins and GitHub publication - Delete mid-run permission, credential, membership and config re-reads: device token issuance, GitHub publication identity and profile/credential subscriptions, skill library roles/scopes, sandbox live config, worker reclaim `authorize` repeats and `reauthorize` plumbing. - Keep Stop, run-close and data fences; reword their refusals to name what ended and the next step. - Prune the session-identity allowlist to the new counts. Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: blocked before merge. What this changesThis PR removes permission rechecks during started operations and rewrites lifecycle errors to explain what ended and how to retry. Example: An operator device handshake with operator.admin scope starts before OpenClaw ID membership changes.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep open: the maintainer-approved direction is useful, but this PR removes skill-publication lifecycle fences and leaves affected consumer tests failing. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherGateway admission establishes caller permissions, then library, publication, plugin, and worker owners carry the operation through filesystem, database, and network effects. flowchart LR
Request[Incoming request] --> Admission[Permission admission]
Admission --> Operation[Started operation]
Operation --> Custody[Stop and lifetime fences]
Custody --> Effects[Filesystem database or GitHub effects]
Effects --> Result[Recorded result]
Technical reviewBest possible solution: Freeze permission facts once while retaining existing Stop, caller-lifetime, and session/turn custody fences at the owning boundaries. Do we have a high-confidence way to reproduce the issue? Current-main source establishes permission comparisons during started operations; this read-only review ran no target code, while current-head CI independently exposes the introduced lifecycle regression. Is this the best way to solve the issue? Removing permission rereads follows the accepted contract, but deleting an opaque caller assertion also removes unrelated lifecycle checks and is broader than the required fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6523d6ace21c. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The skill-library change drops existing custody checks along with permission rechecks. EvidenceSecurity concerns:
What I checked:
PR surfaceSource -60, Tests -275, Other -2. Total -337 across 65 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 23, 2026, 5:58 AM ET / 10:58 UTC. |
…art 2 - Restore src/skills/library/store-access.ts: its authority closure also carries Stop (run close, claim loss, disconnect). - Restore the worker reclaim authorize plumbing and the message-action read fence wording; both move to the next R6d PR. - Fix the restart-recovery and operator-role-policy test expectations; re-prune the session-identity allowlist. Co-authored-by: obviyus <[email protected]>
|
Stopped under the 2-CI-round rule; this PR will not be repaired or landed as-is. Reason: State of head Proposed split:
|
…ation requireCurrentConfig refuses at sandbox preparation start to reuse a hot container built under an older config; it is a data fence on the container's config, not a mid-run authority re-check. Co-authored-by: obviyus <[email protected]>
…er revoke case - github-publication-requester, cli-runner before_agent_reply, subagent authority notice: expected text only. - github-pr-workspace-preparation: delete the case that revokes the maintainer role mid-request (removed mid-run re-check). Co-authored-by: obviyus <[email protected]>
|
Stopped again under the lead's rule: the authorized round on
The restore itself is in A ready fix exists locally and is not pushed: commit |
…mance Co-authored-by: obviyus <[email protected]>
|
Maintainer override: every red on head Also: |
|
Landed as 6c8c6dd.
|
…04110) #204037 reworded the released-execution refusal and the restart-recovery start refusal. Four tests still matched the old text; the refusals stay asserted. Tests only. Co-authored-by: Ayaan Zaidi <[email protected]>
…nd GitHub publication (openclaw#204037) ## Problem Authority is checked once, when work starts (AGENTS.md "Choose good compromises"). Infra, state, channel, plugin, skill and GitHub publication code still refused started work with messages such as "authority changed" or "authority is no longer active". Some of these checks re-read permissions, roles, credentials or config in the middle of a run. Others are valid Stop, run-close or data fences, but their messages said "authority", so they looked like permission refusals. ## Change Each site was classified with one test: can the check fire when only a permission, approval or config changes and nothing about the run or data changes? - Yes: mid-run authority re-check. The check and its plumbing are deleted. - No: Stop, run close or a data fence. The check stays. The message now says what ended and what to do next. This is part 1 of the R6d area. It covers `src/infra`, `src/state`, `src/plugins`, `src/cron`, the device-token connect path and `src/gateway/github-publication*`. The rest of the area moves to part 2. That includes the message-action read fence, the skill library and the worker reclaim `authorize` plumbing (see "Moved to part 2"). | Site | Old message | Kind | Action | |---|---|---|---| | `infra/agent-run-approval-leases.ts` | agent run approval authority is no longer active | run close (approval scope) | reworded: "The approval scope ended. Start a new turn to retry." | | `infra/agent-run-registry.ts` `claimAgentRunApprovalAuthority` | same | data fence (exact run/approval claim) | reworded, same text | | `infra/device-pairing-tokens.ts` + `gateway/server/ws-connection/connect-device-tokens.ts`, `connect-device-pairing.ts` | Device token issuance authority changed / Profile membership changed during device token issuance | mixed: live connect-policy and OpenClaw ID membership re-reads + profile-row lifetime | policy and membership re-reads deleted (with the `isConnectAuthorizationCurrent` argument); profile-row fence kept: "Device token issuance ended. Reconnect to retry." | | `infra/device-pairing-worker.ts` | Device pairing authority changed | data fence (worker writer admission) | reworded: "Device pairing ended. Reconnect to retry." | | `infra/net/fetch-request-authority.ts` | Guarded request authority is no longer active. | run close (request scope) | reworded: "The guarded request ended. Start a new request to retry." | | `infra/operator-authority-error.ts` | operator {execution,source} authority is no longer active… | run close (released execution) | reworded: "Operator execution ended. Reconnect to the Gateway, then resend your message." | | `infra/restart-recovery-errors.ts` | Restart recovery operator authority changed… | start admission of recovered input | reworded: "Restart recovery could not admit this input. Start a new user turn." | | `infra/restart.ts` (log) | scheduled restart cancelled: requester authority changed | admission of queued work at its start (a deferred restart) | reworded: "scheduled restart cancelled: the requester may no longer restart the Gateway" | | `cron/active-jobs.ts` `isCronSelfRemovalCurrent` and markers | (no string) | Stop + occurrence/marker/generation fences | kept, file not changed | | `state/github-publication-source.kernel.ts`, `gateway/github-publication-source.ts` | GitHub publication source authority changed. | data fence (source facts, receipts, session row) + profile/credential event subscriptions | `onUserProfilesChanged` and `observeUserGitHubConnectionAuthority` revocation subscriptions deleted; source-fact and session-row fences kept: "GitHub publication source ended. Retry the publication." | | `state/github-publication-worker.ts`, `gateway/github-publication-store.worker.ts` | GitHub publication turn authority changed before recording. | data fence (turn claim) | reworded: "GitHub publication turn ended. Retry the publication." | | `gateway/github-publication.ts` | GitHub publication authority changed before recording. | mixed: turn claim + credential identity re-read | `matchesCurrentGitHubPublicationIdentity` re-read deleted; turn-claim fence kept, same text as above | | `gateway/github-publication-execution-identity.ts` | GitHub publication session authority changed. | mixed: execution custody + repeated credential identity re-read | identity re-read deleted; custody fence kept: "GitHub publication execution ended. Retry the publication." | | `gateway/github-publication-coordinator-methods.ts` | …session authority changed during snapshot. | data fence (placement generation) | reworded: "GitHub publication session moved during snapshot. Retry the publication." | | `gateway/github-publication-evidence.ts` | Upload authority changed after the request started… | lifecycle | reworded: "The upload ended after dispatch. GitHub may have created the attachment; reconcile the original upload before retrying." | | `gateway/github-publication-worktree-owner.ts` | …workspace authority changed. | data fence (worktree identity) | reworded: "GitHub publication workspace moved. Retry the publication." | | `gateway/github-repository-publication.ts` | …session authority changed. | data fence (workspace and execution owner) | reworded: "GitHub publication session moved. Retry the publication." | | `state/user-channel-identity-operations.ts` (2) | Profile authority changed while preparing the … request | snapshot consistency during admission (before work) | reworded: "The profile snapshot could not settle. Retry the … request" | | `plugins/hooks.ts` | prompt tool authority is no longer active | run close (prompt build) | reworded: "Prompt build ended. Start a new turn to retry." | | `plugins/runtime/index.ts` | Session workspace authority changed during sandbox preparation. | session-row fence + start-time container-config fence (`requireCurrentConfig`) | both kept; reworded: "Session workspace preparation ended. Retry the action." An earlier head of this PR dropped `requireCurrentConfig: true`. It is restored: it refuses, when preparation starts, to reuse a hot sandbox container built under an older config, so it is a data fence on the container's config, not a mid-run authority re-check. | Tests that asserted a refusal after a mid-run permission, credential or membership change are deleted: issuance membership/policy, GitHub publisher identity at push/ref/observation, `revoked-before-run` disclosure, inherited-checkpoint `publisher-revoked`. Tests for Stop, run close and data fences keep their conditions; only their expected text changed. The authority-refusal ratchet count is 0 for every file this PR touches, and the session-identity allowlist is pruned to match. Not changed here, because other PRs own these paths: `src/shared/channel-read-authority.ts`, `src/gateway/server-methods/skills-library.ts`, and the `restart-request.ts` hooks produced in `server-methods/restart.ts`. Moved to part 2 (cut less after CI round 1 and the local review): - `src/skills/library/store-access.ts`: its `authority.assertCurrent()` also carries Stop (run close, claim loss, disconnect), as `node-claude-skill-runtime.test.ts` showed. The permission reads need separating from that Stop first. - Worker reclaim `authorize`/`reauthorize` plumbing (`server-worker-placement-reclaim.ts`, `placement-dispatch.ts`, `placement-reclaim.ts`): the same callback carries the session-target fence and gates Gateway restoration, so removing it touches Stop and ingress behavior across many tests. - `src/channels/plugins/message-action-dispatch.ts`: this is a registration-lifetime fence, so only its wording would change, and about 10 channel tests assert the substring. Accepted edge cases: - A GitHub publication that starts under a personal credential keeps that credential until it finishes, even if the credential is disconnected mid-publication. - A device token issuance that started during connect still completes if OpenClaw ID membership changes during the handshake. The next connect uses the new membership. ## User impact - A started run or GitHub publication is no longer refused because a role, scope, credential or membership changed mid-run. The change applies to the next request. - Stop, run close and data changes still end work. The messages now say what ended and what to do next, not "authority changed". ## Evidence - Local, before push: `tsgo:core`, `tsgo:test`, oxlint on changed files (0 findings), lifetime-check and session-identity ratchets. - Local `ocx test`: touched tests plus importers of the changed GitHub publication, device pairing and restart-recovery sources, and every OURS file from CI round 1. - `test/gateway-yield-restart.e2e.test.ts` fails locally with `SyntaxError: Unexpected end of JSON input` in the mock provider server under host load ~80. It fails the same way on the merge base `d440428264dc`, so it is not caused by this PR. - One-admission E2E (`run.sh`): Q, R and S pass on `a01b868342`, `0fb62b2697` and `98989be54e` (`/tmp/one-admission-e2e.CEOZ92/verdict.json`, `results.jsonl`). Later heads change test files only, so the production code is identical to `98989be54e`. Co-authored-by: Ayaan Zaidi <[email protected]>
…enclaw#204110) openclaw#204037 reworded the released-execution refusal and the restart-recovery start refusal. Four tests still matched the old text; the refusals stay asserted. Tests only. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
Authority is checked once, when work starts (AGENTS.md "Choose good compromises"). Infra, state, channel, plugin, skill and GitHub publication code still refused started work with messages such as "authority changed" or "authority is no longer active". Some of these checks re-read permissions, roles, credentials or config in the middle of a run. Others are valid Stop, run-close or data fences, but their messages said "authority", so they looked like permission refusals.
Change
Each site was classified with one test: can the check fire when only a permission, approval or config changes and nothing about the run or data changes?
This is part 1 of the R6d area. It covers
src/infra,src/state,src/plugins,src/cron, the device-token connect path andsrc/gateway/github-publication*. The rest of the area moves to part 2. That includes the message-action read fence, the skill library and the worker reclaimauthorizeplumbing (see "Moved to part 2").infra/agent-run-approval-leases.tsinfra/agent-run-registry.tsclaimAgentRunApprovalAuthorityinfra/device-pairing-tokens.ts+gateway/server/ws-connection/connect-device-tokens.ts,connect-device-pairing.tsisConnectAuthorizationCurrentargument); profile-row fence kept: "Device token issuance ended. Reconnect to retry."infra/device-pairing-worker.tsinfra/net/fetch-request-authority.tsinfra/operator-authority-error.tsinfra/restart-recovery-errors.tsinfra/restart.ts(log)cron/active-jobs.tsisCronSelfRemovalCurrentand markersstate/github-publication-source.kernel.ts,gateway/github-publication-source.tsonUserProfilesChangedandobserveUserGitHubConnectionAuthorityrevocation subscriptions deleted; source-fact and session-row fences kept: "GitHub publication source ended. Retry the publication."state/github-publication-worker.ts,gateway/github-publication-store.worker.tsgateway/github-publication.tsmatchesCurrentGitHubPublicationIdentityre-read deleted; turn-claim fence kept, same text as abovegateway/github-publication-execution-identity.tsgateway/github-publication-coordinator-methods.tsgateway/github-publication-evidence.tsgateway/github-publication-worktree-owner.tsgateway/github-repository-publication.tsstate/user-channel-identity-operations.ts(2)plugins/hooks.tsplugins/runtime/index.tsrequireCurrentConfig)requireCurrentConfig: true. It is restored: it refuses, when preparation starts, to reuse a hot sandbox container built under an older config, so it is a data fence on the container's config, not a mid-run authority re-check.Tests that asserted a refusal after a mid-run permission, credential or membership change are deleted: issuance membership/policy, GitHub publisher identity at push/ref/observation,
revoked-before-rundisclosure, inherited-checkpointpublisher-revoked. Tests for Stop, run close and data fences keep their conditions; only their expected text changed. The authority-refusal ratchet count is 0 for every file this PR touches, and the session-identity allowlist is pruned to match.Not changed here, because other PRs own these paths:
src/shared/channel-read-authority.ts,src/gateway/server-methods/skills-library.ts, and therestart-request.tshooks produced inserver-methods/restart.ts.Moved to part 2 (cut less after CI round 1 and the local review):
src/skills/library/store-access.ts: itsauthority.assertCurrent()also carries Stop (run close, claim loss, disconnect), asnode-claude-skill-runtime.test.tsshowed. The permission reads need separating from that Stop first.authorize/reauthorizeplumbing (server-worker-placement-reclaim.ts,placement-dispatch.ts,placement-reclaim.ts): the same callback carries the session-target fence and gates Gateway restoration, so removing it touches Stop and ingress behavior across many tests.src/channels/plugins/message-action-dispatch.ts: this is a registration-lifetime fence, so only its wording would change, and about 10 channel tests assert the substring.Accepted edge cases:
User impact
Evidence
tsgo:core,tsgo:test, oxlint on changed files (0 findings), lifetime-check and session-identity ratchets.ocx test: touched tests plus importers of the changed GitHub publication, device pairing and restart-recovery sources, and every OURS file from CI round 1.test/gateway-yield-restart.e2e.test.tsfails locally withSyntaxError: Unexpected end of JSON inputin the mock provider server under host load ~80. It fails the same way on the merge base0ee046199dc2, so it is not caused by this PR.run.sh): Q, R and S pass ona01b868342,0fb62b2697and98989be54e(/tmp/one-admission-e2e.CEOZ92/verdict.json,results.jsonl). Later heads change test files only, so the production code is identical to98989be54e.