Repository navigation
C3b: Enforce container rule (canHaveChildren) in the daemon; source the frontend UI gate from schema - #1264
Conversation
Code Review — C3b: Enforce container rule (canHaveChildren) in the daemonVerdict: Approve with one suggested improvement This is a clean, well-scoped enforcement change. All acceptance criteria from #1260 are met, all 133 Rust tests and 3876 frontend Vitest tests pass clean. The architectural intent — daemon is authoritative, frontend keeps a derived synchronous gate — is correctly implemented. FindingsSuggested Improvements
This function is the third parent-setting path in the service, alongside Granted, Rollback test is under-specified ( The test only asserts Nitpicks
Acceptance Criteria Status
Test ExecutionAll tests green:
|
…ate (closes #1260) ## Daemon enforcement - Add `NodeServiceError::NotAContainer { parent_id, node_type }` variant with constructor - `move_node`: look up new parent's behavior; reject with `NotAContainer` when `!can_have_children()` - `create_node_with_parent`: same guard in Step 2 (parent validation), using the behavior registry - Map `NotAContainer` → `OpsError::ValidationFailed` in `ops/mod.rs` - `service_error_to_status` already maps `ValidationFailed` → `InvalidArgument` via the generic path ## Frontend gate - `pluginRegistry.canHaveChildren` at `indentNode:853` remains as the synchronous UX gate - Existing rollback at lines 966-977 handles daemon rejections; confirmed it fires for non-ignorable errors ## Tests - 4 Rust integration tests: `move_node` rejects non-container parent, accepts container; same for `create_node_with_parent` - 1 daemon error-mapping test: `NotAContainer` → `InvalidArgument` - 1 Vitest parity test: every registered core plugin's `canHaveChildren` matches the Rust `can_have_children()` ground truth - 2 Vitest behavioral tests: container gate returns false for non-container prevSibling; rollback fires on non-ignorable moveNode rejection Co-Authored-By: Claude <[email protected]>
9bd6bc9 to
f79b8af
Compare
…trengthen rollback test - Add NotAContainer guard to upsert_node_with_parent (third parent-setting RPC path) - Extract behavior_for() helper on NodeService; replace 3 inline unwrap_or_else fallbacks - Rollback test: await waitForPendingMoveOperations() to drain background move, then assert depth returns to pre-indent value rather than a brittle call-count check Addresses reviewer recommendations from PR #1264. Co-Authored-By: Claude <[email protected]>
Review addressedAll three reviewer recommendations implemented: ✅ ✅ ✅ Stronger rollback test — Test now imports All tests green: 133 Rust tests, 3862 Vitest tests. |
…he frontend UI gate from schema (#1264) * C3b: Enforce container rule in daemon; add parity test for frontend gate (closes #1260) ## Daemon enforcement - Add `NodeServiceError::NotAContainer { parent_id, node_type }` variant with constructor - `move_node`: look up new parent's behavior; reject with `NotAContainer` when `!can_have_children()` - `create_node_with_parent`: same guard in Step 2 (parent validation), using the behavior registry - Map `NotAContainer` → `OpsError::ValidationFailed` in `ops/mod.rs` - `service_error_to_status` already maps `ValidationFailed` → `InvalidArgument` via the generic path ## Frontend gate - `pluginRegistry.canHaveChildren` at `indentNode:853` remains as the synchronous UX gate - Existing rollback at lines 966-977 handles daemon rejections; confirmed it fires for non-ignorable errors ## Tests - 4 Rust integration tests: `move_node` rejects non-container parent, accepts container; same for `create_node_with_parent` - 1 daemon error-mapping test: `NotAContainer` → `InvalidArgument` - 1 Vitest parity test: every registered core plugin's `canHaveChildren` matches the Rust `can_have_children()` ground truth - 2 Vitest behavioral tests: container gate returns false for non-container prevSibling; rollback fires on non-ignorable moveNode rejection Co-Authored-By: Claude <[email protected]> * Address review: guard upsert_node_with_parent, DRY behavior lookup, strengthen rollback test - Add NotAContainer guard to upsert_node_with_parent (third parent-setting RPC path) - Extract behavior_for() helper on NodeService; replace 3 inline unwrap_or_else fallbacks - Rollback test: await waitForPendingMoveOperations() to drain background move, then assert depth returns to pre-indent value rather than a brittle call-count check Addresses reviewer recommendations from PR #1264. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Closes #1260