Skip to content

feat(session-search): enable indexing on paired servers from a client - #20886

Merged
Jinwoo-H merged 31 commits into
mainfrom
session-search-remote-enable-2
Sep 16, 2026
Merged

Jinwoo-H merged 31 commits into
mainfrom
session-search-remote-enable-2

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​259 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​257
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​234 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​209

Reopens #20727, which GitHub auto-closed as merged when its base branch session-search-verify absorbed it. Same commits, cherry-picked onto the stack.

What and why

A desktop client can now turn Agent Session History indexing on or off on a paired Orca server (runtime host), and the server applies the change immediately without a restart. Before this, consent for a remote host's index could only be set by someone sitting at that host.

SSH hosts are out of scope here and are refused client-side.

Contract

Shared — AiVaultSetSearchEnabledParamsSchema = z.object({ enabled: z.boolean() }) in src/shared/ai-vault-search-contract.ts, with AiVaultSetSearchEnabledParams inferred in ai-vault-search-types.ts. The response is the existing AiVaultSearchStatus.

Runtime RPC — aiVault.setSearchEnabled in src/main/runtime/rpc/methods/ai-vault.ts. It is registered through the generated params catalog (pnpm run generate:rpc-params-catalog), deliberately not added to runtime-rpc-mobile-method-allowlist.ts, and aiVaultSearch is not added to the paired settings projection.

Runtime service — setSessionSearchEnabled(enabled): Promise<void>, owned by the new RuntimeSessionSearchSettingsController and exposed on OrcaRuntimeService through the existing service command surface. It reads the current settings, writes aiVaultSearch: { ...resolveAiVaultSearchSettings(current), enabled } so retention rides along untouched, then hands (before, after) to a host-supplied hook.

Desktop IPC + preload — aiVault:setSearchEnabled in src/main/ipc/ai-vault-search.ts, reached from setSearchEnabled(executionHostId, enabled) on the preload bridge, the preload type, and the web preload (which rejects with unsupported).

Gating decision

The method refuses unless context.pairedDeviceId is set. In-process and undefined callers get a structured forbidden error, which required adding 'forbidden' to the runtime error passthrough set so a method-level refusal reads the same as the transport-level mobile-allowlist refusal. The server logs one line naming the paired device id and the new value as an audit trail.

Note that pairedDeviceId only reaches a handler through dispatchStreaming, which is the path the WebSocket transport a paired client connects over actually uses. The unary dispatch path is the local Unix socket, which has no paired device and is therefore correctly refused.

One deviation from the brief, deliberate. The brief specified sessionSearchServiceStatus({}, 'runtime'). This ships clientKind ? 'relay' : 'runtime', matching aiVault.searchStatus exactly. Because pairedDeviceId and clientKind are always set together by the WebSocket dispatcher, the 'runtime' transport would have returned unredacted degradedRoots[].root host filesystem paths to every remote caller, while searchStatus on the same surface redacts them. The response type is identical either way, so the preload contract the settings UI is being built against is unaffected. A test covers the redaction.

Host wiring

  • Desktop and headless serve (main-process-runtime-service.ts) pass applySessionSearchSettingsChange itself, so a paired client's write and a local settings write reconcile the scanner child through one code path.
  • orcad (orcad-entry.ts) reaches its in-process index through the new apply(settings) on installInProcessSessionSearchService. Because SessionSearchInstance.apply closes and reconstructs unconditionally, orcad dedupes with the new shared changedAiVaultSearchSettings helper, which applySessionSearchSettingsChange now also uses.
  • The relay (relay-runtime-services.ts) is unchanged and registers no such method.

Wire compatibility

Rule 1: a new optional method, no protocol bump. A server that predates it answers method-not-found, and the desktop maps it through the same -32601 / method_not_found predicate the search client uses to an error whose message is exactly host-too-old, so the UI can map it to its own copy. Old clients never call it. callRuntimeSessionSearch does not restrict method names, so no change was needed there.

No case was added to the cross-version wire suite: nothing in tests/e2e/cross-version-wire/ covers aiVault.searchStatus or any other aiVault.* search method today, so there was no existing case to extend.

Tests

  • Runtime method (rpc/methods/ai-vault-search.test.ts): refuses an unpaired caller with forbidden and never touches the setting; a paired call applies once and answers with this host's status; host roots are withheld from a paired client; a runtime with no settings store answers runtime_unavailable, which also proves the command surface really installed the method; a non-boolean is rejected before reaching the runtime.
  • Runtime service (runtime-session-search-settings.test.ts): writes the whole policy with retention preserved and hands the host before/after exactly once; normalizes an absent stored policy; an unchanged value still writes but hands the host an unchanged pair; no store means runtime_unavailable.
  • IPC handler (ipc/ai-vault-search.test.ts): a runtime host forwards {enabled} and returns the parsed status without touching the local index; unknown-method maps to host-too-old while every other failure is preserved; a non-status answer is rejected; local, SSH, unroutable hosts and a non-boolean are all refused; no injected runtime transport reports host-too-old.
  • orcad in-process service (session-search-host-registration.test.ts): apply flips a live service between disabled and answering without reinstalling it, plus a wiring assertion that orcad's runtime hook reaches it.

Gate output

$ pnpm tc
(exit 0)

$ pnpm run typecheck:node / typecheck:cli / typecheck:web
(no `error TS` output)

$ pnpm test <4 changed test files>
 Test Files  4 passed (4)
      Tests  40 passed (40)

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

Also green: verify:rpc-params-catalog, check:max-lines-ratchet, check:ts-nocheck-ratchet, check:reliability-gates, and the four localization verifiers.

The `all` scope on `aiVault:searchSessions` now fans out from the desktop
to every host the session list enumerates and merges the pages into one.
Legs run in parallel: the local index through the search service, SSH and
runtime hosts through the existing remote search client.

Two fixed orders, because relevance scores from independent indexes are
not comparable. `newest` asks every leg for recency and k-way merges on
`updatedAt`, nulls last, ties broken on execution host id. `relevance`
rotates hosts in host-id order by their own rank.

The merged cursor is an opaque base64url payload holding each host's
cursor, how many of its current page were already emitted, and the
generation that offset counts into, plus the page size and sort the
cursor belongs to. A host whose index moved is fenced to `stale` and
stops contributing; the rest keep paging. Per-host outcomes ride back on
one new optional `hosts` field on the results response.

`aiVault:searchStatus` with `all` stays refused, and neither the runtime
RPC nor the CLI gains the scope, so a fan-out is never two hops.
…gs-ui

# Conflicts:
#	src/renderer/src/i18n/locales/en.json
# Conflicts:
#	src/renderer/src/components/right-sidebar/AiVaultSessionRow.test.tsx
#	src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx
#	src/renderer/src/i18n/locales/en.json
…ession-search-panel-all-hosts-2

# Conflicts:
#	src/renderer/src/i18n/locales/en.json
The panel's "All computers" scope produced no request: the hook parsed the
scope into a single host id and stopped when that was null, so the panel
answered "Choose one computer to search its sessions." The desktop already
merges every enumerated host behind `aiVault:searchSessions`, so pass the
scope straight through and stamp each hit with the host it came back on.

Hosts the merge could not search are named under the results header with a
short reason, since a silent partial answer reads as "no such session".

(cherry picked from commit c6b9179)
Adds `aiVault.setSearchEnabled` so a desktop can turn a paired Orca server's
transcript index on or off and have the server apply it without a restart.

The runtime method refuses any caller without a `pairedDeviceId` with a
`forbidden`-class error, writes the whole resolved policy through the runtime
store so retention rides along untouched, then reaches the index through a
host-supplied hook: `applySessionSearchSettingsChange` on the desktop, the
in-process instance's new `apply` on orcad. The relay is unchanged.

Wire compatibility is Rule 1 shaped: a new optional method. A server that
predates it answers method-not-found, which the desktop IPC handler maps to an
error whose message is exactly `host-too-old`. Old clients never call it. The
method is deliberately absent from the mobile allowlist, and `aiVaultSearch`
stays out of the paired settings projection.

(cherry picked from commit 640c715)
… host-too-old on status reads

(cherry picked from commit 1463e8a)

@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 new issues found.

Reviewed changes

  • Consent contract — AiVaultSetSearchEnabledParamsSchema ({ enabled: boolean }) shared type and the regenerated RPC params catalog entry.
  • Runtime RPC method — aiVault.setSearchEnabled refuses any caller without pairedDeviceId (structured forbidden), writes the setting through runtime.setSessionSearchEnabled, logs the device id, and answers with the host's status.
  • Runtime service controller — new RuntimeSessionSearchSettingsController.setEnabled preserves retention on the write and hands the host a (before, after) pair through the existing command surface.
  • Desktop IPC + preload — aiVault:setSearchEnabled maps local/SSH/unroutable/non-boolean to refusals and an unknown method to the literal host-too-old; web preload rejects.
  • Host wiring — desktop/headless reuse applySessionSearchSettingsChange; orcad wired through a new apply on the in-process service with a shared changedAiVaultSearchSettings dedupe.
  • Status read change — runtime-host searchStatus now calls aiVault.searchStatus directly and throws host-too-old on an unknown method instead of reporting unavailable.

The consent boundary holds. pairedDeviceId reaches a handler only through dispatchStreaming, whose sole pairedDeviceId-bearing ingress is the device-token-validated WebSocket path; the unary dispatch (Unix socket, renderer IPC, CLI helpers) never populates it. Mobile callers are refused by MOBILE_RPC_METHOD_ALLOWLIST before dispatch, and the only production runtime hosts both wire the apply hook. The runtimeHostStatus redaction with 'relay' matches aiVault.searchStatus and is safe because paired callers always carry clientKind.

ℹ️ Two observations, no action requested

  • The new method and the host-too-old mapping have no cross-version wire case (tests/e2e/cross-version-wire/ only exercises aiVault.listSessions/prepareSessionResume). The PR body explains there was no aiVault search case to extend, so this is a note rather than a gap that needs filling here.
  • The web preload's unsupported refusal is renderer-level only: a paired browser receives a runtime-scope device token, so the raw RPC is admitted server-side. That is still an authenticated paired client, so it is not a boundary hole — just worth knowing the effective server rule is "paired, non-mobile".
Technical details
# Verification notes

## Gating
- `src/main/runtime/rpc/methods/ai-vault.ts:43` — handler refuses when `pairedDeviceId` is falsy.
- `src/main/runtime/rpc/dispatcher.ts:95` — unary context omits `pairedDeviceId`; only `runtime-rpc-websocket-dispatch.ts:140` supplies it, from a `deviceRegistry.validateToken`-validated token.
- `src/main/runtime/runtime-rpc/runtime-rpc-websocket-dispatch.ts:76` — `clientKind: 'mobile'` gate against `MOBILE_RPC_METHOD_ALLOWLIST`, which omits this method.

## Apply path
- `src/main/runtime/runtime-session-search-settings.ts:25` — write preserves `historyDays` via `resolveAiVaultSearchSettings(before)`, then applies.
- `src/main/startup/main-process-runtime-service.ts:139` and `src/main/orcad/orcad-entry.ts:256` are the two production hosts, both wire the hook.
- `src/main/ai-vault/session-search-enablement.ts:45` now shares `changedAiVaultSearchSettings`, so an unchanged write cannot restart the index.

## Redaction / schema
- `src/shared/ai-vault-search-contract.ts:115` — `degradedRoots[].root` is optional, so `redactStatusForTransport` output still parses.
- `src/main/ipc/ai-vault-search.ts:106` parses the host answer but does not re-redact; correct because the server already redacted (`clientKind ? 'relay' : 'runtime'`).

## `forbidden` passthrough
- `src/main/runtime/rpc/errors.ts:135` only affects errors thrown through `mapRuntimeError`. The other `code: 'forbidden'` throw (`runtime-browser-commands-browser-tab-create.ts:58`) goes through `mapBrowserError`, which already forwarded all structured codes, so no existing method's error code changes.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H changed the base branch from session-search-panel-all-hosts-2 to main September 16, 2026 16:40
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change adds per-host search consent updates through runtime RPC, IPC, and preload APIs. Runtime settings persistence updates only the enabled field and can apply the resulting policy to an installed search service. In-process and orcad services now expose apply. Runtime status handling distinguishes unavailable hosts from hosts that lack the RPC method. Local and SSH consent updates remain refused, while web clients return unsupported. Tests cover validation, authorization, status mapping, persistence, and service updates.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 2a95d

A paired-host response may expose degraded filesystem paths. Confirm or enforce redaction before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.84% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: enabling session-search indexing on paired servers from a client.
Description check ✅ Passed The description is detailed and covers the change, rationale, linked issue, implementation, compatibility, security boundaries, testing, and gate results. It does not reproduce every template heading,…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

@Jinwoo-H
Jinwoo-H merged commit a010276 into main Sep 16, 2026
33 checks passed

@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: 0182de47-e410-4973-8a80-e1564c5ae158

📥 Commits

Reviewing files that changed from the base of the PR and between 8153ec2 and 2a95d2d.

⛔ Files ignored due to path filters (1)
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (23)
  • src/main/ai-vault-search/session-search-enablement.ts
  • src/main/ai-vault-search/session-search-host-registration.test.ts
  • src/main/ai-vault-search/session-search-in-process-service.ts
  • src/main/ipc/ai-vault-search.test.ts
  • src/main/ipc/ai-vault-search.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-session-search.ts
  • src/main/runtime/orca-runtime-state-fields.ts
  • src/main/runtime/rpc/errors.ts
  • src/main/runtime/rpc/methods/ai-vault-search.test.ts
  • src/main/runtime/rpc/methods/ai-vault.ts
  • src/main/runtime/runtime-service-command-surface.ts
  • src/main/runtime/runtime-session-search-settings.test.ts
  • src/main/runtime/runtime-session-search-settings.ts
  • src/main/runtime/runtime-store-contract.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/preload/api/ai-vault-api.ts
  • src/preload/api/ai-vault-bridge.ts
  • src/renderer/src/web/preload-api/web-ai-vault-api.ts
  • src/shared/ai-vault-search-client.ts
  • src/shared/ai-vault-search-contract.ts
  • src/shared/ai-vault-search-settings.ts
  • src/shared/ai-vault-search-types.ts

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

Comment on lines +106 to +108
return AiVaultSearchStatusSchema.parse(
await call(environmentId, 'aiVault.setSearchEnabled', { enabled })
)

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.

🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick win

Information Disclosure

Reachability: External
Exploitability: Moderate
CWE: CWE-200 — Exposure of Sensitive Information to an Unauthorized Actor

Redact the paired-host status before returning it.

This path validates the runtime status but returns degradedRoots[].root unchanged through IPC. A paired client can invoke setSearchEnabled and receive remote filesystem paths when the host is degraded. Apply redactStatusForTransport(..., 'relay') before returning the status, as runtimeHostStatus already does.

Proposed fix
-    return AiVaultSearchStatusSchema.parse(
-      await call(environmentId, 'aiVault.setSearchEnabled', { enabled })
+    return redactStatusForTransport(
+      AiVaultSearchStatusSchema.parse(
+        await call(environmentId, 'aiVault.setSearchEnabled', { enabled })
+      ),
+      'relay'
     )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return AiVaultSearchStatusSchema.parse(
await call(environmentId, 'aiVault.setSearchEnabled', { enabled })
)
return redactStatusForTransport(
AiVaultSearchStatusSchema.parse(
await call(environmentId, 'aiVault.setSearchEnabled', { enabled })
),
'relay'
)

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 18, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 19, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…stablyai#20886)

* feat(session-search): add ranked history panel search and consent

* test: wait for initial session indexing before refreshing results

* feat(session-history): add local search settings and index controls

* Use shared local host identifier for session index status

* feat(session-search): merge all-computers search across hosts

The `all` scope on `aiVault:searchSessions` now fans out from the desktop
to every host the session list enumerates and merges the pages into one.
Legs run in parallel: the local index through the search service, SSH and
runtime hosts through the existing remote search client.

Two fixed orders, because relevance scores from independent indexes are
not comparable. `newest` asks every leg for recency and k-way merges on
`updatedAt`, nulls last, ties broken on execution host id. `relevance`
rotates hosts in host-id order by their own rank.

The merged cursor is an opaque base64url payload holding each host's
cursor, how many of its current page were already emitted, and the
generation that offset counts into, plus the page size and sort the
cursor belongs to. A host whose index moved is fenced to `stale` and
stops contributing; the rest keep paging. Per-host outcomes ride back on
one new optional `hosts` field on the results response.

`aiVault:searchStatus` with `all` stays refused, and neither the runtime
RPC nor the CLI gains the scope, so a fan-out is never two hops.

* fix(preload): let the search bridge address the all-computers scope

* feat(settings): live index status, enable confirm, advanced delete

* feat(session-search): search every computer from the history panel

The panel's "All computers" scope produced no request: the hook parsed the
scope into a single host id and stopped when that was null, so the panel
answered "Choose one computer to search its sessions." The desktop already
merges every enumerated host behind `aiVault:searchSessions`, so pass the
scope straight through and stamp each hit with the host it came back on.

Hosts the merge could not search are named under the results header with a
short reason, since a silent partial answer reads as "no such session".

(cherry picked from commit c6b9179)

* feat(session-search): enable indexing on paired servers from a client

Adds `aiVault.setSearchEnabled` so a desktop can turn a paired Orca server's
transcript index on or off and have the server apply it without a restart.

The runtime method refuses any caller without a `pairedDeviceId` with a
`forbidden`-class error, writes the whole resolved policy through the runtime
store so retention rides along untouched, then reaches the index through a
host-supplied hook: `applySessionSearchSettingsChange` on the desktop, the
in-process instance's new `apply` on orcad. The relay is unchanged.

Wire compatibility is Rule 1 shaped: a new optional method. A server that
predates it answers method-not-found, which the desktop IPC handler maps to an
error whose message is exactly `host-too-old`. Old clients never call it. The
method is deliberately absent from the mobile allowlist, and `aiVaultSearch`
stays out of the paired settings projection.

(cherry picked from commit 640c715)

* fix(session-search): report a paired server without session search as host-too-old on status reads

(cherry picked from commit 1463e8a)

* fix(settings): let Button and Collapsible own their spacing and type
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 21, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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 22, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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 25, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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 27, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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 Sep 29, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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 1, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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.
nplez1 added a commit to nplez1/orca that referenced this pull request Oct 6, 2026
Two breaks the convergence onto upstream's all-hosts engine left behind, both
found by tests rather than by reading the diff:

- The index writer gated `add` on `released || fenced || closed || !storeContent`
  and called `discard()` on the way out. `discard()` marks the write released and
  `commit()` gates on that, so a metadata-only index never wrote its session row
  and the list answered empty. The content skip is now its own early return,
  ahead of the released check, and keeps the session row.

- Upstream's per-host "enable indexing" toggle (stablyai#20886) writes
  `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the
  commit that added the metadata tier renamed that consent to `contentEnabled` and
  made metadata always-on. The toggle was a no-op against AiVaultSearchSettings.
  `setEnabled` now writes `contentEnabled`, so a paired client turns the content
  tier on and off for that host while its metadata keeps answering. The
  registration test asserts that, instead of the `disabled` verdict that no
  production path produces any more.
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