Repository navigation
fix(kuna): verify a warm export once for concurrent first requests - #4049
Conversation
Every request a session admitted checked `#project` before awaiting the cache lookup, so concurrent first requests, such as batch_decompile's parallel resolutions on a fresh server, each re-hashed every export file and re-parsed the export. Concurrent first requests now share one lookup. Refs #1957 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] This PR appears safe to merge; no actionable regressions were found. SummaryConcurrent first requests in one Kuna session now share the cache lookup through
No actionable issues were found. Tests were not run during this review. The supersession check could not be completed because GitHub access required authentication. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Concurrent first requests] --> B{Project already started?}
B -->|Yes| C[Use existing project]
B -->|No| D[Share one startup promise]
D --> E[Verify cached export]
E -->|Found| F[Adopt verified export]
E -->|Missing| G[Start background build]
E -->|Error| H[Return error]
F --> I[Clear startup promise]
G --> I
H --> I
Reviews (1) · Last reviewed commit: "fix(kuna): verify a warm export once for..." · Reviewed by Greptile |
Summary
A Kuna session decided whether to reuse a cached export by checking
#projectand then awaitingcache.lookup(). Concurrent first requests all passed that check before any lookup finished, so each one ran its own lookup. On a fresh server a lookup re-hashes every export file and re-parses the.cand inventory.batch_decompileresolves its addresses in parallel, so it verified a warm export once per address. Refs #1957.Problem and expected behavior
Smallest trigger: warm cache, new MCP server,
open_binarywithprovider_id: "kuna", then onebatch_decompilewith N addresses. Expected: one verification per session, as for a single first request. Observed: N verifications; the cost grows with N × export size.Change and scope
#startProjectnow keeps the in-flight lookup in#starting. Concurrent first requests await that one lookup, which then adopts the export or starts the background build. The promise is cleared when it settles, so a failed lookup is retried by the next request, and the existing eviction recovery (#invalidateProjectfollowed by#startProject) works as before. One line indocs/kuna-provider.mdstates the behavior.Not included: a lookup shared across sessions of one process. Verification stays per session; concurrent sessions for one target in one process are uncommon, and sharing it would need waiter-owned cancellation in the cache.
Scope: an ordinary fix within the existing Kuna provider boundary; no maintainer scope decision applies.
Contract and boundary impact
KunaSessionClient.#startProject(session-level adoption of the cache's verified export).close_binarycancels it as before.Expected effects:
Evidence and regression coverage
Tests added or updated:
kunaProvider.test.tsgets "verifies a warm export once for concurrent first requests on a fresh server". It builds an export, opens a newKunaProvider(a fresh cache instance, like a new server) over the same cache root, sends four concurrent pseudocode requests (names, an address and a duplicate), and asserts all four come fromproject-exportwith exactly oneKunaProjectCache.lookupcall.Base reproduction: the new test fails on the base revision (
git stashofsrc/kuna/KunaSessionClient.ts) attoHaveBeenCalledTimes(1).Real Kuna 1.833, macOS arm64, fresh MCP server, warm 29 MiB export of
mDNSResponderthinned to arm64e (1.7 MiB, 3750 inventory entries,REA_KUNA_JOBS=8),batch_decompileof 12 sized entries, 3 runs per build:batch_decompileFor comparison, a single first
procedure_pseudo_codeon the same warm export takes 88–93 ms on both builds. Response bytes are identical (156318). Process figures come from/usr/bin/time -paround the harness and include the MCP client process. Model tokens were not measured. The time saved grows with export size and the number of addresses.Remaining proof gaps: no Linux host run of this change; cross-session duplicate lookups in one process remain (see scope).
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused -- tests/boundary/providers/kuna/*.test.ts: 90 passed (10 files), three consecutive runs.npm run check:fast: typecheck and lint passed.npm run docs:check: passed.REA_KUNA_COMMAND=… npm run verify:kuna(real Kuna 1.833, darwin/arm64): passed, process lineage verified,cleanup: "complete".Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code