Repository navigation
fix(release): resolve workspace: dependencies before npm pack ships them - #336
Conversation
The just-published v2026.7.35-boon.1 release tarball is broken for every `npm i -g` install, not just one host: #307's upstream sync added `@openclaw/ai` as a root dependency for the first time, declared as `"workspace:*"`. `npm pack` (used by boon-release.yml to build the fork's GitHub Release tarball) has no concept of pnpm's workspace: protocol and ships that literal specifier as-is. Any global install of the tarball then asks npm's resolver to fetch `@openclaw/ai@workspace:*`, which it can't parse -- confirmed on two different npm/node versions (the canary host's npm 11.21.1/node 22.23.4, and a local npm 11.8.0/node 24.13.1) that it dies deterministically right after resolving @mozilla/readability's manifest with a bare `exit 1` and no further diagnostic, a known class of npm bug for unsupported specifiers. Root-caused by comparing against the real npm registry: upstream publishes `@openclaw/ai` in lockstep with their own root `openclaw` releases (confirmed `@openclaw/[email protected]` exists and matches the exact upstream base this fork train is built on), but the fork never publishes packages/* members under its own -boon.N suffix -- there is no `@openclaw/[email protected]` anywhere for npm to fetch, and pointing at it would just trade one failure for a 404. The correct resolution is the real, already-published upstream base version. Adds scripts/lib/resolve-workspace-pack-deps.mjs: rewrites any `workspace:` root dependency to the matching local workspace package's version, stripping a `-boon.N` fork suffix back to the real publishable base (reusing parseForkReleaseVersion from release-version.mjs, the same helper #335 added for the release-preflight gap). Wired into the existing prepack/postpack lifecycle (mirrors scripts/package-changelog.mjs's established backup-and-restore shape) so it applies automatically to any `npm pack`/`npm publish` of the root package, not just boon-release.yml's one call site -- no workflow change needed. The bare CLI mode defaults to a dry-run preview; only `prepare` mutates (with a backup) and only `restore` reverts, after an un-backed-up bare invocation during local verification taught this the hard way. - Verified end-to-end: patched the real v2026.7.35-boon.1 tarball's @openclaw/ai to the resolved 2026.7.35, re-tarred it, and `npm i -g` succeeded ("added 390 packages"), with @openclaw/ai installed at the correct version. - `node scripts/lib/resolve-workspace-pack-deps.mjs` (bare) against the real repo: previews the exact same rewrite without touching disk. - Full prepare/restore round-trip verified byte-identical against the real repo's package.json. - New unit tests in test/scripts/resolve-workspace-pack-deps.test.ts cover glob expansion, *//^/~/explicit-pin rewriting, the missing-match error, the prepare/restore round-trip, the backup-free no-op case, and the stale-version restore refusal; manually executed the equivalent assertions directly (no local node_modules in this worktree) -- all passed. Full Vitest run deferred to CI. - `git diff --check` -> clean; package.json re-parsed as valid JSON. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
View guided diff | Turn on auto-fix | Re-trigger cubic
Addresses cubic review on #336: - Rewrite workspace: specifiers across dependencies, optionalDependencies, AND peerDependencies (only dependencies was handled before), matching the three sections generate-npm-shrinkwrap.mjs already treats as a unit. - An explicit `workspace:<version>` pin now also strips a fork `-boon.N` suffix via publishableBaseVersion, so a pin copied from a local fork-suffixed version doesn't reproduce the same unparseable-specifier break the rest of this fix exists to close. - prepareWorkspacePackDependencies now writes the backup to disk BEFORE mutating package.json (was: mutate, then back up), so a failed backup write can never leave the checkout permanently rewritten with nothing to restore from. - restoreWorkspacePackDependencies now does a full-content comparison against the rewrite its own backup would have produced, not just a version-field check -- a same-version edit made to package.json between prepare and restore is refused instead of silently clobbered. - New scripts/postpack-restore.mjs runs the changelog and workspace-deps restores unconditionally and reports both failures, replacing the `&&`-chained postpack script (which skipped the second restore entirely if the first one failed). - Reordered prepareWorkspacePackDependencies before preparePackageChangelog in openclaw-prepack.ts's main(): a missing-workspace-member error now aborts before the changelog is touched, instead of after. - Removed ticket/PR references from both files' header comments per AGENTS.md ("No Linear ticket references... in code, comments") and the root CLAUDE.md's "no PR/user-specific lore in inline comments" rule; state the protocol invariant and failure mode directly instead. - Did NOT change npm-shrinkwrap.json's existing @openclaw/[email protected] entry (cubic P1, confidence 10): verified the published tarball does not include npm-shrinkwrap.json at all (`tar tzf` on the real packed tarball has zero shrinkwrap entries), so there is nothing "shipped" for npm to read during a downstream `npm i -g` -- the stale shrinkwrap pin is pre-existing pnpm/registry resolution drift, unrelated to the install-breaking bug this PR fixes. Left for a separate change; replied with the evidence on the thread. - Manually re-verified every test-file assertion directly against the updated implementation (multi-section rewriting, explicit-pin stripping, backup-before-mutate ordering, full-content restore refusal for both a version change and a same-version edit) -- all passed. Verified scripts/postpack-restore.mjs surfaces a forced resolve-workspace-pack-deps restore failure with exit 1 while still running the changelog restore step independently. - `git diff --check` -> clean; package.json re-parsed as valid JSON; bare CLI invocation against the real repo still only previews, no mutation. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…k-restore
CI's check-lint failed: typescript(restrict-template-expressions) on
scripts/postpack-restore.mjs:21:40. The `steps` array mixed a string
name with a zero-arg function in each entry with no explicit tuple
type, so TypeScript inferred it as a plain array of the union type
(string | (() => ...))[][] instead of two distinct [string, fn] tuples
-- destructuring `[name, run]` then gave `name` that same union type,
which can include a function, so interpolating `${name}` tripped the
rule.
Replaced the loop-over-heterogeneous-array with two explicit named
calls to a small typed runRestoreStep(name, run) helper -- no array
literal to infer a tuple shape for, and clearer for exactly two fixed
steps anyway.
- `node scripts/postpack-restore.mjs` -> exit 0 (no backups present).
- Re-verified the forced-failure case still surfaces correctly:
a corrupted post-prepare package.json makes
resolve-workspace-pack-deps's restore throw, postpack-restore logs
it and exits 1.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…-deps Addresses cubic review on #336: writeFileSync directly to package.json can truncate the file if the write fails partway (disk full, process killed), leaving the checkout invalid with no automatic recovery. Added writeFileAtomic (write to a same-directory `.<pid>.tmp` file, then renameSync into place), matching the existing pattern in scripts/lib/vitest-shard-timings.mjs. Applied to all three package.json writes in this file: the rewrite in resolveWorkspacePackDependencies, the mutated-manifest write in prepareWorkspacePackDependencies, and the restore write in restoreWorkspacePackDependencies. - Manually re-verified the full prepare/restore round trip still produces a byte-identical restore, with no leftover `.tmp` file in the directory afterward. - New test asserts no `.tmp` file remains after a prepare + restore cycle. - `git diff --check` -> clean. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Addresses cubic review on #336: - The node:fs import line was 110 chars, over this repo's 100-char printWidth -- format:check would have failed. Wrapped it across multiple lines, as oxfmt would reformat it. - The writeFileAtomic docstring claimed the content is "safely on disk" after the rename, which overstates what a write without an fsync actually guarantees. Reworded to state only what this function actually provides: the original file stays intact if the write is interrupted, with no durability-across-power-loss claim. - `node scripts/lib/resolve-workspace-pack-deps.mjs` (bare) still only previews, no mutation. - `git diff --check` -> clean. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
Code Review Summary
Verdict: APPROVE (ready-to-release)
PR: #336: fix(release): resolve workspace: dependencies before npm pack ships them
Author: @convyusboy
Head commit: 6ee1964
Key Changes Verified
package.json
- Updates
postpackscript to runnode scripts/postpack-restore.mjsinstead of only changelog restore.
scripts/openclaw-prepack.ts
- Invokes
prepareWorkspacePackDependencies()beforepreparePackageChangelog(). This ensures any missing-member or workspace resolution error fails fast before modifyingCHANGELOG.md.
scripts/lib/resolve-workspace-pack-deps.mjs
- Dependency-free parser
readWorkspacePackagePatternsreadspackages:frompnpm-workspace.yaml. publishableBaseVersionstrips-boon.Nsuffix back to the publishable base version viaparseForkReleaseVersion.- Rewrites
dependencies,optionalDependencies, andpeerDependenciesacross range specifiers (*,^,~) and explicit version pins. - Backs up
package.jsonto.artifacts/resolve-workspace-pack-deps/package.json.prepack-backupprior to mutation. - Uses
writeFileAtomic(PID-tagged temp file + rename) to protect against truncated files on interrupted writes. restoreWorkspacePackDependenciesverifies the currentpackage.jsonagainst the expected rewrite before restoring, guarding against overwriting concurrent or mid-pack edits.- Defaults bare CLI execution to non-mutating preview mode.
scripts/postpack-restore.mjs
- Runs both
restorePackageChangelogandrestoreWorkspacePackDependenciesunconditionally within individual try/catch handlers so that a failure in one restore does not skip the other. Exits with code 1 if either step fails.
test/scripts/resolve-workspace-pack-deps.test.ts
- Tests pattern reading, workspace member collection, range rewriting, fork suffix stripping, missing-member error handling, atomic write cleanup, and mid-pack change guards.
Automated Checks and Evidence
- Commits: All 5 commits are GPG-signed and verified.
- CI Status: All 28 checks completed successfully, including
ci-gateand full test shard matrix. - Standalone Execution: Verified
node scripts/lib/resolve-workspace-pack-deps.mjspreviews rewrite of@openclaw/ai(workspace:*->2026.7.35) cleanly without external dependencies. - Bot Feedback: Addressed all cubic review items (atomic writes, line formatting, docstring precision, unconditional postpack restore, dependency section coverage).
…ationError's runtime identity (#339) * fix(agent-core): stop depending on @openclaw/ai for ToolArgumentValidationError's runtime identity (ENG-23048) ToolArgumentValidationError (added in #144 for sentry-monitor classification) lives in packages/llm-core/src/validation.ts, which upstream's base-reset (v2026.7.35, #307/#335/#336) recently extracted into the externally-resolved @openclaw/ai package -- never bundled into the openclaw CLI tarball or the standalone @openclaw/agent-core package, per tsdown.config.ts. Boon never publishes its own @openclaw/ai, so any consumer installing openclaw plus a normal @openclaw/ai from the public registry gets upstream's unpatched package, which has never carried this class. The compiled openclaw package's proxy chunk statically imports it as a value from "@openclaw/ai/validation", crashing at module-evaluation time for any consumer touching openclaw/plugin-sdk/agent-harness. agent-loop.ts's only production use of the class is `.summary` via instanceof, so switch to a structural check and a type-only import; the agent-core validation.ts facade re-exports the type only. Type-only exports erase at build time, so the bundler no longer needs a runtime binding for this symbol from the externally-resolved @openclaw/ai. Verified: packages/llm-core and packages/agent-core unit tests pass; `pnpm build` dist no longer imports the class as a value from @openclaw/ai/validation; oxlint and tsgo:core clean; plugin-sdk SDK-surface export budget unaffected; and end-to-end by copying the fixed dist into a consumer repo (anychat-boon-web) with the real, unpatched public @openclaw/ai still installed -- a test that previously crashed on import now passes. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(agent-core): address cubic review feedback on PR #339 Trim both ToolArgumentValidationError comments to the short rationale (why the check is structural, not why the package got externalized) per review feedback on keeping changed-source comments focused. Also drop the `instanceof Error` requirement from isToolArgumentValidationError: the check only needs `name`/`summary`, and `instanceof Error` would reject a cross-realm or plain-object error that otherwise carries both fields. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(agent-core): make ToolArgumentValidationErrorShape a local type, not a re-export (ENG-23048) Published @openclaw/[email protected]'s dist/validation.d.mts exports only validateToolArguments and validateToolCall -- no ToolArgumentValidationError type, matching its missing value export. `export type { ... } from "@openclaw/ai/validation"` resolved fine against the workspace-linked @openclaw/ai (boon's own packages/ai), masking that a real external consumer type-checking against the published registry package would hit TS2305. Define the minimal shape locally instead (just the `name`/`summary` fields agent-loop.ts's structural guard reads), so the public .d.ts no longer depends on the externally-resolved package's declarations at all. Verified against the actual published @openclaw/[email protected] dist/validation.d.mts. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
What Problem This Solves
The just-published
v2026.7.35-boon.1release tarball is broken for everynpm i -ginstall, not just one canary host. Attempting to apply it to the canary (arief-openclaw-testviascripts/fleet-upgrade.sh --apply) failed withFAIL(install:npm-retry — prior package restored)— the script's own fallback correctly left the host safely on the prior version, but the real artifact is unusable.Why This Change Was Made
#307's upstream sync added
@openclaw/aias a root dependency for the first time, declared as"workspace:*"(pnpm's workspace protocol).npm pack— used byboon-release.ymlto build the fork's GitHub Release tarball — has no concept of that protocol and ships the literal specifier as-is. Any global install of the tarball then asks npm's resolver to fetch@openclaw/ai@workspace:*, which it can't parse.Confirmed deterministic and reproducible on two different npm/node versions (the canary host's npm 11.21.1/node 22.23.4 via SSM, and a local npm 11.8.0/node 24.13.1): the install dies right after resolving
@mozilla/readability's manifest (the dependency immediately preceding@openclaw/aialphabetically) with a bareexit 1and zero further diagnostic in the npm debug log — a known class of npm bug for an unsupported specifier, not an OOM/disk/network issue (checkedfree,df,dmesg,ulimit, cgroup limits on the canary host — all clean).Root-caused by comparing against the real npm registry: upstream publishes
@openclaw/aiin lockstep with their own rootopenclawreleases (@openclaw/[email protected]exists and matches the exact upstream base this fork train is built on —npm pack+npm i -gsucceeded locally once patched to that version:added 390 packages). The fork never publishespackages/*members under its own-boon.Nsuffix, so pointing at@openclaw/[email protected]would just trade one failure for an npm 404 (verified: that version doesn't exist on the registry). The correct resolution is the real, already-published upstream base version.User Impact
No fork-only behavior change — this only fixes the packaging step so the published tarball is installable. Without it,
v2026.7.35-boon.1(and every future release, since any root dependency on an internal workspace package hits the same bug) cannot be rolled to any host.Adds
scripts/lib/resolve-workspace-pack-deps.mjs: rewrites anyworkspace:root dependency to the matching local workspace package's version, stripping a-boon.Nfork suffix back to the real publishable base (reusingparseForkReleaseVersionfromrelease-version.mjs, the same helper #335 added for the release-preflight gap). Wired into the existingprepack/postpacklifecycle (mirrorsscripts/package-changelog.mjs's established backup-and-restore shape), so it applies automatically to anynpm pack/npm publishof the root package — noboon-release.ymlchange needed, since that workflow already just callsnpm pack.The bare CLI mode defaults to a dry-run preview; only
preparemutates (with a backup) and onlyrestorereverts — learned the hard way after an un-backed-up bare invocation briefly mutated this repo's ownpackage.jsonduring manual verification (caught and reverted before anything was committed).Evidence
v2026.7.35-boon.1tarball's@openclaw/aito the resolved2026.7.35, re-tarred it, andnpm i -gsucceeded (added 390 packages in 26s), with@openclaw/aiinstalled at the correct version.node scripts/lib/resolve-workspace-pack-deps.mjs(bare, dry-run) against the real repo previews the exact same rewrite without touching disk.prepare/restoreround-trip verified byte-identical against the real repo'spackage.json.test/scripts/resolve-workspace-pack-deps.test.tscover glob expansion,*/^/~/explicit-pin rewriting, the missing-match error, the prepare/restore round-trip, the backup-free no-op case, and the stale-version restore refusal — manually ran the equivalent assertions directly (no localnode_modulesin this worktree); all passed. Full Vitest run deferred to this PR's CI.git diff --check→ clean;package.jsonre-parsed as valid JSON.🤖 Generated with Claude Code
Summary by cubic
Fixes the broken
v2026.7.35-boon.1release tarball, where rootworkspace:dependencies shipped as literal specifiers npm's resolver can't parse, so everynpm i -ginstall failed with a bareexit 1.Adds a prepack/postpack step that rewrites each
workspace:root dependency to the matching local package's real version beforenpm packships it.Bug Fixes
workspace:specifiers independencies,optionalDependencies, andpeerDependencies, stripping a-boon.Nfork suffix from explicitworkspace:<version>pins too.package.jsonatomically (temp file + rename) so a failed write can't truncate it.package.jsonbefore mutating, refuses to restore ifpackage.jsonwas changed mid-pack, and runs the changelog and workspace-deps restores unconditionally.boon-release.ymlchange needed — it already callsnpm pack; bare CLI runs only preview, without touching disk.added 390 packages) and unit tests covering rewriting rules, atomic round-trip, and error cases.Written for commit 6ee1964. Summary will update on new commits.