Skip to content

refactor: drop mid-run authority re-checks in infra, state, plugins and GitHub publication - #204037

Merged
obviyus merged 6 commits into
mainfrom
refactor/rest-refusals-once
Nov 23, 2026
Merged

obviyus merged 6 commits into
mainfrom
refactor/rest-refusals-once

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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 0ee046199dc2, 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.

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

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

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

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

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

  • Current SHA: b91c80778b6ce57c0dc5058c9fe2807e13ec8e66
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server/ws-connection/connect-device-pairing.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-device-tokens.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-tokens.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

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

  • Before: Token issuance can be refused when membership changes during the handshake.
  • After: The admitted handshake can finish while its profile remains valid; the next connection uses the changed membership.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The direction is worthwhile, but runtime proof is absent and source plus CI establish a lifecycle regression and incomplete consumer migration.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Started operations can fail after a permission change, and lifecycle errors can misleadingly describe that failure as lost authority.
Reason: The maintainer-authored direction implements the repository's explicit one-admission policy without adding settings or capabilities.

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

Before merge

  • Preserve caller lifecycle fences during skill publication (P1) - Deleting authority.assertCurrent() from the retained assertion removes more than role and scope rereads: personal authoring carries run/receipt custody through this callback, and node execution adds claim, connection, and assignment fences. If saveSkillLibrary is awaiting staging publication when that custody ends, access.write now grants the database operation using only the still-live database and copied identity fields. Current-head CI confirms an entry is persisted in all five node publication cases at node-claude-skill-runtime.test.ts:493. Preserve those existing lifecycle/data checks while removing only permission re-evaluation.
  • Complete the lifecycle-error consumer migration (P2) - The renamed errors leave affected suites deterministically red: Slack, Discord, Matrix, Mattermost, and Telegram consumers still match the old registration wording, and operator-run-recovery.effects.test.ts still matches /operator|profile/. Two edited expectations also select the wrong producer: cli-runner.before-agent-reply-cron.test.ts:345 receives the guarded-request error, while operator-role-policy.test.ts:582 receives 'This agent run is no longer active'. CI annotations confirm these mismatches. Update the consumers to the actual retained lifecycle errors without weakening their rejection checks.
  • Migrate remaining reclaim permission-revocation cases (P2) - Moving authorization to reclaim start intentionally permits a later permission change, but placement-gateway-recovery.test.ts still expects its 'revoked authorization' variant to reject, and placement-move-abandon.test.ts still expects its 'authority' variant to prevent cleanup. Current-head CI fails both assertions after admitted reclaim completes. Remove or update these obsolete variants while retaining their distinct placement-generation, intent, and failed-recovery cases.
  • Resolve security concern: Stale node custody can publish persistent skill instructions - The affected effect is publication into the person's durable skill library after the node turn loses its claim or session assignment; this is a concrete custody regression, separate from the accepted decision to let permission changes affect only later requests.
  • Explain or restore the original intent of Skill-library worker admission - a38eefe: The worker migration preserved live host grants and existing placement/session ownership through transaction and commit; the current rationale explains removing permission comparisons but not losing these custody checks.

Findings

  • [P1] Preserve caller lifecycle fences during skill publication — src/skills/library/store-access.ts:55-60
  • [P2] Complete the lifecycle-error consumer migration — src/channels/plugins/message-action-dispatch.ts:340-341
  • [P2] Migrate remaining reclaim permission-revocation cases — src/gateway/worker-environments/placement-dispatch.ts:537-538
  • [high] Stale node custody can publish persistent skill instructions — src/skills/library/store-access.ts:55

Provenance

  • Skill-library worker admission changes intended behavior without addressing why it exists (a38eefe: The worker migration preserved live host grants and existing placement/session ownership through transaction and commit; the current rationale explains removing permission comparisons but not losing these custody checks.)

Tests

  • Missing end-to-end proof: Supply redacted Gateway or CLI output exercising a changed publication or library operation across a permission change, subsequent admission, and Stop; no base-red/head-green demonstration is supplied.
Agent review details

How this fits together

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

Technical review

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

  • [P1] Preserve caller lifecycle fences during skill publication — src/skills/library/store-access.ts:55-60
    Deleting authority.assertCurrent() from the retained assertion removes more than role and scope rereads: personal authoring carries run/receipt custody through this callback, and node execution adds claim, connection, and assignment fences. If saveSkillLibrary is awaiting staging publication when that custody ends, access.write now grants the database operation using only the still-live database and copied identity fields. Current-head CI confirms an entry is persisted in all five node publication cases at node-claude-skill-runtime.test.ts:493. Preserve those existing lifecycle/data checks while removing only permission re-evaluation.
    Confidence: 0.99
  • [P2] Complete the lifecycle-error consumer migration — src/channels/plugins/message-action-dispatch.ts:340-341
    The renamed errors leave affected suites deterministically red: Slack, Discord, Matrix, Mattermost, and Telegram consumers still match the old registration wording, and operator-run-recovery.effects.test.ts still matches /operator|profile/. Two edited expectations also select the wrong producer: cli-runner.before-agent-reply-cron.test.ts:345 receives the guarded-request error, while operator-role-policy.test.ts:582 receives 'This agent run is no longer active'. CI annotations confirm these mismatches. Update the consumers to the actual retained lifecycle errors without weakening their rejection checks.
    Confidence: 0.99
  • [P2] Migrate remaining reclaim permission-revocation cases — src/gateway/worker-environments/placement-dispatch.ts:537-538
    Moving authorization to reclaim start intentionally permits a later permission change, but placement-gateway-recovery.test.ts still expects its 'revoked authorization' variant to reject, and placement-move-abandon.test.ts still expects its 'authority' variant to prevent cleanup. Current-head CI fails both assertions after admitted reclaim completes. Remove or update these obsolete variants while retaining their distinct placement-generation, intent, and failed-recovery cases.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • GitHub publication requester and publisher checks changes intended behavior with a stated reason (fix: enforce requester permissions for shared GitHub publication #154655: Publication originally retained requester and publishing-identity checks before effects; later admission work and this maintainer-authored PR explicitly allow admitted operations to retain their credential.)
  • Device-token handshake policy and membership checks changes intended behavior with a stated reason (fa6f9f8: Person-bound token preparation checked current connect policy and membership; this PR explicitly accepts completion of an admitted handshake while retaining profile lifetime checks.)
  • Worker reclaim authorization changes intended behavior with a stated reason (cbc53ac: Reclaim retained authorization across waits; this PR explains moving permission admission to the start while preserving session-generation and workspace ownership fences.)
  • Lifecycle error wording keeps the original intent (unknown: Original blobs show retained resource, run, and data conditions; local history metadata was searched, but missing historical blobs prevented resolving every message's original introduction.)

Testing

Proof path: in-process harness.

Security

Needs attention: The skill-library change drops existing custody checks along with permission rechecks.

Evidence

Security concerns:

  • [high] Stale node custody can publish persistent skill instructions — src/skills/library/store-access.ts:55
    The affected effect is publication into the person's durable skill library after the node turn loses its claim or session assignment; this is a concrete custody regression, separate from the accepted decision to let permission changes affect only later requests.
    Confidence: 0.99

What I checked:

PR surface

Source -60, Tests -275, Other -2. Total -337 across 65 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 29 97 157 -60
Tests 35 134 409 -275
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 7 9 -2
Total 65 238 575 -337

Preflight source

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

Labels

Label changes:

  • add P2: This is useful admission-policy cleanup with concrete merge blockers, without an established urgent production incident.
  • add merge-risk: 🚨 security-boundary: A node-side skill publication can persist after its turn claim or assignment custody ends.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is useful admission-policy cleanup with concrete merge blockers, without an established urgent production incident.
  • merge-risk: 🚨 security-boundary: A node-side skill publication can persist after its turn claim or assignment custody ends.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • 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, 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]>
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Stopped under the 2-CI-round rule; this PR will not be repaired or landed as-is.

Reason: src/plugins/runtime/index.ts drops requireCurrentConfig: true from plugin sandbox preparation. That flag is not a mid-run permission re-check. At preparation, which is the start of the work, it refuses to reuse a hot container built under an older sandbox config. Without it, a restricted plugin dispatch can reuse a container whose policy predates a tightening. The fix is to restore that one line, which would be a third CI round.

State of head 0fb62b2697: local review clean; one-admission E2E Q/R/S pass (/tmp/one-admission-e2e.3xM327). Round-1 OURS failures were fixed in round 2 or moved to part 2. gateway-yield-restart.e2e also fails on merge base 0ee046199dc2.

Proposed split:

  1. R6d-1b, a new PR: this PR's diff with src/plugins/runtime/index.ts reduced to the message reword only (keep requireCurrentConfig: true). That leaves infra, state, plugin hooks, the device-token connect path and GitHub publication.
  2. R6d-2: the remaining 59 string files in src/gateway/** and extensions/**, plus the skill library (store-access.ts authority closure also carries Stop; separate it first), the worker reclaim authorize/reauthorize plumbing, and the message-action read fence wording.

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

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Stopped again under the lead's rule: the authorized round on 98989be54e has OURS reds.

ci-triage on 98989be54e:

  • OURS: subagent-registry.authority-notice.test.ts (expects "start a new user turn."; the restart-recovery message now says "Start a new user turn."), cli-runner.before-agent-reply-cron.test.ts (a second heldClaim assertion still expects "no longer active"). The local review also flags github-publication-requester.test.ts:160 (expects "no longer active"). All three are stale expected text from the reworded run-end messages. No production behavior is involved.
  • MAIN-ALSO: github-publication-imported-actions, github-pr-workspace-preparation, environments.suggested-profile, question.{communication,recovery,session-access}, ui sidebar-complete-roster (and gateway-yield-restart.e2e, red on base 0ee046199dc2).

The restore itself is in 98989be54e: requireCurrentConfig: true is back, and the importer set (52 files) passes locally. E2E Q/R/S pass on 98989be54e (/tmp/one-admission-e2e.CEOZ92).

A ready fix exists locally and is not pushed: commit 64c14ef0c2 (test-only, 4 files, +7/−28). It updates the three expectations above and deletes the github-pr-workspace-preparation "revoked" case, which revokes the maintainer role mid-request (the removed mid-run re-check). Locally cli-runner.before-agent-reply-cron, subagent-registry.authority-notice, github-pr-workspace-preparation and github-publication-requester pass; oxlint is clean. Pushing it is one more CI round and needs the lead's call.

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: every red on head b91c80778b also fails on main; none touches a file this PR changes.

# PR #204037 head b91c80778b6c; main run 45165162201
checks-node-changed-compact-large-38	src/gateway/server.sessions.create.durability.test.ts	MAIN-ALSO
checks-node-changed-compact-large-39	src/gateway/github-publication-imported-actions.test.ts	MAIN-ALSO
checks-node-changed-compact-large-49	src/gateway/server-methods/environments.suggested-profile.test.ts	MAIN-ALSO
checks-node-changed-compact-large-49	src/gateway/server-methods/question.communication.test.ts	MAIN-ALSO
checks-node-changed-compact-large-49	src/gateway/server-methods/question.recovery.test.ts	MAIN-ALSO
checks-node-changed-compact-large-49	src/gateway/server-methods/question.session-access.test.ts	MAIN-ALSO
checks-ui-e2e (1/3)	ui/src/e2e/sidebar-complete-roster.e2e.test.ts	MAIN-ALSO
checks-node-changed-compact-large-26	src/gateway/server-methods/push-authority.test.ts	MAIN-ALSO (ci-triage on 64c14ef0c2, main run 45165162201)

Also: test/gateway-yield-restart.e2e.test.ts fails the same way on merge base 0ee046199dc2 locally. openclaw/ci-gate is the aggregate of the jobs above. Local review on this head is clean; the one-admission E2E Q/R/S passes on 98989be54e (production code identical to this head; later commits are test-only).

@obviyus
obviyus merged commit 6c8c6dd into main Nov 23, 2026
145 of 152 checks passed
@obviyus
obviyus deleted the refactor/rest-refusals-once branch November 23, 2026 12:51
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 6c8c6dd.

  • What changed: infra, state, plugin hooks, the device-token connect path and GitHub publication stop re-reading permissions, credentials or membership mid-run. Stop, run-close and data fences stay; their refusals now say what ended and what to do next instead of "authority changed". The sandbox requireCurrentConfig start-time check is kept.
  • Proof: local review clean on b91c80778b; one-admission E2E Q/R/S pass on 98989be54e (later commits are test-only); every remaining CI red also fails on main (override above).
  • Next (R6d-2): the remaining src/gateway/** and extensions/** strings, the skill-library store-access Stop split, the worker reclaim authorize plumbing and the message-action read-fence wording.

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

Labels

agents Agent runtime and tooling gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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.

1 participant