Skip to content

fix(session-search): keep the index status honest while a sweep has a backlog - #20753

Merged
Jinwoo-H merged 7 commits into
mainfrom
session-search-fix-sweep-backlog
Sep 16, 2026
Merged

Jinwoo-H merged 7 commits into
mainfrom
session-search-fix-sweep-backlog

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44

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

runSessionSearchIndexPass stops 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 to due. The pass still returned completed: true, the indexer stamped lastSweepCompletedAt, and phase() resolved counts.due === 0 && lastSweepCompletedAt !== null to current.

Fix

  • runSessionSearchIndexPass returns left: 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.
  • runSessionSearchPass propagates left in its result.
  • SessionSearchIndexer holds the last completed pass's left (replaced each pass, so a pass that reads everything measures zero) and:
    • reports filesDue as the store's due count plus left;
    • reports phase: 'indexing' while left > 0 or a sweep is owed, with degraded keeping its precedence;
    • no longer sets lastSweepCompletedAt for a sweep the deadline cut short. cyclesSinceSweep still resets on any full pass, and the out-of-time sweep already arms sweepNext, so the cadence is unchanged.

No contract change. AiVaultSearchStatus already carries filesIndexed / filesDue / filesFailed, and with filesDue honest their sum is a usable total for a progress readout.

Tests

src/main/ai-vault-search/session-search-index-pass.test.ts

  • The existing deadline test now asserts left: 1 alongside outOfTime: true.
  • The single-oversized-transcript test asserts left: 0, pinning that a pass which reads everything reports no backlog.

src/main/ai-vault-search/session-search-indexer.test.ts

  • "stops the opening sweep at its deadline and drains the rest": the out-of-time sweep now asserts filesDue: 3, phase: 'indexing' and lastSweepCompletedAt: null; the middle pass asserts filesDue: 1 and still-null lastSweepCompletedAt; the draining pass asserts filesDue: 0, phase: 'current' and a non-null stamp.
  • "reads what one pass has time for": the assertion that encoded the bug (filesDue: 0 with two files unread) now reads filesDue: 2, phase: 'indexing'.

runSessionSearchPass has no direct test file on main; it is covered end to end through the indexer tests above, so no parallel harness was added.

Gates

$ pnpm tc
$ node config/scripts/run-typecheck-projects-in-parallel.mjs
EXIT=0

$ pnpm test src/main/ai-vault-search
 Test Files  43 passed (43)
      Tests  501 passed (501)

$ pnpm run check:code-quality:changed
code quality: 0 new finding(s) across 5 changed file(s).
casting code quality: 0 new finding(s) across 5 changed file(s).
type-aware code quality: 0 new finding(s) across 5 changed file(s).
React Doctor: 0 new finding(s) across 5 changed file(s).
casting SAFETY: rationale: 0 new finding(s) across 5 changed file(s).
Changed-code quality gate passed since b07c4032ea33.

pnpm tc first failed on src/renderer/src/components/editor/rich-markdown-ordered-list.ts importing ORDERED_LIST_MARKER_PATTERN. That was a stale node_modules symlink in the worktree pointing @tiptap/extension-list at 3.22.5 while package.json pins 3.31.3. A pnpm install relinked it and the gate passes; nothing in this branch touches the renderer.

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

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: c8cb4ced-8162-4033-9138-53646a7567e5

📥 Commits

Reviewing files that changed from the base of the PR and between 97b9b64 and d5bc242.

📒 Files selected for processing (2)
  • src/main/ai-vault-search/session-search-index-pass.test.ts
  • src/main/ai-vault-search/session-search-index-pass.ts

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


📝 Walkthrough

Walkthrough

The search index pass now counts candidates skipped after the deadline and returns left. The session search pass propagates this count. The indexer includes the count in filesDue, reports indexing while candidates remain, and records sweep completion only after the backlog reaches zero. Tests now verify these result and status values.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to d5bc2

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 N/A and… Add a valid issue reference after Fixes #. Add the Visual Proof section with the required attachments or N/A and a brief reason. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, …
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: keeping session-search index status accurate when a sweep has remaining backlog.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files.
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.
Full details: Description check

Explanation

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 N/A and a reason if applicable, completed testing checklist items, and the remaining required checklist sections.

Resolution

Add a valid issue reference after Fixes #. Add the Visual Proof section with the required attachments or N/A and a brief reason. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, or explicitly mark items as not applicable with explanations.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2dfd088a-1269-414a-a8bd-2940c92973f5

📥 Commits

Reviewing files that changed from the base of the PR and between ffc3312 and a710249.

📒 Files selected for processing (5)
  • src/main/ai-vault-search/session-search-index-pass.test.ts
  • src/main/ai-vault-search/session-search-index-pass.ts
  • src/main/ai-vault-search/session-search-indexer.test.ts
  • src/main/ai-vault-search/session-search-indexer.ts
  • src/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,

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.

🎯 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.

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

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

  • runSessionSearchIndexPass reports a left counter — every non-skip candidate the deadline deferred is counted, with a documented claim that these are candidates "which have no row to be counted by".
  • runSessionSearchPass propagates left in its result.
  • SessionSearchIndexer holds the last pass's left and reports filesDue: settled.due + this.left, adds a left > 0 → indexing branch to phase(), and only stamps lastSweepCompletedAt when a sweep was not cut short.
  • Tests updated in session-search-index-pass.test.ts and session-search-indexer.test.ts to 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 "while left > 0 or a sweep is owed", but commit a710249 removed the sweepNext condition from phase() (correctly — an armed cadence sweep is not a backlog). The description now overstates the final behavior.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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.

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

ℹ️ No critical issues — one documentation nuance inline.

Reviewed changes

  • Guarded left so a deferred candidate whose row already says due is not counted again (session-search-index-pass.ts:71-77), keeping filesDue: settled.due + this.left from double counting the exact backlog this PR exists to make honest.
  • Rewrote the left docstrings to describe the row-backed case and corrected the pass comment, and added a test asserting left: 0 when every deferred candidate already has a due row.
  • Tightened the existing pass tests to assert left alongside outOfTime (left: 1 on the deadline test, left: 0 when 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +37 to +39
* append, a window that widened), plus candidates the last pass ran out of
* time for, which have no row to be counted by.
*/

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.

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").

@Jinwoo-H
Jinwoo-H merged commit dbd750f into main Sep 16, 2026
28 checks passed
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 18, 2026
…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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 19, 2026
…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.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
… 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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 21, 2026
…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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 22, 2026
…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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 25, 2026
…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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 27, 2026
…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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 29, 2026
…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.
nplez1 added a commit to nplez1/orca that referenced this pull request Oct 1, 2026
…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.
nplez1 added a commit to nplez1/orca that referenced this pull request Oct 6, 2026
…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.
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