Repository navigation
Closed
Labels
Description
Overview
Clarify when to use NodeService directly vs. creating dedicated services like SchemaService.
Problem
Current architecture has:
- TaskNode → Direct NodeService usage
- SchemaNode → Dedicated SchemaService
This appears inconsistent but is actually intentional complexity-driven differentiation.
Analysis
Complexity Comparison
| Aspect | TaskNode | SchemaNode |
|---|---|---|
| Fields | Flat (status, priority) |
Nested array (fields: Vec<SchemaField>) |
| Updates | Atomic replacement | Surgical array mutations |
| Validation | Simple type checks | Protection level enforcement |
| Side effects | None | DDL synchronization |
| Service | Direct NodeService | Dedicated SchemaService |
Why SchemaService Exists
- Array Manipulation -
add_field()appends to array, not replaces - Nested Updates -
extend_enum_field()modifiesuserValuesinside array element - Protection Rules - Prevents deletion of core fields that UI depends on
- DDL Synchronization -
sync_schema_to_database()generates SurrealDBDEFINE FIELDstatements - Transaction Integrity - Multi-step workflows (read-validate-mutate-persist-sync) encapsulated
When to Use Each Pattern
Direct NodeService Pattern:
- Simple node types with flat properties
- Atomic property updates
- No nested mutations
- Examples: TaskNode, PersonNode, ProjectNode
Dedicated Service Pattern:
- Complex node types requiring surgical operations
- Nested array/object mutations
- Domain-specific validation rules
- External system synchronization
- Example: SchemaNode → SchemaService
Solution
Add documentation explaining the service layer pattern to prevent future "why is this different?" questions.
Acceptance Criteria
- Update
/docs/architecture/business-logic/node-behavior-system.mdwith service pattern guide - Add code comments to
SchemaServiceexplaining when to create dedicated services - Document examples of both patterns
Technical Notes
This is NOT architectural inconsistency - it's appropriate separation of concerns:
- TaskNode: User-facing data entity (simple, frequent updates)
- SchemaNode: Meta-schema entity (complex, infrequent updates, system-critical)
Related Issues
- Strongly-Typed Node Structs with Direct Spoke Table Deserialization #673 (Strongly-Typed Node Structs)
Activity
malibio commentedon Nov 30, 2025
Superseded by #690 - we're deleting SchemaService entirely rather than documenting why it exists.