feat(daemon): RpcKnowledgeStore — sync client adapter (phase 3)#24
Conversation
…phase 3) TDD red→green. Client-side Adapter (parent DESIGN §Design patterns, "Adapter, client side") presenting the EXISTING synchronous KnowledgeStore interface — zero ripple to extension/CLI call sites (decision: sync via worker-thread + Atomics blocking bridge). - sync-client.ts: SyncRpcClient — inline eval-worker owns the socket; caller blocks on Atomics.wait + receiveMessageOnPort; fail-fast timeout → BACKEND_UNAVAILABLE (contract §2.3); worker-error capture so a bootstrap failure surfaces instead of deadlocking. Documents the inherent constraint: a sync client must not share an event loop with an in-process daemon (separate process in real topology). - rpc-store.ts: RpcKnowledgeStore implements KnowledgeStore; reconstructs the wire's typed kind (§6) back into the core error class so callers catching EntryNotFoundError etc. keep working unchanged (LSP). - 5 tests against a REAL daemon child process (faithful v2 topology): sync addFact round-trip, LSP parity vs local MykbStore, typed-error reconstruction, lifecycle verbs, 25 sequential blocking calls. Found+fixed a load-flake: per-test daemon spawns tipped an unrelated concurrency test under vitest cross-file parallelism. Fix: one shared daemon per file, tests namespaced by area — minimal faithful footprint, also faster. Full suite 639/639 stable across 3 consecutive runs.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
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 |
Phase 3 of the v2 privileged-write-channel (issue #1): the client-side
Adapter that lets existing call sites talk to the daemon with zero
code change.
Builds on the merged Phase 1 contract (#21) + Phase 2 scaffold (#22).
Decision (user-confirmed)
KnowledgeStoreis synchronous. Rather than ripple an async refactorthrough every extension hook + CLI subcommand,
RpcKnowledgeStorepresents the existing sync interface via a worker-thread + Atomics
blocking bridge. Ripple: one client module.
What landed (TDD red→green)
sync-client.ts—SyncRpcClient: inline eval-worker owns thesocket; caller blocks on
Atomics.wait+receiveMessageOnPort;fail-fast timeout →
BACKEND_UNAVAILABLE(contract §2.3); worker-errorcapture so a bootstrap failure surfaces instead of deadlocking.
Documents the inherent constraint (a sync client must not share an
event loop with an in-process daemon — separate process in real
topology).
rpc-store.ts—RpcKnowledgeStore implements KnowledgeStore;reconstructs the wire's typed
kind(§6) back into the core errorclass so
catch (EntryNotFoundError)keeps working unchanged (LSP).sync round-trip, LSP parity vs local
MykbStore, typed-errorreconstruction, lifecycle verbs, 25 sequential blocking calls.
Flake found + fixed (mine, not waived)
Per-test daemon spawns load-tipped an unrelated concurrency test under
vitest cross-file parallelism. Fix: one shared daemon per file, tests
namespaced by area — minimal faithful footprint, also faster. Verified:
full suite 639/639 across 3 consecutive runs.
Note: a separate, pre-existing, non-deterministic CI flake in
tests/cli/work.test.ts(work handoff --clear, unrelated to daemoncode) was observed once on #22's CI and did not reproduce on re-run;
tracking separately.