Repository navigation
Closed
Labels
Description
Overview
Implement the TaskNodeBehavior for handling task nodes with status tracking, due dates, and priority management.
Prerequisites
Before starting this issue:
- Read Node Behavior System documentation
- Read Database Schema documentation - Tasks Table section
- Review Define Node data structures and models #99
- Review Implement NodeBehavior trait system for extensible node types #100
Implementation Tasks
- Create
TaskNodeBehaviorstruct implementingNodeBehaviortrait - Implement validation for task status (pending, in-progress, completed, cancelled)
- Add due_date format validation (ISO date string)
- Implement priority validation (1-4 range)
- Validate required task description in content
- Set default metadata for tasks
- Implement deletion behavior (orphan children/subtasks)
- Add comprehensive unit tests for task validation
Acceptance Criteria
-
TaskNodeBehaviorproperly implements allNodeBehaviortrait methods - Status validation restricts to valid states
- Due date validation ensures proper ISO format
- Priority validation enforces 1-4 range (1=low, 2=medium, 3=high, 4=urgent)
- Empty task descriptions are rejected
- Default metadata includes status=pending, priority=2, due_date=null
- Deletion orphans subtasks (doesn't cascade delete)
- Unit tests cover all validation rules and edge cases
- Code follows Rust best practices and passes
cargo clippy
Technical Specifications
Implementation Pattern:
pub struct TaskNodeBehavior;
impl NodeBehavior for TaskNodeBehavior {
fn type_name(&self) -> &'static str {
"task"
}
fn validate(&self, node: &Node) -> Result<(), ValidationError> {
// Validate non-empty description
// Validate status in [pending, in-progress, completed, cancelled]
// Validate due_date format if present
// Validate priority in 1-4 range if present
}
fn can_have_children(&self) -> bool {
true // Tasks can have subtasks
}
fn supports_markdown(&self) -> bool {
false // Tasks are single-line descriptions
}
fn default_metadata(&self) -> Value {
json\!({
"status": "pending",
"priority": 2, // medium priority
"due_date": null,
"assignee_id": null,
"estimated_hours": null
})
}
fn on_delete(&self, _node: &Node) -> Result<Vec<DeletionAction>, ProcessingError> {
Ok(vec\![
DeletionAction::DeleteMentions,
DeletionAction::OrphanChildren, // Subtasks become orphaned
])
}
}Metadata Schema:
{
"status": "pending" | "in-progress" | "completed" | "cancelled",
"priority": 1 | 2 | 3 | 4,
"due_date": "YYYY-MM-DD" | null,
"assignee_id": "node-id" | null,
"estimated_hours": number | null
}Validation Rules:
- Content: Must be non-empty string
- Status: Must be one of: pending, in-progress, completed, cancelled
- Due date: If present, must be valid ISO date string (YYYY-MM-DD)
- Priority: If present, must be integer 1-4
- Assignee: If present, should be valid node ID (basic string check)
Dependencies:
- chrono for date validation (optional, if validating due_date format)
- serde_json for metadata access
- Node struct from Define Node data structures and models #99
Testing Requirements:
- Test valid task with all fields
- Test minimal task (only content)
- Test invalid status values
- Test invalid priority values (0, 5, -1)
- Test invalid due_date formats
- Test empty content rejection
- Test default metadata generation
- Test deletion behavior
Related Issues
- Part of Epic EPIC: Implement built-in node behaviors #103
- Depends on Define Node data structures and models #99
- Depends on Implement NodeBehavior trait system for extensible node types #100
- Related to Initialize database schema (Pure JSON, no migrations) #102
Implementation Notes
- Embeddings: Leave
embedding_vectorasNone- NLP integration comes later - Complementary table: Tasks have a complementary
taskstable for indexed queries (created in Initialize database schema (Pure JSON, no migrations) #102) - Status transitions: This issue only validates status values; status transition logic comes later
- Subtasks: Orphaned on parent deletion (don't auto-delete) to preserve work
This provides the foundation for task management in NodeSpace.
Activity