Skip to content

fix(migrate): reject external plugin paths during adoption - #110

Merged
Patrick-Erichsen merged 3 commits into
openclaw:mainfrom
MertBasar0:fix/adopt-external-plugin-containment
Aug 27, 2026
Merged

Patrick-Erichsen merged 3 commits into
openclaw:mainfrom
MertBasar0:fix/adopt-external-plugin-containment

Conversation

@MertBasar0

@MertBasar0 MertBasar0 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

ocm adopt import can retain absolute sourcePath or installPath values for path plugins outside the adopted environment. The import currently succeeds with a warning, so a candidate runtime can still receive a writable reference to source-owned state even though the environment is intended to be disposable.

Why This Change Was Made

Containment is a safety boundary, not a compatibility warning. The import now fails before publishing relocated plugin records when any plugin path cannot be isolated inside the target state root. The existing migration transaction then removes the partially created environment.

User Impact

Adoption no longer produces a runnable environment with external plugin references. Operators must relocate or remove external path plugins before importing. Managed ClawHub and npm plugin records continue to relocate into the adopted state as before.

Verification

Targeted regression test

$ cargo test --test migrate_command_tests adopt_import_rejects_external_plugin_paths_without_mutating_the_source -- --exact --nocapture
running 1 test
test adopt_import_rejects_external_plugin_paths_without_mutating_the_source ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 39 filtered out

Real CLI behavior with a safe temporary fixture

The fixture contains a path plugin outside the source OpenClaw home. Paths are redacted below. The source database and external plugin marker were hashed before and after the production ocm command.

$ ocm adopt import --name proof-external-plugin <fixture>/source/.openclaw --json
ocm: imported OpenClaw plugin path(s) could not be isolated inside the env state: external-dev
Run "ocm help" for usage.

exit: 1
target environment removed: yes
source sqlite unchanged: yes (6a5285e2a14ca9cf4df66734c93ef52404fa218b7a8b2fe2f912e3672ad87bc9)
external plugin unchanged: yes (09d7425c9be6e7eae3c094a5884bba879aef74adb6193f54175898965ed44393)

Additional CI-equivalent verification on commit 9695362:

  • cargo fmt --check passes.
  • cargo test --locked passes in a clean WSL-native Linux checkout.
  • cargo +1.88.0 check --workspace --all-targets --locked passes.
  • git diff --check upstream/main...HEAD passes.

Maintainer Decision Requested

Please confirm that fail-closed adoption is the intended policy when a path plugin cannot be contained. This intentionally changes the previous warning-and-continue behavior: operators must relocate or remove the external path plugin before retrying adoption.

Related: #98
Related: openclaw/openclaw#129673

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 8:11 PM ET / August 27, 2026, 00:11 UTC.

ClawSweeper review

What this changes

The PR changes OCM adoption so an installed path plugin outside the copied state root aborts the import and removes the partial environment.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open pending a maintainer decision on the intentional fail-closed compatibility change. Likely related people: Patrick Erichsen (recent adoption-state contributor, medium confidence) and Shakker (long-running migration-area contributor, medium confidence).

Priority: P1
Reviewed head: ff5264a786dee7e10c431fde4d5ae77b02fb38b0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrowly tested and convincingly demonstrated; merge readiness depends on the explicit compatibility-policy decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body includes an after-fix production ocm adopt import transcript showing rejection, target cleanup, and unchanged source SQLite and external-plugin data.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes an after-fix production ocm adopt import transcript showing rejection, target cleanup, and unchanged source SQLite and external-plugin data.
Evidence reviewed 5 items Current main retains the warning path: Current main collects uncontained plugin IDs rather than failing; the CLI consumes those IDs to print a warning after a successful import, so the central behavior is not already implemented.
Containment check precedes state publication: The proposed check returns an error before the copied SQLite plugin records are updated; the import caller removes the environment when preparation fails.
Regression coverage exercises cleanup and source immutability: The command-level test asserts exit code 1, removal of the target environment, unchanged source SQLite bytes, and unchanged external plugin content.
Findings None None.
Security None None.

Live Verification

Command: cargo run -- help adopt import

Result: FAIL (failed) — execution before step 1 run: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

Assertions:

  • FAIL expect_output: Import a plain OpenClaw home

How this fits together

OCM adoption copies a plain OpenClaw home into a managed environment, rewrites runtime-state references, and then exposes that environment to OCM commands. Installed-plugin records feed the adopted runtime, so their paths must not retain access to source-owned state.

flowchart LR
A[Plain OpenClaw home] --> B[Adopt import]
B --> C[Copy target environment]
C --> D[Rewrite runtime state]
D --> E{Plugin paths contained?}
E -->|yes| F[Publish managed environment]
E -->|no| G[Remove partial target]
F --> H[OCM runtime commands]
Loading

Decision needed

Question Recommendation
Should ocm adopt import fail and remove the target environment whenever a path-plugin record cannot be contained under the adopted state root? Adopt fail-closed containment: Reject imports with uncontained external path plugins and require operators to relocate or remove them before retrying.

Why: The implementation is narrow and tested, but it deliberately replaces the current warning-and-continue compatibility path for existing external path-plugin setups.

Before merge

  • Resolve merge risk (P1) - Existing users with external path plugins will move from warning-and-continue behavior to a hard import failure and must relocate or remove those plugins before retrying.
  • Resolve merge risk (P1) - This PR protects installed-plugin records only; the broader isolation investigation in Adopted environment upgrade mutated the source gateway state database #98 should not be considered fully resolved by this change.
  • Complete next step (P2) - A maintainer must choose the intentional compatibility policy before this otherwise bounded PR can merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 2 files affected; 17 added, 14 removed The change is confined to plugin-record validation and its command-level regression coverage.

Merge-risk options

Maintainer options:

  1. Confirm fail-closed adoption (recommended)
    Accept the external-path-plugin upgrade behavior and merge the containment check after the policy decision.
  2. Retain the compatibility path
    Keep warning-and-continue behavior if maintainers decide an import failure is not acceptable for existing external path-plugin users.

Technical review

Best possible solution:

Confirm fail-closed containment for external path plugins, then merge this narrow validation and retain the broader isolation work in #98.

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

Yes. Current-main source and its existing test establish the warning-and-continue path, while the PR supplies a production CLI transcript showing rejection, cleanup, and unchanged source data after the fix.

Is this the best way to solve the issue?

Yes, conditionally: returning an error before plugin records are published and relying on the existing rollback path is the narrowest repair if maintainers choose fail-closed adoption.

AGENTS.md: not found in the target repository.

Codex review notes: model internal, reasoning high; reviewed against c4365f11c3c7.

Labels

Label justifications:

  • P1: A managed environment retaining a writable reference to source-owned plugin state undermines an active isolation workflow.
  • merge-risk: 🚨 compatibility: Existing imports with external path plugins will now fail instead of completing with a warning.
  • merge-risk: 🚨 security-boundary: The changed decision controls whether an adopted runtime can retain a path outside its isolated state root.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes an after-fix production ocm adopt import transcript showing rejection, target cleanup, and unchanged source SQLite and external-plugin data.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an after-fix production ocm adopt import transcript showing rejection, target cleanup, and unchanged source SQLite and external-plugin data.

Evidence

What I checked:

  • Current main retains the warning path: Current main collects uncontained plugin IDs rather than failing; the CLI consumes those IDs to print a warning after a successful import, so the central behavior is not already implemented. (src/store/openclaw_state.rs:390, c4365f11c3c7)
  • Containment check precedes state publication: The proposed check returns an error before the copied SQLite plugin records are updated; the import caller removes the environment when preparation fails. (src/store/openclaw_state.rs:405, ff5264a786de)
  • Regression coverage exercises cleanup and source immutability: The command-level test asserts exit code 1, removal of the target environment, unchanged source SQLite bytes, and unchanged external plugin content. (tests/migrate_command_tests.rs:1243, ff5264a786de)
  • Migration-area provenance: History identifies Shakker’s earlier migration work and Patrick Erichsen’s current branch integration; available shallow/promisor history could not retrieve every older patch. (src/migrate.rs:262, ff5264a786de)
  • Release and main check: The latest release is v0.2.33 at 7e110ae; current main is c4365f1 and still has warning-and-continue behavior, so this PR is neither shipped nor redundant. (src/cli/migrate.rs:213, c4365f11c3c7)

Likely related people:

  • Patrick Erichsen: Authored the current branch integration commit, is named in the policy-decision discussion, and current checkout blame attributes the surrounding imported-state path to this branch root. (role: recent integration contributor; confidence: medium; commits: ff5264a786de; files: src/store/openclaw_state.rs, src/migrate.rs)
  • Shakker: Migration history contains multiple adoption and migration changes by Shakker, including the direct adoption-path work surfaced by the feature-history search. (role: long-running migration-area contributor; confidence: medium; commits: f7f8873e6337, 7e110ae25c82; files: src/migrate.rs, src/cli/migrate.rs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the requested fail-closed adoption policy for existing external path-plugin setups.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-26T01:02:52.031Z sha a4f91fc :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-26T01:40:51.892Z sha 9695362 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T02:23:00.431Z sha 9695362 :: needs maintainer review before merge. :: none

@MertBasar0

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added the requested after-fix production-command proof from a safe temporary fixture. The targeted regression test passes; the real CLI run exits nonzero, removes the partial target environment, and leaves both the source SQLite database and external plugin marker byte-for-byte unchanged. The PR body now also calls out the remaining maintainer policy decision explicitly.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@MertBasar0

Copy link
Copy Markdown
Contributor Author

@Patrick-Erichsen The requested real-command proof and CI-equivalent local verification are now in the PR body. The remaining maintainer decision is the compatibility policy: this patch intentionally fails closed when an external path plugin cannot be contained, instead of preserving the current warning-and-continue behavior. Could you confirm that fail-closed adoption is the intended policy?

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 26, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit 420100f into openclaw:main Aug 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants