Skip to content

fix(plugins): follow physical paths when authoring local plugins - #199627

Closed
Alix-007 wants to merge 5 commits into
openclaw:mainfrom
Alix-007:alix/fix-plugin-authoring-roots-20261115
Closed

Alix-007 wants to merge 5 commits into
openclaw:mainfrom
Alix-007:alix/fix-plugin-authoring-roots-20261115

Conversation

@Alix-007

@Alix-007 Alix-007 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Local plugin authoring lexically normalizes a path before consulting the filesystem. For selected -> physical/nested, selected/../source names physical/source, but build, validation and packaging can successfully operate on a different valid neighbouring project. Init and explicit archive output can likewise write to the wrong directory.

User Impact

Build/check, validate, pack and runtime-lint use the project the supplied path actually names. Init and pack --out use the physical parent destination. Wrong-project metadata and wrong archive contents are prevented together. Existing no-force refusal, exclusive archive creation and publication cleanup remain enforced.

Why This Change Was Made

Resolve existing project roots through native filesystem traversal while preserving package entry declarations. Reuse fs-safe prefix traversal for an init destination that does not exist yet; reject an unresolved .. rather than collapse it into an existing project. Resolve only the archive parent, keeping final-name wx protection. Include the browser build/settings script and runtime-lint root consumer in this authoring repair.

This completes existing path selection, without new options, defaults, dependencies, permission or config/schema/protocol/upgrade changes. It does not activate, publish or install a plugin. Source confinement, final overwrite refusal and ordinary paths remain covered.

Evidence

Product head: a483ef8b3959f9b69db238350dee69ca9b4aa958; BASE: c0166c395cf81095f431808c9496cb6022ad4387.
Immutable paired receipts, actual archives, full output, frozen collectors and independent review.

Same actual CLI scenario BASE HEAD
plugins build --check / validate --json on stale selected physical project Two commands report the valid decoy as current Both detect the selected physical project's stale metadata
build / pack through the same root Metadata remains stale in the intended project; tar contains decoy plugin Intended metadata updated; independently read tar contains physical plugin
init --directory / pack --out through a directory alias and parent New project/archive appears in neighbouring lexical directory Both appear in physical destination, wrong destination absent
Ordinary build/validate and unchanged decoy/source controls Five controls pass Same five pass
  • Production entry and owner: normally built openclaw.mjs plugins build, validate, pack, init -> actual authoring/artifact owners -> filesystem metadata, scaffold files and independent tar readback. Browser builder (including a settings-only UI fixture) and runtime-lint sibling behavior also run in their existing focused tests. The --prepare-settings repository-discovery branch is source-reviewed only.
  • Exact paired commands: python3 plugin-root-proof-v1.py CHECKOUT FRESH_OUTPUT NODE26 MODE (10 scenarios) and python3 plugin-output-proof-v1.py CHECKOUT FRESH_OUTPUT NODE26 MODE (build control plus explicit archive output), with red on BASE and green on HEAD. Each collector is byte-identical across its pair and requires a clean matching-head normal cliStartup build. HEAD normal clean CLI build result is recorded with this exact product head in checks.json.
  • Recorder/readback: real exit/stdout/stderr; physical/decoy package and manifest hashes; scaffold package identity; actual tar SHA256 and independently unpacked package/openclaw.plugin.json. All 12 HEAD operations pass, including the explicit archive destination sibling. Both archive byte sets are inspectable outside the product branch. No path library or authoring owner is replaced by a test double.
  • Current-head focused checks: pnpm test src/cli/plugins-authoring-command.test.ts src/cli/plugins-authoring-validation.test.ts src/cli/plugins-control-ui-build.test.ts --maxWorkers=1 -t '^(?!.*builds and installs selected entries without changing sibling runtime pairs)':75 PASS, one explicitly filtered known BASE-timeout case, in41.234s. The file/directory alias declarations, sibling runtime mapping, physical project roots, browser build and expected entry errors are covered. The previously run complete selection recorded one120s install-test timeout independently reproduced on clean BASE; that unrelated case is not claimed passing or rerun. No BASE test assertion, source skip or timeout is changed. Current genuine typed lint, semantic types, format and staged line checks pass.
  • First-review fixes / independent review: the retained original declared-entry resolver preserves package/manifest diagnostics before the existing missing-entry guard. The new init refusal explains how to recover. The authorized independent GPT6.1Sol source/evidence/body review is linked; official autoreview execution is not claimed. This complete authoring repair covers project roots, init, archive output, browser build/settings and runtime-lint together; backend entry declarations keep their existing slot identity.
  • Additional real diagnostic regression proof: python3 plugin-diagnostics-proof-v1.py CHECKOUT FRESH_OUTPUT NODE26 MODE (frozen SHA256 bf91372e3d9ebae93a4f3dc7a7740b4cd2b3e4941de804c834febd0b9ccc576b) compares the first published revision a83b8ad928070201c48afc12c67f51bf0ddc28fb to this repaired head, separately from the original current-main BASE above. The first revision masked three metadata errors with missing-entry errors. On the repaired head, malformed JSON with and without debug retains parser-detail policy, a missing manifest is reported before the absent default entry, and unreachable init shows the recovery step. Five actual normal-CLI checks pass; the no-force control preserves its sentinel, malformed source bytes remain unchanged, and the unreachable parent is not created. No old receipt is relabelled as this head.
  • Missing-root diagnostic regression: python3 plugin-missing-root-proof-v2.py CHECKOUT FRESH_OUTPUT NODE26 MODE, frozen SHA256 2762205d5d63b14a6392bb8e544472b4682d0cae91684c30ecfa97217472ba9c, compares first repair f9aa12f0ac37b9f51740ed4abbbc4df09cc1ec76 to this exact head. Four actual commands (build, human and JSON validate, and pack) previously lost the operator-facing root-not-found message. A shared expected-error helper now reports the missing root and an actionable --root recovery step for ENOENT/ENOTDIR; other native errors propagate. Packaging uses its existing validation entry before resolving the physical root. plugins lint retains its existing actionable scan-incomplete warning as the must-not-turn-fatal control. Missing roots remain absent and the fixture sentinel is unchanged. This is a separate diagnostic pair; the original BASE is unchanged.
  • Non-directory entry regression: python3 plugin-entry-enotdir-proof-v1.py CHECKOUT FRESH_OUTPUT NODE26 MODE, frozen SHA256 875e3cee4dd2e77dea5b65121bc2954a627e0053b9c9c2bf1b071fa512decf49, compares previous repair a5ea84b0e91db727c56c7cbcb2678d24b18e3c11 to this head. With an existing project and --entry package.json/index.js, build plus human/JSON validation previously lost the expected entry-not-found diagnostic. Backend entry selection retains the original declaration resolver, so both nonexistent entries and entries beneath a regular file reach the existing expected-error owner. Three actual failures regain their precise entry message; valid build, ordinary missing-entry and valid JSON validation controls retain behavior. Independent package/source/manifest hashes are unchanged after the failing requests, and package.json remains a regular file. No metadata guard or entry-confinement rule is bypassed. This third diagnostic pair retains its own BASE revision.
  • Existing declaration compatibility / narrowed scope: python3 plugin-entry-alias-proof-v1.py CHECKOUT FRESH_OUTPUT NODE26 MODE, frozen SHA256 a7cfcb615b1bdd71f5733cfbfe04e39614375679338ab5585ef6943646a618e8, compares prior repair 050f9f63f297c83d287024ea5e67b712bf75b548 to this head. It starts with already-valid package declarations containing a file alias or directory alias plus a second extension and two runtime mappings. The prior revision rejects those existing declarations and appends the same physical plugin as a duplicate on build. This head validates the original stored package, builds and validates it again without changing either declared slot, runtime mappings, setup entry or source bytes; ordinary entries remain the control. Twelve actual CLI operations are recorded. Physical project-root selection and declared backend entry identity are separate: this PR does not introduce native traversal rules for package entry strings. The BASE lexical handling of entry missing/../... is retained. An absolute entry spelled under the supplied root maps to the same relative declaration under the physical project root; unrelated paths still use the existing confinement guard. The browser core's pre-existing native-entry confinement is unchanged. The browser-copy script reads from the physical root but retains the original logical bundled slot for destination selection; --copy remains source-reviewed only.
  • Cleanup/limitations: isolated Ubuntu24.04/GLIBC2.39/Node26.12.1 and synthetic local projects; proof containers have network disabled and private HOME/config/state. No live plugin activation, external install/publish, real model/channel or production state. Not tested: the --prepare-settings repository-discovery and --copy bundled-destination branches (source-reviewed only), full repository suite, native macOS/Windows, hosted CI, live plugin activation, external install/publish or production services. The baseline install-test timeout remains an unresolved local validation limitation. Fixture archives and logs are retained outside the product branch.
Production / test LOC
3	3	scripts/build-plugin-control-ui.mts
111	38	src/cli/plugins-authoring-command.test.ts
21	27	src/cli/plugins-authoring-command.ts
51	0	src/cli/plugins-authoring-root.ts
47	1	src/cli/plugins-authoring-validation.test.ts
11	1	src/cli/plugins-control-ui-build.test.ts
13	1	src/cli/plugins-feature-artifact.native.test-support.ts
7	4	src/cli/plugins-feature-artifact.ts
5	1	src/cli/plugins-runtime-lint-command.test.ts
3	1	src/cli/plugins-runtime-lint-command.ts

No proof assets or CHANGELOG changes on the product branch.

@clawsweeper

clawsweeper Bot commented Nov 15, 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 cli CLI command changes scripts Repository scripts size: M labels Nov 15, 2026
@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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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-repro Preliminary submission classification; full source review pending. labels Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Make local plugin authoring follow physical project and output paths while preserving declared entry identities.

Example: With selected pointing to physical/nested, run openclaw plugins build --root selected/../source.

  • Before: The command updates the neighboring source project.
  • After: The command updates physical/source and leaves the neighboring project unchanged.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused repair with strong real-CLI evidence and no remaining findings; broad CI is unresolved, and the disclosed installer timeout also occurs on the base.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Inspected immutable exact-head Ubuntu/Node CLI receipts for build/check, validation, packaging, initialization, output destinations, diagnostics, and declaration preservation, including independent archive readback; Settings discovery and bundled-copy branches remain source-reviewed only.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Plugin authors can successfully build or package a neighboring project, or create files in the wrong directory, when supplied paths contain a directory alias followed by a parent component.
Reason: Correct project selection is an existing command contract, and the bounded repair prevents silent wrong-project writes without adding options or changing plugin declaration formats.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete wrong-project authoring bug that remains on current main. The prior findings are addressed, and no remaining introduced defect was found; required CI has not passed.

Priority: P2
Reviewed head: a483ef8b3959f9b69db238350dee69ca9b4aa958

Before merge

None.

Findings

None.

Agent review details

How this fits together

Plugin authoring commands consume project paths and entry declarations, load plugin metadata, and produce manifests, scaffolds, diagnostics, browser assets, or archives.

flowchart TD
  A[Author supplied paths] --> B[Physical root resolution]
  B --> C[Declared entry selection]
  C --> D[Plugin metadata validation]
  D --> E[Manifest publication]
  D --> F[Archive packaging]
  A --> G[Physical destination resolution]
  G --> H[Scaffold or exclusive archive creation]
Loading

Technical review

Best possible solution:

Land the physical-root repair with declared entry identities and existing overwrite protections preserved once required CI passes.

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

Paired built-CLI receipts reproduce the defect on the pinned base, and current main retains the responsible lexical root normalization; no target code was executed during this review.

Is this the best way to solve the issue?

The repair uses native traversal and the existing prefix resolver at path-selection boundaries while retaining metadata, publication, and packaging owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 97dd78cc2cbd.

Provenance checked

  • Authoring root and entry selection keeps the original intent (b17e4ed: Simple tool-plugin authoring introduced root-relative entry selection and synchronized generated metadata; the repair preserves declared entry selection while correcting filesystem root traversal.)
  • Atomic manifest publication keeps the original intent (3be8b66: fix(cli): preserve plugin manifests when builds fail #140740 prevents manifest truncation and preserves publication permissions; the existing atomic writer remains in use.)
  • Selected extension and runtime-pair identity keeps the original intent (facbe21: fix(plugins): keep entry pairs aligned when rebuilding metadata #174732 preserves the selected full-path slot and sibling runtime mappings; the latest repair restores that contract for declared aliases.)
  • Browser assets and Settings preparation keeps the original intent (dbd0a21: Plugin-owned Settings presentation requires bundled asset preparation and copying; physical reads retain logical bundled destination identity and the artifact-ownership wrapper.)
  • Runtime lint diagnostics keeps the original intent (aae1394: feat(plugins): inspect runtime compatibility before activation #182419 adds static compatibility inspection without activation; physical root resolution preserves incomplete-scan warnings.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit b17e4ed adds src/cli/plugins-authoring-command.ts:78 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b17e4ed50cbf; files: src/cli/plugins-authoring-command.ts)
  • Alix-007: Raw commit 45e2704 adds scripts/build-plugin-control-ui.mts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 45e2704c8456; files: scripts/build-plugin-control-ui.mts)

PR surface

Source +50, Tests +145, Other 0. Total +195 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 82 32 +50
Tests 5 187 42 +145
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 3 0
Total 10 272 77 +195

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/support LOC Production +85/-35; tests/support +187/-42 Growth provides shared root/error handling and distinct filesystem, diagnostic, and declaration-compatibility regressions without new state or public APIs.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Symlink-plus-parent paths can silently select or modify the wrong local plugin project, with a limited authoring-workflow blast radius.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-15T14:29:44.974Z sha a83b8ad :: needs changes before merge. :: [P2] Preserve metadata errors before rejecting missing entries | [P2] Explain how to repair the rejected destination
  • reviewed 2026-11-15T15:10:14.405Z sha f9aa12f :: blocked before merge. :: [P2] Preserve actionable errors for nonexistent plugin roots
  • reviewed 2026-11-15T16:01:42.129Z sha a5ea84b :: blocked before merge. :: [P2] Preserve expected entry errors for non-directory components
  • reviewed 2026-11-15T16:44:05.189Z sha 050f9f6 :: blocked before merge. :: [P2] Preserve the selected extension slot when resolving entry aliases

Reviewed November 15, 2026, 12:35 PM ET / 17:35 UTC (Revision 5).

@Alix-007

Copy link
Copy Markdown
Contributor Author

Preserved the original package/manifest error precedence before the missing-entry guard and added a recovery step to the new init refusal. The rebuilt CLI at f9aa12f0ac37b9f51740ed4abbbc4df09cc1ec76 passes the original12 real authoring/output checks plus5 diagnostic checks; all9 validation regressions pass. The unrelated baseline install-test timeout remains disclosed. Updated exact-head evidence is linked in the body.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 15, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

Restored actionable missing-root diagnostics for build, human/JSON validation and packaging, while preserving the lint warning control. The rebuilt CLI at a5ea84b0e91db727c56c7cbcb2678d24b18e3c11 passes all22 original and diagnostic operations with independent file/archive readbacks. All9 post-extraction validation regressions pass; the same BASE install-test timeout remains disclosed. Updated exact-head evidence is linked in the body.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 15, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

Fixed the late ENOTDIR finding: entry paths below a regular file now reach the existing expected-error owner, just like missing entries. The rebuilt CLI at 050f9f63f297c83d287024ea5e67b712bf75b548 passes all28 original and diagnostic operations, including the3 rejected-entry cases and3 controls. The42 selected tests pass; the known BASE install timeout is explicitly excluded and remains disclosed. Updated exact-head evidence is linked in the body.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 15, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

Preserved declared file/directory entry aliases and sibling runtime mappings by restoring the existing entry-selection contract, while retaining physical project-root selection. The rebuilt CLI at a483ef8b3959f9b69db238350dee69ca9b4aa958 passes all40 original and compatibility operations; legacy package declarations validate and remain unchanged after build. The75 selected tests pass, with the known BASE install timeout explicitly excluded and disclosed. Updated exact-head evidence is linked in the body.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 15, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this along with the other open PRs that apply the same change one call site at a time. This series changes symlink, physical-path and literal-path handling at each command separately; path resolution policy belongs in one shared owner and needs a maintainer decision. Please open one issue (or one PR at the shared owner) that covers the whole pattern, with a reproduction of real user-visible harm, instead of separate per-site PRs. Further per-site variants of this pattern will be closed.

@obviyus obviyus closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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.

2 participants