Skip to content

refactor: drop mid-request authority re-checks in bundled plugins and update/MCP sign-in (R6d part 2) - #204077

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

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

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

OpenClaw checks authority once, when work starts (AGENTS.md "Choose good compromises"). Bundled plugins and a few Gateway leftovers still refused started work with "authority changed" / "authority is no longer active/current". Some of these checks re-read a permission, role, scope, credential or config in the middle of a request. Others are valid Stop, run-close or data fences whose text claimed authority.

Change

R6d part 2, first half (split rule: ~65 production files remain in the area; this PR takes extensions/** plus the R6b leftovers update-admission.ts and mcp-auth-login.ts). 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, request close, data fence) → kept, reworded to say what ended and the next step.
Site Old message Kind Action
extensions/browser/.../pw-tools-core.interactions.navigation.ts Browser interaction authority changed fallback text for the caller's assertion reworded: "Browser interaction ended. Retry the action."
extensions/clickclack/.../service-open.ts ClickClack discussion authority changed while opening the channel mixed: account config re-read + session entry fence config re-read deleted; session fence kept: "The discussion session ended. Open the discussion again."
extensions/clickclack/.../service.ts ClickClack discussion authority changed before channel update mixed: account config state + binding/session/revocation data config term deleted; data fences kept: "The discussion binding or session moved. Retry the update."
extensions/codex/src/app-server/native-hook-relay.ts Native spawn execution authority is no longer current fallback text of the spawn's own admission (new work) reworded: "Native subagent spawn was denied. Start a new turn to retry."
extensions/codex/src/node-app-server.ts Worker Codex session authority changed data mismatch (request session ≠ context session) reworded
extensions/discord/.../message-handler.draft-preview.ts Discord retained progress authority is no longer current; Discord channel policy is no longer current lifecycle (retired) + channel policy re-read policy re-read and isPolicyCurrent plumbing deleted; retirement fence kept: "Discord retained progress ended. Start a new turn to retry."
extensions/discord/.../native-command-auth.ts Discord command authority changed / Discord owner authority changed authority already removed on main by #204048; this PR took main's version at the merge
extensions/geolocation/index.ts Gateway requester authority changed authority (client.invalidated, hasCurrentClientAuthority) deleted; signal + session mutation fences kept
extensions/google/research-gateway.ts …authority changed before delivery… provider/session fence reworded: "…the provider or session ended before delivery…"
extensions/knowledge/src/storage-protocol.ts Knowledge authority changed during the operation. worker sentinel for main-thread refusals (caller Stop, service lifetime, store reassignment, runtime retirement) reworded only (cut less): "Knowledge operation ended. Retry the original request."
extensions/memory-wiki/src/gateway.ts Memory Wiki request authority is no longer current. authority + request lifetime hasCurrentClientAuthority() re-read deleted; active/signal kept: "Memory Wiki request ended. Start a new request to retry."
extensions/skill-workshop/src/gateway-methods.ts Gateway requester authority changed authority deleted; signal + commit guard kept
extensions/telegram/src/telegram-ingress-non-retryable.ts matcher for "Gateway requester authority changed" reader of the deleted message matcher and callback-authority-changed reason deleted (no other producer)
extensions/whatsapp/src/agent-tools-login.ts WhatsApp login authority is no longer active. Stop (signal) reworded: "WhatsApp login was stopped. Start a new login to retry."
extensions/workboard/src/gateway.ts Caller authority is no longer active. authority deleted; signal and session fences kept
extensions/workboard/src/store-workflow.ts card workspace authority changed before claim. data fence (card metadata) reworded: "card workspace or placement changed. Retry the claim."
src/gateway/server-methods/update-admission.ts + src/infra/update-managed-service-handoff*.ts Update requester authority changed before parking. authority (owner, commands.restart config re-read at park) retainUpdateRequesterAuthority deleted; the handoff's requesterAuthority carries only the Stop signal; 7 assertCurrent() reads removed
src/gateway/server-methods/mcp-auth-login.ts Sign-in authority is no longer active. authority (client.invalidated, admin scope re-read) deleted; the server/registry fence and connection signal stay. The 10 forced-effects tests now end the sign-in by replacing the method registry (the kept fence) instead of revoking the scope. The "admin scope" variant of "rejects token publication" is deleted.

Deleted tests (they asserted a mid-request permission refusal): geolocation/skill-workshop/workboard hasCurrentClientAuthority cases, ClickClack account-config change variants (before list, during create), Telegram callback-authority-changed drain case, the skill-workshop contract case in server-methods.workshop-contract.test.ts, and the MCP sign-in "admin scope" variant. Stop and data-fence tests keep their conditions; only their expected text changed.

The lifetime-check ratchet reports 0 counted strings in every touched production file. config/session-identity-allowlist.txt is pruned (6280 → 6273 pins).

Accepted edge cases:

  • A ClickClack open/rename that started keeps its account even if the account config changes during the HTTP calls.
  • An update that started keeps going to park even if commands.restart is disabled or the requester loses owner rights after admission. The start-time check in update.ts is unchanged.

Not in this PR (part 3)

  • The remaining 43 string files in src/gateway/** listed in the R6d-2 list (agent-runtime-identity-token.ts … talk/client-run-authority.ts).
  • src/skills/library/store-access.ts: split Stop (run close, claim loss, disconnect) out of the authority check, then delete the authority part.
  • Worker reclaim authorize/reauthorize plumbing (placement-dispatch.ts, placement-reclaim.ts, server-worker-placement-reclaim.ts).
  • src/channels/plugins/message-action-dispatch.ts wording (cut less). It is a registration-lifetime fence, so only the text would change, but the local run showed 21 cases in 8 channel read tests (test/channel-message-read-authority, discord-metadata, feishu, matrix, slack-download, telegram-history, mattermost-read-authority.contract, message-action-dispatch.registry) assert the generic "no longer active" substring, mixed with other producers of that text. Rewording needs each assertion split by producer; it goes with part 3. Its read fence also ends a read on a trustedOfficialInstall downgrade, which is an authority term to delete there.

User impact

A started request, command, update or sign-in is no longer refused because a role, scope, credential 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:extensions, 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.
  • ocx test (continue-on-failure) on 78 files: every touched test file plus every test that imports a changed source directly (the transitive test-support set is 162 files, over the 150 cap; CI runs it). Reds were only the message-action wording (reverted, see above) and one ClickClack mid-open config-change case (deleted); the 21 failed/invalidated files were rerun green.
  • pnpm check:changed: typecheck, coercion and deprecated-API guards pass; its dead-export scan fails on exports this PR does not touch (pre-existing on main).
  • Production vs main after the merge: +22/−99.
  • Local ClawSweeper review on 4e5a9c1a1f43: "patch is correct", no findings.
  • One-admission E2E on 4e5a9c1a1f43 (isolated scratch Gateway, real agent turn): verdict pass; R.running-turn-finishes pass, Q.queued-input-refused-visibly pass, S.stop-cancels pass (verdict.json, results.jsonl kept in the worker's proof directory).

… update/MCP sign-in (R6d part 2)

Authority is checked once at start. Delete the remaining permission, role,
scope and config re-reads in bundled plugins (Discord native commands and
draft preview, geolocation, skill workshop, workboard, memory wiki,
ClickClack account config), the update park requester re-check and the MCP
sign-in scope re-check. Keep Stop, request close and data fences, reworded
to say what ended and the next step.

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

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

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

These security sensitive changes were made:

  • src/gateway/server-methods/mcp-auth-login.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

…s-part2

# Conflicts:
#	extensions/discord/src/monitor/native-command-auth.ts
#	extensions/discord/src/monitor/native-command.interaction-boundary.test.ts
#	extensions/discord/src/monitor/native-command.ts
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR removes repeated permission checks from admitted plugin operations, updates, and MCP sign-in while retaining cancellation and data guards.

Example: An administrator starts MCP browser sign-in, then loses operator.admin while OAuth completes.

  • Before: The sign-in rechecks the scope and refuses continuation.
  • After: The admitted sign-in can finish; connection closure and server changes still stop it.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is coherent and has no actionable correctness finding, but the supplied product-proof summary does not establish the changed entry points.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Already admitted operations can fail because permissions or configuration change while they are running, and some lifecycle errors incorrectly describe an authority failure.
Reason: The maintainer-authored direction matches root policy, documents accepted effects, and removes redundant machinery within its stated stage.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: the scoped cleanup follows the recorded one-admission policy, and review found no discrete introduced defect.

Priority: P2
Reviewed head: 4e5a9c1a1f4315c057ba4f2ab61e97374335b5ef

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted shipped-path output for MCP sign-in and managed-update parking under retained admission, including a latest-stable update with existing settings intact; no changed-path base/head reproduction is supplied.
Agent review details

How this fits together

Gateway admission authorizes requests before plugin and update owners perform network, credential, or storage operations and return their outcomes.

flowchart TD
  A[Operator request] --> B[Gateway admission]
  B --> C[Plugin or update owner]
  C --> D[Cancellation and data guards]
  D --> E[Transport or storage effect]
  E --> F[Recorded result]
Loading

Technical review

Best possible solution:

Keep authority admission in its existing owners while preserving Stop, session, registry, and storage protections.

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

Current-main source directly shows the repeated scope and client-authority checks; no runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Removing the repeated predicates and their plumbing is the smallest scoped change using existing owners; the retained guards still distinguish cancellation and changed data from permission changes.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Recorded authority contract: Root policy permits admitted work to finish after permission changes and requires fresh admission for newly started queued, retried, or replayed work; all changed-path ancestor guides were read. (AGENTS.md:12, 4e5a9c1a1f43)
  • Pinned introduction and simplification: The introduced diff removes repeated checks and their plumbing without adding an alternative authority owner; production changes are +22/-99 lines and tests/support are +64/-237. (4e5a9c1a1f43)
  • MCP admission remains enforced: Administrator scope is still required at entry; registry identity, selected server, browser lifetime, and connection cancellation remain checked after admission. (src/gateway/server-methods/mcp-auth-login.ts:46, 4e5a9c1a1f43)
  • Current-main necessity: Fetched main still contains the removed MCP scope recheck and Memory Wiki client-authority recheck, so the central changes are not already implemented there. (src/gateway/server-methods/mcp-auth-login.ts:115, 7f6e113c68b4)
  • Retained session and storage protections: ClickClack retains prepared-session validation and binding comparison; Workboard retains abort, session-access, mutation-authorization, and commit guards. (extensions/workboard/src/gateway.ts:238, 4e5a9c1a1f43)
  • Accepted update tradeoff: The maintainer-authored body explicitly accepts finishing an admitted update after owner rights or commands.restart change; the handoff retains the Stop signal and existing custody checks. (src/infra/update-managed-service-handoff.ts:1255, 4e5a9c1a1f43)

Likely related people:

  • Ayaan Zaidi: Raw commit 2a48569 adds src/gateway/server-methods/mcp-auth-login.ts:85 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2a48569bfbb8; files: src/gateway/server-methods/mcp-auth-login.ts)
  • Josh Lehman: Raw commit 0dc63ee adds extensions/memory-wiki/src/gateway.ts:127 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0dc63eecaddd; files: extensions/memory-wiki/src/gateway.ts)

PR surface

Source -77, Tests -173, Other -5. Total -255 across 35 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 21 22 99 -77
Tests 13 64 237 -173
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 7 -5
Total 35 88 343 -255

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.

Review metrics

Metric Value Why it matters
Production versus test changes Production +22/-99; tests and support +64/-237 The reduction removes repeated authority plumbing and obsolete refusal expectations without adding production machinery.

Labels

Label changes:

  • add P2: Useful runtime lifecycle cleanup with limited impact; no urgent introduced regression was established.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: Useful runtime lifecycle cleanup with limited impact; no urgent introduced regression was established.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 23, 2026, 8:58 AM ET / 13:58 UTC.

@obviyus
obviyus merged commit 59ae4e0 into main Nov 23, 2026
165 checks passed
@obviyus
obviyus deleted the refactor/rest-refusals-part2 branch November 23, 2026 14:06
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 59ae4e0. Bundled plugins, the update park step and MCP sign-in no longer refuse a started request when a permission, scope or config changes; Stop, request close and data fences stay, with messages that name what ended. Proof: CI green on 4e5a9c1, local ClawSweeper review clean, one-admission E2E Q/R/S pass. Remaining R6d-2 scope (43 gateway string files, skill-library Stop split, worker reclaim plumbing, message-action wording) moves to part 3.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
… update/MCP sign-in (R6d part 2) (openclaw#204077)

Authority is checked once at start. Delete the remaining permission, role,
scope and config re-reads in bundled plugins (geolocation, skill workshop,
workboard, memory wiki, Discord draft preview, ClickClack account config),
the update park requester re-check and the MCP sign-in scope re-check. Keep
Stop, request close and data fences, reworded to say what ended and the next
step. MCP sign-in forced-effects tests now end the sign-in through the kept
registry fence.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…ate acts on it (#201668)

* fix(update): verify recorded data-at-risk marks before repair acts on them

* fix(update): verify any unverified data-at-risk mark and honor receipts in handoff recovery

* fix(update): recognize a Git release-mode service as its checkout's own

* fix(update): check a recorded data-at-risk mark before the next update, including already-current runs

* fix(update): lead data-at-risk refusals with triage and record them on the refused run

* fix(update): keep data-at-risk refusals within the recorded warning limit

* test(e2e): finish the seeded data-at-risk run with a terminal phase

* fix(update): name the agent route in killed-update recovery refusals

* fix(update): drop an unused import

* test(update): expect the agent route in killed-update refusals

* fix(update): verify the newest mark before restoration without comparing run ids

* fix(update): address review: keep the Gateway down on any inconsistent mark, resolve all marks, harden release ownership

* fix(update): break the admission-root import cycle and type the e2e schema read

* fix(update): address rating findings: agent rollback leftovers, helper restart, blocking findings first, shared Git metadata

* test(e2e): prove the next plain update resolves a mark with the Gateway running

* fix(update): address rating round 2: refuse marks before Doctor, registry-based rollback check, handoff fallback, async history read

* test(update): pick the repair run, not a settlement row, in the data-at-risk cell

* fix(update): resolve live-writer marks after Doctor holds the state

* fix(doctor): say a skipped stale-Gateway stop left the PID running

* fix(update): address rating round 3: leftovers before deferrals, retained rollback files, refusal after Doctor fails finalization

* docs(update): note retained rollback files and refusals after Doctor

* fix(doctor): say a stale Gateway stop could not be confirmed when nothing shows it running

* fix(update): address landing review: revert release-mode ownership, check leftovers first, handoff entry guard, durable rollback evidence

* test(update): follow main's Git release link layout in the launcher refusal test

* fix(update): treat uninspectable leftovers and unreadable databases as unchecked; true wording after Doctor

Release adaptation: Retain the stable installed-recovery harness. Do not add main's installed Docker service cell, later retired by #203808, or Git release-launcher wording/test because stable uses the in-place Git updater. Keep the state-verification, next-update, repair and interrupted-handoff paths and their compatible regressions.

Companion audit: #203486 is present-equivalent at 3081077 (preserved). #201978 is selected next in this lane. #203808 and #203966 involve the inapplicable installed service-cell layout; #203497 and #203194 change main's package/Git activation layout and are not applicable; #204017 depends on that release-install layout. #204077, #204043, #203555 and #203520 are independent authority, cleanup, helper-fixture and config-validation changes. #204151, #203917, #203849 and #203406 are separate guidance, cleanup or status changes, not required by the data-risk verifier. #203569 fixes a separate cron receipt fixture in the same Doctor suite; the touched stale-stop cases do not depend on it.

(cherry picked from commit a28f211)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f8d4bc138ed2512c413cf96f66fe0eefb3b28d65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web extensions: browser extensions: clickclack extensions: codex extensions: google extensions: memory-wiki gateway Gateway runtime P2 Normal backlog priority with limited blast radius. plugin: geolocation Geolocation plugin (IP to coarse city) plugin: knowledge plugin: skill-workshop plugin: workboard rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: M 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.

1 participant