Repository navigation
Description
Overview
When a node's type changes (e.g., task → text), the old type's properties should remain dormant rather than being orphaned or conflicting with the new type's properties. This requires implementing namespaced properties where each type's properties live under their own namespace.
Architecture Context
This issue is part of the Universal Graph Architecture (Epic #783). The original design specified namespaced properties (node.properties.task.completed), but during the hub-and-spoke transition and back, we ended up with flat properties (node.properties.completed).
Current State (Problematic)
Storage: Flat properties
{
"properties": {
"completed": true,
"due_date": "2025-01-15"
}
}Problems when type changes (e.g., task → invoice):
- Old properties (
completed,due_date) remain orphaned - If both types have same property name with different semantics (e.g.,
status), values conflict - Partial indexes for old type may still match the node
- No way to "restore" old type's data if user changes back
Current code is inconsistent:
validate_node_with_fields()(line 876) tries namespaced first, falls back to flatapply_schema_defaults_with_fields()writes flatupdate_node()merges flat properties
Target State
Storage: Namespaced properties by type
{
"properties": {
"task": {
"completed": true,
"due_date": "2025-01-15"
}
}
}When type changes to invoice:
{
"properties": {
"task": {
"completed": true,
"due_date": "2025-01-15"
},
"invoice": {
"status": "draft",
"amount": null
}
}
}Benefits:
- Old type's properties preserved (dormant, not orphaned)
- No property name conflicts between types
- Can restore previous type's data if user changes back
- Clear separation of concerns
- Partial indexes work correctly (
properties.task.completedvsproperties.invoice.status)
Acceptance Criteria
Phase 1: Core Storage Changes
- Update
apply_schema_defaults_with_fields()to write under type namespace - Update
update_node()property merge to use type namespace - Update
validate_node_with_fields()to read from type namespace (remove flat fallback) - Update
create_node()to store properties under type namespace
Phase 2: Query & Index Updates
- Update partial indexes to use namespaced paths (
properties.task.completed) - Update query patterns in
QueryServicefor namespaced access - Update any direct property access in handlers
Phase 3: Serialization/Deserialization
- Ensure
Nodestruct properly deserializes namespaced properties - Update any frontend property access patterns
- Verify MCP handlers return correct property structure
Phase 4: Quality
- All existing tests updated for namespaced properties
- New tests for type change scenarios (properties preserved)
- New tests for same-property-name different-type scenarios
- Code passes
bun run quality:fix - Tests pass (
bun run test:all)
Technical Specifications
Property Access Pattern
Writing (on create/update):
// Instead of:
props_obj.insert(field.name.clone(), value);
// Do:
let type_props = props_obj
.entry(&node.node_type)
.or_insert_with(|| json!({}));
type_props.as_object_mut()
.unwrap()
.insert(field.name.clone(), value);Reading (on validate/query):
// Instead of:
node.properties.get(&field.name)
// Do:
node.properties
.get(&node.node_type)
.and_then(|type_props| type_props.get(&field.name))Files to Modify
packages/core/src/services/node_service.rs- Property read/write logicpackages/core/src/db/surreal_store.rs- Storage layerpackages/core/src/services/query_service/mod.rs- Query patternspackages/core/src/db/schema.surql- Partial index definitions- Frontend property access (if any direct access exists)
Migration Consideration
Since this is pre-release with no users, we can:
- Reset database after implementation
- No migration strategy needed
- Update all tests to use new structure
Related Issues
- Epic Epic: Universal Graph Architecture Transition #783 - Universal Graph Architecture Transition (parent)
- Consolidate Edge Tables into Universal Edge Table #788 - Consolidate Edge Tables into Universal Edge Table (sibling)
- feat: Implement Universal Graph Architecture - eliminate spoke tables (Issue #783) #786 - Eliminate spoke tables (completed, created current flat property pattern)
Notes
- This restores the original design intent that was lost during architecture transitions
- Pre-release system with zero users - breaking changes are acceptable
- Should be coordinated with Consolidate Edge Tables into Universal Edge Table #788 (edge table consolidation) as both affect data model
Activity
malibio commentedon Jan 7, 2026
Starting implementation. Test baseline: Frontend: 3431 passed (101 test files), Rust: 678 passed.
feat: Implement namespaced properties for type-safe node type changes…
Address code review: Complete namespaced properties implementation (I…
docs: Update architecture for compound indexes and relationship table
Merge main into feature/issue-794-namespaced-properties
docs: Update architecture for compound indexes and relationship table
feat: Implement namespaced properties for type-safe node type changes…
docs: Update architecture for compound indexes and relationship table
feat: Implement namespaced properties for type-safe node type changes…
feat: Implement namespaced properties for type-safe node type changes…