Skip to content

Kill hung WSL transcript filesystem operations via child process with route quarantine - #15381

Merged
OrcaWin merged 6 commits into
mainfrom
jinjing/sta-4360-p1daily-14183-two-stalled-wsl-transcript-calls-exhaust-the-2
Aug 18, 2026
Merged

OrcaWin merged 6 commits into
mainfrom
jinjing/sta-4360-p1daily-14183-two-stalled-wsl-transcript-calls-exhaust-the-2

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1012 $\color{#cf222e}{\Huge{\mathbf{−}}}$​91 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​921
Prod 25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1345 $\color{#cf222e}{\Huge{\mathbf{−}}}$​252 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1093

Problem

WSL UNC filesystem operations that stall indefinitely can exhaust the main process's libuv thread pool. Two blocked syscalls on a hung mount burn both permits, causing global unavailability. There is no way to interrupt an unabortable 9P syscall.

Solution

Fork filesystem operations on WSL UNC paths to a child process (ELECTRON_RUN_AS_NODE). Kill the child if the operation exceeds its deadline (30s exact, 60s scan). Implement route-level quarantine with exponential backoff to avoid hammering a hung mount after the first stall. Lift quarantine on successful operations; escalate on repeat stalls with strike decay after 5 minutes of quiet. Serialize Dirent and Stats through IPC since they lose prototype methods across process boundaries.

What Changed

  • Added wsl-transcript-fs-process-* modules: child entry point, client connection pool, request/response protocol, slot management, spawn/fork config, and operation handlers
  • Added wsl-transcript-fs-route-quarantine.ts: per-route blocking with exponential back-off and strike decay
  • Extracted error classes to wsl-transcript-fs-error.ts so they work across process boundaries
  • Refactored gate to use child process for UNC paths instead of inline syscalls; local paths still use direct Node APIs
  • Updated wsl-transcript-fs-access.ts to delegate UNC operations through the child dispatcher
  • Updated build config to unpack and entry the child process entry point
  • Updated test fixtures to provide complete Dirent method stubs after deserialization
  • Moved gate reset into route quarantine reset so tests don't leak quarantine state

Verification

New test suites cover: process client lifecycle, handle pinning, idle reap, transport faults, error reconstruction; route quarantine escalation, decay, and sibling-lane deduplication. Existing gate and access tests updated to reset route quarantine per-test and validate the new process-based UNC paths.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • N/A — No UI changes
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (WSL-specific hardening; SSH uses direct Node APIs)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover)

Stalled UNC file operations hold libuv permits even after the gate
timeout expires, blocking Chat tab recovery. Two stalled operations
fill both permits and freeze all WSL access until restart.

Fork file I/O for UNC paths into a separate child process. On deadline
expiry, kill the process to force the hung syscall to exit. This frees
the permit for the affected tab's next read. Temporarily quarantine the
stalled route to avoid retry storms.
Review follow-ups on the sidecar isolation change:

- Only the deadline may abort running gate work. The sole waiter's
  same-duration timeout fired first, killed healthy children on caller
  abandonment, and settled the task before the deadline could quarantine
  a stalled route - leaving the back-off dead for every dedupe:false op.
- Resolve the fork entry from out/main/chunks too: the resolver compiles
  into a shared chunk, and the scanner service child has no
  process.resourcesPath, so packaged WSL vault scans threw entry-not-found
  (masked as an empty tree).
- Allowlist the fork env instead of spreading process.env; ambient
  NODE_OPTIONS would halt or --require code into every child.
- Wrap transport faults (spawn failure, child death) in
  WslTranscriptFsError('unavailable') so discovery reports them as scan
  issues instead of misreading them as missing paths or empty trees.
- Gate the vitest in-process fallback on the vitest worker global so a
  leaked VITEST=true cannot revert production to in-process UNC syscalls.
- Reap idle sidecar processes after 60s instead of holding them for the
  app session.
- Split 'open' into its own protocol union member so the reusable-call
  Exclude actually strips it from the pooled-process API.
- Guard kill('SIGKILL') against the teardown race where an exiting child
  emits an unlistened 'error', and dispatch reads by handle kind before
  path spelling.
Remaining review follow-ups:

- Escalating route quarantine: first strike lifts after 5s so a distro
  that was cold-booting when its op hit the deadline recovers on the
  next poll (~35s total instead of ~90s); repeat stalls double the
  back-off toward the prior 2x-timeout cap, and any settle the deadline
  did not force clears the strikes. Queued same-route tasks fail fast
  at quarantine instead of stranding one waiter deadline per file in
  sequential scans.
- Single request implementation: the vitest in-process fallback now runs
  the child's own dispatcher (WslTranscriptFsProcessOperations + decode),
  so unit suites exercise exactly what the forked process executes and
  the per-call-site fallback closures are gone. Dirent fixtures gained
  the full kind-flag set the serializer reads.
- Dropped the production-dead per-route close queue; UNC FileHandles
  (test fallback only) mirror the process-handle close contract.
- Error class, messages, and factories move to wsl-transcript-fs-error
  (re-exported from the gate) to keep the gate under the lines budget.
Extract quarantine logic into a dedicated module with strike decay: stalls older
than 5 minutes restart from base back-off, and concurrent-lane timeouts count as
one incident. Allow joining live in-flight tasks on quarantined routes (they cost
no new I/O). Preserve quarantine across transport faults (child death). Handle
file shrinking during tail reads by detecting short reads and returning empty.
Defer file closes that arrive mid-read instead of refusing, preventing slot
leaks. Separate process slot and boundary-finding concerns into focused modules.
@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 286947ec-a815-4559-802a-6754fe545c3d

📥 Commits

Reviewing files that changed from the base of the PR and between 997b6d8 and ce56a41.

📒 Files selected for processing (15)
  • src/main/ai-vault/session-scanner-core-parser-wsl-stall.test.ts
  • src/main/native-chat/transcript-read-cache-refusal-recovery.test.ts
  • src/main/native-chat/transcript-tail-reader-wsl-gate.test.ts
  • src/main/native-chat/wsl-transcript-fs-access.ts
  • src/main/native-chat/wsl-transcript-fs-gate.test.ts
  • src/main/native-chat/wsl-transcript-fs-gate.ts
  • src/main/native-chat/wsl-transcript-fs-process-client.test.ts
  • src/main/native-chat/wsl-transcript-fs-process-client.ts
  • src/main/native-chat/wsl-transcript-fs-process-dispatch.ts
  • src/main/native-chat/wsl-transcript-fs-process-handle-owner.ts
  • src/main/native-chat/wsl-transcript-fs-process-lane-pool.ts
  • src/main/native-chat/wsl-transcript-fs-process-send.ts
  • src/main/native-chat/wsl-transcript-fs-process-slot.ts
  • src/main/native-chat/wsl-transcript-fs-route.test.ts
  • src/main/native-chat/wsl-transcript-fs-route.ts

📝 Walkthrough

Walkthrough

The change adds a reusable child process for WSL transcript filesystem operations. It defines IPC protocol types, error handling, result decoding, process slots, handle ownership, restricted spawning, and packaged entry registration. The filesystem gate now applies deadlines and route quarantine. WSL access, reads, directory scans, and transcript tail handling use the new routing. Tests cover process reuse, handle lifecycle, quarantine behavior, stalled routes, serialization, packaging, and test-state reset.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the problem, solution, changes, verification, and checklist, but it omits the required Linked Issue and several template sections. Add a valid Linked Issue entry and complete or explicitly mark the missing template sections, including ELI5, Visual Proof, Testing, Review, Notes, and Author.
Docstring Coverage ⚠️ Warning Docstring coverage is 34.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: terminating hung WSL transcript filesystem operations and applying route quarantine.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/native-chat/wsl-transcript-fs-process-client.ts (1)

81-83: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Classify the busy-slot rejection as a WslTranscriptFsError.

This branch rejects with a plain Error. The comment on lines 11-13 states that discovery layers only rethrow WslTranscriptFsError, so a plain error reads as "path missing" or "empty tree" upstream. A busy slot is reachable at runtime: when a gate waiter abandons a read, the child call stays active, and a later read on the same pinned handle hits this branch. Return a classified refusal so the upstream layers treat it as a temporary condition.

♻️ Proposed change
     if (state.slot.active) {
-      return Promise.reject(new Error('WSL transcript file handle is already in use'))
+      return Promise.reject(
+        wslTranscriptFsProcessFailureError('a read on this file handle is still in flight')
+      )
     }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 89646ed9-f432-4e00-85df-e714aff26a9f

📥 Commits

Reviewing files that changed from the base of the PR and between 3ac4171 and 997b6d8.

📒 Files selected for processing (31)
  • config/build-plugins/plain-node-entry-guard.ts
  • config/electron-builder.config.cjs
  • config/scripts/electron-builder-config.test.mjs
  • electron.vite.config.ts
  • src/main/ai-vault/session-scanner-core-parser-wsl-stall.test.ts
  • src/main/ai-vault/session-scanner-discovery-wsl-gate.test.ts
  • src/main/ai-vault/session-scanner-service-env.ts
  • src/main/native-chat/host-readable-transcript-path.ts
  • src/main/native-chat/transcript-read-cache.ts
  • src/main/native-chat/transcript-tail-boundary.ts
  • src/main/native-chat/transcript-tail-reader.ts
  • src/main/native-chat/transcript-watch-wsl-stall.test.ts
  • src/main/native-chat/wsl-codex-session-path-scan.ts
  • src/main/native-chat/wsl-transcript-fs-access.test.ts
  • src/main/native-chat/wsl-transcript-fs-access.ts
  • src/main/native-chat/wsl-transcript-fs-error.ts
  • src/main/native-chat/wsl-transcript-fs-gate.test.ts
  • src/main/native-chat/wsl-transcript-fs-gate.ts
  • src/main/native-chat/wsl-transcript-fs-process-client.test.ts
  • src/main/native-chat/wsl-transcript-fs-process-client.ts
  • src/main/native-chat/wsl-transcript-fs-process-decode.ts
  • src/main/native-chat/wsl-transcript-fs-process-dispatch.ts
  • src/main/native-chat/wsl-transcript-fs-process-entry.ts
  • src/main/native-chat/wsl-transcript-fs-process-operations.test.ts
  • src/main/native-chat/wsl-transcript-fs-process-operations.ts
  • src/main/native-chat/wsl-transcript-fs-process-protocol.ts
  • src/main/native-chat/wsl-transcript-fs-process-slot.ts
  • src/main/native-chat/wsl-transcript-fs-process-spawn.ts
  • src/main/native-chat/wsl-transcript-fs-route-quarantine.test.ts
  • src/main/native-chat/wsl-transcript-fs-route-quarantine.ts
  • src/main/opencode-usage/scanner-wsl-gate.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@OrcaWin

OrcaWin commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai Fixing. Will be in the next commit

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@OrcaWin Thanks for the update. I will check the next commit.

You are interacting with an AI system.

A late result arriving after the deadline was incorrectly lifting the route
quarantine, allowing subsequent work to start before the back-off period
expired. Now late results are correctly recognized as stale and never cut
the quarantine short.

Process work is now isolated per (route, priority) lane so a scan stall
cannot block exact reads on the same distro. Each lane gets its own client
and process pool; late results and handle faults stay scoped to their lane.

Tests now fake performance.now() alongside timers (the quarantine clock
depends on it) and wait for the full back-off window to expire rather than
advancing by 0. Gate state is reset between test cases since late releases
never lift the quarantine.
@OrcaWin
OrcaWin merged commit 4ec6bbf into main Aug 18, 2026
46 of 50 checks passed
@Jinwoo-H

Copy link
Copy Markdown
Contributor

Heads up — this looks like it broke 4 tests on main, in src/main/ai-vault/ (the PR updated the src/main/native-chat/ tests but not these callers).

src/main/ai-vault/session-scanner-parse-wsl-stall.test.ts
  × caches no resume point when the newline probe is refused mid-append
src/main/ai-vault/session-scanner-index-cache-wsl-stall.test.ts
  × evicts the Codex title index instead of pinning "no titles"
  × evicts the Kimi work-dir index instead of pinning "no cwd"
  × still degrades a missing optional JSON file to null
npx vitest run --config config/vitest.config.ts \
  src/main/ai-vault/session-scanner-parse-wsl-stall.test.ts \
  src/main/ai-vault/session-scanner-index-cache-wsl-stall.test.ts

Red at 4ec6bbf588, green at its parent 1b5cc00870. I hit it because my PR's merge with main picked this commit up; my own diff touches no src/main/ file, and running just these two files (so nothing of mine is even loaded) reproduces it.

The error escapes rather than degrading:

WslTranscriptFsError: WSL transcript files are temporarily unavailable ...
 ❯ wslTranscriptFsUnavailableError src/main/native-chat/wsl-transcript-fs-error.ts:29:10
 ❯ runWslTranscriptFsTask     src/main/native-chat/wsl-transcript-fs-gate.ts:338:27
 ❯ wslGatedOpen               src/main/native-chat/wsl-transcript-fs-access.ts:104:10
 ❯ gatedChunks                src/main/native-chat/wsl-transcript-fs-access.ts:215:24

Line 338 is the new if (routeIsBlocked(route)) return Promise.reject(unavailableError()). These tests stall one path and then expect a subsequent operation on the same route to degrade (cache nothing / return null); with the quarantine, that second call now rejects immediately instead. So it reads like a deliberate semantics change that these AI Vault callers were not updated for — either they should catch unavailable the way they already catch the timeout, or the quarantine should not apply on this path.

Flagging rather than fixing since you own the intended semantics. Happy to take it if that helps.

@OrcaWin

OrcaWin commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@Jinwoo-H will fix the tests on main

brennanb2025 added a commit that referenced this pull request Aug 19, 2026
#15381 applied this same fix to session-scanner-core-parser-wsl-stall,
session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate,
and missed these two files. Adopt that established shape rather than a
parallel one: fold the back-off wait into releaseAndSettle instead of a
separate helper at each call site, and fake performance explicitly, since
performance.now drives the quarantine clock.

The explicit toFake is not strictly required today — vitest's default
already fakes performance — but it documents the dependency and stops a
default change from silently unfaking the quarantine clock.
AmethystLiang pushed a commit that referenced this pull request Aug 19, 2026
… route quarantine (#15381)

* fix(native-chat): kill hung WSL operations via child process

Stalled UNC file operations hold libuv permits even after the gate
timeout expires, blocking Chat tab recovery. Two stalled operations
fill both permits and freeze all WSL access until restart.

Fork file I/O for UNC paths into a separate child process. On deadline
expiry, kill the process to force the hung syscall to exit. This frees
the permit for the affected tab's next read. Temporarily quarantine the
stalled route to avoid retry storms.

* chore: drop internal review artifact from the repo root

* fix(native-chat): harden the WSL transcript fs sidecar

Review follow-ups on the sidecar isolation change:

- Only the deadline may abort running gate work. The sole waiter's
  same-duration timeout fired first, killed healthy children on caller
  abandonment, and settled the task before the deadline could quarantine
  a stalled route - leaving the back-off dead for every dedupe:false op.
- Resolve the fork entry from out/main/chunks too: the resolver compiles
  into a shared chunk, and the scanner service child has no
  process.resourcesPath, so packaged WSL vault scans threw entry-not-found
  (masked as an empty tree).
- Allowlist the fork env instead of spreading process.env; ambient
  NODE_OPTIONS would halt or --require code into every child.
- Wrap transport faults (spawn failure, child death) in
  WslTranscriptFsError('unavailable') so discovery reports them as scan
  issues instead of misreading them as missing paths or empty trees.
- Gate the vitest in-process fallback on the vitest worker global so a
  leaked VITEST=true cannot revert production to in-process UNC syscalls.
- Reap idle sidecar processes after 60s instead of holding them for the
  app session.
- Split 'open' into its own protocol union member so the reusable-call
  Exclude actually strips it from the pooled-process API.
- Guard kill('SIGKILL') against the teardown race where an exiting child
  emits an unlistened 'error', and dispatch reads by handle kind before
  path spelling.

* fix(native-chat): probe stalled WSL routes instead of a fixed quarantine

Remaining review follow-ups:

- Escalating route quarantine: first strike lifts after 5s so a distro
  that was cold-booting when its op hit the deadline recovers on the
  next poll (~35s total instead of ~90s); repeat stalls double the
  back-off toward the prior 2x-timeout cap, and any settle the deadline
  did not force clears the strikes. Queued same-route tasks fail fast
  at quarantine instead of stranding one waiter deadline per file in
  sequential scans.
- Single request implementation: the vitest in-process fallback now runs
  the child's own dispatcher (WslTranscriptFsProcessOperations + decode),
  so unit suites exercise exactly what the forked process executes and
  the per-call-site fallback closures are gone. Dirent fixtures gained
  the full kind-flag set the serializer reads.
- Dropped the production-dead per-route close queue; UNC FileHandles
  (test fallback only) mirror the process-handle close contract.
- Error class, messages, and factories move to wsl-transcript-fs-error
  (re-exported from the gate) to keep the gate under the lines budget.

* fix(native-chat): harden WSL transcript fs with route quarantine strike

Extract quarantine logic into a dedicated module with strike decay: stalls older
than 5 minutes restart from base back-off, and concurrent-lane timeouts count as
one incident. Allow joining live in-flight tasks on quarantined routes (they cost
no new I/O). Preserve quarantine across transport faults (child death). Handle
file shrinking during tail reads by detecting short reads and returning empty.
Defer file closes that arrive mid-read instead of refusing, preventing slot
leaks. Separate process slot and boundary-finding concerns into focused modules.

* fix(native-chat): enforce route quarantine windows and isolate lanes per

A late result arriving after the deadline was incorrectly lifting the route
quarantine, allowing subsequent work to start before the back-off period
expired. Now late results are correctly recognized as stale and never cut
the quarantine short.

Process work is now isolated per (route, priority) lane so a scan stall
cannot block exact reads on the same distro. Each lane gets its own client
and process pool; late results and handle faults stay scoped to their lane.

Tests now fake performance.now() alongside timers (the quarantine clock
depends on it) and wait for the full back-off window to expire rather than
advancing by 0. Gate state is reset between test cases since late releases
never lift the quarantine.

---------

Co-authored-by: OrcaWin <[email protected]>
(cherry picked from commit 4ec6bbf)
brennanb2025 added a commit that referenced this pull request Aug 19, 2026
…15408)

* test(wsl): account for the route quarantine in stalled-mount tests

#15381 added a route-level quarantine: a timed-out task blocks new
admissions on that route for a back-off window, so the next real task
probes recovery instead of hammering a hung mount. It merged with four
tests already failing on main, and they still fail.

Two causes, both test-side:

- The recovery half of three tests read again immediately after releasing
  the stall, which the quarantine now refuses. They wait out the window,
  which is what a real caller does — resetting the gate would skip the
  admission the recovery assertions exist to prove.
- `blockedRoutes` is module state that no test cleared, so a stall in one
  test refused an unrelated read in the next. Both files now reset the
  gate in beforeEach.

Production behavior is unchanged and is working as designed: eviction
still happens, only the immediate re-read is deferred by the back-off.

* test(wsl): match the sibling suites' quarantine idiom

#15381 applied this same fix to session-scanner-core-parser-wsl-stall,
session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate,
and missed these two files. Adopt that established shape rather than a
parallel one: fold the back-off wait into releaseAndSettle instead of a
separate helper at each call site, and fake performance explicitly, since
performance.now drives the quarantine clock.

The explicit toFake is not strictly required today — vitest's default
already fakes performance — but it documents the dependency and stops a
default change from silently unfaking the quarantine clock.
OrcaWin added a commit that referenced this pull request Aug 20, 2026
The AI Vault title reader forks wsl-transcript-fs-process-entry.js for WSL UNC
paths. PR #15381 taught electron.vite.config.ts and electron-builder to emit and
unpack it for the desktop app, but config/scripts/build-relay.mjs was never
updated, so no relay ever shipped it. A packaged Windows relay therefore
advertised the AI Vault title service, reached the fork, threw "entry not
found", and had the throw swallowed by the title reader's per-request catch —
every WSL transcript title came back empty, with no error surfaced anywhere.

Unit suites cannot catch this: the dispatcher runs the child's own operations
in-process under vitest and never forks.

The build, the content hash, and the remote install-completeness probe each
carried their own hand-maintained file list, which is how the three drifted.
Replace them with one declaration in src/shared/relay-artifacts.ts that all
three read, and close the loop in both directions: an artifact declared but not
emitted fails the build, and an artifact emitted but not declared fails it too.
Each platform directory is cleared first, so a stale companion from an earlier
build cannot satisfy the manifest or be hashed into .version.

Adding the helper to the hash changes every relay version, so hosts install into
a fresh immutable directory rather than reusing a partial one.

Verified on a Windows host against a real WSL distro: the built relay returns no
title before and the transcript title after, and the generated install probe
accepts a complete directory and rejects one missing only the helper.
OrcaWin added a commit that referenced this pull request Aug 20, 2026
The AI Vault title reader forks wsl-transcript-fs-process-entry.js for WSL UNC
paths. PR #15381 taught electron.vite.config.ts and electron-builder to emit and
unpack it for the desktop app, but config/scripts/build-relay.mjs was never
updated, so no relay ever shipped it. A packaged Windows relay therefore
advertised the AI Vault title service, reached the fork, threw "entry not
found", and had the throw swallowed by the title reader's per-request catch —
every WSL transcript title came back empty, with no error surfaced anywhere.

Unit suites cannot catch this: the dispatcher runs the child's own operations
in-process under vitest and never forks.

The build, the content hash, and the remote install-completeness probe each
carried their own hand-maintained file list, which is how the three drifted.
Replace them with one declaration in src/shared/relay-artifacts.ts that all
three read, and close the loop in both directions: an artifact declared but not
emitted fails the build, and an artifact emitted but not declared fails it too.
Each platform directory is cleared first, so a stale companion from an earlier
build cannot satisfy the manifest or be hashed into .version.

Adding the helper to the hash changes every relay version, so hosts install into
a fresh immutable directory rather than reusing a partial one.

Verified on a Windows host against a real WSL distro: the built relay returns no
title before and the transcript title after, and the generated install probe
accepts a complete directory and rejects one missing only the helper.
AmethystLiang pushed a commit that referenced this pull request Aug 20, 2026
… route quarantine (#15381)

* fix(native-chat): kill hung WSL operations via child process

Stalled UNC file operations hold libuv permits even after the gate
timeout expires, blocking Chat tab recovery. Two stalled operations
fill both permits and freeze all WSL access until restart.

Fork file I/O for UNC paths into a separate child process. On deadline
expiry, kill the process to force the hung syscall to exit. This frees
the permit for the affected tab's next read. Temporarily quarantine the
stalled route to avoid retry storms.

* chore: drop internal review artifact from the repo root

* fix(native-chat): harden the WSL transcript fs sidecar

Review follow-ups on the sidecar isolation change:

- Only the deadline may abort running gate work. The sole waiter's
  same-duration timeout fired first, killed healthy children on caller
  abandonment, and settled the task before the deadline could quarantine
  a stalled route - leaving the back-off dead for every dedupe:false op.
- Resolve the fork entry from out/main/chunks too: the resolver compiles
  into a shared chunk, and the scanner service child has no
  process.resourcesPath, so packaged WSL vault scans threw entry-not-found
  (masked as an empty tree).
- Allowlist the fork env instead of spreading process.env; ambient
  NODE_OPTIONS would halt or --require code into every child.
- Wrap transport faults (spawn failure, child death) in
  WslTranscriptFsError('unavailable') so discovery reports them as scan
  issues instead of misreading them as missing paths or empty trees.
- Gate the vitest in-process fallback on the vitest worker global so a
  leaked VITEST=true cannot revert production to in-process UNC syscalls.
- Reap idle sidecar processes after 60s instead of holding them for the
  app session.
- Split 'open' into its own protocol union member so the reusable-call
  Exclude actually strips it from the pooled-process API.
- Guard kill('SIGKILL') against the teardown race where an exiting child
  emits an unlistened 'error', and dispatch reads by handle kind before
  path spelling.

* fix(native-chat): probe stalled WSL routes instead of a fixed quarantine

Remaining review follow-ups:

- Escalating route quarantine: first strike lifts after 5s so a distro
  that was cold-booting when its op hit the deadline recovers on the
  next poll (~35s total instead of ~90s); repeat stalls double the
  back-off toward the prior 2x-timeout cap, and any settle the deadline
  did not force clears the strikes. Queued same-route tasks fail fast
  at quarantine instead of stranding one waiter deadline per file in
  sequential scans.
- Single request implementation: the vitest in-process fallback now runs
  the child's own dispatcher (WslTranscriptFsProcessOperations + decode),
  so unit suites exercise exactly what the forked process executes and
  the per-call-site fallback closures are gone. Dirent fixtures gained
  the full kind-flag set the serializer reads.
- Dropped the production-dead per-route close queue; UNC FileHandles
  (test fallback only) mirror the process-handle close contract.
- Error class, messages, and factories move to wsl-transcript-fs-error
  (re-exported from the gate) to keep the gate under the lines budget.

* fix(native-chat): harden WSL transcript fs with route quarantine strike

Extract quarantine logic into a dedicated module with strike decay: stalls older
than 5 minutes restart from base back-off, and concurrent-lane timeouts count as
one incident. Allow joining live in-flight tasks on quarantined routes (they cost
no new I/O). Preserve quarantine across transport faults (child death). Handle
file shrinking during tail reads by detecting short reads and returning empty.
Defer file closes that arrive mid-read instead of refusing, preventing slot
leaks. Separate process slot and boundary-finding concerns into focused modules.

* fix(native-chat): enforce route quarantine windows and isolate lanes per

A late result arriving after the deadline was incorrectly lifting the route
quarantine, allowing subsequent work to start before the back-off period
expired. Now late results are correctly recognized as stale and never cut
the quarantine short.

Process work is now isolated per (route, priority) lane so a scan stall
cannot block exact reads on the same distro. Each lane gets its own client
and process pool; late results and handle faults stay scoped to their lane.

Tests now fake performance.now() alongside timers (the quarantine clock
depends on it) and wait for the full back-off window to expire rather than
advancing by 0. Gate state is reset between test cases since late releases
never lift the quarantine.

---------

Co-authored-by: OrcaWin <[email protected]>
AmethystLiang pushed a commit that referenced this pull request Aug 20, 2026
…15408)

* test(wsl): account for the route quarantine in stalled-mount tests

#15381 added a route-level quarantine: a timed-out task blocks new
admissions on that route for a back-off window, so the next real task
probes recovery instead of hammering a hung mount. It merged with four
tests already failing on main, and they still fail.

Two causes, both test-side:

- The recovery half of three tests read again immediately after releasing
  the stall, which the quarantine now refuses. They wait out the window,
  which is what a real caller does — resetting the gate would skip the
  admission the recovery assertions exist to prove.
- `blockedRoutes` is module state that no test cleared, so a stall in one
  test refused an unrelated read in the next. Both files now reset the
  gate in beforeEach.

Production behavior is unchanged and is working as designed: eviction
still happens, only the immediate re-read is deferred by the back-off.

* test(wsl): match the sibling suites' quarantine idiom

#15381 applied this same fix to session-scanner-core-parser-wsl-stall,
session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate,
and missed these two files. Adopt that established shape rather than a
parallel one: fold the back-off wait into releaseAndSettle instead of a
separate helper at each call site, and fake performance explicitly, since
performance.now drives the quarantine clock.

The explicit toFake is not strictly required today — vitest's default
already fakes performance — but it documents the dependency and stops a
default change from silently unfaking the quarantine clock.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
… route quarantine (stablyai#15381)

* fix(native-chat): kill hung WSL operations via child process

Stalled UNC file operations hold libuv permits even after the gate
timeout expires, blocking Chat tab recovery. Two stalled operations
fill both permits and freeze all WSL access until restart.

Fork file I/O for UNC paths into a separate child process. On deadline
expiry, kill the process to force the hung syscall to exit. This frees
the permit for the affected tab's next read. Temporarily quarantine the
stalled route to avoid retry storms.

* chore: drop internal review artifact from the repo root

* fix(native-chat): harden the WSL transcript fs sidecar

Review follow-ups on the sidecar isolation change:

- Only the deadline may abort running gate work. The sole waiter's
  same-duration timeout fired first, killed healthy children on caller
  abandonment, and settled the task before the deadline could quarantine
  a stalled route - leaving the back-off dead for every dedupe:false op.
- Resolve the fork entry from out/main/chunks too: the resolver compiles
  into a shared chunk, and the scanner service child has no
  process.resourcesPath, so packaged WSL vault scans threw entry-not-found
  (masked as an empty tree).
- Allowlist the fork env instead of spreading process.env; ambient
  NODE_OPTIONS would halt or --require code into every child.
- Wrap transport faults (spawn failure, child death) in
  WslTranscriptFsError('unavailable') so discovery reports them as scan
  issues instead of misreading them as missing paths or empty trees.
- Gate the vitest in-process fallback on the vitest worker global so a
  leaked VITEST=true cannot revert production to in-process UNC syscalls.
- Reap idle sidecar processes after 60s instead of holding them for the
  app session.
- Split 'open' into its own protocol union member so the reusable-call
  Exclude actually strips it from the pooled-process API.
- Guard kill('SIGKILL') against the teardown race where an exiting child
  emits an unlistened 'error', and dispatch reads by handle kind before
  path spelling.

* fix(native-chat): probe stalled WSL routes instead of a fixed quarantine

Remaining review follow-ups:

- Escalating route quarantine: first strike lifts after 5s so a distro
  that was cold-booting when its op hit the deadline recovers on the
  next poll (~35s total instead of ~90s); repeat stalls double the
  back-off toward the prior 2x-timeout cap, and any settle the deadline
  did not force clears the strikes. Queued same-route tasks fail fast
  at quarantine instead of stranding one waiter deadline per file in
  sequential scans.
- Single request implementation: the vitest in-process fallback now runs
  the child's own dispatcher (WslTranscriptFsProcessOperations + decode),
  so unit suites exercise exactly what the forked process executes and
  the per-call-site fallback closures are gone. Dirent fixtures gained
  the full kind-flag set the serializer reads.
- Dropped the production-dead per-route close queue; UNC FileHandles
  (test fallback only) mirror the process-handle close contract.
- Error class, messages, and factories move to wsl-transcript-fs-error
  (re-exported from the gate) to keep the gate under the lines budget.

* fix(native-chat): harden WSL transcript fs with route quarantine strike

Extract quarantine logic into a dedicated module with strike decay: stalls older
than 5 minutes restart from base back-off, and concurrent-lane timeouts count as
one incident. Allow joining live in-flight tasks on quarantined routes (they cost
no new I/O). Preserve quarantine across transport faults (child death). Handle
file shrinking during tail reads by detecting short reads and returning empty.
Defer file closes that arrive mid-read instead of refusing, preventing slot
leaks. Separate process slot and boundary-finding concerns into focused modules.

* fix(native-chat): enforce route quarantine windows and isolate lanes per

A late result arriving after the deadline was incorrectly lifting the route
quarantine, allowing subsequent work to start before the back-off period
expired. Now late results are correctly recognized as stale and never cut
the quarantine short.

Process work is now isolated per (route, priority) lane so a scan stall
cannot block exact reads on the same distro. Each lane gets its own client
and process pool; late results and handle faults stay scoped to their lane.

Tests now fake performance.now() alongside timers (the quarantine clock
depends on it) and wait for the full back-off window to expire rather than
advancing by 0. Gate state is reset between test cases since late releases
never lift the quarantine.

---------

Co-authored-by: OrcaWin <[email protected]>
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…tablyai#15408)

* test(wsl): account for the route quarantine in stalled-mount tests

stablyai#15381 added a route-level quarantine: a timed-out task blocks new
admissions on that route for a back-off window, so the next real task
probes recovery instead of hammering a hung mount. It merged with four
tests already failing on main, and they still fail.

Two causes, both test-side:

- The recovery half of three tests read again immediately after releasing
  the stall, which the quarantine now refuses. They wait out the window,
  which is what a real caller does — resetting the gate would skip the
  admission the recovery assertions exist to prove.
- `blockedRoutes` is module state that no test cleared, so a stall in one
  test refused an unrelated read in the next. Both files now reset the
  gate in beforeEach.

Production behavior is unchanged and is working as designed: eviction
still happens, only the immediate re-read is deferred by the back-off.

* test(wsl): match the sibling suites' quarantine idiom

stablyai#15381 applied this same fix to session-scanner-core-parser-wsl-stall,
session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate,
and missed these two files. Adopt that established shape rather than a
parallel one: fold the back-off wait into releaseAndSettle instead of a
separate helper at each call site, and fake performance explicitly, since
performance.now drives the quarantine clock.

The explicit toFake is not strictly required today — vitest's default
already fakes performance — but it documents the dependency and stops a
default change from silently unfaking the quarantine clock.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
… route quarantine (stablyai#15381)

* fix(native-chat): kill hung WSL operations via child process

Stalled UNC file operations hold libuv permits even after the gate
timeout expires, blocking Chat tab recovery. Two stalled operations
fill both permits and freeze all WSL access until restart.

Fork file I/O for UNC paths into a separate child process. On deadline
expiry, kill the process to force the hung syscall to exit. This frees
the permit for the affected tab's next read. Temporarily quarantine the
stalled route to avoid retry storms.

* chore: drop internal review artifact from the repo root

* fix(native-chat): harden the WSL transcript fs sidecar

Review follow-ups on the sidecar isolation change:

- Only the deadline may abort running gate work. The sole waiter's
  same-duration timeout fired first, killed healthy children on caller
  abandonment, and settled the task before the deadline could quarantine
  a stalled route - leaving the back-off dead for every dedupe:false op.
- Resolve the fork entry from out/main/chunks too: the resolver compiles
  into a shared chunk, and the scanner service child has no
  process.resourcesPath, so packaged WSL vault scans threw entry-not-found
  (masked as an empty tree).
- Allowlist the fork env instead of spreading process.env; ambient
  NODE_OPTIONS would halt or --require code into every child.
- Wrap transport faults (spawn failure, child death) in
  WslTranscriptFsError('unavailable') so discovery reports them as scan
  issues instead of misreading them as missing paths or empty trees.
- Gate the vitest in-process fallback on the vitest worker global so a
  leaked VITEST=true cannot revert production to in-process UNC syscalls.
- Reap idle sidecar processes after 60s instead of holding them for the
  app session.
- Split 'open' into its own protocol union member so the reusable-call
  Exclude actually strips it from the pooled-process API.
- Guard kill('SIGKILL') against the teardown race where an exiting child
  emits an unlistened 'error', and dispatch reads by handle kind before
  path spelling.

* fix(native-chat): probe stalled WSL routes instead of a fixed quarantine

Remaining review follow-ups:

- Escalating route quarantine: first strike lifts after 5s so a distro
  that was cold-booting when its op hit the deadline recovers on the
  next poll (~35s total instead of ~90s); repeat stalls double the
  back-off toward the prior 2x-timeout cap, and any settle the deadline
  did not force clears the strikes. Queued same-route tasks fail fast
  at quarantine instead of stranding one waiter deadline per file in
  sequential scans.
- Single request implementation: the vitest in-process fallback now runs
  the child's own dispatcher (WslTranscriptFsProcessOperations + decode),
  so unit suites exercise exactly what the forked process executes and
  the per-call-site fallback closures are gone. Dirent fixtures gained
  the full kind-flag set the serializer reads.
- Dropped the production-dead per-route close queue; UNC FileHandles
  (test fallback only) mirror the process-handle close contract.
- Error class, messages, and factories move to wsl-transcript-fs-error
  (re-exported from the gate) to keep the gate under the lines budget.

* fix(native-chat): harden WSL transcript fs with route quarantine strike

Extract quarantine logic into a dedicated module with strike decay: stalls older
than 5 minutes restart from base back-off, and concurrent-lane timeouts count as
one incident. Allow joining live in-flight tasks on quarantined routes (they cost
no new I/O). Preserve quarantine across transport faults (child death). Handle
file shrinking during tail reads by detecting short reads and returning empty.
Defer file closes that arrive mid-read instead of refusing, preventing slot
leaks. Separate process slot and boundary-finding concerns into focused modules.

* fix(native-chat): enforce route quarantine windows and isolate lanes per

A late result arriving after the deadline was incorrectly lifting the route
quarantine, allowing subsequent work to start before the back-off period
expired. Now late results are correctly recognized as stale and never cut
the quarantine short.

Process work is now isolated per (route, priority) lane so a scan stall
cannot block exact reads on the same distro. Each lane gets its own client
and process pool; late results and handle faults stay scoped to their lane.

Tests now fake performance.now() alongside timers (the quarantine clock
depends on it) and wait for the full back-off window to expire rather than
advancing by 0. Gate state is reset between test cases since late releases
never lift the quarantine.

---------

Co-authored-by: OrcaWin <[email protected]>
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…tablyai#15408)

* test(wsl): account for the route quarantine in stalled-mount tests

stablyai#15381 added a route-level quarantine: a timed-out task blocks new
admissions on that route for a back-off window, so the next real task
probes recovery instead of hammering a hung mount. It merged with four
tests already failing on main, and they still fail.

Two causes, both test-side:

- The recovery half of three tests read again immediately after releasing
  the stall, which the quarantine now refuses. They wait out the window,
  which is what a real caller does — resetting the gate would skip the
  admission the recovery assertions exist to prove.
- `blockedRoutes` is module state that no test cleared, so a stall in one
  test refused an unrelated read in the next. Both files now reset the
  gate in beforeEach.

Production behavior is unchanged and is working as designed: eviction
still happens, only the immediate re-read is deferred by the back-off.

* test(wsl): match the sibling suites' quarantine idiom

stablyai#15381 applied this same fix to session-scanner-core-parser-wsl-stall,
session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate,
and missed these two files. Adopt that established shape rather than a
parallel one: fold the back-off wait into releaseAndSettle instead of a
separate helper at each call site, and fake performance explicitly, since
performance.now drives the quarantine clock.

The explicit toFake is not strictly required today — vitest's default
already fakes performance — but it documents the dependency and stops a
default change from silently unfaking the quarantine clock.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… route quarantine (stablyai#15381)

* fix(native-chat): kill hung WSL operations via child process

Stalled UNC file operations hold libuv permits even after the gate
timeout expires, blocking Chat tab recovery. Two stalled operations
fill both permits and freeze all WSL access until restart.

Fork file I/O for UNC paths into a separate child process. On deadline
expiry, kill the process to force the hung syscall to exit. This frees
the permit for the affected tab's next read. Temporarily quarantine the
stalled route to avoid retry storms.

* chore: drop internal review artifact from the repo root

* fix(native-chat): harden the WSL transcript fs sidecar

Review follow-ups on the sidecar isolation change:

- Only the deadline may abort running gate work. The sole waiter's
  same-duration timeout fired first, killed healthy children on caller
  abandonment, and settled the task before the deadline could quarantine
  a stalled route - leaving the back-off dead for every dedupe:false op.
- Resolve the fork entry from out/main/chunks too: the resolver compiles
  into a shared chunk, and the scanner service child has no
  process.resourcesPath, so packaged WSL vault scans threw entry-not-found
  (masked as an empty tree).
- Allowlist the fork env instead of spreading process.env; ambient
  NODE_OPTIONS would halt or --require code into every child.
- Wrap transport faults (spawn failure, child death) in
  WslTranscriptFsError('unavailable') so discovery reports them as scan
  issues instead of misreading them as missing paths or empty trees.
- Gate the vitest in-process fallback on the vitest worker global so a
  leaked VITEST=true cannot revert production to in-process UNC syscalls.
- Reap idle sidecar processes after 60s instead of holding them for the
  app session.
- Split 'open' into its own protocol union member so the reusable-call
  Exclude actually strips it from the pooled-process API.
- Guard kill('SIGKILL') against the teardown race where an exiting child
  emits an unlistened 'error', and dispatch reads by handle kind before
  path spelling.

* fix(native-chat): probe stalled WSL routes instead of a fixed quarantine

Remaining review follow-ups:

- Escalating route quarantine: first strike lifts after 5s so a distro
  that was cold-booting when its op hit the deadline recovers on the
  next poll (~35s total instead of ~90s); repeat stalls double the
  back-off toward the prior 2x-timeout cap, and any settle the deadline
  did not force clears the strikes. Queued same-route tasks fail fast
  at quarantine instead of stranding one waiter deadline per file in
  sequential scans.
- Single request implementation: the vitest in-process fallback now runs
  the child's own dispatcher (WslTranscriptFsProcessOperations + decode),
  so unit suites exercise exactly what the forked process executes and
  the per-call-site fallback closures are gone. Dirent fixtures gained
  the full kind-flag set the serializer reads.
- Dropped the production-dead per-route close queue; UNC FileHandles
  (test fallback only) mirror the process-handle close contract.
- Error class, messages, and factories move to wsl-transcript-fs-error
  (re-exported from the gate) to keep the gate under the lines budget.

* fix(native-chat): harden WSL transcript fs with route quarantine strike

Extract quarantine logic into a dedicated module with strike decay: stalls older
than 5 minutes restart from base back-off, and concurrent-lane timeouts count as
one incident. Allow joining live in-flight tasks on quarantined routes (they cost
no new I/O). Preserve quarantine across transport faults (child death). Handle
file shrinking during tail reads by detecting short reads and returning empty.
Defer file closes that arrive mid-read instead of refusing, preventing slot
leaks. Separate process slot and boundary-finding concerns into focused modules.

* fix(native-chat): enforce route quarantine windows and isolate lanes per

A late result arriving after the deadline was incorrectly lifting the route
quarantine, allowing subsequent work to start before the back-off period
expired. Now late results are correctly recognized as stale and never cut
the quarantine short.

Process work is now isolated per (route, priority) lane so a scan stall
cannot block exact reads on the same distro. Each lane gets its own client
and process pool; late results and handle faults stay scoped to their lane.

Tests now fake performance.now() alongside timers (the quarantine clock
depends on it) and wait for the full back-off window to expire rather than
advancing by 0. Gate state is reset between test cases since late releases
never lift the quarantine.

---------

Co-authored-by: OrcaWin <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#15408)

* test(wsl): account for the route quarantine in stalled-mount tests

stablyai#15381 added a route-level quarantine: a timed-out task blocks new
admissions on that route for a back-off window, so the next real task
probes recovery instead of hammering a hung mount. It merged with four
tests already failing on main, and they still fail.

Two causes, both test-side:

- The recovery half of three tests read again immediately after releasing
  the stall, which the quarantine now refuses. They wait out the window,
  which is what a real caller does — resetting the gate would skip the
  admission the recovery assertions exist to prove.
- `blockedRoutes` is module state that no test cleared, so a stall in one
  test refused an unrelated read in the next. Both files now reset the
  gate in beforeEach.

Production behavior is unchanged and is working as designed: eviction
still happens, only the immediate re-read is deferred by the back-off.

* test(wsl): match the sibling suites' quarantine idiom

stablyai#15381 applied this same fix to session-scanner-core-parser-wsl-stall,
session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate,
and missed these two files. Adopt that established shape rather than a
parallel one: fold the back-off wait into releaseAndSettle instead of a
separate helper at each call site, and fake performance explicitly, since
performance.now drives the quarantine clock.

The explicit toFake is not strictly required today — vitest's default
already fakes performance — but it documents the dependency and stops a
default change from silently unfaking the quarantine clock.
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.

2 participants