Repository navigation
feat(session-search): enable indexing on paired servers from a client - #20727
Merged
Merged
Conversation
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.
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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() })insrc/shared/ai-vault-search-contract.ts, withAiVaultSetSearchEnabledParamsinferred inai-vault-search-types.ts. The response is the existingAiVaultSearchStatus.Runtime RPC —
aiVault.setSearchEnabledinsrc/main/runtime/rpc/methods/ai-vault.ts. It is registered through the generated params catalog (pnpm run generate:rpc-params-catalog), deliberately not added toruntime-rpc-mobile-method-allowlist.ts, andaiVaultSearchis not added to the paired settings projection.Runtime service —
setSessionSearchEnabled(enabled): Promise<void>, owned by the newRuntimeSessionSearchSettingsControllerand exposed onOrcaRuntimeServicethrough the existing service command surface. It reads the current settings, writesaiVaultSearch: { ...resolveAiVaultSearchSettings(current), enabled }so retention rides along untouched, then hands(before, after)to a host-supplied hook.Desktop IPC + preload —
aiVault:setSearchEnabledinsrc/main/ipc/ai-vault-search.ts, reached fromsetSearchEnabled(executionHostId, enabled)on the preload bridge, the preload type, and the web preload (which rejects withunsupported).Gating decision
The method refuses unless
context.pairedDeviceIdis set. In-process and undefined callers get a structuredforbiddenerror, 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
pairedDeviceIdonly reaches a handler throughdispatchStreaming, which is the path the WebSocket transport a paired client connects over actually uses. The unarydispatchpath 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 shipsclientKind ? 'relay' : 'runtime', matchingaiVault.searchStatusexactly. BecausepairedDeviceIdandclientKindare always set together by the WebSocket dispatcher, the'runtime'transport would have returned unredacteddegradedRoots[].roothost filesystem paths to every remote caller, whilesearchStatuson 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
main-process-runtime-service.ts) passapplySessionSearchSettingsChangeitself, so a paired client's write and a local settings write reconcile the scanner child through one code path.orcad-entry.ts) reaches its in-process index through the newapply(settings)oninstallInProcessSessionSearchService. BecauseSessionSearchInstance.applycloses and reconstructs unconditionally, orcad dedupes with the new sharedchangedAiVaultSearchSettingshelper, whichapplySessionSearchSettingsChangenow also uses.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_foundpredicate the search client uses to an error whosemessageis exactlyhost-too-old, so the UI can map it to its own copy. Old clients never call it.callRuntimeSessionSearchdoes 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/coversaiVault.searchStatusor any otheraiVault.*search method today, so there was no existing case to extend.Tests
rpc/methods/ai-vault-search.test.ts): refuses an unpaired caller withforbiddenand 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 answersruntime_unavailable, which also proves the command surface really installed the method; a non-boolean is rejected before reaching the runtime.runtime-session-search-settings.test.ts): writes the whole policy with retention preserved and hands the hostbefore/afterexactly once; normalizes an absent stored policy; an unchanged value still writes but hands the host an unchanged pair; no store meansruntime_unavailable.ipc/ai-vault-search.test.ts): a runtime host forwards{enabled}and returns the parsed status without touching the local index; unknown-method maps tohost-too-oldwhile 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 reportshost-too-old.session-search-host-registration.test.ts):applyflips a live service between disabled and answering without reinstalling it, plus a wiring assertion that orcad's runtime hook reaches it.Gate output
Also green:
verify:rpc-params-catalog,check:max-lines-ratchet,check:ts-nocheck-ratchet,check:reliability-gates, and the four localization verifiers.