Skip to content

fix(session-history): stop re-reading every transcript after a cache format change or build switch - #41091

Merged
AmoabaKelvin merged 2 commits into
mainfrom
sta-13607-agent-search-rescan
Nov 27, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
sta-13607-agent-search-rescan

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

Session History keeps a cache of every agent session it has already read, so reopening it should be quick. Two things kept making it slow again. Any update that changed the cache format deleted the whole cache, and so did switching between Orca builds that share a data folder. After that, the next open re-read every transcript (29,000 files for the reporter). Even when nothing had changed, the "Checking N / 29,154" bar sat on screen for seconds while Orca confirmed every file was still cached.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​121 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111

What Changed

  • The cache is kept across format changes and build switches. Each cache format version now has its own file (session-parse-cache.v9.sqlite instead of one shared session-parse-cache.sqlite), so opening a build on another version no longer deletes it.
    • The first start after this change begins with an empty versioned cache: one full re-read, the same cost as any format change today. Copying the old file over was tried and dropped: on a multi-GB cache it could block the scanner past its request deadline.
    • On disk, Orca keeps this version and the most recently used other one, and deletes the rest. A file another running build still has open is skipped.
  • Cached rescans no longer show the "Checking" bar. The scanner now reports how many transcript bytes a scan actually read from disk. Main keeps showing the last finished strip ("Scanned N files ✓"), or nothing, until a scan has read 64 MB. Rescans the cache answers stay quiet, including ones where a few live agents' transcripts grew. Real re-reads still show progress: a cold scan reads hundreds of MB.
    • A scan that fails or is cancelled before it was ever shown no longer leaves a frozen partial strip behind.

Why

The cache was never per-workspace, contrary to the guess in the report. I ran the real scanner over a 29,000-file history: reopening, switching workspaces and restarting all reused it (0 re-reads, about 1.5 s to re-check every file). The full rescans came from openVersionedCacheDatabase deleting the whole file on any version mismatch, newer or older. The format version was bumped 5 times between Oct 22 and Nov 3, one of them hours before the report. And builds on different versions that share a data folder (dev builds from worktrees on different commits, or a downgrade) wiped each other on every switch.

Alternatives considered:

  • Skip the per-file check by looking at folder timestamps. Rejected: resumed Codex sessions append to old rollout files, which doesn't change the folder's timestamp.
  • Show the bar only after the scan has run for a few seconds. Rejected: a 29k-file cached rescan takes 1.5–3 s or more on slower disks, so the bar would still appear. Bytes read measures the work that makes a scan slow.
  • Carry the old cache over on upgrade (rename, or a SQLite snapshot copy). Rejected: renaming or deleting a SQLite file another build has open breaks that build's writes (review reproduced disk I/O error), and a snapshot copy can block the scanner for seconds on large caches.

Linked Issue

Linear: STA-13607 (no GitHub issue)

Visual Proof

N/A. The strip component itself is unchanged; the change is that it no longer appears during cached rescans. I checked the trigger by running the real scanner on my own history and on a synthetic 29,000-file Codex history, reading the bytes each scan reported against the 64 MB threshold:

Scan Bytes read Strip
Cold (no cache) 198 MB – 804 MB shown
Warm rescan, nothing changed 0 – 395 B hidden
Warm after restart, 8 live transcripts changed 29 MB hidden

Testing

Reproduced on main before the fix:

  • Cache wipe: with main's code, a build on another schema version that shares the folder makes the next scan fully reparse every transcript. Main's isStaleSchema deletes the file on any version mismatch. The new "keeps its rows" test fails on main with fullParses: 1.
  • Bar on cached rescans: the real scanner on a synthetic 29,000-file Codex history re-checked every file on each warm rescan (about 1.4 s, 0 parses). Main published that whole re-check as the active "Checking N / 29,000" progress. The new quiet-rule test fails on main.

Confirmed after: the same harness on this branch:

  • Switching builds: after switching workspaces, a restart, or another build's file appearing, the cache was reused with only changed files re-read (7–9 files).

  • Quiet rule: warm rescans reported 0–395 bytes read, so the strip stayed hidden.

  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns

Real scanner runs on macOS, against my own history (5,000 files) and a synthetic 29,000-file Codex history:

New tests, each confirmed to fail with its part of the change reverted:

  • Version files (session-parse-cache-persistence.test.ts): rows survive another build's file. Pruning keeps one other version plus any version still open.
  • Quiet rule (ai-vault-local-scan-progress.test.ts): the last finished strip stays until a rescan reads 64 MB.

Focused ai-vault tests and their dependents pass, as do check:code-quality:changed and the main sync-fs ratchet. pnpm check:changed passed 37 of 38 checks. The unit-test check failed only in server-antigravity-resume-identity.test.ts (agent hooks, unrelated), which passes 5/5 on its own.

Performance

This is a perf fix. Cached rescans no longer re-read every transcript after a cache format change or build switch. The only new work is one directory listing plus a stat and a SQLite open per other-version cache file, once per scanner-child database open, off Electron main. Disk use is at most two cache files (this version and the most recently used other one, plus any version another running build has open).

Risk

The riskiest part is the cache-file handling on first start.

  • Where it runs: pruning runs once, when the scanner child first opens its database. Every failure is caught.
  • First start: one full rescan after upgrading, the same cost as today's schema bump.
  • Disk: at most two cache files (this version and one other, plus any version another running build has open). After an upgrade the old file stays as that "other" until the next format change, so it keeps an older build warm.
  • Progress strip: a slow cached rescan (for example over a slow network or WSL disk) now shows no live strip. The header's loading spinner and the list's loading label still show.
  • Back out: a plain revert. The .vN files would stay on disk unused, and the reverted build goes back to the unversioned file.

Level: Medium

AI Disclosure

Review

Two review rounds (Codex + Claude). Accepted and fixed:

  • Sync filesystem ratchet: added a baseline entry for the one-shot scanner-child startup use.
  • Old cache adoption (two rounds, plus a CodeRabbit Major): moving the old file disturbed a build still using it, and a snapshot copy could block the scanner on large caches. Adoption is removed.
  • Pruning: it could delete a version another running build had open. Now it skips files it can't lock exclusively.
  • Quiet rule threshold: a count of files read didn't track scan time, so it now counts bytes read.
  • Failed scans: a scan that failed before being shown no longer leaves a partial strip.

Declined:

  • Hiding the strip during a cold scan's file-listing stage. That's the agreed behaviour: show progress only once real reading starts.
  • Strip during a scope switch: it keeps showing the previous scope's finished strip during a quiet scan for a never-scanned scope (P3).
  • Prune race: a very narrow window between checking a stale file and deleting it (P3).

Follow-ups:

  • The session search index (ai-vault-search) has the same wipe-on-any-version-mismatch behaviour in openVersionedCacheDatabase and would benefit from the same per-version treatment.
  • OpenCode/zcode SQLite-backed parses report 0 bytes to the quiet rule.

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Windows: renaming or deleting a held file throws and is caught, and pruning also checks exclusivity first.
  • SSH, mobile and remote hosts: they don't read local scan progress. The new progress field only travels from the scanner child to main in the same build.
  • WSL: WSL rows are unchanged.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Scan progress now records transcript and scope-probe bytes read. Local progress uses a 64 MiB threshold before it replaces existing displayed progress. Session parse-cache databases now use schema-versioned paths, and initialization prunes older cache files while retaining the current database and eligible older files.

Merge Risk: Low · up to ced96

Session History progress may appear late or too early for very large transcripts. The versioned parse-cache change itself looks safe to merge. The remaining issues are minor and can be addressed in a follow-up.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: stopping full transcript re-reads after a cache format change or build switch. The conventional-commit prefix fix(session-history): matches the Session History scope…
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.
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, N…
Full details: Title check

Explanation

The title names the main change: stopping full transcript re-reads after a cache format change or build switch. The conventional-commit prefix fix(session-history): matches the Session History scope. The title is specific and accurate for the changeset, which covers versioned cache files, pruning, and the bytes-read progress rule.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections. The ELI5 explains the cache-wipe and slow-bar problems in plain language. What Changed covers the versioned cache files, pruning, and the 64 MB quiet rule. Why explains the root cause and rejected alternatives. Risk names the riskiest part (first-start cache handling and progress-strip visibility), states the level (Medium), and gives a back-out path. Performance has a substantive explanation rather than a one-liner. Visual Proof is marked N/A with a reason and supporting measurements. Testing lists manual runs, reproductions on main, and new tests. Minor gaps: the Performance section's 'None, because' sentence is replaced by a full explanation, which is acceptable. The Linked Issue is a Linear ticket with no GitHub issue, which the template says outside contributors must avoid, though the author appears to be a maintainer. The final lint/typecheck/test/build checklist item is unchecked. The AI Disclosure section is empty, and the template asks for AI model details unless the author is a StablyAI team member, so the author's status should be confirmed.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

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: 6aa95d7f-8118-4b7a-8b13-9c925d783e3d
Commits

Reviewing files that changed from the base of the PR and between 660c021 and ced96fc.

Files selected for processing: 12

  • config/main-blocking-helper-baseline.txt
  • config/main-blocking-sqlite-baseline.txt
  • config/main-sync-fs-baseline.txt
  • src/main/ai-vault/parse-cache/session-parse-cache-database.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-persistence.test.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-persistence.ts
  • src/main/ai-vault/scan-lifecycle/ai-vault-local-scan-progress.test.ts
  • src/main/ai-vault/scan-lifecycle/ai-vault-local-scan-progress.ts
  • src/main/ai-vault/scan-lifecycle/ai-vault-scan-progress.ts
  • src/main/ai-vault/scan-lifecycle/ai-vault-scan-tally.ts
  • src/main/ai-vault/scope/session-scope-cwd.ts
  • src/main/ai-vault/transcripts/session-transcript-reader.ts
Files skipped from review as they are similar to previous changes: 1

  • src/main/ai-vault/parse-cache/session-parse-cache-database.ts

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

@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: 5

Review info

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: 023a36e4-1c03-4cb9-9fb8-27dd9c402727
Commits

Reviewing files that changed from the base of the PR and between 729f757 and a7750f8.

Files selected for processing: 22

  • config/main-sync-fs-baseline.txt
  • src/main/ai-vault/ai-vault-local-scan-progress.test.ts
  • src/main/ai-vault/ai-vault-local-scan-progress.ts
  • src/main/ai-vault/ai-vault-scan-coordinator.test.ts
  • src/main/ai-vault/ai-vault-scan-progress-flow.test.ts
  • src/main/ai-vault/ai-vault-scan-progress.ts
  • src/main/ai-vault/ai-vault-scan-tally.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-database.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-large-scan.test.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-persistence.test.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-persistence.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-preview-upgrade.test.ts
  • src/main/ai-vault/parse-cache/session-parse-cache-version-files.ts
  • src/main/ai-vault/scan-service/session-scanner-service-request-deadline.test.ts
  • src/main/ai-vault/scanners/copilot/session-scanner-copilot-cache-upgrade.test.ts
  • src/main/ai-vault/session-scanner-scope-cwd-facts.test.ts
  • src/main/ai-vault/session-scanner-scope-walk.test.ts
  • src/main/ai-vault/session-scope-cwd.ts
  • src/main/ai-vault/transcripts/session-transcript-reader.ts
  • src/main/sqlite/versioned-cache-database.ts
  • src/renderer/src/components/right-sidebar/ai-vault/scanning/AiVaultScanProgressStrip.test.tsx
  • src/shared/ai-vault/scanning/ai-vault-scan-progress.ts

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

return
}
// Snapshot into a private file first: a build still using the old file keeps it untouched.
const staging = `${path}.adopting`

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.

Minor · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n -C 5 --type ts \
  '\b(adoptUnversionedSessionParseCache|configureSessionParseCachePersistence|initSessionParseCachePersistence)\s*\(' src
rg -n -C 4 --type ts \
  'proper-lockfile|requestSingleInstanceLock|scanner.*lock|cache.*lock' src

Repository: stablyai/orca

Length of output: 41414


Script executed:

cat -n src/main/ai-vault/parse-cache/session-parse-cache-version-files.ts
cat -n src/main/ai-vault/parse-cache/session-parse-cache-persistence.ts | sed -n '1,155p'
rg -n -F -e 'requestSingleInstanceLock' -e 'sessionParseCache:' -e 'configureSessionParseCachePersistence(' -e 'session-scanner-service-entry' src/main
rg -n -F -e 'backup(' -e 'VACUUM INTO' -e 'snapshot' src/main/ai-vault/parse-cache
git diff 801db2bb4cca498ef9c6a7fe5f52390a77c0d912 a7750f89c26d38427d78028bd7537e7131beee8b -- src/main/ai-vault/parse-cache/session-parse-cache-version-files.ts

Repository: stablyai/orca

Length of output: 18144


Script executed:

cat -n src/main/startup/single-instance-lock.ts
cat -n src/main/startup/main-process-preflight.ts | sed -n '245,320p'
cat -n src/main/ai-vault/scan-service/session-scanner-service-spawn.ts
cat -n src/main/ai-vault/scan-service/session-scanner-service-entry.ts | sed -n '150,235p'
cat -n src/main/ai-vault/parse-cache/session-parse-cache-database.ts | sed -n '1,180p'
cat -n src/main/sqlite/sync-database.ts | sed -n '1,200p'
rg -n -F -e 'acquireSingleInstanceLock' -e 'single-instance-lock' -e 'spawnSessionScanner' -e 'createSessionScannerService' -e 'sessionScannerService' src/main/startup src/main/ai-vault
rg -n -F -e 'userData' -e 'ORCA_USER_DATA' src/main/startup/single-instance-lock.ts src/main/startup/main-process-preflight.ts src/main/ai-vault/scan-service

Repository: stablyai/orca

Length of output: 36420


Script executed:

cat -n src/main/ai-vault/scan-service/session-scanner-service-client.ts
cat -n src/main/ai-vault/scan-service/session-scanner-service-entry.ts | sed -n '235,300p'
rg -n -F -e 'spawnAiVaultServiceProcess' -e 'AiVaultScannerServiceClient' src/main --glob '!*.test.ts'
rg -n -F -e 'getSessionParseCachePersistenceOptions' -e 'configureSessionParseCachePersistence' -e 'initSessionParseCachePersistence' src --glob '!*.test.ts'
rg -n -F -e 'SIGKILL' -e 'kill(' -e 'disconnect' -e 'restart' src/main/ai-vault/scan-service --glob '!*.test.ts'
cat -n src/main/sqlite/versioned-cache-database.ts | sed -n '1,190p'

Repository: stablyai/orca

Length of output: 24698


Script executed:

cat -n src/main/ai-vault/scan-service/session-scanner-service-client-state.ts | sed -n '25,145p'
cat -n src/main/ai-vault/scan-service/session-scanner-service-restart-policy.ts
cat -n src/main/ai-vault/scan-service/session-scanner-service-request-deadline.ts
cat -n src/main/ai-vault/scan-service/session-scanner-service-entry.ts | sed -n '1,150p'
rg -n -F -e 'openedDatabase()' src/main/ai-vault/parse-cache/session-parse-cache-persistence.ts

Repository: stablyai/orca

Length of output: 15419


Script executed:

cat -n src/main/ai-vault/scan-service/session-scanner-service-client-state.ts | sed -n '1,30p;160,265p'
cat -n src/main/ai-vault/scan-service/session-scanner-service-protocol.ts | sed -n '1,150p'
rg -n -F -e 'function aiVaultServiceLane' -e 'AI_VAULT_SERVICE_SHUTDOWN_TIMEOUT_MS' -e 'requeueOrRejectAiVaultServiceStart' src/main/ai-vault/scan-service
cat -n src/main/ai-vault/scan-service/session-scanner-service-client-state.ts | sed -n '260,360p'

Repository: stablyai/orca

Length of output: 15496


Script executed:

cat -n src/main/ai-vault/parse-cache/session-parse-cache-persistence.ts | sed -n '160,230p'
rg -n -F -e 'coldTier' -e 'parseAgentSessionFileCached' src/main/ai-vault/parse-cache/session-parse-cache-store.ts src/main/ai-vault/parse-cache --glob '!*.test.ts'
cat -n src/main/ai-vault/parse-cache/session-parse-cache-store.ts | sed -n '1,200p'

Repository: stablyai/orca

Length of output: 14799


Give each adoption exclusive staging and publication.

If a scanner is retired during a slow adoption, a replacement can start before it exits. One scanner can remove the other's staging file. On POSIX, a later renameSync can also replace a destination that the other scanner has already opened, losing cached writes and causing transcripts to be reparsed.

Use a private staging file for each adoption and publish it atomically only if the destination is still absent. If another scanner has created the destination, open that file instead.

}
others.sort((left, right) => right.usedAt - left.usedAt)
for (const stale of others.slice(RETAINED_OTHER_VERSIONS)) {
if (openElsewhere(stale.path)) {

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.

Minor · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n -C 5 --type ts \
  '\b(pruneOtherSessionParseCacheVersions|openElsewhere|openedDatabase)\s*\(' \
  src/main/ai-vault
rg -n -C 4 --type ts \
  'proper-lockfile|requestSingleInstanceLock|scanner.*lock|cache.*lock' src

Repository: stablyai/orca

Length of output: 41551


Script executed:

cat -n src/main/ai-vault/parse-cache/session-parse-cache-version-files.ts
cat -n src/main/ai-vault/parse-cache/session-parse-cache-persistence.ts | sed -n '1,145p'
rg -n -F -e 'removeVersionedCacheDatabase' -e 'class SessionParseCacheDatabase' -e 'configureSessionParseCache' -e 'owner:' src/main/ai-vault
rg -n -F -e 'requestSingleInstanceLock' -e 'acquireProfileStateRuntimeAdmission' src/main/startup src/main/index.ts

Repository: stablyai/orca

Length of output: 14515


Web query:

SQLite how to corrupt database unlink open database different processes unix sqlite database file

Result:

Sources consulted:
- [sqlite] Error 1032: SQLITE_READONLY_DBMOVED with one writer and one reader process — https://www.mail-archive.com/[email protected]/msg90531.html
- Is it ok to replace a sqlite file while a program has an open db connection to it? — https://stackoverflow.com/questions/4550272/is-it-ok-to-replace-a-sqlite-file-while-a-program-has-an-open-db-connection-to-i
- How To Corrupt An SQLite Database File — https://sqlite.org/howtocorrupt.html
- Different databases with the same name: SQLite WAL and POSIX unlink|HOO Works — https://note.com/hooworks/n/ne4b03e9306ae?hl=en
- SQLite User Forum: Renaming a database — https://sqlite.org/forum/forumpost/33ff5204bc3bec85?t=c

Script executed:

cat -n src/main/sqlite/versioned-cache-database.ts
cat -n src/main/ai-vault/parse-cache/session-parse-cache-database.ts | sed -n '1,105p'
cat -n src/main/startup/single-instance-lock.ts
cat -n src/main/startup/main-process-preflight.ts | sed -n '200,285p'
cat -n src/main/persistence/profile-state/profile-state-access.ts
rg -n -F -e 'initSessionParseCachePersistence(' -e 'configureSessionParseCachePersistence(' -e 'getSessionParseCachePersistenceOptions(' src/main
rg -n -F -e 'singleInstance' -e 'SingleInstance' -e 'ORCA_USER_DATA_PATH' src/main/startup src/main/ai-vault

Repository: stablyai/orca

Length of output: 34730


Script executed:

cat -n src/main/ai-vault/scan-service/session-scanner-service-spawn.ts
cat -n src/main/ai-vault/scan-service/session-scanner-service-entry.ts | sed -n '155,235p'
cat -n src/main/startup/main-process-preflight.ts | sed -n '288,304p'
rg -n -F -e 'acquireDesktopProfileLockOrExplain' -e 'configureSessionParseCachePersistence' -e 'sessionParseCache:' src
rg -n -F -e 'session-scanner-service-spawn' -e 'spawnSessionScanner' -e 'scannerProcess' src/main/ai-vault/scan-service

Repository: stablyai/orca

Length of output: 12790


Script executed:

cat -n src/main/ai-vault/scan-service/session-scanner-service-entry.ts | sed -n '235,290p'
cat -n src/main/ai-vault/scan-service/session-scanner-service-client.ts
cat -n src/main/startup/main-process-preflight-failure.ts | sed -n '1,75p'
rg -n -F -e 'disposeAiVault' -e 'shutdownAiVault' -e 'resetAiVaultScannerServiceForTests' -e 'sharedClient?.dispose' src/main

Repository: stablyai/orca

Length of output: 17261


Script executed:

cat -n src/main/startup/desktop-profile-instance-lock.ts
cat -n src/main/ai-vault/parse-cache/session-parse-cache-persistence.ts | sed -n '165,230p'
cat -n src/main/ai-vault/scan-service/session-scanner-service-entry.ts | sed -n '1,165p'
rg -n -F -e 'function retireAiVaultServiceChild' -e 'function stopAiVaultServiceChild' src/main/ai-vault/scan-service

Repository: stablyai/orca

Length of output: 11686


Script executed:

cat -n src/main/ai-vault/parse-cache/session-parse-cache-database.ts | sed -n '100,235p'
cat -n src/main/ai-vault/scan-service/session-scanner-service-client-state.ts | sed -n '96,145p'
cat -n src/main/ai-vault/parse-cache/session-parse-cache-persistence.test.ts | sed -n '300,455p'

Repository: stablyai/orca

Length of output: 14587


Prevent pruning a cache that opens after the probe.

After the main process exits, its scanner can still open the cache while it finishes work. If that happens between openElsewhere and removal, pruning can unlink an active cache on POSIX. Cache writes can fail or be lost, requiring a cold rescan.

Keep pruning disabled unless ownership protection covers the probe through removal and also covers older scanners that may still open the file. Add a test for an open between the probe and removal.

if (args.stats) {
args.stats.bytesRead += readResult.bytesRead
}
noteAiVaultScanContentRead(args.signal, readResult.bytesRead)

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.

Minor · Functional Correctness · Heavy lift

Report bytes while the transcript is being read.

If one transcript exceeds 64 MiB, consumeCompleteJsonlLines can read and parse the entire file before this call reports any bytes. The live strip therefore stays hidden throughout that work. If the read fails or is cancelled, this call is never reached. Report bytes from the streaming read path instead.

args.stats.fullParses++
args.stats.bytesRead += file.sizeBytes ?? 0
}
noteAiVaultScanContentRead(args.signal, file.sizeBytes ?? 0)

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.

Minor · Functional Correctness · Heavy lift

Count bytes after they are read.

This call counts the stat size before parseAgentSessionFile opens the transcript. An unreadable or deleted file can therefore make progress visible without any content being read. If sizeBytes is unavailable, a successful read contributes zero instead. Count actual bytes at the read sites.

@AmoabaKelvin
AmoabaKelvin force-pushed the sta-13607-agent-search-rescan branch 2 times, most recently from 67d8ce6 to 660c021 Compare November 12, 2026 00:22
… stay quiet on cached rescans

A cache format bump or switching between builds that share a data folder
deleted the whole parse cache, so the next open re-read every transcript.
Each format version now gets its own file, and the progress strip stays
hidden until a scan has read 64 MB.
@AmoabaKelvin
AmoabaKelvin force-pushed the sta-13607-agent-search-rescan branch from 660c021 to ced96fc Compare November 27, 2026 22:00
@AmoabaKelvin
AmoabaKelvin merged commit 1ae6828 into main Nov 27, 2026
57 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant