Repository navigation
Daemon does not suppress same-origin WatchNodes echo — frontend guesses via content-comparison heuristic instead of authoritative client identity - #1691
Conversation
…euristic (closes #1689) The daemon now tags each gRPC connection's writes with an x-ns-client-id header, scoped through NodeService::with_client(), and WatchNodes drops any broadcast whose source_client_id matches the subscribing connection's own id before it ever reaches the client. This replaces isPlausibleOwnEcho and its lastPersistedContent cache, a client-side content-comparison guess that required three rounds of tightening (#1437, #1586, #1684) for the same underlying reason ADR-026's C5 amendment already rejected a prior client-side conflict heuristic: guessing instead of adjudicating is inherently racy across an async round-trip. Every database-sourced broadcast the frontend's skip-while-editing guard now sees is guaranteed to be a genuine foreign write, so it always raises a conflict notification instead of trying to classify content. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis is a clean, well-scoped architectural fix that removes a client-side guessing heuristic in favor of daemon-side authoritative adjudication, exactly per ADR-026 C5's original intent. The implementation correctly threads client identity through the write path ( This is a net positive and I see no blockers. FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Verification of the four specific concerns raised(a) write-scoping vs. subscribe-filtering split in (b) removing (c) CLI writes still treated as foreign by a future second desktop window: Confirmed. See "Suggested Improvements" above — the CLI's interceptor is untouched and never stamps the header, so its writes carry no (d) local-agent writes correctly NOT tagged with the frontend's own client id: Confirmed. Acceptance Criteria (issue #1689)All checked:
|
…p interceptor cross-reference - NodeServiceImpl doc comment now steers future unary vs. streaming RPC handlers toward the correct client-id plumbing pattern (route() for writes, standalone client_id_header() pre-route() for subscriptions). - Cross-referenced the CLI's and desktop-app's independent, same-named DatabaseIdInterceptor structs so a future contributor doesn't assume updating one covers both; documented why the CLI's copy intentionally never stamps x-ns-client-id (one-shot process, never opens WatchNodes, so its writes should stay unsuppressed/foreign to any subscriber). - Clarified the real-transport test's window-a/window-b naming: both are the same tonic client reused with different per-request headers, since the daemon keys suppression on the header, not the transport connection. Skipped (non-blocking, from PR #1691 review): - Making the "one client id per GrpcClient lifetime" invariant type-safe instead of convention-enforced — the field is already centralized in GrpcClientInner and the risk was called out as low; a structural fix would mean restructuring interceptor construction for marginal benefit in a single-process desktop app with exactly one GrpcClient instance. - Merging the CLI and desktop-app DatabaseIdInterceptor structs into a shared helper — pre-existing duplication not introduced by this PR, out of scope; the reviewer explicitly called it "not a blocker." Co-Authored-By: Claude <[email protected]>
The pre-push gate's real-transport ADR-048 tests caught a downstream consequence of this change: optimistic_echo_race_test.rs drove writes and watched for their echo through the SAME GrpcClient, which is now architecturally impossible — the daemon suppresses a connection's own writes on its own WatchNodes stream. Rewrote both tests to use two independent GrpcClients (two TauriTestApp::connect calls against the same daemon, matching the existing pattern in cross_window_hierarchy_sync_test.rs), so a watching window observes a genuinely foreign writer's broadcasts — the scenario that remains real after this PR, per the issue's explicit multi-client carve-out. Co-Authored-By: Claude <[email protected]>
Addressed Review FeedbackAddressed (4):
Skipped (2, both explicitly non-blocking per the review):
Also found and fixed during verification (not from the review, but surfaced by the pre-push gate's real-transport test suite): Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: All changes in this round were either (a) documentation-only steering comments, (b) a straightforward two-client rewrite of an existing test file following an established pattern already used elsewhere in the same test directory, or (c) grammar fixes. No production logic changed. Full |
…t fix PR #1693 landed on main while this branch was in review and independently re-added a version-comparison guard (incomingIsNewer) to decideRemoteUpdate to fix "conflict toast on every keystroke" — but via a different, still- needed mechanism than this PR's daemon-side fix: #1693's guard protects against stale echoes from the sync service (nodespace-sync writes in-process via NodeService::with_client("sync-service"), a path this PR's x-ns-client-id gRPC header does not cover), while this PR's daemon-side suppression eliminates same-gRPC-connection echoes entirely. Resolution: kept the incomingIsNewer version guard (still needed for sync-service stale replays) but dropped the content-based isPlausibleOwnEcho/stashVersion machinery it was paired with (unreachable now that same-connection echoes never arrive at all). Updated remote-update-policy.ts's doc comment and tests to describe both mechanisms and why each is still necessary post-merge. Co-Authored-By: Claude <[email protected]>
Merge conflict resolvedRebasing on `main` surfaced a substantive conflict with #1693 (merged after this PR was reviewed): #1693 independently added a version-comparison guard (`incomingIsNewer`) to `decideRemoteUpdate` to fix the same visible symptom ("conflict toast on every keystroke"), but via a different mechanism targeting a different echo source — stale replays from `nodespace-sync`'s in-process writes (`NodeService::with_client("sync-service")`, ADR-027), which this PR's `x-ns-client-id` gRPC header does not cover (the sync service never opens a gRPC connection). Resolution: kept #1693's `incomingIsNewer` version guard (still required — it's the only remaining protection against stale sync-service replays) but dropped the content-based `isPlausibleOwnEcho`/`stashVersion` machinery it was paired with, since that's now unreachable — same-gRPC-connection echoes never arrive at all after this PR's daemon-side fix. Updated `remote-update-policy.ts`'s doc comment and tests to describe both mechanisms and why each is independently still necessary. Full `test:all` (166 files / 4098 tests) and the complete pre-push gate (gRPC round-trip + Tauri-seam ADR-048 suites) pass post-merge. |
Closes #1689