Repository navigation
perf(relay): release canceled AI Vault startup requests - #23027
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe AI Vault client now uses cancellable waiters for child readiness. Call state tracks startup attempts and uses a shared helper to arm operation-specific timeouts. Regression tests cover cancellation, disposal, readiness races, and startup retry. The reliability-gates configuration adds a gate for AI Vault readiness ownership; changes to existing gate arrays only reformat their values. The hourly-build version test mocks package-file reads and sets a fixed package version. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to The new tests do not exercise delayed startup failure during retry, so a regression in recovery could go unnoticed. This is a bounded coverage gap. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Out of Scope Changes checkExplanation The AI Vault client, state, regression tests, and reliability-gate entry support the PR scope. ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No blocking issues. One scope question about the sibling local scanner client, plus a trivial nit.
Reviewed changes
- Canceled readiness owners release their payloads —
RelayAiVaultServiceClient.pump()now waits on the shared readiness throughPromiseSettlementWaiters.wait({ signal, onFulfilled: sendCall }), so an aborted waiter is removed and its capturedcall/request array is freed before the sidecar is ready (src/relay/ai-vault-service-client.ts:136). - Disposal settles readiness —
dispose()callsreadyReject?.(error)and clearsreadybefore settling active/queued calls (src/relay/ai-vault-service-client.ts:77). - Per-attempt ownership — new
RelayAiVaultServiceCall.startAttempt, bumped inpump(), and the failure handler bails when the captured attempt is stale (src/relay/ai-vault-service-client.ts:134,:143). - Timeout arming extracted —
armRelayAiVaultCallTimeoutmoved tosrc/relay/ai-vault-service-client-state.ts:31; behavior unchanged, keeps the client under its line budget. - Regression coverage + gate —
src/relay/ai-vault-service-ready-retention.test.ts(1000-call WeakRef/GC retention, disposal, cancel-on-ready turn, spawn-failure two-lane retry) and experimental gaterelay-performance.ai-vault-ready-ownership.
I re-ran the focused suites (19/19 pass), check-reliability-gates (127 gates), oxlint, and pnpm tc:node; all clean.
ℹ️ Sibling local scanner client has the same readiness capture
The fix lands only in the relay client. The parallel main-process client, AiVaultScannerServiceClient, still attaches a permanent .then reaction to its shared readiness promise in pump(), capturing the same call/request payload (src/main/ai-vault/session-scanner-service-client.ts:142). A call canceled before its child is ready is deleted from active, but its closure stays on readyWaiter.promise until ready resolves — and this client's dispose() never settles that promise, so the capture can outlive disposal entirely. Issue #23024 is written generically ("Canceled AI Vault title requests ... captured by reactions on the shared pending sidecar readiness promise"), so it is worth confirming whether the local path is deliberately out of scope or tracked separately. The two clients also both sit under the same 16-call admission bound, which is the bound the issue says retention bypasses.
Technical details
# Same retention in the local AI Vault scanner client
## Affected sites
- `src/main/ai-vault/session-scanner-service-client.ts:142` — `void this.ensureChild().then((child) => sendAiVaultServiceCall(child, call, ...), ...)`; the `onFulfilled` arrow captures `call`, whose `request` holds the payload array. On abort, `cancelAiVaultServiceCall` (`src/main/ai-vault/session-scanner-service-client-state.ts:139`) deletes the call from `active` but the reaction on `readyWaiter.promise` remains until the child is ready.
- `src/main/ai-vault/session-scanner-service-client.ts:111` — `dispose()` calls `retireChild()` but never rejects `readyWaiter.promise`, so pending reactions are not settled at disposal.
- Compare the fix under review: `src/relay/ai-vault-service-client.ts:136` and `:77`.
## Required outcome
- Decide whether canceled-request retention during readiness applies to the local execution host too; if so, the local client should use a detachable wait (e.g. `PromiseSettlementWaiters`) and dispose should settle the readiness promise, mirroring this PR.
## Open questions for the human
- Is the local `AiVaultScannerServiceClient` intentionally out of scope for #23024, or is a follow-up planned?ℹ️ Nitpicks
src/relay/ai-vault-service-ready-retention.test.ts:117re-invokesvi.useFakeTimers(...)even thoughbeforeEachat line 35 already installs the same fake-timer set; the extra call is a no-op.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
861b85b to
4304f33
Compare
|
Reviewed the local scanner sibling: this PR deliberately covers RelayAiVaultServiceClient only. The unchanged main-process AiVaultScannerServiceClient still has the same readiness-promise capture; this change does not claim to fix it. It is recorded as remaining local scanner work in the audit, without creating a GitHub issue. The redundant vi.useFakeTimers call in the retry test is removed; the shared beforeEach already installs those timers. The relay ownership/restart/cancellation/waiter suites passed 38 tests across six suites on the reviewed head. The generic docstring percentage suggestion is declined under this repository’s instruction to keep comments concise and limited to non-obvious reasoning. Existing comments describe the ownership decisions; no runtime change is needed for that style warning. Published fix: 4304f3376d20; the 38 focused tests pass after rebasing. |
4304f33 to
4784437
Compare
There was a problem hiding this comment.
ℹ️ No code issues in this delta. One merge-hygiene note: the PR currently conflicts with
main, and the catalog entries it restores have already landed there with different Japanese/Korean wording.
Reviewed changes
- Relocated the AI Vault reliability gate —
relay-performance.ai-vault-ready-ownershipmoves from the last entry ingatesto the first, and the adjacentworkspace-hooks.execution-host-ownershiparrays were compacted to single lines. Gate content is unchanged andcheck:reliability-gatespasses (129 gates). - Restored the diff-note localization catalog — added
f6c449191e,5fa4bfebaa, and5e9b3d0c2eto all six locale files and reworded the Japanese/Koreanf6c449191evalue so the AI is the recipient. All six JSONs parse;verify:localization-catalogandverify:localization-runtime-catalogpass. - No relay-service changes — the retention fix and its tests are untouched by these commits.
ℹ️ The restored catalog entries conflict with main instead of dropping out
The PR description expects the restored catalog entries to "drop out of this diff once they land on main." They have already landed on origin/main, but the branch's base predates that and the Japanese/Korean f6c449191e values differ, so GitHub reports the PR CONFLICTING / DIRTY. Merging needs those two lines reconciled (presumably keeping this PR's AI 向けの… / AI에게 전달할… wording per the #23256 correction) rather than a clean drop-out.
Technical details
# Restored i18n entries already exist on main with different values
## Affected sites
- `src/renderer/src/i18n/locales/ja.json:15500` — `f6c449191e`: this branch `"AI 向けのメモを追加"` vs `origin/main` `"AI に関するメモを追加"`.
- `src/renderer/src/i18n/locales/ko.json:15500` — `f6c449191e`: this branch `"AI에게 전달할 메모 추가"` vs `origin/main` `"AI에 대한 메모 추가"`.
- The `en` / `es` / `fr` / `zh` additions are byte-identical to `origin/main` and merge cleanly.
## Required outcome
- On rebase/merge, keep the recipient-oriented Japanese/Korean wording and drop the duplicated additions so the branch carries no i18n churn.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
4a6e2eb to
70b3c13
Compare
|
The merge-hygiene finding is addressed in |
|
The formatting-only gate-array warning is declined: these lines are the repository formatter’s output. Every preexisting gate object, including workspace-hooks.execution-host-ownership, was compared by parsed value and preserved unchanged. Reverting the formatter output would restore formatting drift without changing scope or behavior. The generic docstring threshold is also declined under AGENTS.md’s concise, non-obvious-comments-only policy. The historical hourly-version test prerequisite is now disclosed in the description; it changes only the fixture input and keeps the original assertions. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/relay/ai-vault-service-ready-retention.test.ts (1)
116-152: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winCover the delayed startup failure ordering.
The added retry test only simulates a synchronous
processFactorythrow. It does not create an earlier child whose failure is handled after the replacement attempt starts. ItstoContainEqualassertions also allow duplicate requests.The existing cold-start test emits the first child’s
exitbefore advancing the retry timer. Its failure handler therefore runs before the replacement child is created. Add a test that delays the earlier attempt’s rejection until after the replacement starts, then assert that the replacement remains active and sends the later call exactly once.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: e4ec1f06-a7a3-4e0f-ae75-1ea3689661b7
📒 Files selected for processing (1)
config/scripts/hourly-build-version.test.mjs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
✅ No new issues found in the new commits.
Reviewed changes
- Pinned the historical hourly package version —
getHourlyBuildIdentitynow accepts an optionalpackageVersion, and the September 14 regression passes1.4.201instead of reading the livepackage.json(now1.4.214), so the test is deterministic again; production callers omit it, so release behavior is unchanged. - Repositioned the AI Vault reliability gate — the rebase moves
relay-performance.ai-vault-ready-ownershipamong the other gates and compacts adjacent arrays; gate content is unchanged andcheck:reliability-gatespasses (131 gates). - Dropped the locale churn — the diff-note catalog entries now live on
main, so the branch no longer touches the six locale JSONs. - Relay retention fix untouched —
ai-vault-service-client.ts,ai-vault-service-client-state.ts, and the retention test are byte-identical to the prior reviewed revision.
Verified locally: hourly-build-version.test.mjs 16/16 pass.
ℹ️ Nitpicks
- The PR description still says the test's "package read" is pinned to the 1.4.201 fixture; the final commits instead thread a
packageVersionoption through the build. Worth a wording update so the description matches the code.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Addressed the delayed-startup coverage note in 993aa36. The new test synchronously advances the restart timer before the old readiness rejection microtasks run, starts the second lane on the replacement child, and asserts the complete sent-message arrays: one initialization per child and exactly one request per lane. Both requests must resolve, the factory must remain at two calls, and disposal must leave no timers. The five focused suites pass (27 tests). As a negative control, removing the |
There was a problem hiding this comment.
✅ No new issues found in the new commit.
Reviewed changes
Since the prior pullfrog review (b4e61dd), one commit landed:
- Added delayed-readiness-rejection regression —
src/relay/ai-vault-service-ready-retention.test.tsgainsignores an earlier readiness rejection after a replacement startup begins: it lets the first attempt's readiness rejection settle only after the scheduled restart has begun a replacement on the same lane, then asserts the replacement sendslistandtitlesexactly once and both calls resolve. The production files are byte-identical to the prior review.
This test is not theatre: I re-ran the file with the call.startAttempt !== attempt clause removed from pump()'s failure handler and only this test failed (list rejected with the stale Relay AI Vault service exited (1).), so it genuinely covers the startAttempt ownership half of the guard rather than just the active.get(lane) check. All 5 tests in the file pass with the guard intact. It also answers the CodeRabbit request for delayed-failure ordering coverage.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Historical release-test CI prerequisite
The CI merge base advanced the package version beyond a historical release fixture: the test expected 1.4.203 but read today’s 1.4.214 package. The build-identity helper now accepts an optional package version alongside its existing release inputs, and that test supplies its historical 1.4.201 version. Normal callers still read package.json. Both original version/build-number assertions remain; all 16 tests pass, and two exact before/after comparisons confirm unchanged default output. Targeted lint, including the no-module-mocking rule, passes. Application and native terminal code are unchanged; fresh CI remains required.
ELI5
Canceled requests no longer leave their luggage behind while the background scanner starts. Live requests still wait for the scanner and run normally.
What Changed
Repeatedly canceling AI Vault title lookups during remote scanner startup now releases their request data immediately. The client uses existing detachable promise waiters instead of adding an undetachable callback for every call. Disposing the client also settles and clears startup readiness.
Each startup attempt has its own counter so a delayed failure cannot reject a request already retried on another attempt. The existing timeout arming moved beside cancellation timer handling to keep the client within its file-size limit.
Why
Canceling freed the active lane but left its request captured by the shared startup promise, bypassing the 16-call admission bound for retained data. Reusing the existing waiter utility removes that retention without canceling the shared scanner or changing live request deadlines.
Linked Issue
Fixes #23024
Visual Proof
N/A — startup memory ownership only. No visual or interaction behavior change; no app/window launched.
Performance proof
Production-module synthetic cold-start fixture: hold readiness, issue/cancel 1,000 title calls with 50 distinct paths each, then force GC. Retained canceled arrays: 1,000 → 0 before ready. Incremental Node heap was 34,771,464 → 492,504 bytes in the recorded run (includes runtime noise).
The normal startup deadline remains 5s. This measures adverse cold-start churn, not typical frequency, UI latency, or all scanner memory. Disposal retention is covered separately.
Testing
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/relay/ai-vault-service-ready-retention.test.ts src/relay/ai-vault-service-client.test.ts src/shared/promise-settlement-waiters.test.ts.Review
Merge risk: low to moderate. Asynchronous startup, retry and cancellation ownership are the sensitive paths. The gate manifest addition may need a simple merge resolution with other audit PRs.
Negative user-facing trade-offs: none identified. Same call caps, deadlines, lane ordering, cancellation acknowledgements and wire messages. Only abandoned owners release earlier.
Reliability: experimental gate
relay-performance.ai-vault-ready-ownership. Invariant: canceled/disposed readiness owners release payloads while live calls still deliver exactly once. Failure source: cancellation churn during slow startup. Oracle: GC, request counts, zero cleanup timers, cold-start and failed-spawn races. No new polling, process starts or deadline timers.Agent skill upstream boundary
Notes
The shared diff-note catalog prerequisite is now in main and has dropped out of this branch’s diff.
Scanner work stays on the execution host. Local/daemon PTYs, WSL shell selection and mobile terminal streams are unaffected. No process-death inference, Git/provider routing, folder-workspace assumption or protocol change.
Checklist