Repository navigation
fix(session-search): keep the index status honest while a sweep has a backlog - #20753
Conversation
… backlog A pass stops reading at its wall-clock deadline and records nothing about the candidates it never opened, which is correct: being owed a read is a fact about the row, not an entry in a queue. But a candidate the opening sweep never reached has no row at all, so the store's `due` count cannot see it. The sweep still reported `completed`, the indexer stamped `lastSweepCompletedAt`, and `status()` answered `current` with a backlog of thousands: "Up to date - 130 files indexed", then 630, then more. The read loop now counts what it decided was owed and did not read and hands the number back as `left`; the pass propagates it; the indexer holds the last pass's count, adds it to `filesDue`, reports `indexing` while it is non-zero or a sweep is owed, and no longer stamps a sweep the deadline cut short as complete.
An armed cadence sweep on a drained index is not a backlog, so it no longer flashes the pane to indexing with nothing due.
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe search index pass now counts candidates skipped after the deadline and returns Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The deadline backlog remains reported and is drained before a sweep is marked complete, so the change is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description clearly explains the bug, root cause, fix, tests, and validation results. However, it omits required template content, including a linked issue, the Visual Proof section with Resolution Add a valid issue reference after ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 2dfd088a-1269-414a-a8bd-2940c92973f5
📒 Files selected for processing (5)
src/main/ai-vault-search/session-search-index-pass.test.tssrc/main/ai-vault-search/session-search-index-pass.tssrc/main/ai-vault-search/session-search-indexer.test.tssrc/main/ai-vault-search/session-search-indexer.tssrc/main/ai-vault-search/session-search-pass.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| phase: this.phase(settled), | ||
| filesIndexed: settled.current, | ||
| filesDue: settled.due, | ||
| filesDue: settled.due + this.left, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Avoid double-counting deferred due rows in filesDue.
runSessionSearchIndexPass increments left for every non-skip candidate after the deadline. A row with state due returns whole, and SessionSearchStore.stateCounts().due already includes that row. status() therefore counts the deferred row twice. Increment left only when the deferred candidate is not already represented by a due row. Preserve counting for modified current rows.
There was a problem hiding this comment.
Important
The phase fix is sound, but the new left counter is not disjoint from the store's row counts: a due row the deadline defers is added to left and remains in settled.due, so filesDue double counts the exact backlog this PR exists to make honest.
Reviewed changes
runSessionSearchIndexPassreports aleftcounter — every non-skipcandidate the deadline deferred is counted, with a documented claim that these are candidates "which have no row to be counted by".runSessionSearchPasspropagatesleftin its result.SessionSearchIndexerholds the last pass'sleftand reportsfilesDue: settled.due + this.left, adds aleft > 0 → indexingbranch tophase(), and only stampslastSweepCompletedAtwhen a sweep was not cut short.- Tests updated in
session-search-index-pass.test.tsandsession-search-indexer.test.tsto assert the new counts and phase.
ℹ️ The "status is a query over the rows" invariant is now only conditionally true
session-search-store-is-memory.test.ts:92-119 ("S1: reports exactly what a hand-written query over the rows reports") asserts reported.filesDue === counted.due, where counted is a raw GROUP BY state over the files table. settled.due + this.left only preserves that equivalence while left is zero — the test passes today solely because its fake clock makes every pass deadline-free. Consider either loosening S1 to account for the in-memory backlog, or scoping left to rowless candidates so the row-query equivalence survives.
Technical details
# S1 pins an invariant the PR changes
## Affected sites
- `src/main/ai-vault-search/session-search-store-is-memory.test.ts:109` — `expect(reported?.filesDue).toBe(counted.due ?? 0)`.
- `src/main/ai-vault-search/session-search-indexer.ts:203` — `filesDue: settled.due + this.left`.
## Required outcome
- The test either documents the new in-memory component of `filesDue`, or the implementation keeps `filesDue` equal to the row query.
## Open questions for the human
- Is `filesDue` intended to remain exactly the row-derived count (with `left` surfaced separately, e.g. a future `filesBacklog` field), or may it now include the unread-overflow estimate? The PR description leans on `filesIndexed + filesDue + filesFailed` as a total, which only works if the three are disjoint from `left`.ℹ️ Nitpicks
- The PR description says
phase: 'indexing'is reported "whileleft > 0or a sweep is owed", but commita710249removed thesweepNextcondition fromphase()(correctly — an armed cadence sweep is not a backlog). The description now overstates the final behavior.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…sDue `status()` reports `filesDue` as `stateCounts().due + left`. The read loop incremented `left` for every candidate the deadline cut off, including one whose row already said `due` — and that row is what `stateCounts().due` counts. A sweep that ran out of time therefore reported each already-due transcript twice. `left` now skips a deferred candidate whose row is already `due`. A candidate with no row, and a `current` row whose file moved, still count: those are the backlog no query can see, which is why `left` exists.
There was a problem hiding this comment.
ℹ️ No critical issues — one documentation nuance inline.
Reviewed changes
- Guarded
leftso a deferred candidate whose row already saysdueis not counted again (session-search-index-pass.ts:71-77), keepingfilesDue: settled.due + this.leftfrom double counting the exact backlog this PR exists to make honest. - Rewrote the
leftdocstrings to describe the row-backed case and corrected the pass comment, and added a test assertingleft: 0when every deferred candidate already has aduerow. - Tightened the existing pass tests to assert
leftalongsideoutOfTime(left: 1on the deadline test,left: 0when one file is read alone).
Technical details
# `filesDue` docstring does not cover the row-backed component of `left`
## Affected sites
- `src/main/ai-vault-search/session-search-indexer.ts:36-40` — docstring says the deferred candidates `left` adds are ones that "have no row to be counted by".
- `src/main/ai-vault-search/session-search-index-pass.ts:71-77` — the guard excludes only `row.state === 'due'`; a deferred non-held-out `failed` row or a moved-`current` row still increments `left`.
- `src/main/ai-vault-search/session-search-indexer.ts:203` — `filesDue: settled.due + this.left`, so a deferred `failed` row lands in both `filesDue` and `filesFailed`, and a moved-`current` row in both `filesDue` and `filesIndexed`.
## Required outcome
- The docstring matches what `left` holds (mirror the `left` docstring at `session-search-index-pass.ts:36-40`), or the PR description's `filesIndexed + filesDue + filesFailed` total is documented as not disjoint.
## Open questions for the human
- Is a disjoint `filesIndexed + filesDue + filesFailed` total still intended? The commit message deliberately keeps a moved-`current` row in `left`, so the sum can exceed the file total.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| * append, a window that widened), plus candidates the last pass ran out of | ||
| * time for, which have no row to be counted by. | ||
| */ |
There was a problem hiding this comment.
The filesDue docstring says the deferred candidates left adds are ones that "have no row to be counted by", but the guard at session-search-index-pass.ts:74 only excludes a due row — a deferred non-held-out failed row or a moved-current row has a row and still increments left. Since filesDue: settled.due + this.left, those files are then counted in filesDue and in filesFailed/filesIndexed, so the filesIndexed + filesDue + filesFailed total the PR body leans on can exceed the file count. Reword to match the left docstring ("a candidate with no row yet, or one whose row does not say it is owed").
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, stablyai#20986), so that layer is now upstream's: `searchAllExecutionHosts` over `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
… backlog (stablyai#20753) * fix(session-search): keep the index status honest while a sweep has a backlog A pass stops reading at its wall-clock deadline and records nothing about the candidates it never opened, which is correct: being owed a read is a fact about the row, not an entry in a queue. But a candidate the opening sweep never reached has no row at all, so the store's `due` count cannot see it. The sweep still reported `completed`, the indexer stamped `lastSweepCompletedAt`, and `status()` answered `current` with a backlog of thousands: "Up to date - 130 files indexed", then 630, then more. The read loop now counts what it decided was owed and did not read and hands the number back as `left`; the pass propagates it; the indexer holds the last pass's count, adds it to `filesDue`, reports `indexing` while it is non-zero or a sweep is owed, and no longer stamps a sweep the deadline cut short as complete. * fix(session-search): only an unread backlog keeps the phase at indexing An armed cadence sweep on a drained index is not a backlog, so it no longer flashes the pane to indexing with nothing due. * fix(session-search): stop counting a deferred `due` row twice in filesDue `status()` reports `filesDue` as `stateCounts().due + left`. The read loop incremented `left` for every candidate the deadline cut off, including one whose row already said `due` — and that row is what `stateCounts().due` counts. A sweep that ran out of time therefore reported each already-due transcript twice. `left` now skips a deferred candidate whose row is already `due`. A candidate with no row, and a `current` row whose file moved, still count: those are the backlog no query can see, which is why `left` exists.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.

Bug
The session-search pane claimed the index was up to date while thousands of transcripts were still unread, and the count it showed alongside that claim kept climbing: "Up to date · 130 files indexed", then 630, then more.
Root cause
runSessionSearchIndexPassstops reading at its wall-clock deadline and records nothing about the candidates it never opened. That is the intended design — being owed a read is a fact about the row, not an entry in a queue, so the next pass rediscovers it for the same reason.The gap is that a candidate the opening sweep never reached has no row at all.
SessionSearchStore.stateCounts()can only count rows, so the backlog is invisible todue. The pass still returnedcompleted: true, the indexer stampedlastSweepCompletedAt, andphase()resolvedcounts.due === 0 && lastSweepCompletedAt !== nulltocurrent.Fix
runSessionSearchIndexPassreturnsleft: candidates it decided were owed a read and did not read because the pass was out of time. The decide step already runs past the deadline, so this is a counter, not new work.runSessionSearchPasspropagatesleftin its result.SessionSearchIndexerholds the last completed pass'sleft(replaced each pass, so a pass that reads everything measures zero) and:filesDueas the store'sduecount plusleft;phase: 'indexing'whileleft > 0or a sweep is owed, withdegradedkeeping its precedence;lastSweepCompletedAtfor a sweep the deadline cut short.cyclesSinceSweepstill resets on any full pass, and the out-of-time sweep already armssweepNext, so the cadence is unchanged.No contract change.
AiVaultSearchStatusalready carriesfilesIndexed/filesDue/filesFailed, and withfilesDuehonest their sum is a usable total for a progress readout.Tests
src/main/ai-vault-search/session-search-index-pass.test.tsleft: 1alongsideoutOfTime: true.left: 0, pinning that a pass which reads everything reports no backlog.src/main/ai-vault-search/session-search-indexer.test.tsfilesDue: 3,phase: 'indexing'andlastSweepCompletedAt: null; the middle pass assertsfilesDue: 1and still-nulllastSweepCompletedAt; the draining pass assertsfilesDue: 0,phase: 'current'and a non-null stamp.filesDue: 0with two files unread) now readsfilesDue: 2, phase: 'indexing'.runSessionSearchPasshas no direct test file onmain; it is covered end to end through the indexer tests above, so no parallel harness was added.Gates
pnpm tcfirst failed onsrc/renderer/src/components/editor/rich-markdown-ordered-list.tsimportingORDERED_LIST_MARKER_PATTERN. That was a stalenode_modulessymlink in the worktree pointing@tiptap/extension-listat 3.22.5 whilepackage.jsonpins 3.31.3. Apnpm installrelinked it and the gate passes; nothing in this branch touches the renderer.