Skip to content

refactor(plugins): share managed npm package traversal - #140040

Merged
steipete merged 1 commit into
mainfrom
codex/plugin-npm-package-traversal
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/plugin-npm-package-traversal

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Managed npm installation scans and host peer-link repair duplicated the same root/scoped package traversal, making their filesystem error handling and ordering harder to maintain consistently.

Why This Change Was Made

One directory walker now serves both owners. Each caller retains its own entry policy and ordering: installation scans include package symlinks, while peer repair operates only on real directories. Missing directories remain tolerated; other native errors remain visible. Production decreases by 17 lines.

User Impact

Package discovery and peer repair preserve their existing behavior, including malformed installer scopes and packages whose directories disappear during enumeration. The installer rollback and quarantine paths are unchanged.

Evidence

  • Before/after characterization uses generated filesystem trees and the real installer, peer audit, and peer repair entry points. Actual audit → repair → audit verifies five broken host links become valid; linked package targets and excluded directories remain untouched.
  • Cases preserve root/scoped ordering, missing directories, disappearing scopes, and native ENOTDIR errors—including a root scope that is a regular file, which installer scanning rejects and peer repair skips.
  • 26 baseline checks passed on unchanged owners. Final validation passed 123 tests, including the full existing npm-spec/quarantine regression suite.
  • Typed lint, the complete changed-file gate, and independent P2 review passed. Production is −17 LOC, tests +201; two assertion-baseline entries only shrink after duplicate casts are removed.

Related: #135599. This is an independent installer-owner refactor with real filesystem proof; no registry download or Gateway behavior is claimed.

The rebase onto main resolved only an assertion-baseline conflict, preserving both main's unrelated reductions and this PR's two reduced entries. All three production files and the characterization test are byte-identical to the reviewed and tested commit. The exact assertion ratchet passed again after resolution.

@clawsweeper

clawsweeper Bot commented Sep 6, 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 size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 7:06 AM ET / 11:06 UTC.

ClawSweeper review

What this changes

Shares npm package-directory traversal between plugin installation and host dependency-link repair while preserving their distinct filtering, ordering, and filesystem-error behavior.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded refactor absent from the inspected main revision. No actionable introduced defect was found, and the maintainer-authored, protected PR should remain open for normal landing.

Priority: P3
Reviewed head: 92a079672e4cc0a05c1aac6bd78a2d76f905d337

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving extraction with meaningful boundary characterization and no identified correctness blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a MEMBER author, so the external-contributor gate does not apply; no material authority change triggers an exception. The captured body reports filesystem audit → repair → audit through the changed owners, supported by inspected characterization tests, without claiming registry or Gateway proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a MEMBER author, so the external-contributor gate does not apply; no material authority change triggers an exception. The captured body reports filesystem audit → repair → audit through the changed owners, supported by inspected characterization tests, without claiming registry or Gateway proof.
Evidence reviewed 8 items Pinned introduced change: The verified merge-base-to-head diff extracts traversal, replaces both existing loops, and reduces two assertion-baseline entries. Installer symlink inclusion, peer-repair directory-only filtering, ordering, and ENOENT-only suppression are preserved.
Current-main necessity: The inspected fetched-main revision still contains the separate traversal implementations; the difference in these production files is the proposed extraction. This comparison establishes current behavior, not PR ownership.
Latest-release check: The supplied latest-release commit has no shared npm-package-dirs.ts helper. No evidence establishes that this refactor has already shipped or been superseded by a merged fixing PR.
Findings None None.
Security None None.

How this fits together

OpenClaw scans managed npm directories to identify newly installed dependencies and repair plugins’ links to the host package. The shared walker supplies package paths to those two operations, each retaining its own selection rules.

flowchart TD
  A[Managed npm directory] --> B[Shared package walker]
  B --> C[Root and scoped entries]
  C --> D[Installer selection rules]
  C --> E[Peer repair selection rules]
  D --> F[New dependency scan]
  E --> G[Audit and repair host links]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -17, Tests +201, Other 0. Total +184 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 61 78 -17
Tests 1 201 0 +201
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 2 0
Total 5 264 80 +184

Review metrics

None.

Technical review

Best possible solution:

Keep one internal traversal owner with explicit caller-specific selection and ordering, backed by filesystem characterization at the installer and repair boundaries.

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

Not applicable: this PR addresses duplicated implementation rather than a reported runtime defect; source comparison and filesystem characterization support behavioral equivalence.

Is this the best way to solve the issue?

Yes: the extraction removes duplicated traversal without merging the callers’ intentionally different policies or adding a public API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8029fcccab8b.

Labels

Label justifications:

  • P3: This is internal maintenance that preserves existing package discovery and repair behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a MEMBER author, so the external-contributor gate does not apply; no material authority change triggers an exception. The captured body reports filesystem audit → repair → audit through the changed owners, supported by inspected characterization tests, without claiming registry or Gateway proof.

Evidence

What I checked:

  • Pinned introduced change: The verified merge-base-to-head diff extracts traversal, replaces both existing loops, and reduces two assertion-baseline entries. Installer symlink inclusion, peer-repair directory-only filtering, ordering, and ENOENT-only suppression are preserved. (src/plugins/npm-package-dirs.ts:6, 92a079672e4c)
  • Current-main necessity: The inspected fetched-main revision still contains the separate traversal implementations; the difference in these production files is the proposed extraction. This comparison establishes current behavior, not PR ownership. (src/plugins/install-managed-npm-state.ts:477, 8029fcccab8b)
  • Latest-release check: The supplied latest-release commit has no shared npm-package-dirs.ts helper. No evidence establishes that this refactor has already shipped or been superseded by a merged fixing PR. (3928bad9badf)
  • Behavioral characterization: Read the complete new test: it invokes actual installer discovery, peer audit, and peer repair against temporary filesystem trees, asserts five repaired links, excludes linked targets, and exercises missing or malformed roots and disappearing scopes. The captured PR body reports 26 baseline checks and 123 final tests passing; those runs were not independently executed during this read-only review. (src/plugins/npm-package-traversal.test.ts:32, 92a079672e4c)
  • Production boundary and documented contract: Installer discovery feeds additional dependency scanning, while peer repair retains the existing manifest and real-directory checks before linking. The documented doctor behavior repairs host links after updates and npm repairs; this PR changes neither that contract nor plugin SDK APIs. Public docs: docs/cli/plugins.md. (docs/cli/plugins.md:602, 92a079672e4c)
  • Prior merged-area history: Current-main file history identifies Peter Steinberger and Vincent Koc among contributors to host-link repair and runtime dependency handling. These are routing signals, not verified source-line introduction attribution. (src/plugins/plugin-peer-link.ts, 8029fcccab8b)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-06T10:39:04.346Z sha 67b6f77594243759c3de005351c1ab98eccfc738 :: blocked before merge. :: none
  • reviewed 2026-09-06T10:44:52.213Z sha 67b6f77594243759c3de005351c1ab98eccfc738 :: blocked before merge. :: none
  • reviewed 2026-09-06T10:53:52.957Z sha 92a0796 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 6, 2026 10:40
@steipete
steipete force-pushed the codex/plugin-npm-package-traversal branch from 67b6f77 to 92a0796 Compare September 6, 2026 10:48
@steipete
steipete merged commit d8922d3 into main Sep 6, 2026
179 checks passed
@steipete
steipete deleted the codex/plugin-npm-package-traversal branch September 6, 2026 11:08
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to ylcn91/openclaw that referenced this pull request Sep 6, 2026
* origin/main: (47 commits)
  ci: record CPU time for Node test jobs (openclaw#140054)
  test(crabbox): consolidate wrapper boundary coverage (openclaw#140058)
  fix(test): keep native filesystem access checks portable (openclaw#140047)
  fix: preserve models when OAuth preparation fails (openclaw#139951)
  feat(update): recover failed updates with bounded repair (openclaw#139495)
  refactor(plugins): share managed npm package traversal (openclaw#140040)
  chore(ui): refresh control ui locales (openclaw#140059)
  refactor(auth): share profile failure state reset (openclaw#140049)
  fix(cron): surface skipped on-exit payloads when jobs are busy (openclaw#139987)
  fix(codex): preserve exec-server WebSocket backpressure under Bun (openclaw#140048)
  fix(agents): ground exec approvals in tool results (openclaw#140043)
  refactor(policy): reuse authored policy value helpers (openclaw#140019)
  docs: keep ClawSweeper status inspection read-only (openclaw#139958)
  fix: reduce task maintenance stalls with large histories (openclaw#140038)
  fix(code-mode): identify unawaited promise output (openclaw#140028)
  fix(test): release memory search fixtures after failed phases (openclaw#140013)
  test(gateway): isolate Serve hello lifecycle fixtures (openclaw#140044)
  fix(microsoft-foundry): bound Entra token retention across accounts (openclaw#127216)
  fix(process): preserve the cause of cleanup observation failures (openclaw#140015)
  fix: clear Side chat when its parent conversation is deleted (openclaw#139974)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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