Skip to content

fix(pi): decline to load on Node instead of failing the session - #615

Merged
abogartz merged 1 commit into
mainfrom
fix/pi-610-fail-soft-load
Nov 29, 2026
Merged

abogartz merged 1 commit into
mainfrom
fix/pi-610-fail-soft-load

Conversation

@abogartz

Copy link
Copy Markdown
Owner

Installing the Pi adapter into a normal Pi installation makes Pi refuse to start. The adapter threw while the extension was loading, Pi treats a load failure as fatal for the session, and the only remedy the host offers is pi -ne — start with extensions disabled. pi install reports success, so the failure surfaces on the next ordinary launch, which is the worst ordering available.

Decline instead of throwing: register nothing, warn once with a command the user can paste, and let the host continue. The warning names Bun and prints the entry point the host resolved for itself, because a path inside a repository does not exist in an installed package. Failures that are genuine misconfiguration — an unusable store, a config the engine cannot honour — still throw out of installPiMemory, where a silent fallback would hide the fact that memory is off.

Closes #610.

Validation, fail-before then the same test after. Packed with bun pm pack, installed with bun add --ignore-scripts into a consumer directory, registered with pi install, then launched against the packed src/adapters/pi/extension.ts under Node 22.23.4 with the scripted provider. Before: exit=1, stdout empty, stderr Failed to load extension …: Pi memory requires Bun. … Hint: Start without extensions using "pi -ne". After: exit=0, the turn completes, stderr carries the three warning lines verbatim, and the request the host sent the model lists native tools while containing zero names from MEMORY_TOOLS — declining is total, and the assertion that native tools are present keeps that check from passing on a session with no tools at all. bun test ./integration/pi/node-launcher.test.ts — 1 passed, 0 failed, 5 assertions. Unit suite bun test ./test/ --parallel=4 --timeout=20000 — 2130 passed, 23 skipped, 0 failed. bun run lint:comments, bun run typecheck, bun run lint and bun x tsc --noEmit -p integration/pi/tsconfig.json — exit 0.

Two measured facts sit under the new test. Pi 1.7.0 declares engines.node >=22.19.0, and its bundle does not parse below Node 22: under Node 20.20.2 it dies before extensions load with SyntaxError: The requested module 'node:module' does not provide an export named 'enableCompileCache'. So the pi job now pins Node 22 rather than inheriting whatever the runner image ships — the same class of image-version flake as #609 — and PI_TEST_NODE overrides the interpreter for a machine whose node on PATH is older than the host's floor.

Not in scope: whether memory should work on the Node launcher at all. That is #612, and this file is deliberately shaped so that flipping its last assertion to "MEMORY_TOOLS are offered" is the proof that #612 landed.

Pi treats an extension that throws while loading as fatal for the session, so
installing the adapter made a plain `pi` launch exit 1 with no model call and
its only hint being to start Pi without extensions. Warn once with a pasteable
Bun command and register nothing instead. Misconfiguration that is real — an
unusable store, a config the engine cannot honour — still throws, where a
silent fallback would hide memory being off.

Adds integration/pi/node-launcher.test.ts, which installs the packed tarball
and runs it under Node, and pins Node 22 for the pi job because Pi 1.7.0's
bundle does not parse below it.

Closes #610
@ocsi-reviewer

ocsi-reviewer Bot commented Nov 29, 2026

Copy link
Copy Markdown

Verified on the branch, not from the diff.

Packed the branch with bun pm pack, installed into a consumer directory with bun add --ignore-scripts, registered with pi install, then launched the packed src/adapters/pi/extension.ts under Node 22.23.4 against the scripted provider. With the guard still throwing: exit=1, stdout empty, stderr Failed to load extension …: Pi memory requires Bun. … Hint: Start without extensions using "pi -ne". With the guard returning: exit=0, the turn completes, the three warning lines appear verbatim, and the request the host sent the model lists native tools while containing zero names from MEMORY_TOOLS.

That ordering matters and was done in that order: the same test file produced the failure first, so the assertion is known to be capable of failing rather than passing by construction. The offered.length > 0 check is what keeps the zero-memory-tools assertion from also passing on a session that registered nothing at all, including a session where the host failed to start.

Local gates: bun test ./test/ --parallel=4 --timeout=20000 — 2130 passed, 23 skipped, 0 failed. bun test ./integration/pi/shared-store.test.ts — 7 passed, 0 failed. bun run lint:comments, bun run typecheck, bun run lint — exit 0. bun x tsc --noEmit -p integration/pi/tsconfig.json — exit 0.

Two notes for whoever reads this next.

The pi job's new Node pin is load-bearing, not decoration. Pi 1.7.0's bundle references enableCompileCache from node:module, which does not exist before Node 22, so on an older interpreter the suite fails inside the host before any extension loads — a failure that looks nothing like ours and would be blamed on the runner image. The test resolves an interpreter at or above the host's declared engines.node >=22.19.0 and names the observed version when it is below that floor, so a misconfigured machine says what is wrong instead of skipping quietly.

Declining is the right shape here, but it is the interim shape. The intended end state is that this warning never prints because the store no longer needs bun:sqlite; the last assertion in node-launcher.test.ts is the one that flips when that lands, and a change that makes it pass without touching the lock layer has not actually fixed anything.

@abogartz
abogartz merged commit 381836e into main Nov 29, 2026
9 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.40.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

abogartz-opencode-self-improvement Bot pushed a commit that referenced this pull request Nov 30, 2026
# [0.41.0](v0.40.2...v0.41.0) (2026-11-30)

### Bug Fixes

* **package:** state the Bun floor the node:sqlite lock actually needs ([38bf33a](38bf33a))
* **runtime:** set MIN_BUN where node:sqlite lands ([b2deb49](b2deb49))
* **runtime:** the text reader strips a BOM like the Bun.file call it replaced ([a3930f6](a3930f6))

### Features

* **runtime:** native installs on plain Node for the Pi-family adapters ([162689f](162689f)), closes [#612](#612) [#615](#615)
WhollyMindless pushed a commit to WhollyMindless/opencode-self-improvement that referenced this pull request Nov 30, 2026
Completes abogartz#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 abogartz#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.
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.

Pi adapter throws at extension load, so a Node-launched Pi refuses to start

1 participant