Repository navigation
Closed
Labels
Description
Overview
Implement the DateNodeBehavior for handling date nodes with deterministic IDs and date validation.
Prerequisites
Before starting this issue:
- Read Node Behavior System documentation
- Read Database Schema documentation - Date Nodes section
- Review Define Node data structures and models #99
- Review Implement NodeBehavior trait system for extensible node types #100
Implementation Tasks
- Create
DateNodeBehaviorstruct implementingNodeBehaviortrait - Implement date format validation using regex (
YYYY-MM-DD) - Add date validity check using
chrono::NaiveDate - Implement
create_date_nodehelper for deterministic date node creation - Validate that content matches ID
- Set default metadata for date nodes
- Implement deletion behavior (orphan children)
- Add comprehensive unit tests for date validation and creation
Acceptance Criteria
-
DateNodeBehaviorproperly implements allNodeBehaviortrait methods - Date validation uses regex pattern
^\d{4}-\d{2}-\d{2}$ - Invalid dates (e.g.,
2024-13-45) are rejected using chrono validation - Node ID matches content exactly (both are
YYYY-MM-DD) -
create_date_nodehelper creates valid date nodes with deterministic IDs - Default metadata includes timezone and is_holiday fields
- Deletion behavior orphans children (doesn't cascade delete)
- Unit tests cover valid dates, invalid formats, and edge cases
- Code follows Rust best practices and passes
cargo clippy
Technical Specifications
Implementation Pattern:
pub struct DateNodeBehavior;
impl NodeBehavior for DateNodeBehavior {
fn type_name(&self) -> &'static str {
"date"
}
fn validate(&self, node: &Node) -> Result<(), ValidationError> {
// Validate YYYY-MM-DD format using regex
// Validate actual date validity using chrono
// Ensure content matches ID
}
fn can_have_children(&self) -> bool {
true // Dates can contain events, tasks, etc.
}
fn supports_markdown(&self) -> bool {
false // Dates are simple identifiers
}
fn default_metadata(&self) -> Value {
json!({
"is_holiday": false,
"timezone": "UTC"
})
}
}
impl DateNodeBehavior {
pub fn create_date_node(date: &str) -> Result<Node, ProcessingError> {
// Validate and create date node with deterministic ID
}
}Date Node Design:
- ID format:
YYYY-MM-DD(e.g.,2024-01-15) - NOdate:prefix - Content: Matches ID exactly
- Deterministic: Same date always produces same node ID
- No embeddings:
embedding_vectoris alwaysNone - No complementary table: Uses only universal
nodestable
Validation Requirements:
- Regex:
^\d{4}-\d{2}-\d{2}$(format check) - Chrono:
NaiveDate::parse_from_str(validity check) - Content == ID (consistency check)
Dependencies:
- regex for pattern matching (use
lazy_staticfor compiled patterns) - chrono with serde features for date parsing
- serde_json for metadata
- Node struct from Define Node data structures and models #99
Testing Requirements:
- Test valid dates:
2024-01-15,2025-12-31 - Test invalid formats:
24-1-15,2024/01/15,date:2024-01-15 - Test invalid dates:
2024-13-01,2024-02-30,2024-00-15 - Test
create_date_nodehelper - Test content/ID mismatch rejection
- Test default metadata generation
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
Implementation Notes
- No
date:prefix: Unlike early designs, use cleanYYYY-MM-DDformat - No recurring field: Recurrence belongs to future
RecurringEventNodetype - No complementary table: Date nodes use only the universal
nodestable - Embeddings: Always
None- dates don't need semantic search - Lazy static: Use
lazy_staticcrate for regex pattern compilation
This provides the foundation for date-based organization in NodeSpace.
Activity