Skip to content

Complete Container Terminology Removal - Phase 2 #543

Closed

Description

@malibio

Complete Container Terminology Removal - Phase 2

Problem

Issue #533 removed container_node_id from CreateNodeParams and simplified parent-only hierarchy, but 207 references to "container" still remain in the codebase:

  • get_container_id() methods (should be get_root_id())
  • getMentioningContainers() (should be getMentioningRoots())
  • container_id variables and parameters
  • Comments and documentation using "container" terminology
  • MCP tool: update_container_from_markdown (should be update_tree_from_markdown)

Why This Matters

"Container" is confusing because it's ambiguous:

  • Does it mean parent? Root? Scope?
  • In graph-native architecture, we have parent (immediate) and root (top of tree)
  • "Container" conflates these concepts

Clean terminology:

  • Parent: Immediate parent (one level up via <-has_child<-)
  • Root: Top of tree (traverse until !EXISTS(<-has_child<-))
  • Ancestor: Any node up the tree chain

Test Baseline Status

Baseline (before implementation)

  • Test Files: 6 failed, 88 passed, 8 skipped (102 total)
  • Tests: 24 failed, 1708 passed, 102 skipped (1834 total)
  • Failing Tests:
    • HierarchyService tests (2 failures in path operations)
    • Other pre-existing failures not related to container terminology

This is a pure refactor task - no new test failures have been introduced.

Progress Summary

COMPLETED ✓

Phase 1: Core Error Types (COMPLETE - Commit 2be7423)

  • Renamed all error enum variants (Container* → Root*)
  • Updated error helper methods
  • Updated error messages and documentation
  • Updated tests for new error types
  • Result: 3 files modified, compiles with cargo check

Phase 2: Rust Backend Functions (COMPLETE - Commit b21a9a0)

  • get_container_id() → get_root_id() in NodeService and NodeOperations
  • get_nodes_by_container_id() → get_nodes_by_root_id()
  • Updated all callsites in operations/mod.rs
  • Updated local variables: container_id → root_id, final_container_id → final_root_id
  • Updated function documentation and comments
  • Verified: cargo check -p nodespace-core ✓
  • Verified: cargo check -p nodespace-app ✓
  • Result: 3 files modified, all quality checks pass

IN PROGRESS / REMAINING

Phase 3: Backend Variable Renames (~2-3 hours)

  • Complete variable renames in operations/mod.rs
  • Complete variable renames in services/node_service.rs
  • Update comments: container-level → root-level
  • packages/core/src/db/surreal_store.rs variable renames
  • Rename test file: node_service_container_test.rs → node_service_root_test.rs

Phase 4: MCP Handler Updates (~2-3 hours) - CRITICAL for external API

  • packages/core/src/mcp/handlers/markdown.rs
    • Note: container_title is PUBLIC API parameter - requires backward compatibility handling
  • packages/core/src/mcp/handlers/tools.rs
    • Implement deprecation aliases for old tool names
    • Register new tool names alongside old ones with warnings
  • packages/core/src/mcp/handlers/search.rs
  • packages/core/src/mcp/handlers/nodes.rs

Phase 5: Tauri Commands (~1-2 hours)

  • Rename command handlers in packages/desktop-app/src-tauri/src/commands/nodes.rs
  • Rename command handlers in packages/desktop-app/src-tauri/src/commands/embeddings.rs
  • Update command registrations in lib.rs

Phase 6: TypeScript Frontend (~1-2 hours)

  • Update interface methods in backend-adapter.ts
  • Both TauriAdapter and HttpAdapter implementations
  • Update invoke() calls in tauri-node-service.ts
  • Update component usage in backlinks-panel.svelte

Phase 7: Test Updates (~1-2 hours)

  • Update Rust test files (200+ test assertions)
  • Update TypeScript test utilities and integration tests

Phase 8: Documentation (~1 hour)

  • Update architecture decision records
  • Update business logic documentation
  • Review and update code comments

Scope by Layer

Backend (Rust) - 150+ references

COMPLETED:

  • ✓ Error types (ContainerCannotHaveParent → RootCannotHaveParent)
  • ✓ Core functions (get_container_id → get_root_id, get_nodes_by_container_id → get_nodes_by_root_id)

REMAINING:

  • Variable renames throughout operations/mod.rs and node_service.rs
  • MCP handlers with backward compatibility
  • Database queries (container_id fields in edges)
  • Test file names and assertions

Frontend (TypeScript) - 50+ references

REMAINING:

  • Backend adapter interface and implementations
  • Service layer method calls
  • Component usage
  • Type definitions

MCP API - CRITICAL (requires backward compatibility)

REMAINING:

  • Tool name registration with deprecation aliases
  • Parameter names in JSON schemas
  • Handler function renames

Documentation

REMAINING:

  • Architecture decision records
  • Code comments
  • Function documentation

Key Architectural Decisions

MCP Backward Compatibility Strategy

Old tool names will continue to work but log deprecation warnings:

// In tools.rs - handle_tools_call
match tool_name {
    "update_root_from_markdown" => { /* new handler */ }
    "update_container_from_markdown" => {
        // DEPRECATED ALIAS
        tracing::warn!("Tool 'update_container_from_markdown' is deprecated. Use 'update_root_from_markdown' instead.");
        // Delegate to new implementation
    }
}

Semantic Clarity

  • "Root" = top of hierarchy (traverse up parent chain until None)
  • "Parent" = immediate parent (one level up)
  • "Ancestor" = any node above in hierarchy
  • "Container" = DEPRECATED term, use "root" instead

Verification Status

Rust Compilation: ✓

  • cargo check -p nodespace-core - PASS
  • cargo check -p nodespace-app - PASS
  • cargo clippy --all-targets --all-features - PASS

Quality Checks: ✓

  • bun run quality:fix - PASS
  • No new linting issues introduced

Test Baseline: ✓

  • 24 pre-existing failures (not introduced by this refactor)
  • 1708 tests passing
  • No NEW failures introduced so far

Expected Effort

  • Phase 3: 2-3 hours (straightforward variable renames)
  • Phase 4: 2-3 hours (MCP handlers, most complex part)
  • Phase 5: 1-2 hours (Tauri command renaming)
  • Phase 6: 1-2 hours (TypeScript frontend updates)
  • Phase 7: 1-2 hours (test updates)
  • Phase 8: 1 hour (documentation)
  • Total remaining: ~10-14 hours

Acceptance Criteria Progress

From issue #543:

  • Phase 1 complete: All error types renamed
  • Phase 2 complete: Core backend functions renamed
  • Phase 3: Variable renames (partial - just critical functions done)
  • Phase 4: MCP handler updates with backward compatibility
  • Phase 5: Tauri command renames
  • Phase 6: Frontend TypeScript updates
  • Phase 7: Test updates
  • Phase 8: Documentation updates
  • Code quality: No new style/format issues introduced
  • Compiles: cargo check passes for all packages
  • Test baseline: No NEW failures vs baseline (same 24 pre-existing failures)

Next Steps for Continuation

  1. Minimal Risk Phase 3: Continue with backend variable renames (straightforward)
  2. Critical Phase 4: Implement MCP deprecation strategy for external API stability
  3. Parallel Phases 5-7: TypeScript, Tauri, and tests can be done in parallel
  4. Phase 8: Final documentation cleanup

Git History

b21a9a0 Phase 2: Rename critical Rust backend functions (get_root_id, get_nodes_by_root_id)
2be7423 Phase 1: Rename container→root in core error types and operations

Branch Info

  • Branch: feature/issue-543-container-terminology-removal
  • Status: In Progress
  • Base: main
  • Changes: 5 files modified (operations/error.rs, services/error.rs, operations/mod.rs, services/node_service.rs)

Note: This refactoring is a significant undertaking affecting 200+ references across the entire stack. The phased approach allows for incremental progress and testing at each stage to catch any issues early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions