Repository navigation
fix(install): keep native packages on their intended platforms - #165997
Conversation
Generate explicit optional platform edges for bundled packages so npm 10 does not promote them to required dependencies during global installation. Preserve and validate native platform constraints in npm dependency evidence. Fixes #165602. Thanks to @TommyFive for the report and detailed reproduction.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 4:45 AM ET / 08:45 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR prepares package metadata so npm retains compatible optional native packages, validates their platform constraints, and preserves recovery from interrupted packaging. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main lacks the install fix. The previous receipt-recovery blocker is resolved, the recorded platform install proof covers the changed behavior, and no remaining introduced defect was found. Priority: P0 Review scores
Verification
How this fits togetherOpenClaw’s packaging tools turn the reviewed dependency graph into published package metadata. npm consumes that metadata during installation, determining which native binaries remain in the installed tree. flowchart TD
A[Reviewed dependency graph] --> B[Validate versions and platform constraints]
B --> C[Prepare package metadata]
C --> D[Declare native packages optional]
D --> E[npm platform filtering]
E --> F[Compatible installed binaries]
C --> G[Capture source and prepared bytes]
G --> H[Restore source manifest]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +286, Docs +2, Other +140. Total +428 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep platform filtering in package metadata while preserving validated dependency identities, patched bundles, and recovery from shipped preparation receipts. Do we have a high-confidence way to reproduce the issue? Yes: the captured evidence provides clean npm 10 release-install reproductions and metadata-only A/B controls on macOS and Linux. This review inspected source and recorded results without executing installation. Is this the best way to solve the issue? Yes: deriving optional edges from the existing validated graph fixes installation before lifecycle scripts run, while retaining the existing dependency and integrity policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d3c121c23788. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
The prior-head receipt finding is fixed in 6869c46. Recovery now accepts the v2026.9.8 raw backup and the captured-byte format, with the same ownership check for intervening edits. Both legacy regressions failed before the correction; all six manifest cases now pass, and Codex autoreview is clean through P2. The final source-built package has passed normal npm 10 installs and scripts-disabled registry installs on macOS arm64 and Linux x64. Both retain only seven compatible native packages. Normal installations measure 508.69 MiB and 504.05 MiB respectively; CLI/native probes and the exact published 1 GiB integrity reader passed on both platforms. The AWS lease is released. The PR body records the immutable tarball hash, source-build/install run links, same-release causal A/B, and the limit of this proof for already oversized old installations. The subsequent receipt-only correction changes no shipped file or fresh-package output. Validation: Exact final-head CI passed without an admin exception: https://github.com/openclaw/openclaw/actions/runs/37434792745 (head |
|
Merged via squash.
|
…law#165997) * fix(install): retain platform filtering in global npm installs Generate explicit optional platform edges for bundled packages so npm 10 does not promote them to required dependencies during global installation. Preserve and validate native platform constraints in npm dependency evidence. Fixes openclaw#165602. Thanks to @TommyFive for the report and detailed reproduction. * fix(packaging): narrow lock versions before platform validation * fix(packaging): recover interrupted legacy manifest preparation
* fix(install): retain platform filtering in global npm installs Generate explicit optional platform edges for bundled packages so npm 10 does not promote them to required dependencies during global installation. Preserve and validate native platform constraints in npm dependency evidence. Fixes #165602. Thanks to @TommyFive for the report and detailed reproduction. * fix(packaging): narrow lock versions before platform validation * fix(packaging): recover interrupted legacy manifest preparation (cherry picked from commit 2277f76)
Closes #165602. Thanks @TommyFive for the report and detailed reproduction; @Kenmege's earlier install/update investigation in #164955 helped narrow the affected npm version.
What Problem This Solves
Fixes: global npm installs retain native binaries for unrelated platforms, adding more than 500 MiB and exceeding the 1 GiB package-tree limit in published updaters.
User Impact
Global installs retain only compatible optional native packages, including when lifecycle scripts are disabled. Patched bundled runtimes remain bundled, and dependency pins and integrity limits are unchanged. This does not retroactively shrink an already oversized installation; an older updater that rejects its existing tree may still need a manual reinstall.
Why This Change Was Made
npm 10's global bundle loader turns hoisted optional children into required dependencies before checking their platform. Package preparation now derives explicit root optional platform dependencies from the validated npm graph, preserving npm's optional-edge precedence. The npm lock generator also retains
libcand rejects missing or changedos,cpu, orlibcconstraints against the pnpm source.The published 2026.9.8 archive contains no shrinkwrap or package-lock at any depth. Missing published lock constraints were therefore not the installation root cause. The existing lockless tarball contract stays intact; all 104 npm mirrors are regenerated transiently for validation/evidence. Manifest restoration uses captured original/prepared bytes and still accepts raw backups written by v2026.9.8. Both formats preserve intervening edits and recover without registry access.
Evidence
loadActualretainsglobal: true, adds native children to rootdependencies, and changesoptional: truetofalsewhile leaving their platform constraints intact. npm 10 then skips its optional-only platform check. Explicit root optional edges prevent that promotion.The seven retained families are esbuild, koffi, node-pty, fs-safe, cua-driver, ubjs, and sqlite-vec, each with the host OS/architecture (and glibc where declared). The source fs-safe version is unchanged by this PR.
cbx_05de94ff5580.libc; package preparation omitted root optional platform edges. The combined owner suite passed 84/84 tests (pnpm test test/scripts/generate-npm-package-lock.test.ts test/scripts/package-manifest.test.ts --maxWorkers=1, 196.18 s wrapper wall time). New manifest tests took 26 ms; existing npm subprocess fixtures dominate the generator suite. After version-type narrowing, 18 affected cases passed in 4.10 s.pnpm changed:lanes --jsonselected scripts/root-test/docs/tooling lanes.pnpm tsgo:scripts,pnpm tsgo:test:root, all 104 npm lock validations, dependency and architecture guards, formatting, and unused-export scans passed. The changed-check wrapper initially caught one new lint error in an untyped version expression; explicit input narrowing fixed it. Script/test lint and the remaining Docker/HTTP2 checks then passed. Docs link audit: 14,917 links, zero broken.The canonical source package from
03d3b74877302128c119f505d6334dd2f6869c94passed its full build (9m 57s), tarball inventory and dist-import validation on AWS. Archive SHA-256:2b25071deecc4389a21a695e06c156aee377585317034cc3bebcd1ae0d2266a5. Source build. Final source-artifact installs passed on both platforms:All four cells retain only the seven compatible native packages. Normal lifecycle scripts replace esbuild's JS shim with a native hardlink, so logical path sums are slightly larger than script-disabled installs. Disk allocation for normal installs is 622,640 KiB on macOS and 617,068 KiB on Linux. CLI identity reports
03d3b74; esbuild transforms, native-required fs-safe write/read, and CUA native imports passed on both systems. The exact published 1 GiB reader accepts both final normal installs (macOS 291.36 s on the loaded host; Linux 8.14 s). Final Linux install/runtime proof. AWS leasecbx_05de94ff5580is verified released.ClawSweeper's receipt-compatibility finding is fixed in
6869c4617c3d5a534b8ecf7aea255063c6764e1b: legacy recovery failed before the correction; all six manifest cases then passed (11.59 s wrapper wall time), along with script/root-test types and scoped lint. Fresh manifest generation and installed bytes are unchanged by that follow-up; the two changed files are excluded from the tarball, so the existing source-package install proof remains applicable. Independent review of the correction is clean through P2.The initial implementation's exact-head CI run 37432857764 passed. Final-head CI 37434792745, attempt 1, passed on
6869c4617c3d5a534b8ecf7aea255063c6764e1b: 36 successful jobs, 25 skipped, no failures or cancellations. The hosted tooling shard ran all 80 generator tests in 12.972 s and all six manifest tests in 22 ms. No inherited-failure attribution, rerun, or admin exception was needed.