Repository navigation
fix(vault): read OpenCode SQLite inside WSL and SSH hosts - #23128
Conversation
Preserve verified remote cache reuse and latch only unresolved host work. Update WSL source-guard and remote dedup test integration.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe changes add OpenCode SQLite reader processes and integrate them with local, WSL, and relay session scans. They add runtime preparation and routing for WSL and SSH relay hosts, session discovery from SQLite alongside legacy files, and full first-user-prompt reads through worker parsers. Cancellation, request framing, runtime verification, cache behavior, and cleanup are also covered by implementation and tests. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No actionable runtime failure was established from the stale-manifest race; the reviewed change has no identified merge-blocking risk. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Out of Scope Changes checkExplanation The directly linked issue [
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 58329cb8-2d4d-4b75-ae9a-913a16019f97
📒 Files selected for processing (80)
config/scripts/build-relay.mjsconfig/scripts/relay-artifact-manifest.test.mjssrc/main/ai-vault-search/session-search-scan-roots.test.tssrc/main/ai-vault-search/session-search-scan-roots.tssrc/main/ai-vault/cached-session-list-wsl-probe.test.tssrc/main/ai-vault/cached-session-list.tssrc/main/ai-vault/opencode-wsl-runtime-preparation.test.tssrc/main/ai-vault/opencode-wsl-runtime-preparation.tssrc/main/ai-vault/remote-session-large-transcripts.test.tssrc/main/ai-vault/remote-session-parse-cache.tssrc/main/ai-vault/remote-session-scan-concurrency.tssrc/main/ai-vault/remote-session-scanner-discovery.tssrc/main/ai-vault/remote-session-scanner-opencode-source.tssrc/main/ai-vault/remote-session-scanner-opencode.test.tssrc/main/ai-vault/remote-session-scanner-types.tssrc/main/ai-vault/remote-session-scanner.tssrc/main/ai-vault/remote-session-transcript-read.tssrc/main/ai-vault/session-first-user-prompt-opencode.test.tssrc/main/ai-vault/session-first-user-prompt-read.tssrc/main/ai-vault/session-scanner-agent-parser.tssrc/main/ai-vault/session-scanner-background.tssrc/main/ai-vault/session-scanner-opencode-cancellation.test.tssrc/main/ai-vault/session-scanner-opencode-process-admission.test.tssrc/main/ai-vault/session-scanner-opencode-sources.tssrc/main/ai-vault/session-scanner-opencode-sqlite-discovery.tssrc/main/ai-vault/session-scanner-opencode-sqlite-dispatch.tssrc/main/ai-vault/session-scanner-opencode-sqlite-process-client.tssrc/main/ai-vault/session-scanner-opencode-sqlite-process-entry.tssrc/main/ai-vault/session-scanner-opencode-sqlite-process-framing.tssrc/main/ai-vault/session-scanner-opencode-sqlite-process.test.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-client.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-entry.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-protocol.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-spawn.tssrc/main/ai-vault/session-scanner-opencode-wsl-client.test.tssrc/main/ai-vault/session-scanner-opencode-wsl-client.tssrc/main/ai-vault/session-scanner-opencode-wsl-routing.test.tssrc/main/ai-vault/session-scanner-opencode-wsl-runtime.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner-service-env.test.tssrc/main/ai-vault/session-scanner-service-env.tssrc/main/ai-vault/session-scanner-source-discovery.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner-unlimited-dedup.test.tssrc/main/ai-vault/session-scanner.tssrc/main/ai-vault/session-transcript-reader.tssrc/main/lazy-worker-thread-host.tssrc/main/ssh/relay-bundle-paths.tssrc/main/ssh/relay-socket-path-limit.test.tssrc/main/ssh/ssh-relay-deploy-incumbent-verdict.test.tssrc/main/ssh/ssh-relay-deploy-staged-upload.test.tssrc/main/ssh/ssh-relay-deploy-windows-pipe.test.tssrc/main/ssh/ssh-relay-deploy.test.tssrc/main/ssh/ssh-relay-deploy.tssrc/main/ssh/ssh-relay-native-deps-cache-deploy.test.tssrc/main/ssh/ssh-relay-native-deps-install.test.tssrc/main/ssh/ssh-relay-native-deps-probe-verdict.test.tssrc/main/ssh/ssh-relay-node-pty-spawn-repair.test.tssrc/main/ssh/ssh-relay-opencode-runtime-commands.test.tssrc/main/ssh/ssh-relay-opencode-runtime-commands.tssrc/main/ssh/ssh-relay-opencode-runtime-retry.test.tssrc/main/ssh/ssh-relay-opencode-runtime-retry.tssrc/main/ssh/ssh-relay-opencode-runtime.test.tssrc/main/ssh/ssh-relay-opencode-runtime.tssrc/main/ssh/ssh-relay-pty-master-cloexec-install.test.tssrc/main/ssh/ssh-relay-session.test.tssrc/main/ssh/ssh-relay-session.tssrc/main/ssh/ssh-relay-sftp-namespace-install.test.tssrc/main/worker-thread-request-queue.test.tssrc/main/worker-thread-request-queue.tssrc/main/wsl-running-distro-cache.tssrc/main/wsl-running-distros.test.tssrc/main/wsl-running-path-filter.tssrc/main/wsl.tssrc/relay/ai-vault-handler.test.tssrc/relay/ai-vault-opencode-reader.test.tssrc/relay/ai-vault-opencode-reader.tssrc/relay/ai-vault-service-entry.tssrc/relay/ai-vault-service-filesystem.tssrc/shared/relay-artifacts.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
Important
Two live issues in new code: WSL OpenCode rows carry a Windows UNC cwd, which breaks the copied resume command, and the SSH runtime-setup latch is keyed on the pooled SshConnection, so it outlives a reconnect and permanently disables setup.
Reviewed changes
Initial review of all 80 files at 8b1fcb0 (base 4cafa50), focused on the new host-side OpenCode SQLite read path.
- WSL runtime preparation —
opencode-wsl-runtime-preparation.tsprobes the guest for a database, runs a realnode:sqliteprobe, and otherwise downloads/hash-verifies the pinned Bun; caches per distro with coalesced in-flight work. - WSL reader client —
session-scanner-opencode-wsl-client.tsspawns the bundled reader throughwsl.exe -d <distro> --execand maps guest sessions back to UNC identities. - Host-routed reads —
session-scanner-opencode-sqlite-worker-spawn.tssplits native vs WSL database paths and routes list/parse/capture to the owning host. - Remote OpenCode source —
remote-session-scanner-opencode-source.tsadds database discovery and a legacy merge; the parse cache is rekeyed byagent\0path. - SSH runtime setup —
ssh-relay-opencode-runtime*.tsplus thessh-relay-deploy.tscleanup-chain refactor provision the reader on the relay host, serialized against cleanup, with a scan-triggered retry. - Reader process transport —
session-scanner-opencode-sqlite-process-*frames JSON lines over a persistent child;worker-thread-request-queue.tsgains abort/dispose support. - Relay artifact and env —
opencode-sqlite-reader.cjsbecomes a required relay artifact;buildRelayAiVaultServiceEnvallowlistsXDG_DATA_HOME/OPENCODE_DB.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ Incremental review of
d728c59only. The queue cancellation fix is correct; the two findings from the previous review still stand at this head.
Reviewed changes
Delta since the prior review (8b1fcb0 → d728c59), 2 files.
fix(queue): discard aborted requests before respawn—worker-thread-request-queue.tsnow stores the dispatchsignalonPendingCalland drains already-aborted queued calls inpump()beforehost.ensure(), so a shared scan-signal abort no longer spawns-and-kills one worker per queued request.worker-thread-request-queue.test.tsadds a covering test asserting a single worker for 8 cancelled calls, plus an optional survivor that still gets dispatched.
The drain is self-consistent: it settles each cancelled call through settle, which removes that call's abort listener during the in-flight abort dispatch (so the remaining listeners never run), and the now-empty queue falls through to scheduleIdleTeardown(), which is a no-op once host.destroy() has cleared the worker. No new issues in the delta.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Delta since the prior review (d728c59 → b0fedcb), 9 files.
- Preserved WSL
cwdas the guest's POSIX path —mapOpenCodeWslSessionno longer rewritescwdto a\\wsl.localhost\…UNC path, so the copied resume command (cd '/home/ada/project' && opencode …) runs inside the distro;filePath/idstay UNC for the first-user-prompt route. - Scoped the SSH runtime-setup latch to the connection generation — the
installationsmap is now keyed byconn.getConnectGeneration(), so a reconnect starts a fresh setup map and an unconfirmed teardown no longer permanently disables setup for that target;remote()refuses a superseded generation, which is classified'failed'(retryable) rather than'teardown-unconfirmed'. - Gated WSL admission on an un-aborted controller —
createAdmittedProcessTransportcallscontroller.signal.throwIfAborted()beforeadmit(...), so a reader cancelled before admission no longer fires awsl.exerunning-distro probe. - Coverage — new tests assert no admission probe for a pre-cancelled reader, per-generation recovery after an unconfirmed teardown, that a superseded setup issues no further host commands, and WSL identity/cwd mapping.
All four findings from the previous reviews are addressed; their review threads were replied to and resolved. The queue fan-out fix (d728c59) remains verified.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 2a55632b-cc2d-48dd-9818-308d59835bdd
📒 Files selected for processing (11)
src/main/ai-vault/session-scanner-opencode-process-admission.test.tssrc/main/ai-vault/session-scanner-opencode-sqlite-process-client.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-spawn.tssrc/main/ai-vault/session-scanner-opencode-wsl-client.test.tssrc/main/ai-vault/session-scanner-opencode-wsl-client.tssrc/main/ai-vault/session-scanner-opencode-wsl-routing.test.tssrc/main/ssh/orcad-deployment-target.test.tssrc/main/ssh/orcad-deployment-target.tssrc/main/ssh/ssh-connection.tssrc/main/ssh/ssh-relay-opencode-runtime.test.tssrc/main/ssh/ssh-relay-opencode-runtime.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Delta since the prior review (b0fedcb → 629df77), 3 files.
- Fenced every runtime platform probe across reconnects —
resolveOrcadDeploymentTargetnow accepts an optional injectedexec, and the SSH runtime setup passes its generation-checkedexec(install's helper). Previously the outerremote(() => resolveOrcadDeploymentTarget(...))fenced only the call boundary, so the internal fallbackgetconf/musl probe could run on a torn-down channel; now both thelddand fallback probes pass throughremote(). - Coverage —
orcad-deployment-target.test.tsadds a test that a generation change between the first and fallback probe rejects withSSH connection changedand issues no secondexecCommand; the existing default (noexec) path is unchanged for theorcad-remote-deploy.tscaller.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Delta since the prior pullfrog review (629df77 → 7c393f7), 3 files.
- Rejected setup results from superseded connections —
ssh-relay-opencode-runtime.tsnow asserts the connection generation before and after every host operation insideremote(), and once more afterinstall()resolves. A lateready/not-neededfrom a superseded generation now resolves'failed'(retryable) instead of being admitted. - Kept the newer generation's setup registered — the old setup's cleanup
byDirectory.deletestill runs against the generation-1 map it captured, so a setup registered under the new generation survives; the coalesced newer call keeps joining it. - Coverage — extended the late-result case to both
readyandnot-needed, added generation-change-during-publication/cleanuptests with exactexeccounts, and a regression that a newer setup stays registered while a superseded one finishes late.ssh-relay-cross-version-isolation.test.tsmocks the runtime module so the deploy path stays isolated.
I traced the rejection path end to end: a generation error is neither signal.aborted nor an unconfirmed termination, so it is classified 'failed', and the map deletion touches the superseded generation's map only. Ran both touched suites locally at 7c393f7 (23 + 1 tests) — all pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
OpenCode sessions created inside WSL or on an SSH host can disappear from Agent Session History because they now live in SQLite. Orca will read those databases on the host that owns them, including changes still in SQLite's WAL file.
What Changed
A small background reader reuses the existing OpenCode v1/v2 parsers. WSL reads execute inside the running distro; SSH reads execute beneath its relay. Session paths and identities retain their host, and SQLite candidates enter the existing sorting, limits, scope, cache and legacy-file pipeline.
The reader uses a host Node runtime only after an actual SQLite read succeeds. Otherwise host preparation supplies the existing pinned, hash-verified Bun runtime through Orca's proxy-aware downloader. Only the matching runtime is installed; desktop packages carry the small reader bundle, not every Bun platform. The older Node relay keeps running independently. Setup failures become Vault scan issues and do not block terminals or local history. Hosts without an OpenCode database skip runtime provisioning; later scans retry preparation when data appears. SSH uploads reuse the existing bounded, ownership-checked staging pool and stale recovery. An uncertain transfer prevents further setup commands on that connection.
Requests are queued with bounded messages, cancellation, timeouts, idle teardown and a guest watchdog. WSL full-prompt and search reads share the host route. SSH wire APIs stay unchanged.
Why
Windows cannot reliably take SQLite locks through WSL network paths, and older SSH Node runtimes cannot open SQLite. Copying the main database can miss uncheckpointed WAL changes. Running the existing read-only parsers beside the database preserves its locking and schema behavior without requiring a system Node upgrade.
Linked Issue
Fixes #20821.
Visual Proof
N/A — Agent Session History uses its existing presentation; this repairs missing database-backed rows. Live guest database fixtures verify the recovered rows and transcript data; no presentation code changes.
Testing
Validation includes 174 OpenCode/remote/first-prompt regressions across 25 suites, 204 affected SSH tests across 15 suites, and WSL admission/cancellation/source tests. Final independent native SSH review reran 97 tests across 6 suites successfully. Node and CLI typechecks, scoped lint/format and changed-code-quality gate pass (zero findings). All six relay targets and the actual Bun daemon artifact build. Native and Claude Opus reader and WSL reviews found no remaining P0/P1. The final SSH Opus review found no P0/P1; its targeted retry recheck found no P0/P1 or blocking findings and passed 279 focused tests plus typecheck/lint and four abort-classification reproductions.
An official Node 18.20.8 runtime ran the actual relay service with a Bun reader against a live uncheckpointed WAL fixture and returned the session with no scan issues, then shut down cleanly. This caught and fixed a real Node 18 file-read incompatibility.
Real Windows 11 / Ubuntu 24.04 qualification passed with both guest Node 24.18.0 and an actually downloaded, SHA-verified Bun 1.4.2 fallback. It covered an open WAL containing 28,872 bytes, list/parse/capture, a full 5,039-character prompt, UNC session/database/cwd identities, Linux resume commands, cancellation followed by a new reader, and the missing-distro guard. First preparation returned in 4–5 ms; test fixture processes and guest directories were removed. The existing running distro was preserved; this was not a distro stop/start test. Fifteen generated SSH setup operations also ran on real Windows PowerShell 5.1. No live SSH endpoint was exercised.
The retry review confirmed that local cancellation is retryable, while unresolved remote work remains blocked from retrying on the same connection. A narrow residual can leave a bounded upload slot until stale recovery if cancellation occurs during local filesystem work after reservation; this uses the existing 40-minute recovery policy. Prior d728c59 passed full CI. On 629df77, storage/platform, static, types, both package lanes, real WSL and seven unit shards passed; shard 4 exposed a stale fixture for the new connection-generation API, now corrected without changing its assertions. Merged reviewed head 7c393f7 as da6d483 after the final platform/native matrix, static/types, both package lanes, all eight unit shards, real WSL, localhost SSH and verify checks passed. Changed E2E specs and SSH Docker watcher isolation were still running at merge; no final-head failures were reported. This is not a claim that the final full workflow had completed.
Generation is checked before and after every remote operation, including Linux libc fallback, and after final cleanup. Late results cannot mark a reconnected host ready or clear its newer setup. The late-result regressions and targeted suites pass (38 tests); independent Codex and Claude Opus review found no P0/P1/P2, with Opus rerunning 34 runtime/launcher/fixture tests.
Review
Native SQLite work stays off the calling thread. Missing host access never redirects a query to the client's database. Existing file-only providers retain their prior behavior; remote transcript/search APIs are not expanded in this PR.
Agent skill upstream boundary
Notes
The existing arbitrary
OPENCODE_DBfilename limitation remains; canonicalopencode*.dboverrides are supported. First-time Bun setup requires network access unless a verified cache is already present. WSL discovery retains its existing default home-directory roots; this repairs database access at those roots. Older remote version/ripgrep collectors retain their existing best-effort error handling; this PR does not claim to fix uncertainty across all deployment cleanup. A confirmed running-distro probe gates each WSL reader start or queued respawn, while reads through a live reader reuse its process. A failed probe cannot use stale running state to start a reader. As with other WSL commands, a distro can still stop between the check and launch. Runtime setup progress is surfaced as a scan issue; refresh retries after setup.Checklist
Final comment fixes: preserve the guest POSIX working directory for WSL resume while retaining UNC database identity; reject cancellation before reader admission; scope uncertain setup to a connection generation and fence every runtime probe, including Linux fallback. 48 targeted tests passed, followed by 34 resolver/runtime tests; Node types, scoped lint and strict anti-slop checks passed. Native and final Opus rechecks are clean of P0/P1/P2; Opus reran 101 targeted tests and 297 caller/connection tests, plus Node types and lint. All review threads are resolved.