Cycle-2 revision of 23e77a3 per adversarial-pair + VM synthesis.
r2 MUST-FIX: npm pack excluded scripts/check-abi.mjs because the
files field only listed ['dist', 'daemon', 'ui']. Fresh installs
failed with MODULE_NOT_FOUND before any ABI logic ran. Fixed by
adding 'scripts' to the files array. New repo-level test
(scripts/check-packing.test.mjs) verifies the script IS in the
tarball; prevents silent drift.
r2 HIGH: catch block classified every native-addon-load failure as
ABI mismatch. A MODULE_NOT_FOUND error got the "native binary does
not match" headline + wrong nvm/rebuild fix. Fixed by branching on
NODE_MODULE_VERSION in the error message: ABI mismatch gets the
specific message; other failures get a generic "native addon failed
to load" with honest detail + appropriate fix commands.
Files changed:
- packages/cli/package.json (files field + already had postinstall)
- packages/cli/scripts/check-abi.mjs (error classification branch)
- packages/cli/test/check-abi.test.ts (+2 tests: MODULE_NOT_FOUND
gets generic message, EACCES gets generic message; total 10/10)
- scripts/check-packing.test.mjs (tarball-content regression)
Gates: check-abi 10/10; check-packing 1/1; CLI 446/447
(1 preexisting chatroom); daemon 1792/1792; tsc + build clean.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
npm install @openrig/cli now runs a postinstall check that fails
loudly if the Node runtime can't load better-sqlite3's native
binary. Layered on top of the engines.node constraint from 587206d:
engines warns at npm level; this hard-blocks at install time with
a copy-paste fix command.
Two-phase check (Option C hybrid):
1. Version-range fast path: rejects odd-numbered Node majors
(21/23/25) and versions below 20 before attempting any native
load. Short-circuits with clear error + nvm install fix.
2. Native addon load: on supported versions, requires
better-sqlite3 and catches ABI mismatch (wrong
NODE_MODULE_VERSION). Reports npm rebuild fix command.
Error messages follow honest-errors principle: what failed + why
it matters + copy-paste fix (nvm install 22 or npm rebuild).
Files:
- packages/cli/scripts/check-abi.mjs (postinstall script)
- packages/cli/package.json scripts.postinstall wiring
- packages/cli/test/check-abi.test.ts (8 unit tests covering
supported versions, odd versions, old versions, ABI mismatch,
and fast-path short-circuit verification)
Gates: check-abi 8/8; CLI 444/445 (1 preexisting chatroom fail);
daemon 1792/1792; tsc + build clean.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>