Skip to content

fix(cli): guard local plugin state writes at command boundaries - #168757

Merged
steipete merged 9 commits into
mainfrom
dbasync/pluginguard
Oct 11, 2026
Merged

steipete merged 9 commits into
mainfrom
dbasync/pluginguard

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A separate CLI process must not change plugin installation records, registry state, or plugin configuration while a Gateway owns local state. Some plugin commands already delegate mutations to the Gateway, but local fallbacks and standalone updates can still write beside it.

Supersedes #168420.

Design

Reuse the command-boundary runWithLocalStateOwner guard from #168417. Existing install, uninstall, enable/disable, and reload Gateway routes remain unchanged. Local mutation paths acquire the existing offline owner and carry its assertion to existing effect callbacks. There is no new routing protocol, compensation, cancellation settlement, lease mechanism, or fencing.

Guarded paths:

  • Local plugin install and hook-pack install fallback, including the deprecated hooks install alias.
  • Local plugin uninstall and enable/disable fallbacks.
  • plugins registry --refresh.
  • plugins update and the deprecated hooks update alias.
  • plugins marketplace entries when fetching and plugins marketplace refresh, because both can persist feed snapshots. entries --offline stays read-only.
  • hooks enable and hooks disable configuration writes.

A running owner produces actionable stop-Gateway-and-rerun guidance; routed lifecycle commands continue to use their existing Gateway methods. Offline behavior is preserved. Update and marketplace refresh now save for the next Gateway start instead of writing locally then requesting a runtime refresh.

Accepted edge case: a Gateway starting mid-command is covered by the existing ownership guard at the effect. We do not add compensation or a second admission protocol around that race. Existing in-process Gateway callers retain their current owner.

Proof

The requested Codex P1 autoreview completed with no actionable findings.

  • AWS focused proof on eac4c5d985671dcd3e29592af79718d794c7f1ef: 12 test files, 227 tests passed with --maxWorkers=1 (154.38 s wall time; Vitest runner 153.69 s).
  • The 23 ownership cases cover refusal with an active owner, offline execution, effect-time revalidation, hook fallback, and unchanged install/uninstall/enable/disable Gateway routes. Hook enable/disable and all 37 existing migration scenarios also pass.
  • Negative control: the registry-owner refusal test fails against the pre-fix runtime because the command resolves instead of refusing.
  • Required CI is green on 0ac0b6fd583e62d6103c48bb77e40f98e2d78ea7: https://github.com/openclaw/openclaw/actions/runs/38102314276.
  • Type-aware oxlint and export-collision checks passed. Remote check:changed on 0ac0b6fd583e62d6103c48bb77e40f98e2d78ea7 passed formatting, every ratchet, production typechecking, and all core test typechecking groups. It stops only on Knip's existing src/gateway/server-instance-runtime.types.ts: GatewayApprovalEventPublisherV2 unused export. The identical finding was independently reproduced on main bbd2daf8b6def57eb0ac47c5e270c9b39cc168e6; this PR does not touch that file.
  • The only change after the 227-test run removed the obsolete mock-export baseline entry; test and production inputs are unchanged. Earlier CI caught stale update/migration assertions, a missing mock export, and the retired baseline entry; those are fixed.

Production delta: +193 / -156 lines (37 net), excluding tests, test support, and docs. The oversized runtime file does not grow.

Plugin loading is untouched, so the published-driver update cell is not required for this change.

Keep existing Gateway lifecycle routes and require offline state ownership for local plugin and hook mutations, updates, registry repair, and marketplace snapshot writes.
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: L labels Oct 11, 2026
@steipete
steipete merged commit 31b1db6 into main Oct 11, 2026
133 of 136 checks passed
@steipete
steipete deleted the dbasync/pluginguard branch October 11, 2026 01:53
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…claw#168757)

Guard local plugin install and hook fallback, uninstall, enable/disable, registry repair, updates, marketplace snapshot writes, and hook configuration writes with the existing local-state owner. Preserve existing Gateway lifecycle RPC routes and offline behavior; refuse local writes while the Gateway owns state with stop-and-rerun guidance.

Reuse effect-time ownership checks without adding cancellation settlement, compensation, fencing, or a new lease protocol. A Gateway starting mid-command is covered by the existing guard at the effect.

Supersedes openclaw#168420. Focused remote tests cover the command boundaries and existing migration behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant