Skip to content

fix: share fs-safe native assets across package graphs - #132193

Merged
RomneyDa merged 2 commits into
mainfrom
fix/dedupe-fs-safe-native
Aug 28, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
fix/dedupe-fs-safe-native

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where npm packages contained two identical copies of every fs-safe native binary after the sealed worker gained native-mode support.

Why This Change Was Made

The normal runtime and sealed worker are emitted at different directory depths, while @openclaw/fs-safe resolves native binaries relative to its emitted loader. The sealed-worker build now rewrites that dependency-owned relative lookup to the package's canonical dist/native directory. The runtime build remains the sole owner that copies the seven platform binaries.

The transform validates the exact upstream source shape and fails the build if that contract changes. This preserves native off, auto, and require behavior without symlinks, fallback paths, or duplicate package assets.

User Impact

Installed npm packages retain native fs-safe support while using 16,233,360 fewer unpacked bytes (15.48 MiB).

Evidence

  • Before the fix, the package build emitted identical 16,233,360-byte trees at dist/native and dist/dist/native.
  • After the fix, the full package build emits seven platform binaries only at dist/native; dist/dist/native is absent.
  • The generated sealed worker resolves ../../dist/native/, sharing the runtime-owned asset tree.
  • npm pack --dry-run --ignore-scripts --json: 228,483,134 unpacked bytes; removing the duplicate accounts for exactly 16,233,360 bytes.
  • Pre-fix regression proof: the relocated worker test failed because the canonical shared tree was absent, and the focused transform test returned no rewrite.
  • node scripts/run-vitest.mjs test/scripts/worker-deploy-build-plugin.test.ts test/scripts/tsdown-config.test.ts — 27 tests passed.
  • NODE_OPTIONS=--max-old-space-size=8192 pnpm build:package — passed, including CLI bootstrap and plugin SDK checks.
  • Local autoreview — clean, no actionable findings.

Production/tooling delta is +12 lines. The added lines implement and fail-closed validate the dependency path transform required to preserve native-mode behavior while deleting the second asset-copy owner; no smaller dependency-supported configuration seam exists in @openclaw/fs-safe 0.5.6 or its current main source.

@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 scripts Repository scripts size: S maintainer Maintainer-authored PR labels Aug 28, 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 Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 7:39 PM ET / 23:39 UTC.

ClawSweeper review

What this changes

The PR rewrites the sealed worker’s bundled fs-safe asset lookup to share one package-level native-binary directory and splits the UI test typecheck shard.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No concrete introduced correctness defect was found, but this maintainer-owned package-layout change needs exact-head package validation before merge because the locked dependency source and latest remote main were unavailable locally.

Priority: P3
Reviewed head: a93c579cae5236be86cb78885f16f69a1f02c7af
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused source and runtime-oriented test coverage are present, but independent dependency-contract and current-main/package validation are unavailable here.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR author is a MEMBER, so the external-contributor proof gate does not apply; its supplied body reports a real package build and relocated runtime probe, but this reviewer could not independently rerun them because fs-safe is absent from the worktree.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR author is a MEMBER, so the external-contributor proof gate does not apply; its supplied body reports a real package build and relocated runtime probe, but this reviewer could not independently rerun them because fs-safe is absent from the worktree.
Evidence reviewed 5 items Worker lookup ownership: The introduced transform identifies the bundled fs-safe native loader by canonical path, rewrites its relative native directory only for the worker graph, and errors if the expected dependency-owned source shape is absent.
Single asset-copy owner: The normal unified build retains the native-asset copy into dist/native, while the worker build has no copy configuration and is emitted as dist/worker/worker.mjs.
Runtime-path coverage: The relocated-output test builds both graphs, exercises require/configured/off/auto native modes, compares the seven native assets, and verifies required-native failure after asset removal; the focused transform test also guards the rewrite shape.
Findings None None.
Security None None.

How this fits together

The package build emits the normal runtime and sealed worker at different directory depths. Both must locate fs-safe native binaries in an installed npm package, while the typecheck shard list determines CI coverage.

flowchart LR
  A[Package build] --> B[Runtime bundle]
  A --> C[Sealed worker bundle]
  B --> D[Package native assets]
  C --> E[Worker lookup rewrite]
  E --> D
  D --> F[Installed native behavior]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned package-layout repair land after exact-head package output confirms one native tree and worker native-mode behavior? Verify packaged output before merge: Run the exact-head package build and confirm one dist/native tree plus successful worker native-require and fallback behavior.

Why: The author is a repository member and the PR carries the protected maintainer label; the review environment cannot independently inspect the pinned dependency or current remote main.

Before merge

  • Resolve merge risk (P1) - A malformed or changed fs-safe relative-path contract would make installed worker native require mode unable to find its binary; the transform fails closed, but this reviewer could not inspect the pinned dependency or run the exact-head package build.
  • Resolve merge risk (P1) - Production tooling is net +17 lines; the added lookup transform and shape guard appear necessary to remove the duplicate asset-copy owner, but this should be confirmed by the exact-head package artifact check.
  • Complete next step (P2) - This is a normal maintainer-owned review and exact-head validation step, not a discrete repair suitable for an automated replacement branch.
Agent review details

Security

None.

PR surface

Tests +44, Other +17. Total +61 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 51 7 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 25 8 +17
Total 7 76 15 +61

Review metrics

Metric Value Why it matters
Production versus test LOC production +25/-8 (net +17); tests/test support +51/-7 The production growth is confined to the worker dependency-path transform and CI shard split; test support covers the relocated package layout and transform guard.

Merge-risk options

Maintainer options:

  1. Verify the packed native layout (recommended)
    Before merge, validate the exact head produces only the canonical native tree and that the sealed worker loads it in required-native mode.
  2. Accept the packaging risk
    Maintainers may rely on the recorded local build evidence if the exact-head package validation cannot be repeated.

Technical review

Best possible solution:

Keep one runtime-owned dist/native tree and verify the packed exact head resolves it correctly for the worker’s required-native and fallback modes before landing.

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

Unclear: the checked-in test defines a focused relocated-package path, and the PR body reports it passing, but unavailable dependencies prevented an independent current-head run.

Is this the best way to solve the issue?

Unclear: one canonical asset tree plus a worker-only relative-path rewrite is coherent, but direct inspection of fs-safe 0.5.6 and the latest main artifact was unavailable in this checkout.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: A bad packaged relative path would break existing users who enable fs-safe native require mode after upgrade.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P3: This removes duplicate package assets and adjusts CI sharding without evidence of an active user outage.
  • merge-risk: 🚨 compatibility: A bad packaged relative path would break existing users who enable fs-safe native require mode after upgrade.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR author is a MEMBER, so the external-contributor proof gate does not apply; its supplied body reports a real package build and relocated runtime probe, but this reviewer could not independently rerun them because fs-safe is absent from the worktree.

Evidence

What I checked:

  • Worker lookup ownership: The introduced transform identifies the bundled fs-safe native loader by canonical path, rewrites its relative native directory only for the worker graph, and errors if the expected dependency-owned source shape is absent. (scripts/lib/worker-deploy-build-plugin.mts:84, a93c579cae52)
  • Single asset-copy owner: The normal unified build retains the native-asset copy into dist/native, while the worker build has no copy configuration and is emitted as dist/worker/worker.mjs. (tsdown.config.ts:174, a93c579cae52)
  • Runtime-path coverage: The relocated-output test builds both graphs, exercises require/configured/off/auto native modes, compares the seven native assets, and verifies required-native failure after asset removal; the focused transform test also guards the rewrite shape. (test/scripts/tsdown-config.test.ts:89, a93c579cae52)
  • Feature history: Local history places the preceding sealed-worker build at f661f01 and the bundled-native repair at d43520b; this PR’s two commits follow those changes. (scripts/lib/worker-deploy-build-plugin.mts:30, f661f0155f3d)
  • Reviewer limitation: This worktree has no installed @openclaw/fs-safe native loader, and GitHub access failed, so the dependency’s locked source contract, later main revision, and omitted comment bodies could not be independently inspected here.

Likely related people:

  • RomneyDa: The author also appears in prior merged history for the sealed-worker artifact immediately preceding this patch. (role: sealed-worker feature owner; confidence: high; commits: f661f0155f3d, a93c579cae52; files: scripts/lib/worker-deploy-build-plugin.mts, tsdown.config.ts)
  • Peter Steinberger: Recent history credits the bundled-install native fs-safe repair and subsequent native-probe test work. (role: recent native-runtime contributor; confidence: high; commits: d43520b04c29, 86a0b223142e; files: tsdown.config.ts, test/scripts/tsdown-config.test.ts)

Rank-up moves

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

  • Run exact-head package validation against the locked fs-safe dependency and retain redacted output showing the single native directory and worker native-mode results.

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 (1 earlier review cycle)
  • reviewed 2026-08-28T23:15:54.664Z sha 0c4619a9a31d2386f163aad9508c2bbcf3c11a36 :: needs maintainer review before merge. :: none

@RomneyDa
RomneyDa force-pushed the fix/dedupe-fs-safe-native branch from 0c4619a to ee7201b Compare August 28, 2026 23:29
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@RomneyDa
RomneyDa force-pushed the fix/dedupe-fs-safe-native branch from ee7201b to a93c579 Compare August 28, 2026 23:29
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

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

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S 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