Repository navigation
Make daemon NodeService RPCs thin: delegate collection/lifecycle/version logic to core node_ops (B3 + B4) - #1244
Conversation
…ode_ops (closes #1241) - daemon: refactor create_node, update_node, delete_node to delegate to node_ops::{create_node,update_node,delete_node} — removes inline collection resolution, lifecycle defaulting, and version auto-fetch from the gRPC layer (B3+B4 from architectural audit #1228) - core/node_ops: fix update_node to skip the NodeUpdate call when no field changes are present (only collection ops) — prevents "Update contains no changes" error on collection-only updates - daemon/tests: add 3 parity tests asserting create+collection+lifecycle, auto-fetch version, and add/remove collection membership via gRPC - agent/tools: add missing id/position fields to CreateNodeInput struct (required after InsertPosition enum was introduced in #1236) Co-Authored-By: Claude <[email protected]>
Scope note on B4 follow-upThe 11 remaining The non-negotiable B3 deliverable (create/update/delete delegation) is complete in this PR. #1243 tracks the architectural cleanup of the collection RPCs. |
malibio
left a comment
There was a problem hiding this comment.
Code Review Summary
This PR successfully achieves its primary goal: eliminating the three highest-risk violations of ADR-031 (daemon's thin-adapter contract) by delegating create_node, update_node, and delete_node to node_ops. The agent path and daemon path now share a single implementation. The change is a clear net improvement and most acceptance criteria are met.
One improvement-level finding worth addressing before merge, plus one gap in the issue's own acceptance criteria that should either be fixed in-PR or tracked explicitly.
Findings
Suggested Improvements
packages/core/src/ops/node_ops.rs, update_node — unit test coverage for the collection-only (no-field-change) path is missing from the unit test module
The new is_empty() guard added to update_node (line 243) is a behaviour change introduced in this PR, not carried forward from before. The integration test update_node_add_then_remove_collection_membership in grpc_round_trip.rs does exercise the content: None path end-to-end, which is good. However, the unit tests in node_service.rs's tests module (update_node_rpc_collection_add_then_remove) deliberately include a content: Some(...) change alongside the collection op to "so NodeUpdate is non-empty" — explicitly avoiding the is_empty branch. The pure collection-only case (no content/type/properties/lifecycle change, only add_to_collection populated) is only covered by the integration test, not the unit test. Given this is a new control-flow branch, a unit test for update_node_rpc_collection_add_then_remove without a content change would make the coverage complete at both levels.
packages/daemon/src/services/node_service.rs, imports — CreateNodeParams is no longer needed for the refactored handlers but still imported
CreateNodeParams at line 25 is only used at line 1109 (create_collection). That usage is legitimate, so this is not dead code — but worth double-checking with cargo clippy that no unused-import warning surfaces. If clippy is clean this is a non-issue.
packages/daemon/src/services/node_service.rs, update_node response — parent_id is hard-coded to String::new()
Lines 171–175: the update_node handler sets parent_id: String::new() in the NodeResponse. This is unchanged from origin/main (pre-refactor the same value was emitted), so it is not a regression introduced here. It is still a correctness gap: a caller that relies on parent_id in the update response will silently get an empty string. This is tracked as part of the broader thin-adapter cleanup (B5/B6), so acceptable to defer — but worth noting for #1242.
Nitpicks
Nit: packages/core/src/ops/node_ops.rs, create_node — lifecycle "active" special-case encoding
Lines 173–189: the if lifecycle_status != "active" guard hard-codes the default status string. This is pre-existing logic (not introduced by this PR) but it moved from the daemon into core in this change. The string "active" should ideally be a constant from the core models layer. Low priority since the issue scope is narrowly architectural, but worth a follow-up.
Nit: packages/daemon/tests/grpc_round_trip.rs, create_node_with_collection_and_lifecycle_status — test comment says "parity test" but doesn't assert parity with a direct node_ops call
The integration test verifies the RPC produces correct outputs but doesn't cross-check against a parallel node_ops::create_node call on the same service (unlike the unit test create_node_rpc_parity_with_node_ops in node_service.rs). Not a blocker — the unit test covers the parity assertion; the integration test independently validates the wire contract. Just worth aligning the comment to say "contract test" rather than "parity test" to avoid misleading reviewers.
Acceptance Criteria Verification
-
create_node,update_node,delete_nodedelegate tonode_ops— inline collection/lifecycle/version logic removed from daemon - Inline
CollectionService::newat original lines 109, 203, 212 are gone (confirmed: 11 remaining sites are all in pure-collection RPCs, not in the mutating handlers) - Errors map through
ops_error_to_status(consistent with search RPC) - Stale comment at original lines 197–199 ("would silently drop several fields") is deleted; field parity confirmed by inspection (
node_ops::update_nodehandlescontent,node_type,properties,lifecycle_status,add_to_collection,remove_from_collection) - Wire contract unchanged:
NodeResponse/DeleteNodeResponsepopulated identically (parity test + re-fetch pattern preserved) - The 11 remaining collection-RPC
CollectionService::newsites are not folded into core. The issue allows deferral with an explicit follow-up filed and referenced. No follow-up issue was filed for this. The commit message does not reference a follow-up tracking issue for B4's remaining 11 sites. This should either be addressed in-PR or a follow-up issue filed and referenced (e.g. "remaining 11CollectionService::newsites in daemon — B4 follow-up") before merge to satisfy the acceptance criterion. - No
#[allow(dead_code)], no#[deprecated], no lint suppression -
cargo testandcargo clippy— not directly observable from review but the change is structurally sound; test suite structure matches the required parity tests
Summary verdict: Approve pending the B4 follow-up issue being filed and referenced (acceptance criterion is explicit that if the 11 sites are deferred, the follow-up must be filed and referenced). The core refactoring is correct, well-tested, and a clear architectural improvement.
Review feedback addressedAddressed (2):
Skipped (3):
|
…ode_ops (closes #1241) (#1244) - daemon: refactor create_node, update_node, delete_node to delegate to node_ops::{create_node,update_node,delete_node} — removes inline collection resolution, lifecycle defaulting, and version auto-fetch from the gRPC layer (B3+B4 from architectural audit #1228) - core/node_ops: fix update_node to skip the NodeUpdate call when no field changes are present (only collection ops) — prevents "Update contains no changes" error on collection-only updates - daemon/tests: add 3 parity tests asserting create+collection+lifecycle, auto-fetch version, and add/remove collection membership via gRPC - agent/tools: add missing id/position fields to CreateNodeInput struct (required after InsertPosition enum was introduced in #1236) Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Closes #1241
Summary
create_node,update_node,delete_nodeinpackages/daemon/src/services/node_service.rsto delegate tonodespace_core::ops::node_ops::{create_node,update_node,delete_node}(ADR-031 / findings B3+B4 from Architectural audit (post-daemon + post-SQLite): structural findings & improvement plan #1228)node_opsnode_ops"would silently drop several fields" (verified false:node_ops::update_nodecovers all fields)idandpositionfields tonode_ops::CreateNodeInputso the daemon can delegate fully without losing wire-contract fieldsB4 deferral
The 3
CollectionService::newsites in the CRUD handlers (old lines 109, 203, 212) are gone. The remaining 11 sites in pure collection-management RPCs are deferred to #1243.Test plan
cargo test -p nodespace-core -p nodespace-daemon— all passcargo clippy --all-targets -- -D warnings— cleanbun run test— 131 frontend test files, no regressions🤖 Generated with Claude Code