Repository navigation
Implement WatchNodes gRPC streaming, add Tauri watcher.rs (closes #1114) - #1145
Conversation
Daemon side (live):
- Replace WatchNodes Unimplemented stub with async_stream handler that
subscribes to NodeService::subscribe_to_events() and translates each
DomainEvent::Node{Created,Updated,Deleted} into a proto NodeEvent.
- For Created/Updated, fetch the current node payload so clients get
full node data inline (no follow-up GetNode round trip).
- Handle broadcast lag as a warn-and-continue rather than a hard error;
on channel closure, end the stream cleanly.
- Add 3 integration tests: single-watcher round trip (create/update/delete),
multiple concurrent watchers receiving the same event, and a fresh
watcher succeeding after a prior client dropped its stream.
Filter fields (WatchRequest.node_type, root_id) are accepted but
ignored — the issue's Non-Goals list filtering as a future enhancement.
A debug log fires when a non-default filter is requested.
No ops-layer changes were needed: nodespace_core already publishes
domain events via NodeService::subscribe_to_events(), so the daemon
becomes a pure event consumer/translator.
Tauri side (inert until #1113):
- New packages/desktop-app/src-tauri/src/watcher.rs module: gRPC client
that opens a WatchNodes stream against nodespaced, re-emits each
proto event as a Tauri event (node:created/updated/deleted) using the
same NodeIdPayload format as the existing in-process
DomainEventForwarder, and reconnects with exponential backoff
(1s start, 30s cap).
- Module is declared in lib.rs but not spawned. Activation belongs to
#1113 (Tauri → thin gRPC client migration), which will remove
DomainEventForwarder and call watcher::spawn() in its place. Running
both simultaneously would double-emit every node:* event.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Code Review — PR #1145 (Initial Review)Review Type: Initial Review (no prior reviews exist; reviewing full diff vs Scope: ~493 lines across daemon SummaryA clean, surgical implementation that satisfies the AC for The Tauri Net-positive change. A few important callouts about contract drift the activation PR (#1113) must reconcile, but nothing blocks merging this scaffold. Requirements Check (Issue #1114 AC)
Non-Goals honored correctly:
Findings🟢 Strengths
🟡 Important (worth addressing in #1113, not blocking this PR)1.
2.
3. AC "Stream closes gracefully when the client disconnects" is covered only indirectly. [
4. Per-event
🟢 Nits (optional polish)
Final Recommendation: APPROVEThe PR is a net-positive change that correctly scopes the daemon side of |
malibio
left a comment
There was a problem hiding this comment.
Recommendation: APPROVE. Full review posted as a PR comment. (GitHub blocks formal --approve on self-authored PRs, so leaving the recommendation as a review comment.)
…xlate Addresses reviewer feedback on PR #1145: 🟡 #1 — node:deleted payload contract aligned with DomainEventForwarder Extend proto `NodeDeleted` with `node_type` (carried from `DomainEvent::NodeDeleted::node_type` in the core event channel). Watcher now emits `{ id, nodeType }` for delete events, matching the in-process forwarder's payload exactly. Test asserts the field is populated. This unblocks #1113 — when it removes DomainEventForwarder, the watcher carries the same information. 🟢 Nit-1 — document Arc clone in watch_nodes Comment explains the stream future outlives `&self` so the Arc must own its own handle. 🟢 Nit-3 — extract WATCH_EVENT_TIMEOUT constant 5-second per-event timeout in WatchNodes tests is now named, so a CI flake can be retuned in one line. 🟢 Nit-4 — document serial translation tradeoff Comment in the WatchNodes stream loop notes that a slow `get_node` delays the next `rx.recv()` and increases lag risk. Acceptable for point-reads; documents the parallelization path if telemetry forces it. Skipped (with reasoning): 🟡 #2 — source_client_id feedback-loop filter not honored: Reviewer explicitly tagged this as "worth addressing in #1113, not blocking this PR". The fix requires propagating envelope metadata through the proto, which is a contract widening best done with a consumer (which lands in #1113). #1113 already owns the SharedNodeStore idempotency audit. 🟡 #3 — Stream-close test is indirect: Reviewer acknowledged the surrogate test (verify a fresh watcher works after one drops) is acceptable and that direct observation would require invasive instrumentation. The gap is documented in the test. 🟡 #4 — Per-event get_node refetch: Reviewer explicitly said "track as separate issue if perf telemetry surfaces it" — premature without measurement. Documented as a parallelization path in Nit-4 above. 🟢 Nit-2 — IPv4/IPv6 endpoint mismatch concern: Verified daemon binds `[::1]:50051` (main.rs:24) and watcher dials the same address (watcher.rs:42). The reviewer's concern was theoretical; the existing doc comment at watcher.rs:41 already documents the match. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Address Review — SummaryPushed ✅ Addressed (4)
⏭️ Skipped (4) with reasoning
Verification
|
…) (#1145) * Implement WatchNodes gRPC streaming, add Tauri watcher.rs (closes #1114) Daemon side (live): - Replace WatchNodes Unimplemented stub with async_stream handler that subscribes to NodeService::subscribe_to_events() and translates each DomainEvent::Node{Created,Updated,Deleted} into a proto NodeEvent. - For Created/Updated, fetch the current node payload so clients get full node data inline (no follow-up GetNode round trip). - Handle broadcast lag as a warn-and-continue rather than a hard error; on channel closure, end the stream cleanly. - Add 3 integration tests: single-watcher round trip (create/update/delete), multiple concurrent watchers receiving the same event, and a fresh watcher succeeding after a prior client dropped its stream. Filter fields (WatchRequest.node_type, root_id) are accepted but ignored — the issue's Non-Goals list filtering as a future enhancement. A debug log fires when a non-default filter is requested. No ops-layer changes were needed: nodespace_core already publishes domain events via NodeService::subscribe_to_events(), so the daemon becomes a pure event consumer/translator. Tauri side (inert until #1113): - New packages/desktop-app/src-tauri/src/watcher.rs module: gRPC client that opens a WatchNodes stream against nodespaced, re-emits each proto event as a Tauri event (node:created/updated/deleted) using the same NodeIdPayload format as the existing in-process DomainEventForwarder, and reconnects with exponential backoff (1s start, 30s cap). - Module is declared in lib.rs but not spawned. Activation belongs to #1113 (Tauri → thin gRPC client migration), which will remove DomainEventForwarder and call watcher::spawn() in its place. Running both simultaneously would double-emit every node:* event. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Address review: extend NodeDeleted with node_type, doc clones/serial xlate Addresses reviewer feedback on PR #1145: 🟡 #1 — node:deleted payload contract aligned with DomainEventForwarder Extend proto `NodeDeleted` with `node_type` (carried from `DomainEvent::NodeDeleted::node_type` in the core event channel). Watcher now emits `{ id, nodeType }` for delete events, matching the in-process forwarder's payload exactly. Test asserts the field is populated. This unblocks #1113 — when it removes DomainEventForwarder, the watcher carries the same information. 🟢 Nit-1 — document Arc clone in watch_nodes Comment explains the stream future outlives `&self` so the Arc must own its own handle. 🟢 Nit-3 — extract WATCH_EVENT_TIMEOUT constant 5-second per-event timeout in WatchNodes tests is now named, so a CI flake can be retuned in one line. 🟢 Nit-4 — document serial translation tradeoff Comment in the WatchNodes stream loop notes that a slow `get_node` delays the next `rx.recv()` and increases lag risk. Acceptable for point-reads; documents the parallelization path if telemetry forces it. Skipped (with reasoning): 🟡 #2 — source_client_id feedback-loop filter not honored: Reviewer explicitly tagged this as "worth addressing in #1113, not blocking this PR". The fix requires propagating envelope metadata through the proto, which is a contract widening best done with a consumer (which lands in #1113). #1113 already owns the SharedNodeStore idempotency audit. 🟡 #3 — Stream-close test is indirect: Reviewer acknowledged the surrogate test (verify a fresh watcher works after one drops) is acceptable and that direct observation would require invasive instrumentation. The gap is documented in the test. 🟡 #4 — Per-event get_node refetch: Reviewer explicitly said "track as separate issue if perf telemetry surfaces it" — premature without measurement. Documented as a parallelization path in Nit-4 above. 🟢 Nit-2 — IPv4/IPv6 endpoint mismatch concern: Verified daemon binds `[::1]:50051` (main.rs:24) and watcher dials the same address (watcher.rs:42). The reviewer's concern was theoretical; the existing doc comment at watcher.rs:41 already documents the match. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Implements the
WatchNodesserver-streaming gRPC RPC onnodespacedso connected clients receive real-time node change events without polling. Also lands a ready-to-use Tauri-sidewatcher.rsmodule that reconnects with exponential backoff and re-emits each proto event as the samenode:created/node:updated/node:deletedTauri events the existing in-process forwarder produces — so the swap will be invisible to Svelte stores once #1113 activates it.Closes #1114.
What landed
Daemon (live):
WatchNodeshandler subscribes toNodeService::subscribe_to_events()and translates eachDomainEvent::Node{Created,Updated,Deleted}into a protoNodeEvent. Created/Updated events carry the full node payload (re-fetched server-side) so clients don't need a follow-upGetNode.packages/daemon/tests/grpc_round_trip.rs:watch_nodes_receives_create_update_delete_events— AC: "mutate via gRPC, watcher receives event"watch_nodes_supports_multiple_concurrent_watchers— AC: "multiple concurrent watchers supported"watch_nodes_closes_when_client_drops_stream— AC: "stream closes gracefully on client disconnect"Tauri (inert, activation gated on #1113):
packages/desktop-app/src-tauri/src/watcher.rs: opensWatchNodesagainstnodespaced, re-emits proto events asnode:created/updated/deletedTauri events using the sameNodeIdPayloadshape asDomainEventForwarder, with exponential backoff (1s start, 30s cap).DomainEventForwarder. Migrate Tauri command handlers to thin gRPC proxy wrappers #1113 will remove the forwarder and callwatcher::spawn()in its place.Scope notes
nodespace_corealready publishes domain events. The daemon becomes a pure event consumer/translator — noEventBusneeded on the daemon side, contrary to the issue body's suggestion.WatchRequestfilter fields (node_type,root_id) are accepted but ignored. The issue's Non-Goals list filtering as a future enhancement; a debug log fires when a non-default filter is requested.Test plan
cargo test -p nodespace-daemon— 10/10 tests passing (3 new + 7 existing)cargo test --lib -p nodespace-core -- --test-threads=2— 1182/1182 passingcargo clippy -p nodespace-daemon --all-targets -- -D warnings -D clippy::unused-async— cleancargo clippy -p nodespace-app --all-targets -- -D warnings -D clippy::unused-async— cleancargo fmt --all -- --check— cleancargo build -p nodespace-daemon— cleancargo build -p nodespace-app— cleanbun run test(frontend) — 3918/3918 passing (matches baseline of 3918/3918)🤖 Generated with Claude Code