Skip to content

fix(release): resolve workspace: dependencies before npm pack ships them - #336

Merged
convyusboy merged 5 commits into
boonfrom
ridho/fix-workspace-pack-deps
Nov 19, 2026
Merged

convyusboy merged 5 commits into
boonfrom
ridho/fix-workspace-pack-deps

Conversation

@convyusboy

@convyusboy convyusboy commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The just-published v2026.7.35-boon.1 release tarball is broken for every npm i -g install, not just one canary host. Attempting to apply it to the canary (arief-openclaw-test via scripts/fleet-upgrade.sh --apply) failed with FAIL(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/ai as a root dependency for the first time, declared as "workspace:*" (pnpm's workspace protocol). npm pack — used by boon-release.yml to 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/ai alphabetically) with a bare exit 1 and zero further diagnostic in the npm debug log — a known class of npm bug for an unsupported specifier, not an OOM/disk/network issue (checked free, df, dmesg, ulimit, cgroup limits on the canary host — all clean).

Root-caused by comparing against the real npm registry: upstream publishes @openclaw/ai in lockstep with their own root openclaw releases (@openclaw/[email protected] exists and matches the exact upstream base this fork train is built on — npm pack+npm i -g succeeded locally once patched to that version: added 390 packages). The fork never publishes packages/* members under its own -boon.N suffix, 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 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 — no boon-release.yml change needed, since that workflow already just calls npm pack.

The bare CLI mode defaults to a dry-run preview; only prepare mutates (with a backup) and only restore reverts — learned the hard way after an un-backed-up bare invocation briefly mutated this repo's own package.json during manual verification (caught and reverted before anything was committed).

Evidence

  • 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 in 26s), with @openclaw/ai installed 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.
  • 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 ran the equivalent assertions directly (no local node_modules in this worktree); all passed. Full Vitest run deferred to this PR's CI.
  • git diff --check → clean; package.json re-parsed as valid JSON.

🤖 Generated with Claude Code


Summary by cubic

Fixes the broken v2026.7.35-boon.1 release tarball, where root workspace: dependencies shipped as literal specifiers npm's resolver can't parse, so every npm i -g install failed with a bare exit 1.

Adds a prepack/postpack step that rewrites each workspace: root dependency to the matching local package's real version before npm pack ships it.

Bug Fixes

  • Rewrites workspace: specifiers in dependencies, optionalDependencies, and peerDependencies, stripping a -boon.N fork suffix from explicit workspace:<version> pins too.
  • Writes package.json atomically (temp file + rename) so a failed write can't truncate it.
  • Backs up package.json before mutating, refuses to restore if package.json was changed mid-pack, and runs the changelog and workspace-deps restores unconditionally.
  • Resolves workspace deps before the changelog writes so a missing-member error aborts prepack cleanly.
  • No boon-release.yml change needed — it already calls npm pack; bare CLI runs only preview, without touching disk.
  • Verified with a patched tarball (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.

View guided diff Turn on auto-fix

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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread package.json Resolved
Comment thread scripts/openclaw-prepack.ts Resolved
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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

convyusboy and others added 2 commits November 19, 2026 09:55
…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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. package.json
  • Updates postpack script to run node scripts/postpack-restore.mjs instead of only changelog restore.
  1. scripts/openclaw-prepack.ts
  • Invokes prepareWorkspacePackDependencies() before preparePackageChangelog(). This ensures any missing-member or workspace resolution error fails fast before modifying CHANGELOG.md.
  1. scripts/lib/resolve-workspace-pack-deps.mjs
  • Dependency-free parser readWorkspacePackagePatterns reads packages: from pnpm-workspace.yaml.
  • publishableBaseVersion strips -boon.N suffix back to the publishable base version via parseForkReleaseVersion.
  • Rewrites dependencies, optionalDependencies, and peerDependencies across range specifiers (*, ^, ~) and explicit version pins.
  • Backs up package.json to .artifacts/resolve-workspace-pack-deps/package.json.prepack-backup prior to mutation.
  • Uses writeFileAtomic (PID-tagged temp file + rename) to protect against truncated files on interrupted writes.
  • restoreWorkspacePackDependencies verifies the current package.json against the expected rewrite before restoring, guarding against overwriting concurrent or mid-pack edits.
  • Defaults bare CLI execution to non-mutating preview mode.
  1. scripts/postpack-restore.mjs
  • Runs both restorePackageChangelog and restoreWorkspacePackDependencies unconditionally 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.
  1. 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-gate and full test shard matrix.
  • Standalone Execution: Verified node scripts/lib/resolve-workspace-pack-deps.mjs previews 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).

@convyusboy
convyusboy merged commit 8330f1f into boon Nov 19, 2026
138 of 142 checks passed
@convyusboy
convyusboy deleted the ridho/fix-workspace-pack-deps branch November 19, 2026 04:51
convyusboy added a commit that referenced this pull request Nov 20, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant