Skip to content

feat(daemon): RpcKnowledgeStore — sync client adapter (phase 3)#24

Merged
vilosource merged 1 commit into
developfrom
feature/v2-rpc-client
May 16, 2026
Merged

feat(daemon): RpcKnowledgeStore — sync client adapter (phase 3)#24
vilosource merged 1 commit into
developfrom
feature/v2-rpc-client

Conversation

@vilosource
Copy link
Copy Markdown
Owner

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)

KnowledgeStore is synchronous. Rather than ripple an async refactor
through every extension hook + CLI subcommand, RpcKnowledgeStore
presents the existing sync interface via a worker-thread + Atomics
blocking bridge. Ripple: one client module.

What landed (TDD red→green)

  • sync-client.tsSyncRpcClient: 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.tsRpcKnowledgeStore implements KnowledgeStore;
    reconstructs the wire's typed kind (§6) back into the core error
    class so catch (EntryNotFoundError) keeps working unchanged (LSP).
  • 5 tests vs a REAL daemon child process (faithful v2 topology):
    sync round-trip, LSP parity vs local MykbStore, typed-error
    reconstruction, 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 daemon
code) was observed once on #22's CI and did not reproduce on re-run;
tracking separately.

…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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Warning

Rate limit exceeded

@vilosource has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 21 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 225b1551-29c6-4d06-b451-6710f6aa375c

📥 Commits

Reviewing files that changed from the base of the PR and between 2e12102 and a35be8e.

📒 Files selected for processing (3)
  • src/daemon/rpc-store.ts
  • src/daemon/sync-client.ts
  • tests/daemon/rpc-store.test.ts

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 and usage tips.

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