Skip to content

Commit 9987d84

Browse files
committed
fix(plugins): preserve declared dependencies in source checkouts
pnpm owns source dependency versions and workspace links. Remove both source pruning owners, isolate npm bundle staging, preserve importer trees in CI caches, and keep the Bun Undici workaround importer-relative. Source tests now exercise declared plugin versions after install and build. Packaged runtime cleanup remains unchanged; no dependency pins change. Related: #132385
1 parent 90c1d79 commit 9987d84

16 files changed

Lines changed: 421 additions & 386 deletions

‎.github/actions/setup-node-env/action.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ runs:
209209
node_modules
210210
ui/node_modules
211211
packages/*/node_modules
212+
extensions/*/node_modules
212213
examples/*/node_modules
213214
.cache/openclaw-pnpm-store
214215
key: ${{ steps.dependency-cache-key.outputs.key }}
@@ -449,9 +450,9 @@ runs:
449450
# reconciliation validates them without reaching the registry. Later
450451
# build wrappers can use installed Node entrypoints directly.
451452
echo "OPENCLAW_BUILD_ALL_NO_PNPM=1" >> "$GITHUB_ENV"
452-
# Postinstall intentionally prunes plugin-local node_modules. Pnpm's
453-
# redundant pre-run check treats that as stale and can launch unsafe
454-
# concurrent implicit installs after CI fans out.
453+
# Install and frozen reconciliation own dependency writes. Keep later
454+
# shard commands read-only so they cannot launch concurrent implicit
455+
# installs after CI fans out.
455456
# zizmor: ignore[github-env] static pnpm policy owned by this action.
456457
echo "pnpm_config_verify_deps_before_run=false" >> "$GITHUB_ENV"
457458
fi

‎.github/workflows/vitest-cache-warm.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
node_modules
9393
ui/node_modules
9494
packages/*/node_modules
95+
extensions/*/node_modules
9596
examples/*/node_modules
9697
.cache/openclaw-pnpm-store
9798
key: ${{ steps.setup-node-env.outputs.dependency-cache-key }}

‎docs/ci.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ The slowest Node test families are split or balanced so each job stays small wit
225225
- Broad browser, QA, media, and miscellaneous plugin tests use their dedicated Vitest configs instead of the shared plugin catch-all. Include-pattern shards record timing entries using the CI shard name, so `.artifacts/vitest-shard-timings.json` can distinguish a whole config from a filtered shard.
226226
- The browser native-host launch test is a separate POSIX E2E case. Linux `build-artifacts` runs it explicitly after building or restoring dist, using `OPENCLAW_E2E_USE_PREBUILT_DIST=1` so the test cannot start another build. Its JSON report must contain exactly the named passing assertion in the expected file, with one passed test and zero failures, pending tests, or todos; missing artifacts, skipped tests, and absent results fail. The workflow step skips only when a frozen historical checkout lacks the test file: that is unavailable historical proof, not coverage. Current checkouts with a missing file still fail. Changes to the case, its installation fixture, or its relay-key fixture select the artifact job even on test-only diffs; unrelated browser unit tests stay build-free. Manual CI uses the same artifact step, independently of the release-only plugin sweep.
227227
- Linux Node shard jobs persist Vitest's experimental filesystem module cache through the upstream Actions cache API, which Blacksmith transparently accelerates on its runners. Blacksmith CI shards are restore-only and unpack the protected seed into isolated runner-local roots. While the GitHub-hosted outage backend is active, every `checks-node-*` test shard, `check-sqlite-session-lifecycle`, `checks-ui`, the ordinary sharded `checks-ui-e2e` job, both fast contract matrices, and the Vitest-running `checks-fast-core` tasks restore that same immutable transform seed. The composite action's single default-off `restore-test-caches` input keeps the expansion easy to disable without changing cache keys or writer policy; mixed fast-core rows enable it only for tasks that invoke Vitest. The small real-Gateway UI job stays cold because its two targeted files do not justify the archive restore, while native and Control UI i18n lanes do not invoke Vitest. The hybrid planner profile restores the same seeds: attempt-1 Blacksmith rows read the archives through Blacksmith's Actions-cache proxy and hosted retries read them directly. The planner still elects exactly one Node shard to restore and save the shared transform archive so hosted runs can recover a cold cache without waiting for the daily warmer; every other job remains restore-only. The non-cancelling warmer runs daily, accepts manual or repository dispatch, follows `OPENCLAW_CI_RUNNER_BACKEND`, and serializes per ref, so maintainers can rebuild both the Vitest transform cache and test-scope Node compile cache on hosted runners without canceling a main writer. The warmer launches each selected shard/config envelope in a fresh child process with concurrency one, preserving its include patterns and environment while reusing the same serial cache leaf. It finishes every selected envelope and saves the content-keyed transform and compile caches even when a test fails, then reports the test failure after the cache saves; ordinary CI shard execution remains fail-fast. This prevents config-global state from leaking, avoids expanding filtered shards into whole configs, and retains transforms produced by the previous child. A transform-input fingerprint clears incompatible lockfile, package, tsconfig, and Vitest-config generations. Each writer scans and prunes its restored cache to 75% after it exceeds 2 GiB. Vitest hashes module id, source content, environment, and resolved transform config, so ordinary partial source changes keep unchanged entries warm while changed modules miss safely. Coarse restore prefixes bridge workflow runs; normal Actions cache LRU and inactivity eviction bound old immutable archives.
228-
- Trusted Blacksmith Linux Node jobs restore root `node_modules`, retained workspace importer links, and the workspace-local pnpm store from one immutable upstream Actions cache, which Blacksmith transparently serves from its colocated backend. Pnpm imports with hard links where the filesystem permits, and keeping the complete installed tree and store in one archive preserves those links; plugin importer trees that postinstall intentionally removes remain absent. The key includes an explicit archive format, runner OS and architecture, the exact Node patch, and the semantic install-input fingerprint; there are no stale-prefix fallbacks. Manifests are canonicalized before hashing. The repository-owned `openclaw` metadata block and non-install scripts are excluded because pnpm and the audited direct root hooks do not read them, so runtime schema, publication metadata, formatting, and ordinary test/build script edits keep the dependency tree warm; unaudited lifecycle-hook drift fails closed until its source inputs join the fingerprint contract. Dependency, package-manager, hook-source, and lockfile changes always select a new immutable archive. Every exact restore runs frozen offline pnpm reconciliation, so an unchanged archive validates without registry access or importer relinking. If reconciliation fails, setup first clears every importer tree and rebuilds it offline from the restored store, then clears both modules and store and retries from the network rather than serving a partial tree. Setup then disables pnpm's redundant pre-run dependency check because postinstall intentionally prunes plugin-local `node_modules`, which pnpm otherwise treats as stale and can repair through unsafe concurrent installs during shard fanout. Preflight is the sole writer and saves immediately after a successful deterministic install: canonical `main` publishes the default-branch seed, while same-repo pull requests publish only into their merge-ref scope before their dependent jobs fan out. Consumers are restore-only; an exact miss automatically falls back to the coarser pnpm store cache. Manual dispatches, fork pull requests, and hosted retries use only that store cache, and the separate store-warmer is skipped when preflight already owns either exact-cache write. Cache restore/save failures are optimization misses rather than correctness failures, and normal branch scoping, LRU, and inactivity eviction bound obsolete archives. The former mutable dependency StickyDisk path was retired after repeated successful writers acknowledged commits that later runs still restored as empty filesystems.
228+
- Trusted Blacksmith Linux Node jobs restore root `node_modules`, workspace importer trees (including plugin-local versions and links), and the workspace-local pnpm store from one immutable upstream Actions cache, which Blacksmith transparently serves from its colocated backend. Pnpm imports with hard links where the filesystem permits, and keeping the complete installed tree and store in one archive preserves those links. Source postinstall and build preparation leave pnpm-owned dependency trees intact. The key includes an explicit archive format, runner OS and architecture, the exact Node patch, and the semantic install-input fingerprint; there are no stale-prefix fallbacks. Manifests are canonicalized before hashing. The repository-owned `openclaw` metadata block and non-install scripts are excluded because pnpm and the audited direct root hooks do not read them, so runtime schema, publication metadata, formatting, and ordinary test/build script edits keep the dependency tree warm; unaudited lifecycle-hook drift fails closed until its source inputs join the fingerprint contract. Dependency, package-manager, hook-source, and lockfile changes always select a new immutable archive. Every exact restore runs frozen offline pnpm reconciliation, so an unchanged archive validates without registry access or importer relinking. If reconciliation fails, setup first clears every importer tree and rebuilds it offline from the restored store, then clears both modules and store and retries from the network rather than serving a partial tree. Setup then disables pnpm's redundant pre-run dependency check so install and frozen reconciliation remain the only dependency writers; shard commands must not launch concurrent implicit installs. Preflight is the sole writer and saves immediately after a successful deterministic install: canonical `main` publishes the default-branch seed, while same-repo pull requests publish only into their merge-ref scope before their dependent jobs fan out. Consumers are restore-only; an exact miss automatically falls back to the coarser pnpm store cache. Manual dispatches, fork pull requests, and hosted retries use only that store cache, and the separate store-warmer is skipped when preflight already owns either exact-cache write. Cache restore/save failures are optimization misses rather than correctness failures, and normal branch scoping, LRU, and inactivity eviction bound obsolete archives. The former mutable dependency StickyDisk path was retired after repeated successful writers acknowledged commits that later runs still restored as empty filesystems.
229229
- Node shard and build-artifact jobs also restore Node's portable on-disk compile cache through immutable Actions caches. In GitHub-hosted outage mode, the hosted Vitest lane set above restores the same test-scope archive alongside the transform seed. Independent `test` and `build` namespaces prevent their writers from replacing each other's archives: the scheduled test warmer owns the protected test seed, while `build-artifacts` may publish at most one protected build archive per UTC day from trusted `main` pushes. PR and ordinary test jobs only read protected snapshots, so feature-branch bytecode never enters the shared seed and PR traffic creates no cache archives. This reuses V8 bytecode for Node-loaded orchestration, build tooling, and external dependencies across different checkout paths, including when only part of the source graph changes. A maximum-size 2 GiB transform archive costs roughly 15–20 seconds to restore at about 125 MB/s; measured fast-contract transforms are roughly 21 seconds against an approximately 8-second restore, and broader cold imports reach roughly 100–143 seconds. The optimization should be reverted if measured savings fall below restore cost. Vitest child processes disable an inherited compile cache because coverage can be enabled inside dynamic configs and V8 coverage can lose source-position precision when scripts are deserialized from bytecode.
230230
- Hosted `check-lint` restores and saves the same content-keyed extension package-boundary archive as the dedicated boundary lane before rebuilding any missing declarations; Blacksmith keeps its read-only sticky-disk fast path. The Control UI and UI E2E jobs share a Linux Playwright Chromium archive keyed by the exact pinned Playwright version. `macos-node` saves the pnpm store after an exact miss, allowing both hosted and Blacksmith macOS runners to seed the cache they already restore.
231231
- The build-artifact job also persists content-fingerprinted `build-all` step outputs. The `ciArtifacts` profile skips global declaration emission, then stages the canonical public/private `tsdown` SDK declaration groups through `scripts/write-plugin-sdk-entry-dts.ts`. It publishes declarations to `dist/` only after both groups succeed and all relative declaration references resolve within the staged output. This step has no separate declaration cache and writes no workspace forwarding bridges. Local plugin lint and package-boundary compilation use independent native declaration trees, not packaged declarations; see [declaration ownership](/reference/test#shared-test-state-and-process-helpers). The built Doctor plugin-index proof reuses that exact `dist/` output instead of invoking the E2E harness's fallback TypeScript build a second time.

‎docs/plugins/dependency-resolution.md‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ rm -rf "$tmpdir"
121121
OpenClaw-owned npm plugin packages can also publish with explicit
122122
`bundledDependencies`. The npm publish path overlays the runtime dependency
123123
name list, strips dev-only workspace metadata from the published manifest,
124-
runs a script-free npm install for the package-local runtime dependencies,
125-
then packs or publishes the plugin tarball with those dependency files
126-
included. Native-heavy packages (Codex, ACPX, Copilot, llama.cpp,
124+
stages a separate package directory without source `node_modules`, and runs a
125+
script-free npm install there for runtime dependencies. It then packs or publishes
126+
the plugin tarball with those dependency files included and removes the staging
127+
directory. The pnpm-owned source dependency tree stays unchanged.
128+
Native-heavy packages (Codex, ACPX, Copilot, llama.cpp,
127129
memory-lancedb, Microsoft Teams, Tlon) opt out with
128130
`openclaw.release.bundleRuntimeDependencies: false`; they still ship a
129131
precisely pinned manifest, but npm resolves runtime dependencies during install
@@ -201,10 +203,11 @@ External plugins keep their runtime dependencies plugin-local.
201203

202204
In source checkouts, use `pnpm install` followed by `pnpm build`. OpenClaw
203205
prefers `dist/extensions`, then `dist-runtime/extensions`, and falls back to
204-
`extensions` when neither built tree is available. Postinstall and build
205-
preparation remove plugin-local `node_modules`, so bundled runtime resolution
206-
must not depend on those directories. Rebuild to pick up source edits when
207-
using a built tree. Source checkout development is pnpm-only; plain
206+
`extensions` when neither built tree is available. pnpm owns the source dependency
207+
trees: postinstall and build preparation preserve plugin-local versions and
208+
workspace links. Native Node imports resolve from each plugin package;
209+
packaged bundled runtime still uses the root runtime declarations above.
210+
Rebuild to pick up source edits when using a built tree. Source checkout development is pnpm-only; plain
208211
`npm install` at the repository root does not prepare the pnpm workspace.
209212

210213
| Install shape | Bundled plugin location | Dependency owner |
@@ -222,8 +225,9 @@ convergence remains intentionally script-disabled and continues to use the
222225

223226
### Native imports from a standalone source build
224227

225-
To import an already-built `extensions/<package>/dist` directly with Node,
226-
explicitly prepare its host link from the source checkout root:
228+
To import an already-built `extensions/<package>/dist` directly with Node, use
229+
the host link installed by pnpm. If that link is missing, explicitly prepare it
230+
from the source checkout root:
227231

228232
```bash
229233
node scripts/lib/plugin-npm-runtime-build.mjs --prepare-native-import extensions/<package>
@@ -240,10 +244,9 @@ through the pnpm workspace.
240244

241245
Preparation refuses symlinked package paths, unsafe manifests, and conflicting
242246
dependency paths instead of reporting success. Ordinary package builds remain
243-
artifact-only. Postinstall and root build preparation still remove source
244-
plugin-local `node_modules`, including this link; rerun the explicit preparation
245-
command afterward when needed. Runtime loading never performs this setup or
246-
runs a package manager.
247+
artifact-only. Postinstall and root build preparation preserve source
248+
plugin-local `node_modules`, including this link. Runtime loading never performs
249+
this setup or runs a package manager.
247250

248251
## Legacy cleanup
249252

‎docs/start/setup.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ ignores these settings; Node runtime support does not imply support for its
3737
bundled npm as a source resolver. [Published/global installs](/install) do not
3838
inherit the repository's `.npmrc`. Source installs continue to use pnpm.
3939

40+
pnpm owns root and plugin-local dependencies, including workspace links and
41+
versions that differ between packages. Postinstall and build preparation preserve
42+
those trees. If an older checkout pruned plugin-local dependencies, run
43+
`pnpm install --frozen-lockfile` after updating to restore them before testing.
44+
4045
## Tailoring strategy (so updates do not hurt)
4146

4247
If you want "100% tailored to me" _and_ easy updates, keep your customization in:

0 commit comments

Comments
 (0)