Skip to content

fix(wsl): close the session scanner's post-stop boot gaps - #35729

Merged
nwparker merged 2 commits into
mainfrom
nwparker/wsl-e9-scanner-gaps
Oct 29, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/wsl-e9-scanner-gaps

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​313 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​299
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​185 $\color{#cf222e}{\Huge{\mathbf{−}}}$​41 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​144

Flag-off: this is not WSL-host-specific. It applies to the session scanner on any Windows desktop with WSL distros, flag on or off.
User-risk: low.

  • History in a distro that just stopped may drop out of a scan, with the existing per-root "not running" issue, until the distro runs again.
  • If wsl --list --running fails, the scan lists no WSL roots (and no extra WSL Codex homes) for that scan, rather than reusing an old answer.
  • Every transcript read on a WSL path now re-checks the running state. That check is in memory inside the 5 s lease, and a wsl --list --running probe after it.

ELI5

After you stop a WSL distro, Orca's chat-history scanner could still start it again. A reader process that died with the distro was restarted. A database was opened over the distro's file share. Reads that had queued up before the stop ran afterwards. An old "these distros are running" answer was reused. Now each of those checks that the distro really is running first, and leaves it alone if it isn't.

What Changed

Four gaps that wsl-e9-preflight found on main after #35367, all in session-history reading:

  1. OpenCode/ZCode WSL SQLite reader respawn (session-scanner-opencode-sqlite-process-client.ts, session-scanner-opencode-wsl-client.ts).
    • Before: when the guest reader process exited unexpectedly (as it does when its distro stops), nothing recorded it. The next request respawned it through wsl.exe --exec, and the admission check trusted a running read from up to 5 s earlier, so the respawn booted the distro. This is the likeliest cause of verify-18 (a).
    • After: the process client takes an onUnexpectedExit hook, and the WSL client calls noteWslDistroMayHaveStopped(distro) from it. The respawn's admission then needs a running list probed after that exit's 500 ms settle window.
  2. Devin sessions.db over 9P (session-scanner-devin-db.ts).
    • Before: only the earlier WAL stat was gated; the SQLite open itself was not.
    • After: the read is synchronous, so the open needs wasWslDistroLastSeenRunningSettled(distro, { maxAgeMs: 5 s }) (the transcript lease). The sidecar stat just before it has just taken such a list. Otherwise the database counts as unreadable for this scan and is retried on the next one.
  3. Queued transcript filesystem work (native-chat/wsl-transcript-fs-access.ts).
    • Before: a stat/readdir/access/readFile/open was admitted when it was queued, then ran later, possibly after a stop.
    • After: each one re-admits inside its task, right before the touch.
    • Reads on an already-open handle also re-admit, because the handle is a 9P handle in a Windows-side child, and reading it can reconnect to a stopped distro and start it. Closes stay ungated.
  4. Main-side WSL roots (cached-session-list.ts, wsl/wsl-home-unless-stopped.ts).
    • Before: these came from the non-confirmed running list, which falls back to the last-known-good answer when a probe fails. Together with a cached home, that could hand a stopped distro's root to the scanner.
    • After: listRunningWslHomeDirsUnlessStopped uses listConfirmedRunningWslDistros, and the extra Codex homes use requireConfirmed. A failed probe lists no WSL roots for that scan.

Why

  • Note the stop where it is seen. That reuses the gate's existing stop and settle bookkeeping rather than adding a new check.
  • Re-admit inside each task. The task can wait in its lane for a long time, and admitting only at queue time is what let a stopped distro through.
  • Prefer listing nothing on a failed probe over listing stale roots. Under E9, an unverifiable distro is never touched in the background anyway. The old comment's concern about narrowing roots for deletion and subagent validation now means a brief refusal, not a boot.

Linked Issue

Internal WSL tracker, E9; Windows verification verify-18 (a); gaps found by wsl-e9-preflight's sweep. The chat/bridge part (c) is #35707, which this PR does not overlap.

Visual Proof

N/A: no UI change.

Testing

Each new case fails with its source change reverted (checked file by file):

  • session-scanner-wsl-stop-gaps.test.ts, with a mocked wsl.exe and win32:
    • after a reader exits, its respawn re-probes and is refused once the distro stopped;
    • a WSL Devin database opens on a fresh running list, but not on one older than the lease;
    • with a cached home and a failed probe, no WSL root is listed.
  • session-scanner-opencode-sqlite-process.test.ts (real Node child): an unexpected exit reports through onUnexpectedExit, and a retirement does not.
  • wsl-transcript-running-admission.test.ts:
    • a read queued behind a busy lane is refused when it finally runs after a stop, and never reaches the filesystem;
    • a read on an open handle after a stop is refused.

Also run:

  • The ai-vault, native-chat and wsl suites pass (6,455 tests). The only failures were one test that also fails on another branch (structured-agent-session-at-rest-commands) and two load flakes that pass alone.

  • Load rule: pnpm tc, typecheck:ci, check:code-quality:changed, the anti-slop lint and the ast-grep gates.

  • Not run on Windows. A re-run of verify-18 (a) on a build with this is the device check.

  • I manually tested these changes locally

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

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Platforms: Windows only in effect. Off Windows, no path names a distro. SSH transcripts take their own path.
  • Wire: no wire change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

An OpenCode/ZCode WSL reader that exits notes its distro may have
stopped, so a respawn needs a settled running read. The Devin
sessions.db opens only on a running list from the transcript lease.
Queued transcript reads re-admit right before they run, and reads on
open 9P handles re-admit too. WSL roots and extra Codex homes come
from a confirmed running list (E9).
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66b54256-84c1-487b-b3d5-b1ab9c67b38e
Commits

Reviewing files that changed from the base of the PR and between c56d97b and 74f16cd.

Files selected for processing: 11
  • src/main/ai-vault/ai-vault-wsl-session-carryover.ts
  • src/main/ai-vault/cached-session-list.test.ts
  • src/main/ai-vault/cached-session-list.ts
  • src/main/ai-vault/session-scanner-devin-db.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-process-client.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-process.test.ts
  • src/main/ai-vault/session-scanner-opencode-wsl-client.ts
  • src/main/ai-vault/session-scanner-wsl-stop-gaps.test.ts
  • src/main/native-chat/wsl-transcript-fs-access.ts
  • src/main/native-chat/wsl-transcript-running-admission.test.ts
  • src/main/wsl/wsl-home-unless-stopped.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 2/5

[Medium impact] The changes affect Windows workflows that scan session history stored in WSL.

The PR needs fixes before merging: deleted sessions can return, and both previous findings remain unresolved.

Findings

  1. P1 Deleted sessions can return ▶
  2. P1 Reader errors hide stopped distros ▶
  3. P1 Slow scans drop Devin metadata ▶
  4. P2 Carryover rows exceed requested limits ▶

Summary

The PR adds WSL checks before reader restarts, database opens, and queued transcript reads.

  • Queued WSL transcript reads check again before touching files.
  • OpenCode reader restarts check WSL again after an unexpected exit.
  • Session scans use confirmed WSL roots and keep history visible during probe outages.
  • Devin session details are read only with a recent WSL running check.

Reviews (2) · Last reviewed commit: "fix(wsl): a failed running-list probe ke..." · Reviewed by Greptile

child.stderr.on('error', fault)
child.on('exit', (code) => {
if (!retired) {
options.onUnexpectedExit?.()

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 Reader errors hide stopped distros

If a reader error arrives before its exit, the new stop notice is skipped. For example, writing a request after the distro stops can fail with a broken pipe before the child reports its exit. fault() makes the request queue destroy the transport, setting retired = true. The exit handler then skips onUnexpectedExit.

The replacement reader can trust the old five-second running answer and boot the stopped distro. Notify the WSL client on unexpected transport failures too, before the queue can start another reader.

Comment on lines +104 to +108
if (
distro &&
!wasWslDistroLastSeenRunningSettled(distro, { maxAgeMs: WSL_TRANSCRIPT_RUNNING_LEASE_MS })
) {
return { index: null, unreadable: true }

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 Slow scans drop Devin metadata

The sidecar stat happens during discovery, which waits for all sources before parsing. If another source takes more than five seconds, an unchanged Devin transcript with a changed database goes straight to metadata enrichment without another WSL check. This guard rejects the expired answer instead of refreshing it, even when the distro is still running.

The session then loses its database title and working directory, and a hidden session can appear again. Refresh admission in the async enrichment path before this synchronous open.

…oots

Background discovery keeps confirmed-only WSL roots, but an unconfirmed
probe now carries over the last confirmed WSL rows (marked partial)
instead of dropping them. Path checks for user acts (delete, subagents,
transcript lookup) use last-known-good roots, since checking a path
against a root reads nothing.
Comment on lines +180 to +184
const result = carryOverUnconfirmedWslSessions(
key,
{ ...attachAiVaultScopeCwdAliases(scanned, scope), scanId },
wslConfirmed
)

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 Deleted sessions can return

carryOverUnconfirmedWslSessions saves rows before the generation check. A scan can read a WSL session, finish after that session is deleted, and restore the deleted row to the carryover map. The next failed WSL check then brings it back into the list.

Only let scans from the current generation update the carryover map.

Comment on lines +180 to +184
const result = carryOverUnconfirmedWslSessions(
key,
{ ...attachAiVaultScopeCwdAliases(scanned, scope), scanId },
wslConfirmed
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Carryover rows exceed requested limits

The merged carryover list bypasses the requested depth. After a deep confirmed scan, an unconfirmed request with limit: 100 can append thousands of saved WSL rows to its 100 fresh rows. The first caller receives all of them, while the next cache hit trims the same result to 100.

Apply truncateAiVaultListResult after merging, before returning and caching the result.

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