Skip to content

fix: avoid rebuilding package-local plugin memory artifacts - #131538

Merged
steipete merged 1 commit into
mainfrom
steipete/interesting-clarke-ac103e
Aug 28, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/interesting-clarke-ac103e

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #131531 (package-local profiler discovery and unnecessary rebuilds).

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.

What Problem This Solves

Fixes an issue where developers profiling an already-built standalone plugin would trigger an unnecessary cliStartup rebuild and still fail to select the compiled entry when it lived in package-local output rather than the flat root-dist layout. Unfiltered reports also silently omitted these entries, and the unnecessary smaller rebuild could replace completed private-QA artifacts.

Why This Change Was Made

Readiness and profiling now share one built-entry discovery flow that delegates artifact choice to the existing public plugin resolver. It recognizes flat root-dist, nested plugin-local dist, and source-checkout package-local output, preserves root-artifact precedence, deduplicates/sorts IDs, and excludes TypeScript source results. The existing default expected-build inventory and explicit-selection completeness checks remain intact.

This deletes the duplicate root-only enumeration instead of adding plugin-name exceptions, artifact symlinks, loader fallbacks, settings, or dependencies. Plugin runtime/installation policy, build profiles, timeouts, and the report schema are unchanged.

The existing timeout-cleanup test also now waits for a real descendant's readiness before starting its unchanged 250 ms timeout; it no longer confuses slow process startup with cleanup failure. Its existing subprocess seam is typed to the actual ignore/pipe/pipe invocation rather than all Node spawn overloads.

User Impact

Developers can select existing package-local compiled plugin entries without rebuilding unrelated artifacts. Default profiling includes those built entries, and missing native dependencies remain explicit import failures rather than being hidden by a source fallback.

The fresh full root build does not itself supply WhatsApp's index under current build-ownership policy; its existing standalone package builder supplies the package-local artifact. This PR does not change that policy or claim to fix the separate Doctor cold-start investigation.

Evidence

Local proof ran against main baseline 60c1dc35becf066b3e2da379a85abed5b07f2ce9 plus this candidate. The affected profiler/build-entry owners remained unchanged when main was rechecked at 629a47e3cc20a9f8b6d19c105f840b8a693ec4aa. Exact-head CI passed on b9a6097a7f69210335389fa9e97f0d2bea6fd848: pull_request run 33142845760, attempt 1, and required openclaw/ci-gate succeeded. The repository CI watcher completed GREEN.

  • Seven new discovery/readiness regressions failed on pre-fix production code: false readiness, unnecessary build attempts, and omission from default enumeration.
  • Final focused tests: 45 passed. They cover package-only output without root dist, nested output, selected/default mixed layouts, precedence/deduplication, source exclusion, partial required sets, reports, failures, and child cleanup.
  • Build-selection, standalone-build, and performance-report sibling tests: 59 passed. Total: 104 tests in seven files.
  • Changed-file formatting, script/test-root typechecks, targeted lint, and selected repository guards passed. The final documentation-only clarification also passed formatting and git diff --check.
  • A complete OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build passed, including 64 external plugin builds, 48 control-plane module/Doctor-closure checks, and 147 public SDK subpath checks.
  • The canonical standalone WhatsApp builder added 68 package-local files while preserving all 15,461 pre-existing QA artifacts.
  • Real scoped and mixed-layout profiler runs selected extensions/whatsapp/dist/index.js without invoking a rebuild. All 15,529 artifact hashes, sizes, timestamps, and symlink targets remained identical before/after. Inventory SHA-256: 0d43b5a4efd79a9ee02b0bd86e958ceef83b03fc1cead85476210f610e603e8d.
  • Real memory-core profiling from root dist passed.
  • AI-assisted implementation; fresh independent pre-commit Codex autoreview exited 0 with no actionable findings at its default P0 threshold. This does not claim broader-priority review coverage. No agent transcript is included.

Focused commands:

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs test/scripts/ensure-extension-memory-build.test.ts test/scripts/profile-extension-memory.test.ts src/plugins/public-surface-runtime.test.ts --reporter=verbose
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs test/scripts/build-external-plugin-local-dist.test.ts test/scripts/bundled-plugin-build-entries.test.ts test/scripts/check-plugin-npm-runtime-builds.test.ts test/scripts/openclaw-performance-source-summary.test.ts --reporter=verbose
node scripts/check-changed.mjs -- scripts/ensure-extension-memory-build.mts scripts/profile-extension-memory.mts test/scripts/ensure-extension-memory-build.test.ts test/scripts/profile-extension-memory.test.ts docs/reference/test.md
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build
node scripts/lib/plugin-npm-runtime-build.mjs extensions/whatsapp
OPENCLAW_LOCAL_CHECK=0 node --import tsx scripts/profile-extension-memory.mts --extension whatsapp --skip-combined --concurrency 1

Explicit native-import proof gap

The actual WhatsApp report selects the correct package-local artifact and proves no rebuild, but its native import then fails with ERR_MODULE_NOT_FOUND for the openclaw host package. Repository source-checkout postinstall deliberately removes plugin-local node_modules; a normal frozen offline dependency installation does not restore that host peer. The full workspace dependency set was restored after the scoped install attempt, and the import was retried with the same result.

That pre-existing dependency-setup boundary is recorded separately, not silently fixed through a symlink or TypeScript loader in this PR. A successful WhatsApp native import or Doctor cold-start repair is not claimed. The changed discovery/no-rebuild boundary is covered by both real profiler observations and successful native-CLI fixture imports.

Scope and size

Production/tooling: +62/-57 (net +5). The executable discovery refactor is net -3; eight erased type lines narrow the pre-existing child-spawn dependency to its actual stdio contract. Tests: +205/-62. Docs: +4/-0. No runtime plugin resolver, manifest, package/dependency file, configuration, schema, or persistence contract changes.

Provenance: the automatic root-only readiness check was authored and committed by @vincentkoc in 4ce3c3e on May 28, 2026; GitHub exposes no associated PR. The old layout assumption was carried through the TypeScript migration. The canonical public resolver is the appropriate owner to reuse; a second artifact policy or plugin-specific exception would perpetuate the mismatch.

ClawSweeper review disposition

The published review found no introduced code or security defect. Its live help check failed before OpenClaw ran because pnpm was absent in the review environment. The exact command pnpm test:extensions:memory -- --help succeeds in the prepared source checkout (exit 0):

Usage: node --import tsx scripts/profile-extension-memory.mts [options]

The pending-CI request is resolved by successful exact-head CI run 33142845760 and its required gate. The size request is covered above: executable refactoring is net -3, with eight erased type lines narrowing the existing spawn contract; the shared finder remains the sole discovery flow. Maintainer review has accepted this focused discovery/no-rebuild boundary and its explicitly separate native-import limitation.

For the optional after-fix real-setup Rank-up move, these are redacted selections from the saved actual profiler reports (paths made repository-relative):

{"profile":"internal","entries":[{"dir":"memory-core","file":"dist/extensions/memory-core/index.js","status":"ok"}]}
{"profile":"standalone","entries":[{"dir":"whatsapp","file":"extensions/whatsapp/dist/index.js","status":"fail"}]}
{"profile":"mixed","entries":[{"dir":"memory-core","file":"dist/extensions/memory-core/index.js","status":"ok"},{"dir":"whatsapp","file":"extensions/whatsapp/dist/index.js","status":"fail"}]}

The standalone failure is the recorded ERR_MODULE_NOT_FOUND for the openclaw host peer, not a discovery failure. No rebuild occurred; the before/final inventories contain the same 15,529 artifact records and compare equal. Successful WhatsApp native import remains unproven. No recording is added because this is a terminal artifact-selection repair with real report and preservation evidence, not a UI change. No source changes or redundant re-review request were made.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M maintainer Maintainer-authored PR labels Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 04:47
@steipete steipete self-assigned this Aug 28, 2026
@steipete

steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Pre-land proof for b9a6097. The approved five-file patch is committed unchanged. Readiness and profiling now share the canonical public artifact resolver, removing duplicate root-only discovery while retaining required-build completeness, root precedence, sorted/deduplicated IDs, and TypeScript exclusion.

Seven discovery regressions failed before the fix; 104 focused/sibling tests in seven files passed afterward. Changed formatting/types/lint/guards and the full private-QA build passed (64 external plugins, 48 control-plane modules, 147 SDK subpaths). Commands:

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs test/scripts/ensure-extension-memory-build.test.ts test/scripts/profile-extension-memory.test.ts src/plugins/public-surface-runtime.test.ts --reporter=verbose
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs test/scripts/build-external-plugin-local-dist.test.ts test/scripts/bundled-plugin-build-entries.test.ts test/scripts/check-plugin-npm-runtime-builds.test.ts test/scripts/openclaw-performance-source-summary.test.ts --reporter=verbose
node scripts/check-changed.mjs -- scripts/ensure-extension-memory-build.mts scripts/profile-extension-memory.mts test/scripts/ensure-extension-memory-build.test.ts test/scripts/profile-extension-memory.test.ts docs/reference/test.md
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build
node scripts/lib/plugin-npm-runtime-build.mjs extensions/whatsapp
OPENCLAW_LOCAL_CHECK=0 node --import tsx scripts/profile-extension-memory.mts --extension whatsapp --skip-combined --concurrency 1
node scripts/watch-pr-ci.mjs 131538 b9a6097a7f69210335389fa9e97f0d2bea6fd848

CI run 33142845760, attempt 1, completed successfully on this exact head; required openclaw/ci-gate succeeded and the watcher returned GREEN. The initial draft-only run was skipped; no recovery rerun or close/reopen was needed. Fresh independent pre-commit Codex autoreview reported no actionable P0 findings; broader-priority review is not claimed.

Native-import limitation: actual WhatsApp profiling selects extensions/whatsapp/dist/index.js without rebuilding, but its import still fails ERR_MODULE_NOT_FOUND for the openclaw host package after normal frozen offline dependency setup. Source-checkout postinstall prunes plugin-local node_modules. Successful WhatsApp native import is not claimed or hidden with a symlink/source loader. Real memory-core import passed, and all 15,529 artifact records remained identical across the scoped/mixed profiling attempts. The standalone host-peer setup gap is separate from this discovery repair.

Production/tooling +62/-57 (net +5): executable refactoring net -3, plus eight erased type lines narrowing the existing spawn stdio contract. Tests +205/-62; docs +4/-0. No dependency, configuration, schema, or runtime installation-policy changes.

Native review artifacts are validated for this head. Live applicable rules require the CI gate, with no enforced reviewer-approval rule. ClawSweeper is still reviewing; its latest comment has no final Rank-up moves to disposition. This is the requested pre-land checkpoint: prepare and merge have not run, and issue #131531 remains open pending the final landing continuation.

ClawSweeper review disposition

The published review found no introduced code or security defect. Its live help check failed before OpenClaw ran because pnpm was absent in the review environment. The exact command pnpm test:extensions:memory -- --help succeeds in the prepared source checkout (exit 0):

Usage: node --import tsx scripts/profile-extension-memory.mts [options]

The pending-CI request is resolved by successful exact-head CI run 33142845760 and its required gate. The size request is covered above: executable refactoring is net -3, with eight erased type lines narrowing the existing spawn contract; the shared finder remains the sole discovery flow. Maintainer review has accepted this focused discovery/no-rebuild boundary and its explicitly separate native-import limitation.

For the optional after-fix real-setup Rank-up move, these are redacted selections from the saved actual profiler reports (paths made repository-relative):

{"profile":"internal","entries":[{"dir":"memory-core","file":"dist/extensions/memory-core/index.js","status":"ok"}]}
{"profile":"standalone","entries":[{"dir":"whatsapp","file":"extensions/whatsapp/dist/index.js","status":"fail"}]}
{"profile":"mixed","entries":[{"dir":"memory-core","file":"dist/extensions/memory-core/index.js","status":"ok"},{"dir":"whatsapp","file":"extensions/whatsapp/dist/index.js","status":"fail"}]}

The standalone failure is the recorded ERR_MODULE_NOT_FOUND for the openclaw host peer, not a discovery failure. No rebuild occurred; the before/final inventories contain the same 15,529 artifact records and compare equal. Successful WhatsApp native import remains unproven. No recording is added because this is a terminal artifact-selection repair with real report and preservation evidence, not a UI change. No source changes or redundant re-review request were made.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 12:55 AM ET / 04:55 UTC.

ClawSweeper review

What this changes

The PR changes the plugin memory profiler and its readiness check to reuse built package-local plugin entry points instead of rebuilding unrelated plugin artifacts.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 4 items remain

Keep open. This is a focused maintainer-authored repair for a current root-only artifact-discovery defect; the proposed shared-resolver path covers both readiness and profiling, and no introduced correctness or security defect was found. Exact-head CI is still running.

Priority: P2
Reviewed head: b9a6097a7f69210335389fa9e97f0d2bea6fd848

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current-main defect: The fetched main revision still requires entries under dist/extensions, so a package-local extensions/<id>/dist/index.js cannot satisfy readiness.
Shared owner boundary: The PR replaces separate root-only discovery paths with one helper that delegates each plugin root to the existing public-surface resolver and admits only JavaScript runtime results.
Resolver contract: The reused resolver prefers an entry at the plugin root, then its dist directory, before considering source files; this matches the intended per-plugin artifact precedence.
Findings None None.
Security None None.

Live Verification

Command: pnpm test:extensions:memory -- --help

Result: FAIL (failed) — step 1 expect_output Usage: node --import tsx scripts/profile-extension-memory.mts [options]: terminal command failed with exit status 127: "pnpm test:extensions:memory -- --help"

[failure]
terminal command failed with exit status 127: "pnpm test:extensions:memory -- --help"

[command 1 combined output]
‹private command›: line 1: pnpm: command not found

Assertions:

  • FAIL expect_output: Usage: node --import tsx scripts/profile-extension-memory.mts [options]

How this fits together

The extension memory profiler discovers built plugin entry points, imports them in isolated processes, and reports RSS usage. A readiness check decides whether a build must run before profiling begins.

flowchart LR
  A[Plugin build outputs] --> B[Artifact resolver]
  B --> C[Memory readiness check]
  C --> D{Built entries available?}
  D -->|Yes| E[RSS profiler]
  D -->|No| F[Build profile]
  F --> E
  E --> G[JSON memory report]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Exact-head CI remains in progress, so the supplied local proof has not yet been corroborated by the required hosted checks.
  • Resolve merge risk (P1) - The tooling portion is net +5 lines for a bug fix; the growth is limited to one shared discovery helper that removes the duplicate root-only enumerator, but it should remain the sole artifact-selection path.
  • Complete next step (P2) - The linked maintainer-owned fix is coherent; it needs ordinary exact-head CI completion and maintainer landing review rather than automated repair.
Agent review details

Security

None.

PR surface

Tests +143, Docs +4, Other +5. Total +152 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 205 62 +143
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 2 62 57 +5
Total 5 271 119 +152

Review metrics

Metric Value Why it matters
Production versus test delta tooling +62/-57 (net +5); tests +205/-62; docs +4/-0 The small tooling increase centralizes discovery for two call paths, while the test growth covers the supported artifact layouts and timeout stability.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #131531
Summary: This PR is the explicit candidate fix for the canonical package-local plugin profiler report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared discovery helper after exact-head CI completes, retaining the public resolver as the only artifact-selection policy for readiness and RSS profiling.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the shared discovery helper after exact-head CI completes, retaining the public resolver as the only artifact-selection policy for readiness and RSS profiling.

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

Yes, source-reproducible: fetched main requires dist/extensions/<id>/index.js for both readiness and enumeration, while the linked scenario supplies only package-local compiled output. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes. Reusing the existing per-plugin public-surface resolver removes the two inconsistent root-only decisions instead of adding a plugin exception or another artifact policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a deterministic developer profiling workflow without affecting normal agent, channel, or provider operation.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • add status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This repairs a deterministic developer profiling workflow without affecting normal agent, channel, or provider operation.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the current TypeScript implementation carrying the root-only assumption and this focused repair. (role: current script author and recent area contributor; confidence: high; commits: 3aaf13ca8427, b9a6097a7f69; files: scripts/ensure-extension-memory-build.mts, scripts/profile-extension-memory.mts)

Rank-up moves

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

  • Add after-fix proof from a real setup, such as a short recording, terminal output, linked artifact, or redacted logs.

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.

@steipete
steipete merged commit 648d0c4 into main Aug 28, 2026
220 of 221 checks passed
@steipete
steipete deleted the steipete/interesting-clarke-ac103e branch August 28, 2026 05:22
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Memory profiler rebuilds completed package-local plugin artifacts

1 participant