Skip to content

feat(ai-vault): read remote OpenCode history with the pinned Node; remove Bun - #24128

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/node-rt-p2-vault
Oct 1, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/node-rt-p2-vault

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​441 $\color{#cf222e}{\Huge{\mathbf{−}}}$​506 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65
Prod 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​312 $\color{#cf222e}{\Huge{\mathbf{−}}}$​524 $\color{#cf222e}{\Huge{\mathbf{−}}}$​212

ELI5

When a remote host's Node can't read OpenCode's chat history database, Orca used to download Bun to read it. It now uses the same pinned Node that orcad uses, stored once per host by hash. That removes Orca's last runtime use of Bun.

What Changed

  • SSH (POSIX): ssh-relay-opencode-pinned-node.ts reuses ensureRemoteOrcadNodeRuntime. The runtime lives at ~/.orca-remote/runtimes/node-<sha>/bin/node: probed by hash and .verified, uploaded as the official archive only when missing, then hash-checked and self-tested on the host.
  • SSH (Windows): the client uploads a verified node.exe to runtimes/node-<sha>/node.exe. Uploading the archive and extracting it on the host is later Phase 2 work.
  • WSL: the same layout, under $HOME/.cache/orca/runtimes/.
  • Probe: now requires node:sqlite backup() too, so hosts on Node 22.13–22.15 use the pinned Node.
  • Deleted: orcad-bun-runtime.ts (the Bun asset table), the Bun materializer, bun-sqlite-*, bun-readonly-wal, the Bun branch of sync-database.ts, and the bun:sqlite external in build-relay.mjs.
  • Old relays: their vault-sqlite/<sha>/bun reference is never read or rewritten, so they keep working.

Why

This completes design D4: node:sqlite is the only SQLite backend outside Electron. Reusing orcad's runtime store avoids a second pinned binary on each host.

Linked Issue

Part of the Node runtime plan (Phase 2). Stacked on #24110.

Visual Proof

N/A. The only effect is which runtime a background reader uses.

Testing

  • Targeted suites pass under the pinned Node 24.21.0: sqlite, profile-state, ai-vault, relay, the SSH vault, the orcad runtime and the materializer.

  • orcad-remote-node-runtime installed the real darwin archive through a real shell.

  • The cross-runtime profile test passes with Bun 1.4.2 and the pinned Node.

  • build:relay output contains no bun:sqlite or versions.bun. pnpm tc, the changed-code gate and anti-slop pass.

  • Known gaps:

    • POSIX hosts now need tar -z and sha256sum or shasum.
    • Hosts below glibc 2.28 whose own Node can't read the database lose remote OpenCode history until the old-glibc fallback (rung B) exists.
    • Runtimes on chrooted-SFTP hosts need the exec-stdin upload fallback.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Removes Bun runtime support and switches SQLite to Node.

The PR does not appear safe to merge for POSIX SSH hosts whose SFTP paths differ from shell paths.

Findings

  1. P1 Runtime upload misses SFTP mapping ▶

Summary

The PR replaces the remote OpenCode history reader’s Bun fallback with pinned Node, sharing the remote runtime store with orcad and removing the Bun SQLite adapter.

  • SSH and WSL readers probe the host runtime before installing pinned Node.
  • Windows SSH hosts receive a verified node.exe; POSIX hosts receive the verified archive.
  • SQLite, build, and cross-runtime tests are adjusted for the Node-only backend.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Remote OpenCode database] --> B{Host Node supports SQLite reader API?}
  B -- Yes --> C[Use host Node]
  B -- No --> D{Host platform}
  D -- POSIX SSH or WSL --> E[Install verified archive in shared runtime store]
  D -- Windows SSH --> F[Upload verified node.exe]
  C --> G[Run OpenCode reader]
  E --> G
  F --> G
Loading

Reviews (4) · Last reviewed commit: "test(native-chat): drop the Bun SQLite d..."

await exec(conn, `mkdir -p ${shellEscape(stageDir)}`, signal)
await uploadRelayDirectory(conn, localStage, stageDir, host, { signal })
await exec(`mkdir -p ${shellEscape(stageDir)}`, signal)
await remoteStep(() => uploadRelayDirectory(conn, localStage, stageDir, host, { signal }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Runtime upload misses SFTP mapping

If a POSIX host's SFTP subsystem sees different paths from its shell, this upload uses the shell's stage path without translating it for SFTP. The previous vault upload used a mapped stage. Here the archive can fail to upload or land where the shell cannot find it, so the pinned Node cannot be installed and remote OpenCode history remains unavailable.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the full branch through fa6bde90, which removes the Bun SQLite backend and moves remote OpenCode history onto the pinned Node runtime.

  • Bun SQLite adapter deleted — bun-sqlite-database.ts, bun-sqlite-statement.ts, bun-readonly-wal.ts, and src/shared/orcad-bun-runtime.ts are gone; sync-database.ts, sqlite-read-failure.ts, and profile-state-backup-worker.ts now use node:sqlite unconditionally. build-relay.mjs no longer externalises bun:sqlite and config/tsconfig.cli.json drops the removed modules.
  • Probes require node:sqlite.backup() — both the SSH probe (probeOpenCodeNodeSqliteCommand) and the WSL SQLITE_PROBE now fail capability when backup is absent, so 22.13–22.15 hosts fall through to the pinned runtime.
  • Shared runtime store on POSIX/WSL — the vault reader reuses runtimes/node-<executableSha256>/bin/node; new installNodeRuntimeFromHostArchiveCommand stages a host-readable archive, extracts/verifies/self-tests/promotes it, then removes the stage. ensureRemoteOrcadNodeRuntime now returns the executable and wraps each host round trip in remoteStep.
  • Windows vault path — uploads a verified bare node.exe under the same store layout; on-host archive extraction is explicitly deferred.
  • Materializer refactor — materializeCachedNodeRuntime (client cache node/<sha>/node[.exe]) replaces the Bun materializer, findExtractedExecutable is removed now that member always contains /, and the tar branch passes the member.

I verified pnpm tc:node, pnpm run check:code-quality:changed, and the focused suites (orcad-remote-node-runtime, ssh-relay-opencode-pinned-node, ssh-relay-opencode-runtime, pinned-runtime-materializer, opencode-wsl-runtime-preparation, sync-database, sqlite-read-failure) all pass. The install/promote ordering is safe under concurrency and interruption: the executable hash and --version self-test run before .verified is written, so the probe never accepts wrong bytes, and stages are token-scoped.

Note for reviewers: the mixed-version direction is sound but has no staged-rollout gate — a new client rewrites opencode-sqlite-runtime.json to a Node path while an older relay may still be live; that older reader bundle still reads through node:sqlite under Node, and a new reader handles an old Bun reference via Bun's node:sqlite. Worth confirming on a real upgrade before this reaches users.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review (fa6bde90): the base-branch merge 91f87dd and one test-only commit.

  • Dropped a stale Bun driver test — journal-open-failure.test.ts lost its SQLiteError / errno-shaped case. Since fa6bde90 removed the errno fallback and the name === 'SQLiteError' acceptance from isSqliteDriverError, that input no longer classifies as corrupt, so the case was failing; deleting it is the right fix. isSqliteCorruption has no caller outside the journal classifier, so no production path still distinguishes Bun's error shape.
  • Merged the base branch — 91f87dd is a clean merge of OrcaWin/node-rt-cutover (0b15611f); it touches no PR-authored file.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

m4air added 3 commits October 1, 2026 00:40
… Bun

SSH hosts whose Node lacks node:sqlite (or its backup(), which 22.13-22.15
omit) now get the pinned Node in the shared ~/.orca-remote/runtimes/node-<sha>
store orcad uses: POSIX hosts receive the official archive and extract and
hash-verify it on the host; Windows hosts receive the verified node.exe the
client extracted, promoted by host Node with the same hash check. WSL distros
use the same layout and checks under ~/.cache/orca/runtimes/.

The Bun release pin table and its materializer are deleted. Old relays keep
reading their vault-sqlite/<sha>/bun references; nothing deletes those files.
An unconfirmed runtime upload now keeps its stage instead of removing it.
…y backend

Nothing outside Electron runs on Bun any more (design D4), so SyncDatabase
loses its Bun branch, and bun-sqlite-database, bun-sqlite-statement and
bun-readonly-wal go, with the relay's bun:sqlite external. The profile-state
backup worker admits Electron or an entry that exists, and startup errors
name the pinned Node. The D7 cross-runtime gate still runs Bun 1.4.2, now
reaching Bun's SQLite through its node:sqlite.
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p2-vault branch from 4d44093 to 2937783 Compare October 1, 2026 07:53
@OrcaWin
OrcaWin changed the base branch from OrcaWin/node-rt-cutover to main October 1, 2026 07:53
@OrcaWin OrcaWin closed this Oct 1, 2026
@OrcaWin OrcaWin reopened this Oct 1, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review (4d44093): the branch was rebased onto main (merge-base 6593d7d1, which already carries #24110), so the three PR commits now sit directly on main instead of a merge of OrcaWin/node-rt-cutover.

  • Probes adapted to main's shared reader API — isSqliteAvailable() in sync-database.ts, the SSH probeOpenCodeNodeSqliteCommand, and the WSL SQLITE_PROBE now call hasNodeSqliteReaderApi / embed NODE_SQLITE_READER_API_SOURCE from main's node-sqlite-reader-api.ts instead of inline DatabaseSync+backup checks. Admission semantics are unchanged, and the embedded source is routed through shellEscape/powerShellNativeArg, so its quotes stay safe.
  • New WSL probe test — opencode-wsl-runtime-preparation.test.ts runs the real probe with a preload that deletes node:sqlite.backup, asserting rejection, and confirms an ExperimentalWarning on stderr does not fail the probe.
  • Rebased journal test — journal-open-failure.test.ts picks up main's NO_LEGACY_JOURNAL_RECORDS argument; the prior deletion of the Bun-driver corruption case still stands.

I verified pnpm tc:node and the focused suites (opencode-wsl-runtime-preparation, sync-database, sqlite-read-failure) pass. No behavioral regression in the rebase adaptation.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 92e41529-d9f3-40dd-ac1e-9b2b2288804d

📥 Commits

Reviewing files that changed from the base of the PR and between 94f6c53 and 2937783.

📒 Files selected for processing (40)
  • config/scripts/build-relay.mjs
  • config/scripts/check-runtime-launcher-protocol-ratchet.mjs
  • config/scripts/ci-shard-timings.json
  • config/scripts/electron-builder-runtime-resources.test.mjs
  • config/scripts/node-server-change-scope.test.mjs
  • config/tsconfig.cli.json
  • src/main/ai-vault/opencode-wsl-runtime-preparation.test.ts
  • src/main/ai-vault/opencode-wsl-runtime-preparation.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-process.test.ts
  • src/main/native-chat/agent-session-journal/journal-open-failure.test.ts
  • src/main/orcad/orcad-node-slot-fixture.ts
  • src/main/persistence/profile-state/profile-state-backup-worker.test.ts
  • src/main/persistence/profile-state/profile-state-backup-worker.ts
  • src/main/persistence/profile-state/profile-state-cross-runtime.integration.test.ts
  • src/main/persistence/profile-state/profile-state-database-snapshot.test.ts
  • src/main/persistence/profile-state/profile-state-startup-authority.test.ts
  • src/main/persistence/profile-state/profile-state-startup-authority.ts
  • src/main/persistence/profile-state/profile-state-store-factory.test.ts
  • src/main/persistence/profile-state/profile-state-store-factory.ts
  • src/main/persistence/profile-state/profile-state-worker-export-failures.test.ts
  • src/main/sqlite/bun-readonly-wal.test.ts
  • src/main/sqlite/bun-readonly-wal.ts
  • src/main/sqlite/bun-sqlite-database.ts
  • src/main/sqlite/bun-sqlite-statement.ts
  • src/main/sqlite/sqlite-read-failure.test.ts
  • src/main/sqlite/sqlite-read-failure.ts
  • src/main/sqlite/sync-database-concurrent-backup.test.ts
  • src/main/sqlite/sync-database.test.ts
  • src/main/sqlite/sync-database.ts
  • src/main/ssh/orcad-remote-node-runtime.test.ts
  • src/main/ssh/orcad-remote-node-runtime.ts
  • src/main/ssh/pinned-runtime-materializer.test.ts
  • src/main/ssh/pinned-runtime-materializer.ts
  • src/main/ssh/runtime-archive-download.ts
  • src/main/ssh/ssh-relay-opencode-pinned-node.test.ts
  • src/main/ssh/ssh-relay-opencode-pinned-node.ts
  • src/main/ssh/ssh-relay-opencode-runtime-commands.ts
  • src/main/ssh/ssh-relay-opencode-runtime.test.ts
  • src/main/ssh/ssh-relay-opencode-runtime.ts
  • src/shared/orcad-bun-runtime.ts
💤 Files with no reviewable changes (9)
  • config/scripts/check-runtime-launcher-protocol-ratchet.mjs
  • config/scripts/ci-shard-timings.json
  • config/tsconfig.cli.json
  • src/shared/orcad-bun-runtime.ts
  • src/main/sqlite/bun-readonly-wal.ts
  • src/main/sqlite/bun-sqlite-database.ts
  • src/main/sqlite/bun-readonly-wal.test.ts
  • src/main/native-chat/agent-session-journal/journal-open-failure.test.ts
  • src/main/sqlite/bun-sqlite-statement.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change replaces Bun-specific SQLite handling with Node’s node:sqlite APIs and removes the Bun SQLite adapters and readonly-WAL helper. OpenCode WSL and SSH setup now prepares pinned Node runtimes through shared runtime-store paths. The change also updates runtime installation, SQLite, and profile-state tests.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 29377

The change moves OpenCode history reading and SQLite access from Bun to the pinned Node runtime. No concrete merge-blocking issue remains after review. Remote installs on real hosts were not exercised here, so ordinary pre-release validation still applies.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 29377

Digest verification and atomic updates limit the migration’s risk. No introduced security weakness was established in the inspected paths, but host compatibility and cleanup after interrupted installations remain partly unresolved.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The directly inspected exposure is the selected remote account’s runtime store, relay reference, and OpenCode history, or the selected WSL guest user’s cache. Sharing the digest-addressed store makes integrity relevant to other consumers of that pin, but the inspected caller does not demonstrate newly granted credentials or elevated execution authority.

Trust Boundaries and Controls

  • observed — Downloaded archive bytes cross into executable authority only after local archive verification and downstream executable verification. POSIX publication additionally requires a successful self-test. Token-specific stages isolate attempts, and concurrent promotion is designed to replace only identically pinned executable bytes.

Resilience and Maintainability Implications

  • observed — SSH setup tracks connection generation and prevents another installer on a connection whose teardown is unconfirmed. Runtime stages may intentionally survive unconfirmed transfers. WSL rejects timed-out setup results, but its post-command cleanup is not proven to run after forced guest termination. Residual stages are distinct from the authoritative executable and reference.

Hardening Proposals

  • proposed — Define ownership-aware recovery and retention limits for abandoned runtime stages and unreferenced repair executables. Recovery should confirm that an attempt is no longer active before deletion, preserving the current protection for unconfirmed transfers. This is a failure-containment proposal, not an established security finding.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 51.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 41 functions across 31 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: using the pinned Node runtime for remote OpenCode history and removing Bun.
Description check ✅ Passed The description is mostly complete. It includes the user impact, implementation details, rationale, issue reference, visual-proof status, testing results, and known gaps. Some template sections such a…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit 8c2cd7d into main Oct 1, 2026
48 of 50 checks passed
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