Repository navigation
feat: Preserve created_at on same-parent reorders (Issue #795) - #796
Conversation
## Summary Differentiate between same-parent reorder and cross-parent move operations in the `move_node` function to support cloud sync and conflict resolution. ## Changes - **Same-parent reorder**: Now uses UPDATE to preserve `created_at`, update `modified_at`, and increment `version` for OCC - **Cross-parent move**: Continues to use DELETE + CREATE (new relationship gets new `created_at` and `version` reset to 1) - Added detection logic to compare current parent with target parent ## Benefits - **Sync-ready**: Preserved timestamps enable accurate conflict resolution - **OCC support**: Version increment enables optimistic concurrency control - **Distinguishable operations**: Sync systems can differentiate reorders from cross-parent moves ## Tests Added - `test_same_parent_reorder_preserves_created_at` - `test_same_parent_reorder_increments_version` - `test_cross_parent_move_creates_new_relationship` - `test_multiple_same_parent_reorders_accumulate_version` Closes #795 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review: PR #796 - Sync-ready Relationship TimestampsSummaryThis PR implements a critical optimization for cloud sync and conflict resolution by differentiating between same-parent reorders (UPDATE pattern) and cross-parent moves (DELETE + CREATE pattern). The implementation is clean, well-documented, and includes comprehensive test coverage. Recommendation: APPROVE Requirements Validation
All 6 acceptance criteria from Issue #795 are satisfied. Analysis by Review Category1. Architectural Design & IntegrityVerdict: Excellent The implementation correctly distinguishes the semantic difference between operations:
The solution is elegant - minimal code change (~50 lines of logic) with clear separation: let is_same_parent_reorder = match (&new_parent_id, ¤t_parent_id) {
(Some(new_pid), Some(cur_pid)) => new_pid == cur_pid,
(None, None) => true, // Both root - same "parent"
_ => false, // Different parents
};This pattern correctly handles all three cases: child-to-child reorder, root-to-root reorder, and any cross-parent move. 2. Functionality & CorrectnessVerdict: Correct The UPDATE query correctly:
UPDATE relationship
SET properties.order = $order,
modified_at = time::now(),
version = version + 1
WHERE in = $parent_id AND out = $node_id AND relationship_type = 'has_child';Edge case consideration: The root-level case ( 3. SecurityVerdict: No concerns No security-sensitive changes. The implementation uses parameterized queries (preventing injection) and doesn't introduce any new attack surfaces. 4. Maintainability & ReadabilityVerdict: Good
5. Testing Strategy & RobustnessVerdict: Comprehensive Four well-designed tests covering all critical scenarios:
The tests use proper timing delays ( 6. Performance & ScalabilityVerdict: Improved The implementation actually improves performance for the common case:
This reduces write amplification and transaction overhead for reordering operations. Minor ObservationsNit: Uncommitted formatting changesThere are minor formatting changes (line wrapping) in the working directory that aren't committed: - store
- .move_node(&child2.id, Some(&parent.id), None)
- .await?;
+ store.move_node(&child2.id, Some(&parent.id), None).await?;These should either be committed or reverted for consistency. Recommend running ConclusionThis is a well-implemented feature that correctly addresses the sync-readiness requirements. The code is clean, the tests are comprehensive, and the change improves both correctness and performance. The semantic distinction between reorder and move operations will be valuable for conflict resolution in the cloud sync layer. Final Verdict: APPROVE Review by Principal Engineer AI Reviewer |
malibio
left a comment
There was a problem hiding this comment.
Principal Engineer Review Complete - Recommendation: APPROVE. See detailed review comment above.
Address reviewer nit about uncommitted formatting changes. Standardize formatting per rustfmt rules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Review Feedback AddressedChanges Made✅ Applied Summary
Commits Added
All quality checks passed. PR ready for merge. 🤖 Generated with Claude Code |
* feat: Preserve created_at on same-parent reorders (Issue #795) ## Summary Differentiate between same-parent reorder and cross-parent move operations in the `move_node` function to support cloud sync and conflict resolution. ## Changes - **Same-parent reorder**: Now uses UPDATE to preserve `created_at`, update `modified_at`, and increment `version` for OCC - **Cross-parent move**: Continues to use DELETE + CREATE (new relationship gets new `created_at` and `version` reset to 1) - Added detection logic to compare current parent with target parent ## Benefits - **Sync-ready**: Preserved timestamps enable accurate conflict resolution - **OCC support**: Version increment enables optimistic concurrency control - **Distinguishable operations**: Sync systems can differentiate reorders from cross-parent moves ## Tests Added - `test_same_parent_reorder_preserves_created_at` - `test_same_parent_reorder_increments_version` - `test_cross_parent_move_creates_new_relationship` - `test_multiple_same_parent_reorders_accumulate_version` Closes #795 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * style: Apply cargo fmt formatting Address reviewer nit about uncommitted formatting changes. Standardize formatting per rustfmt rules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
* feat: Preserve created_at on same-parent reorders (Issue #795) ## Summary Differentiate between same-parent reorder and cross-parent move operations in the `move_node` function to support cloud sync and conflict resolution. ## Changes - **Same-parent reorder**: Now uses UPDATE to preserve `created_at`, update `modified_at`, and increment `version` for OCC - **Cross-parent move**: Continues to use DELETE + CREATE (new relationship gets new `created_at` and `version` reset to 1) - Added detection logic to compare current parent with target parent ## Benefits - **Sync-ready**: Preserved timestamps enable accurate conflict resolution - **OCC support**: Version increment enables optimistic concurrency control - **Distinguishable operations**: Sync systems can differentiate reorders from cross-parent moves ## Tests Added - `test_same_parent_reorder_preserves_created_at` - `test_same_parent_reorder_increments_version` - `test_cross_parent_move_creates_new_relationship` - `test_multiple_same_parent_reorders_accumulate_version` Closes #795 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * style: Apply cargo fmt formatting Address reviewer nit about uncommitted formatting changes. Standardize formatting per rustfmt rules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
* feat: Preserve created_at on same-parent reorders (Issue #795) ## Summary Differentiate between same-parent reorder and cross-parent move operations in the `move_node` function to support cloud sync and conflict resolution. ## Changes - **Same-parent reorder**: Now uses UPDATE to preserve `created_at`, update `modified_at`, and increment `version` for OCC - **Cross-parent move**: Continues to use DELETE + CREATE (new relationship gets new `created_at` and `version` reset to 1) - Added detection logic to compare current parent with target parent ## Benefits - **Sync-ready**: Preserved timestamps enable accurate conflict resolution - **OCC support**: Version increment enables optimistic concurrency control - **Distinguishable operations**: Sync systems can differentiate reorders from cross-parent moves ## Tests Added - `test_same_parent_reorder_preserves_created_at` - `test_same_parent_reorder_increments_version` - `test_cross_parent_move_creates_new_relationship` - `test_multiple_same_parent_reorders_accumulate_version` Closes #795 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * style: Apply cargo fmt formatting Address reviewer nit about uncommitted formatting changes. Standardize formatting per rustfmt rules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
Summary
created_atand incrementversionThis differentiation is critical for cloud sync and conflict resolution.
Changes Made
Modified
move_nodeinsurreal_store.rsto detect same-parent reorders and use UPDATE instead of DELETE + CREATE.Test plan
test_same_parent_reorder_preserves_created_at- verifies timestamp preservationtest_same_parent_reorder_increments_version- verifies version incrementtest_cross_parent_move_creates_new_relationship- verifies new timestamps/versiontest_multiple_same_parent_reorders_accumulate_version- verifies version accumulationAcceptance Criteria
move_nodedetects if parent is changing vs. just reorderingcreated_at, incrementsversion)modified_atupdated on both operationsversionincrements on reorder (for OCC)Test Results
Baseline:
After changes:
Closes #795
🤖 Generated with Claude Code