Repository navigation
Add index-based child operations and fix sibling chain integrity - #339
Merged
Merged
Conversation
## Critical Bug Fix - Fix sibling chain integrity in delete_node() operation - Previously, deleting a node left dangling before_sibling_id references - Now properly updates next sibling to maintain chain integrity - Added comprehensive tests for delete operations (middle, first, last, with children) ## New MCP Tools (Index-Based Operations) - get_children: Get all children with 0-based indexes - get_child_at_index: Get specific child by position - insert_child_at_index: Insert child at specific position - move_child_to_index: Reorder child within siblings - get_node_tree: Get hierarchical tree structure with descendants ## Helper Functions - get_children_ordered: Follow sibling chain to build ordered list - ensure_parent_exists: Auto-create date nodes (YYYY-MM-DD format) - is_valid_date_format: Validate date strings - build_tree_node: Recursive tree builder with circular chain detection ## Date Node Auto-Creation - Date nodes (YYYY-MM-DD) now auto-create when referenced as parent_id - Example: insert_child_at_index(parent_id='2025-10-23', ...) automatically creates date container ## Tool Registration - Updated tools.rs with routing for 5 new tools - Added comprehensive JSON schemas following MCP 2024-11-05 spec - Organized tools into logical sections (CRUD, Hierarchy, Markdown, Search) ## Initialize Response - Added instructions about date nodes, node types, and hierarchy - Helps AI agents understand virtual date containers and index-based operations ## Testing - All existing tests pass (15 operation tests) - Delete operation tests verify sibling chain integrity - Quality checks pass (oxlint, clippy, prettier, svelte-check) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
## Code Review Improvements Applied ### Performance Optimization - Optimize get_children_ordered from O(n²) to O(n) using HashMap - Added clear documentation explaining the constant-time lookup optimization ### Code Style - Move chrono::NaiveDate import to top of nodes.rs file - Remove inline use statement for cleaner code organization ### Comprehensive Test Coverage Added 8 new integration tests for index-based operations: - test_insert_child_at_index_with_date_auto_creation - test_insert_child_at_index_with_invalid_date_format - test_insert_child_at_index_with_non_date_invalid_parent - test_move_child_to_index_beyond_sibling_count - test_get_node_tree_with_max_depth_1 - test_get_child_at_index_out_of_bounds - test_get_children_ordered_with_multiple_insertions - test_get_node_tree_max_depth_validation ## Critical Bug Fixes Discovered ### Fixed reorder_node() Sibling Chain Integrity - Previously: Moving a node could create circular chains or orphaned references - Now: Properly fixes the sibling chain before moving (like delete_node does) - Impact: Prevents data corruption during node reordering operations ### Fixed insert_child_at_index() Chain Integrity - Previously: Inserting at specific positions created duplicate first nodes - Now: Updates displaced node's before_sibling_id to maintain chain - Impact: HashMap-based get_children_ordered now works correctly ## Quality Verification - All quality checks pass (bun run quality:fix) - All 1,286 tests pass (100% success rate) - All 18 integration tests pass - Zero lint suppressions added - Code follows all project standards 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
5 tasks
malibio
added a commit
that referenced
this pull request
Feb 4, 2026
* Add index-based child operations and fix sibling chain integrity (#338) ## Critical Bug Fix - Fix sibling chain integrity in delete_node() operation - Previously, deleting a node left dangling before_sibling_id references - Now properly updates next sibling to maintain chain integrity - Added comprehensive tests for delete operations (middle, first, last, with children) ## New MCP Tools (Index-Based Operations) - get_children: Get all children with 0-based indexes - get_child_at_index: Get specific child by position - insert_child_at_index: Insert child at specific position - move_child_to_index: Reorder child within siblings - get_node_tree: Get hierarchical tree structure with descendants ## Helper Functions - get_children_ordered: Follow sibling chain to build ordered list - ensure_parent_exists: Auto-create date nodes (YYYY-MM-DD format) - is_valid_date_format: Validate date strings - build_tree_node: Recursive tree builder with circular chain detection ## Date Node Auto-Creation - Date nodes (YYYY-MM-DD) now auto-create when referenced as parent_id - Example: insert_child_at_index(parent_id='2025-10-23', ...) automatically creates date container ## Tool Registration - Updated tools.rs with routing for 5 new tools - Added comprehensive JSON schemas following MCP 2024-11-05 spec - Organized tools into logical sections (CRUD, Hierarchy, Markdown, Search) ## Initialize Response - Added instructions about date nodes, node types, and hierarchy - Helps AI agents understand virtual date containers and index-based operations ## Testing - All existing tests pass (15 operation tests) - Delete operation tests verify sibling chain integrity - Quality checks pass (oxlint, clippy, prettier, svelte-check) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: Apply code review improvements and fix sibling chain bugs ## Code Review Improvements Applied ### Performance Optimization - Optimize get_children_ordered from O(n²) to O(n) using HashMap - Added clear documentation explaining the constant-time lookup optimization ### Code Style - Move chrono::NaiveDate import to top of nodes.rs file - Remove inline use statement for cleaner code organization ### Comprehensive Test Coverage Added 8 new integration tests for index-based operations: - test_insert_child_at_index_with_date_auto_creation - test_insert_child_at_index_with_invalid_date_format - test_insert_child_at_index_with_non_date_invalid_parent - test_move_child_to_index_beyond_sibling_count - test_get_node_tree_with_max_depth_1 - test_get_child_at_index_out_of_bounds - test_get_children_ordered_with_multiple_insertions - test_get_node_tree_max_depth_validation ## Critical Bug Fixes Discovered ### Fixed reorder_node() Sibling Chain Integrity - Previously: Moving a node could create circular chains or orphaned references - Now: Properly fixes the sibling chain before moving (like delete_node does) - Impact: Prevents data corruption during node reordering operations ### Fixed insert_child_at_index() Chain Integrity - Previously: Inserting at specific positions created duplicate first nodes - Now: Updates displaced node's before_sibling_id to maintain chain - Impact: HashMap-based get_children_ordered now works correctly ## Quality Verification - All quality checks pass (bun run quality:fix) - All 1,286 tests pass (100% success rate) - All 18 integration tests pass - Zero lint suppressions added - Code follows all project standards 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 5, 2026
* Add index-based child operations and fix sibling chain integrity (#338) ## Critical Bug Fix - Fix sibling chain integrity in delete_node() operation - Previously, deleting a node left dangling before_sibling_id references - Now properly updates next sibling to maintain chain integrity - Added comprehensive tests for delete operations (middle, first, last, with children) ## New MCP Tools (Index-Based Operations) - get_children: Get all children with 0-based indexes - get_child_at_index: Get specific child by position - insert_child_at_index: Insert child at specific position - move_child_to_index: Reorder child within siblings - get_node_tree: Get hierarchical tree structure with descendants ## Helper Functions - get_children_ordered: Follow sibling chain to build ordered list - ensure_parent_exists: Auto-create date nodes (YYYY-MM-DD format) - is_valid_date_format: Validate date strings - build_tree_node: Recursive tree builder with circular chain detection ## Date Node Auto-Creation - Date nodes (YYYY-MM-DD) now auto-create when referenced as parent_id - Example: insert_child_at_index(parent_id='2025-10-23', ...) automatically creates date container ## Tool Registration - Updated tools.rs with routing for 5 new tools - Added comprehensive JSON schemas following MCP 2024-11-05 spec - Organized tools into logical sections (CRUD, Hierarchy, Markdown, Search) ## Initialize Response - Added instructions about date nodes, node types, and hierarchy - Helps AI agents understand virtual date containers and index-based operations ## Testing - All existing tests pass (15 operation tests) - Delete operation tests verify sibling chain integrity - Quality checks pass (oxlint, clippy, prettier, svelte-check) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: Apply code review improvements and fix sibling chain bugs ## Code Review Improvements Applied ### Performance Optimization - Optimize get_children_ordered from O(n²) to O(n) using HashMap - Added clear documentation explaining the constant-time lookup optimization ### Code Style - Move chrono::NaiveDate import to top of nodes.rs file - Remove inline use statement for cleaner code organization ### Comprehensive Test Coverage Added 8 new integration tests for index-based operations: - test_insert_child_at_index_with_date_auto_creation - test_insert_child_at_index_with_invalid_date_format - test_insert_child_at_index_with_non_date_invalid_parent - test_move_child_to_index_beyond_sibling_count - test_get_node_tree_with_max_depth_1 - test_get_child_at_index_out_of_bounds - test_get_children_ordered_with_multiple_insertions - test_get_node_tree_max_depth_validation ## Critical Bug Fixes Discovered ### Fixed reorder_node() Sibling Chain Integrity - Previously: Moving a node could create circular chains or orphaned references - Now: Properly fixes the sibling chain before moving (like delete_node does) - Impact: Prevents data corruption during node reordering operations ### Fixed insert_child_at_index() Chain Integrity - Previously: Inserting at specific positions created duplicate first nodes - Now: Updates displaced node's before_sibling_id to maintain chain - Impact: HashMap-based get_children_ordered now works correctly ## Quality Verification - All quality checks pass (bun run quality:fix) - All 1,286 tests pass (100% success rate) - All 18 integration tests pass - Zero lint suppressions added - Code follows all project standards 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 26, 2026
* Add index-based child operations and fix sibling chain integrity (#338) ## Critical Bug Fix - Fix sibling chain integrity in delete_node() operation - Previously, deleting a node left dangling before_sibling_id references - Now properly updates next sibling to maintain chain integrity - Added comprehensive tests for delete operations (middle, first, last, with children) ## New MCP Tools (Index-Based Operations) - get_children: Get all children with 0-based indexes - get_child_at_index: Get specific child by position - insert_child_at_index: Insert child at specific position - move_child_to_index: Reorder child within siblings - get_node_tree: Get hierarchical tree structure with descendants ## Helper Functions - get_children_ordered: Follow sibling chain to build ordered list - ensure_parent_exists: Auto-create date nodes (YYYY-MM-DD format) - is_valid_date_format: Validate date strings - build_tree_node: Recursive tree builder with circular chain detection ## Date Node Auto-Creation - Date nodes (YYYY-MM-DD) now auto-create when referenced as parent_id - Example: insert_child_at_index(parent_id='2025-10-23', ...) automatically creates date container ## Tool Registration - Updated tools.rs with routing for 5 new tools - Added comprehensive JSON schemas following MCP 2024-11-05 spec - Organized tools into logical sections (CRUD, Hierarchy, Markdown, Search) ## Initialize Response - Added instructions about date nodes, node types, and hierarchy - Helps AI agents understand virtual date containers and index-based operations ## Testing - All existing tests pass (15 operation tests) - Delete operation tests verify sibling chain integrity - Quality checks pass (oxlint, clippy, prettier, svelte-check) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: Apply code review improvements and fix sibling chain bugs ## Code Review Improvements Applied ### Performance Optimization - Optimize get_children_ordered from O(n²) to O(n) using HashMap - Added clear documentation explaining the constant-time lookup optimization ### Code Style - Move chrono::NaiveDate import to top of nodes.rs file - Remove inline use statement for cleaner code organization ### Comprehensive Test Coverage Added 8 new integration tests for index-based operations: - test_insert_child_at_index_with_date_auto_creation - test_insert_child_at_index_with_invalid_date_format - test_insert_child_at_index_with_non_date_invalid_parent - test_move_child_to_index_beyond_sibling_count - test_get_node_tree_with_max_depth_1 - test_get_child_at_index_out_of_bounds - test_get_children_ordered_with_multiple_insertions - test_get_node_tree_max_depth_validation ## Critical Bug Fixes Discovered ### Fixed reorder_node() Sibling Chain Integrity - Previously: Moving a node could create circular chains or orphaned references - Now: Properly fixes the sibling chain before moving (like delete_node does) - Impact: Prevents data corruption during node reordering operations ### Fixed insert_child_at_index() Chain Integrity - Previously: Inserting at specific positions created duplicate first nodes - Now: Updates displaced node's before_sibling_id to maintain chain - Impact: HashMap-based get_children_ordered now works correctly ## Quality Verification - All quality checks pass (bun run quality:fix) - All 1,286 tests pass (100% success rate) - All 18 integration tests pass - Zero lint suppressions added - Code follows all project standards 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #338