Repository navigation
fix(session-search): read oversized numeric file IDs on Windows - #20551
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
node:sqlite raises RangeError when a column returns an INTEGER outside Number.MAX_SAFE_INTEGER, so a files row whose dev/ino came from a rounded fs.stat double on Windows became unreadable once stored. The fix reads both identity columns through CAST(... AS REAL) so SQLite returns the original double.
indexedFile()cast —session-search-index-writer.tsnow selectsCAST(dev AS REAL)/CAST(ino AS REAL); the null/half-pair comparison logic is unchanged.files()cast —session-search-store.tsapplies the same casts, so a full row list no longer throws on an oversized ID.- Regression coverage — new
session-search-file-id.test.tsexercises the unsafe-ID read, round-trip across reopen throughfiles()/indexedFile/read-decision/consumer append, replacement rejection, and already-written INTEGER/half-pair rows.
Verification this run
I reproduced the RangeError on Node v24.19.0 and confirmed CAST(x AS REAL) round-trips the discovery-time double while the raw read throws. files() and indexedFile are the only production readers of dev/ino (retention, delete, and the pass do not select them), and the new assertions are exact, so they fail without the fix. The new file passes 11/11, the four related suites 53/53, and check-changed-code-quality.mjs reports zero findings.
The residual lossy-identity limitation (two raw IDs that already round to the same double stay indistinguishable) predates the PR and is explicitly scoped out — discovery rounds in fs.stat before storage, so this change introduces no new ambiguity.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
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 (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change casts Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The file-identity fix preserves reconciliation behavior for unsafe Windows IDs without an identified current-head regression. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 7 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description is detailed and covers the change, rationale, testing, visual proof, review, and known limitations. However, the required Linked Issue section does not provide an issue link or issue number.
✨ 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.
✅ No new issues found.
Reviewed changes
Test-only delta since the prior review at fe11afadf4: the production CAST(... AS REAL) fix and its unit test are untouched, and the new commit adds a Windows-only opt-in reproduction harness under config/scripts/session-search-file-id-e2e/.
run.ts— asserts native Windows,git archives an overlay export of #20516 head9845bef63a6plus the real scanner entry, bundles red/green variants with esbuild while injecting labelled local fixture seams, then runs lifecycle and restart phases against the Electron host.host.cjs— windowless Electron host installs production search enablement, transport, and dispatcher; drives default-off → enable → recent/full reconciliation → append → rename-replacement → restart → disable, cross-checking every marker against an independent read-only SQLite connection andfs.stat.client.cjs— external Node client querying over the real named pipe throughaiVault.searchSessions.verify.cjs— asserts red fails with the expectedRangeError, green reports succeed with real IPC and a distinct client PID, both oracles are identical after formatter normalization, and exactly the two SELECT source files differ.README.md— topology, fixture seams, and the boundaries deliberately not exercised.
The new files are coherent as an evidence harness: red and green differ only in the two SELECT projections, verify.cjs pins that with a hash diff, and no production path changed in this commit. The residual lossy-identity limitation and the harness's pin to an unmerged external commit remain as documented, opt-in scope rather than regressions.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Windows can assign transcript files IDs larger than Node SQLite will return as JavaScript integers. The first indexing pass succeeds, but subsequent passes throw
RangeError. Read those IDs in SQLite's REAL representation so the index can reconcile again.What Changed
Cast
devandinoto REAL inSessionSearchStore.files()andSessionSearchIndexWriter.indexedFile(). Add 11 regression cases covering both reads, unsafe IDs in either field, existing INTEGER rows, null/partial pairs, reopen, unchanged-file decisions, append cursors, and replacement rejection.Why
Discovery already uses ordinary numeric
fs.statthroughwslGatedStat; remote discovery also supplies numbers.fileIdentity()passes these numbers through to INTEGER-affinity columns. SQLite stores the integer represented by that double, and REAL recovers the same double without Node's unsafe-INTEGER read exception. This preserves the existing numeric identity contract, including already-written rows, without rebuilding or migrating the database. Offsets and sizes remain integers.This is not lossless raw filesystem identity: distinct raw IDs that already round to the same number remain indistinguishable. The native repro demonstrated this before storage: raw NTFS inode
11821949025838489became numeric integer11821949025838488. Casting to TEXT or stringifying current stats cannot recover those bits. A lossless redesign would need bigint discovery, WSL/remote transport, and storage changes; it is outside this small crash fix. Distinct representable IDs still reject appends and force whole reads through the existing decision path.No wire, execution-host, folder-workspace, root-refresh, or production-wiring changes. This branches directly from current main; it neither modifies nor stacks on #20516.
Linked Issue
Directly reported Windows bug; no standalone issue supplied. Existing code originated in #19687 (
2c984bcdaa7) and #19751 (1fedda14caa), before #20516.Visual Proof
N/A — database read fix with no visual or interaction changes.
Testing
ORCA_BACKGROUND_LAUNCH=1throughout.25614222884620952RangeError, independently covering both read sites. Native 5,000-file / 91,617,014-byte corpus indexes successfully, then full and recent reconciliation throw on11821949025838488.pnpm tc:node,pnpm run check:code-quality:changed, targeted formatting, andgit diff --checkpass.Focused tests ran with
pnpm exec vitest run --config config/vitest.config.ts <suite paths>. Dependencies were installed withpnpm install --ignore-scripts; these tests use built-innode:sqliteand do not need the optional native postinstall. Linux/SSH execution and a full app build were not run.Electron scanner IPC and external RPC verification
Added an opt-in reproduction under
config/scripts/session-search-file-id-e2e/(runner, windowless host, small external client, evidence verifier). No additional production changes. All overlay sources, profiles, SQLite DBs, logs and reports remain ignored undernotes/search-ipc/.Topology: fix source
fe11afadf4e6e4e209d11e60ac1b005a2bbce788; LOCAL integration overlay #20516 head9845bef63a6d0b80ec37af82b5b275287b8e17df, exported withgit archive, never stacked or pushed onto this PR. #20514 CLI overlay was not used. An esbuild-bundled windowless Electron 43.7.0 host installs the production search enablement, shared scanner client, and productionspawnAiVaultServiceProcess. It forks the real scanner entry with Electron's bundled Node 24.21.0,ELECTRON_RUN_AS_NODE=1, and real IPC.External query boundary: separate Node 24.18.0 clients → real Windows named pipe → production
UnixSocketTransport→ productionRpcDispatcherwithAI_VAULT_METHODS→ production search registry/child service → scanner IPC → production instance/indexer/SQLite engine. Status polling uses registered handlers directly. Search responses are independently checked against active FTS rows and filesystem/DB cursor, size and mtime.Labelled fixture seams: isolated roots; JSON-backed
getSettingssupplied to real enablement/settings-change functions; background-launch child environment; passive child/read/IPC observation; explicit search RPC catalog with unused default catalog excluded; fixture runtime ID. No search-result mocks. Production runtime auth/metadata bootstrap is not started: transport is connected directly to dispatcher with a fixture token. This verifies a real external RPC socket, not full authenticated CLI/runtime startup. No UI, packaging, or SSH/relay claim.90071992588374849007199258837328RangeError; reconciliation stops advancingappendreadreplacereadRed and green use the same oracle.
verify.cjsconfirms equivalent oracle code after formatter normalization and SHA-256 manifests differing in exactlysession-search-store.tsandsession-search-index-writer.ts. Green has no search errors. Red host PID 18208 / scanner 5000; green host PIDs 17776 and 3948 / scanners 16892, 19428 and 11600. All scanner exits were 0, and a final OS check found none of the 20 recorded host/scanner/client PIDs running. Processes were closed through their owned handles/protocol; unrelated processes were untouched.Exact commands from this workspace root:
Evidence:
notes/search-ipc/red/1789365864644/,notes/search-ipc/green/1789365820413/,comparison.json, andcleanup.json. Reproduction README documents topology, seams, commands, and gaps. Harness typecheck, syntax checks, changed-code quality, formatting and diff checks pass.Secondary coverage, independently run and reported by the supervising Codex agent on macOS at
fe11afa: 68 focused tests pass; reverting only both SELECT changes makes 7/11 file-ID tests fail, including the reported RangeError. This is supervisor-reported evidence, separate from the Windows runs above.Review