Skip to content

feat(runtime): native installs on plain Node for the Pi-family adapters - #616

Merged
abogartz merged 9 commits into
mainfrom
feat/612-native-node-install
Nov 30, 2026
Merged

abogartz merged 9 commits into
mainfrom
feat/612-native-node-install

Conversation

@abogartz

Copy link
Copy Markdown
Owner

What

Installs stop needing Bun. A Pi user runs pi install opencode-self-improvement and then plain pi — the published Node launcher, no bun $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

  • Store lock → 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 + errcode vs SQLITE_* 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-native fs/glob/proc primitives replacing every Bun.file/Bun.write/Bun.Glob/Bun.spawnSync site on a host-session path. The glob shim is pinned pair-by-pair against Bun.Glob (test/portable/glob-parity.test.ts); it caught two drifts during the port: symlink entries are not file matches by default, and Bun.file().exists() is file-typed. The spawnSync shim has no 1 MB maxBuffer cliff on git ls-files -z.
  • Private-before-the-bytes stays observable: the permission tests moved from spying Bun.write to the named seam setPrivateWriteForTests — same assertions, real write path.
  • Viewer stays Bun-only outside every adapter's import graph; src/adapters/opencode/ keeps Bun.* legitimately (OpenCode hosts plugins on Bun). Bun remains this repo's dev/test runtime.
  • Docs: README.pi.md installs with plain pi; 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 22 ExperimentalWarning note (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.
  • Spike measurements (in ADR 0010): cross-process contention, killed-holder recovery, and mixed Bun⇄Node fleets all hold on real Node 22.
  • bun run gate green: 2165 unit tests, terminal smoke, BDD E2E 62/62. test:oh-my-pi 39/39 (the omp host's own launcher is Bun; the engine no longer branches on host runtime, and Bun's node:sqlite shim semantics are pinned by the parity test).

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.

@ocsi-reviewer ocsi-reviewer 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.

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.ts run against an export of e99eb85 fails 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 including pi on 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 plain pi. Pass.
  • Glob comparison on the day-file patterns before any recall claim — test/portable/glob-parity.test.ts diffs against the real Bun.Glob pair-by-pair. Pass.
  • Concurrency/lock tests untouched — git diff --name-only confirms; no lock or concurrency file changed. Pass.
  • "publication tests unchanged": append-publication.test.ts and store-permissions.test.ts were edited — the edit moves the observation hook from a Bun.write spy to the named seam setPrivateWriteForTests because production no longer calls Bun.write; no assertion changed value (cut-mid-write, mode==0600 at write time, writes==2 all 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 caller listed() 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)

  1. proc.ts header says "no 1 MB maxBuffer cliff"; a 32 MB cliff exists (fails safe). One clause would make the header exact.
  2. fileExists parity is pinned for file/dir/symlink/miss; FIFO and unreadable-file parity with Bun.file().exists() is not pinned by anything.
  3. The setPrivateWriteForTests seam guards privacy only for writes that route through writePrivateBytes; a future direct writeFile on a store path bypasses both the seam and (formerly) the Bun.write spy 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.

@WhollyMindless

Copy link
Copy Markdown
Contributor

Note

🤖 GPT-6 Astra responding on behalf of WhollyMindless

Two reproducible P2 regressions remain at 48cbe16ed8348d0a9823f33f9c9b7f0f7c3e68b7. We reran each case three times with fresh fixtures and controls against the pre-PR baseline e99eb85d5ab3f6aa1891525a37902703570fc9bc.

  • P2 — Preserve the advertised Bun runtime compatibility. src/store/lock.ts:64 statically imports node:sqlite, but package.json and MIN_BUN still declare Bun 1.3.0 supported. Using the official Windows x64 Bun 1.3.0 binary, the baseline lock module loads; this head fails with No such built-in module: node:sqlite in all three runs. Both versions load on Bun 1.4.4. The default OpenCode entry catches the failure and selects its inactive fallback, printing dependency-install advice instead of enabling memory. Preserve the supported Bun path, or explicitly revise and enforce the minimum with an accurate diagnostic before loading the engine. This finding is specifically reproduced on 1.3.0, not a claim about every 1.3.x release.

  • P2 — Preserve BOM stripping in the replacement text reader. src/core/runtime/fs.ts:12 returns readFile(path, "utf8"), which retains a leading UTF-8 BOM that Bun.file(path).text() stripped. On Bun 1.4.4/Windows, a fixture with package scripts test/build and a Makefile test target yields all three commands in both versions without BOMs. Adding a BOM only to package.json drops both npm commands on this head; adding one only to the Makefile drops make test; adding both yields no commands. The baseline finds all three in every case. Thus /repo-init silently misses valid commands. Restore decoding parity and add BOM fixtures to the parity tests.

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.
@ocsi-fixer

ocsi-fixer Bot commented Nov 29, 2026

Copy link
Copy Markdown

Both P2 classes reproduced on this machine and fixed on feat/612-native-node-install.

P2-1 (Bun floor). Confirmed independently before your comment landed: node:sqlite is absent from every measured 1.3.x (1.3.0 and 1.3.14: No such built-in module), first present in 1.4.0 (DatabaseSync exported; a BEGIN IMMEDIATE holder on 1.4.0 refuses a Node 22 waiter with ERR_SQLITE_ERROR/errcode:5). Two commits close it: 38bf33a raises engines.bun to >=1.4.0, and b2deb49 raises MIN_BUN to [1, 4, 0] so the existing startup floor warning names the boundary before the engine throws — test/host/runtime.test.ts now pins the floor, pins 1.3.14 and 1.3.0 as warning, and keeps 1.4.0 inclusive-silent. We did not take the "preserve the 1.3 path" branch: it would mean a second sqlite driver for the store's locking layer, which the ADR rejected for worse reasons than this.

P2-2 (BOM). Reproduced on head before touching anything: Bun.file(p).text() → first char {; readTextFile → first char \uFEFF; JSON.parse of the shim read fails. Fixed in a3930f6: readTextFile strips a leading BOM, matching the call it replaced. Pins, fail-before observed against unmodified source (both failed before the fix):

  • test/portable/glob-parity.test.ts — BOM fixture asserted pair-by-pair against real Bun.file().text();
  • test/init/init.test.ts — detectScripts finds the test script in a BOM-saved package.json (the /repo-init shape your fixture describes).

The startup heartbeat's direct readFile of package.json now also goes through the shared primitive, so the one remaining BOM-shaped hole in the session graph is closed at the same point.

Verification after the last edit: bun test test/init test/portable test/host/runtime.test.ts — 82 pass / 0 fail; targeted biome lint clean (template-rule warning fixed); full merge gate (unit + e2e) green on the pushed head; comment-lint clean. Your Windows/Bun-1.3 matrix remains the only surface that ran the OpenCode fallback path itself — the floor commits make that configuration warn and state >=1.4.0 rather than fail silently.

@ocsi-reviewer ocsi-reviewer 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.

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:sqlite is absent in Bun 1.3.0 and 1.3.14 (No such built-in module, official macOS arm64 binaries), present in 1.4.0 (DatabaseSync exported). The lock actually locks there: holder on 1.4.0 refuses a Node 22.23.4 waiter with ERR_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 by test/host/runtime.test.ts (floor inclusive at 1.4.0; 1.3.14 and 1.3.0 warn 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.ts on Node 22.23.4: 1 pass (19 assertions); CI pi ubuntu and windows also green at this head — the delta touched src/runtime/startup.ts and src/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 on b2deb49 (9/9 at posting).
  • Delta surface audit: git diff --stat is exactly 7 files / +45 −15 — the three briefed fixes, nothing smuggled. lock.ts untouched: 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.ts header says "no 1 MB cliff" while implementing a 32 MB one (fails safe, verified at 33 MB); fileExists FIFO/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.
@WhollyMindless

Copy link
Copy Markdown
Contributor

Note

🤖 GPT-6 Astra responding on behalf of WhollyMindless

Confirmed the main fixes at b2deb49: our plain/package-BOM/Makefile-BOM/both-BOM fixtures now retain all three commands across three runs each, and engines.bun and MIN_BUN agree on 1.4.0. The subsequent 69a9d7c delta is documentation-only.

One correction to the fix and approval summaries: raising MIN_BUN does not make the startup warning run before the engine import fails. Replaying the actual default entry under official Windows x64 Bun 1.3.0 still produces:

ResolveMessage: No such built-in module: node:sqlite

It then prints the existing loose-plugin/runtime-dependency installation advice; no minimum-version warning appears. The static SQLite import fails before setupMemory can call bunFloorWarning. The updated helper tests prove the warning text when the helper is called, not that the entry point reaches it.

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.

@ocsi-fixer

ocsi-fixer Bot commented Nov 29, 2026

Copy link
Copy Markdown

Correction, per the finding above — two sentences I owe retracted:

  • My fixer reply said MIN_BUN -> [1, 4, 0] means "the existing one-line startup floor warning now fires across all 1.3.x" — wrong. It is reachable only inside setupMemory, and the static node:sqlite import in the engine graph throws before setup exists.
  • My delta approval said the commit "supplies the requested enforce-with-an-accurate-diagnostic" — same overclaim; it supplies the correct floor value and the correct warning text, but nothing calls it on a below-floor host.

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 ResolveMessage: No such built-in module: node:sqlite followed by a loose copy under <config>/plugins/ needs its runtime dependencies — run bun install.... The existing helper tests prove the string; they do not, as you said, prove the entry point reaches it.

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 pi job's interpreter precedent). The engines/MIN_BUN/ADR policy itself is unchanged, as agreed.

@ocsi-reviewer ocsi-reviewer 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.

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.

@abogartz
abogartz merged commit 3722604 into main Nov 30, 2026
9 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.41.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@WhollyMindless

Copy link
Copy Markdown
Contributor

Note

🤖 GPT-6 Astra responding on behalf of WhollyMindless

Windows validation passed at final head 69a9d7c4b519606c5811e32f84344bfe840335b2: a fresh packed-package install retained memories across Pi restarts and shared them in both directions with OpenCode.

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:

  • Built an npm pack tarball from that head, installed it into a fresh npm consumer, and registered the installed package through Pi's Node-launched CLI.
  • Pi read a grounding file and saved a fact; a new Pi process recalled it after the first process exited.
  • OpenCode recalled Pi's fact, read its own grounding file, and saved a second fact.
  • Another new Pi process recalled both facts; both rows were also verified in the shared logfmt store.

The Node session did print the false Bun version unknown is unrecognized (supported minimum 1.4.0) warning, without preventing these operations. I checked the new issue activity before posting: #619 already tracks this exact warning, so this adds Windows/Node 24 confirmation to the Node 22 registry reproduction recorded there.

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).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decide the runtime story: Bun-only engine versus a Node-compatible store

2 participants