Skip to content

fix(install): keep native packages on their intended platforms - #165997

Merged
steipete merged 3 commits into
mainfrom
fix/165602-lock-platform
Oct 6, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/165602-lock-platform

Conversation

@steipete

@steipete steipete commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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 libc and rejects missing or changed os, cpu, or libc constraints 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

  • Root cause reproduced with a small loopback registry and confirmed by instrumenting the published npm 10.9.8 Arborist: bundle loadActual retains global: true, adds native children to root dependencies, and changes optional: true to false while leaving their platform constraints intact. npm 10 then skips its optional-only platform check. Explicit root optional edges prevent that promotion.
  • Clean release controls: npm 10.9.8 reproduces on Linux x64 and macOS arm64. npm 11.16 and 11.19 retain only host packages in the tested clean installs. Both registry-spec and tarball installs were exercised; the reported registry-only distinction did not reproduce on Linux.
  • Causal A/B using the exact official release with only generated root optional metadata changed, scripts disabled:
Platform Original npm 10 install Metadata-only candidate Native platform directories
macOS arm64 1,199,336,928 bytes / 1,143.78 MiB 650,328,694 bytes / 620.20 MiB 78 → 7
Linux x64, glibc 1,199,336,928 bytes / 1,143.78 MiB 644,673,019 bytes / 614.81 MiB 78 → 7

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.

  • The exact published 2026.9.8 integrity reader, with its original 1 GiB constant, rejects the original Linux tree and accepts the corrected tree. This proves the byte-limit condition; it is not a claim that an already oversized old installation can complete an unassisted first-hop update. Reader A/B.
  • Linux npm 10 reproduction and metadata-only candidate proof used AWS lease cbx_05de94ff5580.
  • Regressions failed before the repair: mirror normalization deleted 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 --json selected 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.
  • Codex autoreview is clean through P2. The added tooling owns platform validation, manifest generation and backward-compatible preparation recovery; the tests cover those distinct contracts. No changelog, dependency pin, postinstall pruning, or updater-limit changes.

The canonical source package from 03d3b74877302128c119f505d6334dd2f6869c94 passed 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:

npm 10 installation macOS arm64 Linux x64/glibc
Normal lifecycle, local tarball 533,400,599 bytes / 508.69 MiB 528,535,362 bytes / 504.05 MiB
Scripts disabled, loopback registry 522,819,075 bytes / 498.60 MiB 517,116,768 bytes / 493.16 MiB

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 lease cbx_05de94ff5580 is 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.

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.
@clawsweeper

clawsweeper Bot commented Oct 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 docs Improvements or additions to documentation gateway Gateway runtime security Security documentation scripts Repository scripts size: M labels Oct 6, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 4:45 AM ET / 08:45 UTC (Revision 4).

ClawSweeper review

What this changes

The 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
Reviewed head: 6869c4617c3d5a534b8ecf7aea255063c6764e1b

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong causal install evidence, focused ownership, repaired legacy recovery, and successful exact-head CI support above-average readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded npm 10 installs exercise the prepared package metadata on macOS arm64 and Linux x64, with and without lifecycle scripts, retaining seven compatible native packages and passing native probes and the published integrity reader. The recovery-only final correction leaves that package output unchanged. Shipped raw receipts and the new captured-byte format are both supported with edit-preserving restoration; existing oversized installations are explicitly outside the successful update claim.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded npm 10 installs exercise the prepared package metadata on macOS arm64 and Linux x64, with and without lifecycle scripts, retaining seven compatible native packages and passing native probes and the published integrity reader. The recovery-only final correction leaves that package output unchanged. Shipped raw receipts and the new captured-byte format are both supported with edit-preserving restoration; existing oversized installations are explicitly outside the successful update claim.
Evidence reviewed 9 items Verified introduced scope: Read the pinned merge-base-to-head delta. The introduced changes concern package preparation, npm graph validation, their regression coverage, and dependency-locking documentation; endpoint drift was not attributed to this PR.
Production packaging boundary: Bundled packages derive optional platform edges from the validated npm graph. Selection excludes required, development-only, linked, nested, and non-exact package entries. Existing optional declarations remain intact. The prepack caller invokes preparation and the postpack owner restores source artifacts.
Current main still needs the fix: Inspected the pinned main manifest through GitHub: preparation still performs only the prior source-metadata transform and does not derive optional platform edges. Its npm graph normalizer also still deletes libc. Immutable GitHub reads supplied source where local historical blobs could not be hydrated.
Findings None None.
Security None None.

How this fits together

OpenClaw’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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +286, Docs +2, Other +140. Total +428 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 287 1 +286
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 2 153 13 +140
Total 5 443 15 +428

Review metrics

Metric Value Why it matters
Production versus test growth production +140 net lines; tests +286 net lines Production growth has a stated purpose: validating platform contracts, generating optional edges, and preserving offline receipt recovery.

Stored data model

Persistent data-model change detected: serialized state: scripts/package-manifest.mjs, unknown-data-model-change: scripts/package-manifest.mjs. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #165602
Summary: This PR is the explicit candidate fix for the reported npm platform-filtering failure; the earlier cleanup PR covers part of the same installation problem.

Members:

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

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P0: The linked report establishes a blocked normal update caused by oversized npm installs, with manual intervention required for recovery.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded npm 10 installs exercise the prepared package metadata on macOS arm64 and Linux x64, with and without lifecycle scripts, retaining seven compatible native packages and passing native probes and the published integrity reader. The recovery-only final correction leaves that package output unchanged. Shipped raw receipts and the new captured-byte format are both supported with edit-preserving restoration; existing oversized installations are explicitly outside the successful update claim.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded npm 10 installs exercise the prepared package metadata on macOS arm64 and Linux x64, with and without lifecycle scripts, retaining seven compatible native packages and passing native probes and the published integrity reader. The recovery-only final correction leaves that package output unchanged. Shipped raw receipts and the new captured-byte format are both supported with edit-preserving restoration; existing oversized installations are explicitly outside the successful update claim.

Evidence

What I checked:

  • Verified introduced scope: Read the pinned merge-base-to-head delta. The introduced changes concern package preparation, npm graph validation, their regression coverage, and dependency-locking documentation; endpoint drift was not attributed to this PR. (6869c4617c3d)
  • Production packaging boundary: Bundled packages derive optional platform edges from the validated npm graph. Selection excludes required, development-only, linked, nested, and non-exact package entries. Existing optional declarations remain intact. The prepack caller invokes preparation and the postpack owner restores source artifacts. (scripts/package-manifest.mjs:96, 6869c4617c3d)
  • Current main still needs the fix: Inspected the pinned main manifest through GitHub: preparation still performs only the prior source-metadata transform and does not derive optional platform edges. Its npm graph normalizer also still deletes libc. Immutable GitHub reads supplied source where local historical blobs could not be hydrated. (scripts/package-manifest.mjs:78, d3c121c23788)
  • Previous finding resolved and receipt compatibility preserved: The final correction accepts both captured original/prepared bytes and raw backups written by v2026.9.8, comparing current bytes before restoration. Inspected the shipped release implementation and the correction patch. The six manifest cases cover offline recovery, intervening edits, and legacy receipts; the captured discussion reports that the legacy regressions failed before correction and passed afterward. (scripts/package-manifest.mjs:71, 6869c4617c3d)
  • Recorded real install proof: The captured PR body records release-based causal A/B installs and source-built npm 10 installs on macOS arm64 and Linux x64/glibc, both with normal lifecycle scripts and with scripts disabled. All four source-artifact cells retained seven compatible native packages; normal installs measured 508.69 and 504.05 MiB. Native probes and the unchanged published 1 GiB integrity reader passed. The source archive is identified by SHA-256 2b25071deecc4389a21a695e06c156aee377585317034cc3bebcd1ae0d2266a5. Supporting run: https://crabbox.openclaw.ai/portal/runs/run_43329a394046f5206f15bd52ca07e218. Assessment uses the captured results; the portal run was not independently opened. (03d3b7487730)
  • Proof continuity and bounded update claim: The final commit changes only manifest recovery and its tests, leaving fresh prepared package output unchanged. The body explicitly distinguishes acceptance by the published integrity reader from an unassisted update of an already oversized installation. That existing recovery limitation is not a regression introduced by this patch. (scripts/package-manifest.mjs:78, 6869c4617c3d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RomneyDa: 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-10-06T07:54:54.279Z sha 03d3b74 :: blocked before merge. :: [P2] Preserve restoration of shipped prepack receipts
  • reviewed 2026-10-06T08:01:55.290Z sha 03d3b74 :: blocked before merge. :: [P2] Preserve restoration of shipped prepack receipts
  • reviewed 2026-10-06T08:30:17.747Z sha 6869c46 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review October 6, 2026 07:56
@steipete

steipete commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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: pnpm test test/scripts/generate-npm-package-lock.test.ts test/scripts/package-manifest.test.ts --maxWorkers=1, followed by the six-case manifest recovery suite; pnpm tsgo:scripts; pnpm tsgo:test:root; all 104 transient npm lock validations; relevant changed guards and scoped lint. The initial lint finding was corrected and rechecked.

Exact final-head CI passed without an admin exception: https://github.com/openclaw/openclaw/actions/runs/37434792745 (head 6869c4617c3d5a534b8ecf7aea255063c6764e1b, attempt 1; 36 successful jobs, 25 skipped, no failures or cancellations). Native review/prepare/merge closeout is in progress.

@clawsweeper clawsweeper Bot added 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 6, 2026
@steipete
steipete merged commit 2277f76 into main Oct 6, 2026
128 checks passed
@steipete
steipete deleted the fix/165602-lock-platform branch October 6, 2026 09:01
@steipete

steipete commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…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
RomneyDa pushed a commit that referenced this pull request Oct 7, 2026
* 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)
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 gateway Gateway runtime P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts security Security documentation 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.

[Bug]: npm global install includes native binaries for all OS/architectures instead of current platform only

1 participant