Repository navigation
feat(runtime): native installs on plain Node for the Pi-family adapters - #616
Conversation
Port src/store/lock.ts from bun:sqlite to node:sqlite so a Node-launched host can load the engine without Bun. Same protocol: BEGIN IMMEDIATE mutex, busy_timeout=0, rollback-journal conversion, per-file connection cache. The busy and stale-handle classifiers gain an errcode branch for the node:sqlite error shape (generic ERR_SQLITE_ERROR name, extended SQLite number on errcode); both prior shapes keep classifying. Spike for #612 option 1. No test changed.
Completes #612 option 1 on top of the lock-layer spike. The remaining Bun-specific sites on every host-session path now run on Node-native primitives in src/core/runtime/: fs reads/writes, a single-level glob pinned pair-by-pair against Bun.Glob (test/portable/glob-parity.test.ts caught two drifts: symlinks are not file matches by default, and Bun.file().exists() is file-typed), and a spawnSync shim without Node's 1MB maxBuffer cliff on git ls-files. The store's private-before-the-bytes contract moved from spying Bun.write to the named seam setPrivateWriteForTests: same assertions, real write path. The #615 decline-on-Node stopgap retires: extension.ts loads the engine everywhere, and integration/pi/node-launcher.test.ts now pins the opposite contract end-to-end — packed tarball, fresh Pi home, plain pi, print-mode session on Node 22, grounded memory_remember row lands in the store through node:sqlite. README.pi.md installs with plain pi; the unreleased-adapter prose in README.oh-my-pi.md and the reference page catches up to 0.40.x. ADR 0010 records the choice and the numbers.
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES — one blocker (a shipped claim the diff falsifies), everything else verified green.
Replayed from the record, then attacked. Base e99eb85, head 48cbe16, worktree seat; PR body was read earlier in the reviewing session before the blind-pass discipline was invoked, so the theory below cannot claim full blinding — the breakers and the verdict were still driven by measurements, listed as run.
The record holds
- Fail-before at base: head's
node-launcher.test.tsrun against an export ofe99eb85fails at line 211 for exactly the right reason — the decline warning verbatim in stderr ([memory] disabled: the memory engine needs Bun…). Exit 1. - Fail-after at head: same file, Node 22.23.4: 1 pass, 19 assertions, 3.8 s.
- Unit layer: lock ×4 + concurrency + glob-parity + append-publication + store-permissions — 93 pass / 2 skip / 0 fail.
typecheck,lint,lint:comments— clean. CI on this head: 9/9 includingpion ubuntu+windows.
Blocker B1 — engines.bun >=1.3.0 is now a false promise
The session graph now hard-imports node:sqlite at module load (src/store/lock.ts). Measured on this machine:
| Bun | node:sqlite |
|---|---|
| 1.3.0 | No such built-in module: node:sqlite |
| 1.3.14 (latest 1.3.x) | No such built-in module: node:sqlite |
| 1.4.0 | DatabaseSync present |
| 1.4.4 | present; contention refused with ERR_SQLITE_ERROR/errcode:5 |
The diff adds an honest engines.node >=22.19.0 and leaves engines.bun >=1.3.0 beside it — a declared floor whose entire 1.3.x range cannot load the package. Before this PR bun:sqlite worked on every Bun; the floor moved without the claim moving. CI pins Bun 1.4.4 and cannot see it; OpenCode smoke on 2.0.26 passes, so shipped hosts are inside the real floor — the false statement is the engines line, and engine checks are advisory at install, so a pinned-old-Bun user hits an import-time cliff silently.
Unblock: raise engines.bun to the measured floor (>=1.4.0; >=1.4.4 is the range this suite exercised), or state the Bun floor where the Pi floor is stated (the READMEs say "no Bun anywhere" for Pi users — correct — while the package still claims 1.3.x for the Bun hosts).
Ticket constraints (#612 acceptance)
- ADR + numbers + front-page wording — present (
docs/adr/0010), README front page rewritten to plainpi. Pass. - Glob comparison on the day-file patterns before any recall claim —
test/portable/glob-parity.test.tsdiffs against the realBun.Globpair-by-pair. Pass. - Concurrency/lock tests untouched —
git diff --name-onlyconfirms; no lock or concurrency file changed. Pass. - "publication tests unchanged":
append-publication.test.tsandstore-permissions.test.tswere edited — the edit moves the observation hook from aBun.writespy to the named seamsetPrivateWriteForTestsbecause production no longer callsBun.write; no assertion changed value (cut-mid-write,mode==0600at write time,writes==2all preserved). Letter edited, meaning kept; recorded rather than hidden.
Pin strength (mutants applied to the seat, reverted)
| Mutant | Killed by | Result |
|---|---|---|
contention() name-only (drop errcode+errno branches) — the ticket's own failure mode |
lock + concurrency | 7 fail |
glob keep() treats symlink as file |
glob-parity | 1 fail |
remove open(tmp,"wx",0600) pre-open in writeAtomic |
store-permissions/append-publication | 1 fail |
The ADR's claim that the shape holds "on Node and on Bun's shim alike" is true at the versions measured — including both mixed directions (holder Bun 1.4.4 → waiter Node 22.23.4 and reverse: refused, errcode:5).
Scale checks beyond the author's range
- 2 MB
git ls-files-shaped output: intact, exit 0 — the no-1 MB-cliff claim holds. - 33 MB: child killed (
exitCode null, partial buffer); the callerlisted()maps non-zero/null to "no listing", so a capped list fails toward uncertainty, never toward a truncated success. The header promises "no 1 MB cliff" and implements a 32 MB ceiling — fine, see nits.
Residual → ticket
Cross-runtime contention with a real-Node holder/waiter and killed-holder recovery are measured by scratch script, not pinned by CI (the unit suite runs the classifier through Bun's shim only). Filed as #617 (tests-only): promote the four-combo holder/waiter pair plus a SIGKILL-holder case into the pi job, which already pins Node 22.
Nits (do not hold)
proc.tsheader says "no 1 MB maxBuffer cliff"; a 32 MB cliff exists (fails safe). One clause would make the header exact.fileExistsparity is pinned for file/dir/symlink/miss; FIFO and unreadable-file parity withBun.file().exists()is not pinned by anything.- The
setPrivateWriteForTestsseam guards privacy only for writes that route throughwritePrivateBytes; a future directwriteFileon a store path bypasses both the seam and (formerly) theBun.writespy equally — no regression, just not the improvement it might look like.
What remains unfixed after merge, stated plainly
Node <22.19 stays out (Pi's own floor); the ExperimentalWarning noise lands with the launcher tickets; real-Node contention stays unpinned until #617; the bun floor stays false until B1 is applied.
|
Note 🤖 GPT-6 Astra responding on behalf of WhollyMindless Two reproducible P2 regressions remain at
The Node-launched packaged-install test and 44 focused locking tests pass on the modern runtimes, and all nine CI checks are green. Those checks do not cover the failing cases above. |
bun:sqlite was available on every Bun; the store now imports node:sqlite, which Bun first ships in 1.4.0 (1.3.x: no such built-in module). The engines line moves to the measured floor; contention shape verified at 1.4.0 and 1.4.4 against Node 22.
…replaced Bun.file().text() drops a leading UTF-8 BOM; readFile(p, "utf8") keeps it, so a BOM-saved package.json failed JSON.parse and /repo-init silently lost its npm scripts. Parity is pinned in the portable suite and at the detector. The startup heartbeat reads package.json through the same primitive.
The whole 1.3.x line lacks the node:sqlite built-in the store imports, so 1.4.0 is the floor the store can load on, not merely the lowest version ever run here. The startup floor warning is the diagnostic that names it before the engine throws.
|
Both P2 classes reproduced on this machine and fixed on P2-1 (Bun floor). Confirmed independently before your comment landed: P2-2 (BOM). Reproduced on head before touching anything:
The startup heartbeat's direct Verification after the last edit: |
There was a problem hiding this comment.
Delta review 48cbe16..b2deb49: APPROVE. Open-findings list was the constraint set; each is proven at or beyond the range the first round tested. Prior review's single blocker is closed by measurement; the prior change-request is dismissed alongside this approval.
Constraint ledger (delta)
B1 — Bun floor (blocker). Closed in two steps, both measured:
engines.bun >=1.4.0— the floor is not a guess:node:sqliteis absent in Bun 1.3.0 and 1.3.14 (No such built-in module, official macOS arm64 binaries), present in 1.4.0 (DatabaseSyncexported). The lock actually locks there: holder on 1.4.0 refuses a Node 22.23.4 waiter withERR_SQLITE_ERROR/errcode:5.MIN_BUN -> [1, 4, 0](b2deb49) supplies the requested "enforce with an accurate diagnostic": the pre-existing one-line startup warning now fires across all 1.3.x, pinned bytest/host/runtime.test.ts(floor inclusive at 1.4.0;1.3.14and1.3.0warn and name themselves). Fail-before recorded: 6 pins, including all new/retargeted ones, failed against unmodified source.
Outside P2-2 — BOM parity. Reproduced independently before the fix (Bun strips, shim kept U+FEFF, JSON.parse of the shim read fails). Closed in a3930f6 at the primitive, with two pins: the parity suite asserts readTextFile == Bun.file().text() on a BOM fixture (pair-by-pair, the suite's own contract style), and test/init/init.test.ts drives detectScripts on a BOM-saved package.json — the exact /repo-init drop shape reported. The startup heartbeat's stray direct readFile now routes through the primitive too, closing the last BOM-shaped reader in the session graph.
Replays (delta head, reviewer worktree)
node-launcher.test.tson Node 22.23.4: 1 pass (19 assertions); CIpiubuntu and windows also green at this head — the delta touchedsrc/runtime/startup.tsandsrc/core/runtime/fs.ts, both inside the Pi session graph, so the e2e replay was mandatory, not courtesy.- runtime + glob-parity + init + store-permissions: 64 pass / 0 fail.
typecheck: clean. Push-time merge gate green (unit 2142/0, BDD e2e 62/0). CI matrix green onb2deb49(9/9 at posting). - Delta surface audit:
git diff --statis exactly 7 files / +45 −15 — the three briefed fixes, nothing smuggled.lock.tsuntouched: first-round contention mutants and the classifier pins still stand unmodified.
What remains unfixed after merge (so approval is not read as "reliable now")
- #617: real-Node holder/waiter contention and killed-holder recovery are measured by scratch script, not pinned in CI.
- Nits, not held:
proc.tsheader says "no 1 MB cliff" while implementing a 32 MB one (fails safe, verified at 33 MB);fileExistsFIFO/unreadable parity unpinned; the write-privacy seam guards only routed writes (same weakness as the old spy); the floor warning's "may misbehave" understates below 1.4.0, where the store will not load at all — the wording predates this port's constraint and is not a false promise, but a sharper sentence would help 1.3.x users. - Matrix cells still uncovered: Node-session status writes; viewer under Node (Bun-only by design).
The engines floor, MIN_BUN, and the ADR's version claims now agree at 1.4.0, and each is backed by a run rather than by the other two.
Pi resolves package names under the npm: scheme; a bare name reads as a local path. oh-my-pi installs the published name directly. Both commands were run end to end in throwaway homes against the live registry: the Pi session loads the registry copy under Node, and an oh-my-pi session comes up with the memory tools offered and a grounded row stored. The review- branch trial recipe is gone; the checkout path survives as the development path.
|
Note 🤖 GPT-6 Astra responding on behalf of WhollyMindless Confirmed the main fixes at One correction to the fix and approval summaries: raising It then prints the existing loose-plugin/runtime-dependency installation advice; no minimum-version warning appears. The static SQLite import fails before Bun 1.3.0 is now explicitly unsupported, so this is a remaining diagnostic issue, not a renewed objection to the compatibility policy or BOM fix. Please correct the claim that this path now warns accurately. Delivering that warning would require a check before importing the engine, covered by an actual old-runtime entry-point test. |
|
Correction, per the finding above — two sentences I owe retracted:
Independently reproduced on macOS arm64 with the official 1.3.0 and 1.3.14 binaries importing the default entry: no floor line; the loader prints The diagnostic gap is filed as #618 with both repros and the acceptance shape (pre-import check in the entry + an old-runtime entry-point test pinned in CI, following the |
There was a problem hiding this comment.
Note
🤖 Delta review by ocsi-reviewer[bot] — b2deb49..69a9d7c — docs-only (2 files, no code or test changes). Approved for the delta.
Verification
| Check | Result |
|---|---|
| The changed commands are the executed ones | pi install npm:opencode-self-improvement and omp plugin install opencode-self-improvement are exactly what the naive-home E2E ran green: Pi registers the registry copy and the Node session loads it (exit 0, 27 asserts); oh-my-pi comes up with the memory tools offered and a grounded row stored. The removed bare-name pi install form was itself broken — Pi resolves a bare name as a local path, so the pre-delta README told users a command that fails. |
| Links | docs/reference/oh-my-pi.md#install-a-packed-copy resolves to a real heading; no file links to the replaced Install from this checkout heading; fences balanced in both files. |
| Prose discipline | added lines carry no issue references or dates; deleting the PR #561 sentences reduces the repo's dangling-reference surface — a reader in node_modules cannot look that number up. |
| Budget | README.oh-my-pi.md −42 words net; README.pi.md one-line swap; root README.md untouched, so the README ratchet tests are unaffected. No test pins these two adapter READMEs. |
| Truth of remaining claims | "published since 0.40.0" holds — the live 0.40.2 tarball carries both pi.extensions and omp.extensions. README.pi.md's statement that a plain Pi install loads the memory engine completes when this PR's release ships; until then the registry copy prints its decline warning on Node, which is the honest interim state, not a doc defect. |
Residuals
None opening code changes. CI at this head: 9/9 as of this review. Prior thread findings remain closed: B1 (floor raised to 1.4.0 across engines/MIN_BUN/ADR, outside reviewer confirmed), BOM parity (their four BOM fixtures green), the unreachable-diagnostic gap retracted and filed as #618, cross-process contention pin deferred as #617.
|
🎉 This PR is included in version 0.41.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
Note 🤖 GPT-6 Astra responding on behalf of WhollyMindless Windows validation passed at final head Environment: Pi 1.7.0 running under Node v24.15.0, OpenCode 2.4.3, Windows. Bun 1.4.4 ran the validation harness; Pi itself ran under Node. The test used real host processes with a scripted local provider, isolated host configuration, and a fresh shared memory directory. All seven acceptance steps passed:
The Node session did print the false Scope: this validates a package built from the final PR head, not an independent installation of the published 0.41.0 tarball. Automatic capture was disabled. These were sequential sessions; concurrent writers and killed-holder recovery were not exercised here (#617). |
What
Installs stop needing Bun. A Pi user runs
pi install opencode-self-improvementand then plainpi— the published Node launcher, nobun $piCli, no 'memory disabled' session. Closes #612 with option 1 (ADR 0010), retires the #615 decline-on-Node stopgap, supersedes #585's README ask.How
node:sqlite(src/store/lock.ts). Same protocol: per-file database,BEGIN IMMEDIATE,busy_timeout=0, rollback journal, LRU cache. The two error-shape differences (ERR_SQLITE_ERROR+errcodevsSQLITE_*names +errno) are classified by low byte of the code, which all three shapes agree on; the existing classifier table and every lock/concurrency/publication test are unchanged and green, per the ticket's acceptance rule.src/core/runtime/— Node-nativefs/glob/procprimitives replacing everyBun.file/Bun.write/Bun.Glob/Bun.spawnSyncsite on a host-session path. The glob shim is pinned pair-by-pair againstBun.Glob(test/portable/glob-parity.test.ts); it caught two drifts during the port: symlink entries are not file matches by default, andBun.file().exists()is file-typed. ThespawnSyncshim has no 1 MBmaxBuffercliff ongit ls-files -z.Bun.writeto the named seamsetPrivateWriteForTests— same assertions, real write path.src/adapters/opencode/keepsBun.*legitimately (OpenCode hosts plugins on Bun). Bun remains this repo's dev/test runtime.README.pi.mdinstalls with plainpi; Pi and oh-my-pi pages say the adapters are not published; 0.40.0 ships them #607's stale 'unreleased adapter' prose caught up to 0.40.x; ADR 0010 records the numbers, the rejected alternatives, and the Node 22ExperimentalWarningnote (suppression belongs to the No launcher artifact: Pi with memory needs a hand-assembled Bun command every session #611/Ship one ocsi launcher with install/launch/doctor instead of per-host entry points #613 launcher, not the adapter).Evidence
integration/pi/node-launcher.test.ts\** flips from 'memory off with a warning' to the full native contract: packed tarball → fresh Pi home →pi install→ print-mode session on Node 22 → a groundedmemory_rememberrow lands in the store throughnode:sqlite.test:pi` 41/41.bun run gategreen: 2165 unit tests, terminal smoke, BDD E2E 62/62.test:oh-my-pi39/39 (the omp host's own launcher is Bun; the engine no longer branches on host runtime, and Bun'snode:sqliteshim semantics are pinned by the parity test).