Repository navigation
Closed
Labels
Description
Overview
Implement the TextNodeBehavior for handling general text content nodes with markdown support and mention extraction.
Prerequisites
Before starting this issue:
- Read Node Behavior System documentation
- Review Define Node data structures and models #99
- Review Implement NodeBehavior trait system for extensible node types #100
Implementation Tasks
- Create
TextNodeBehaviorstruct implementingNodeBehaviortrait - Implement validation logic for text nodes
- Add markdown content validation (optional feature)
- Implement mention extraction for
@node:node-idand[[node-id]]patterns - Add content processing for text normalization
- Set default metadata for text nodes
- Implement deletion behavior (clean up mentions)
- Add comprehensive unit tests for all behavior methods
Acceptance Criteria
-
TextNodeBehaviorproperly implements allNodeBehaviortrait methods - Validation prevents empty text content
- Markdown validation works when enabled in metadata
- Mention extraction correctly identifies node references in content
- Content processing handles text normalization
- Default metadata includes markdown_enabled, auto_save, word_wrap
- Deletion behavior removes mentions properly
- Unit tests cover validation, mention extraction, and edge cases
- Code follows Rust best practices and passes
cargo clippy
Technical Specifications
Implementation Pattern:
pub struct TextNodeBehavior;
impl NodeBehavior for TextNodeBehavior {
fn type_name(&self) -> &'static str {
"text"
}
fn validate(&self, node: &Node) -> Result<(), ValidationError> {
// Validate non-empty content
// Optional markdown validation if enabled
}
fn can_have_children(&self) -> bool {
true // Text nodes can contain other nodes
}
fn supports_markdown(&self) -> bool {
true
}
fn extract_mentions(&self, content: &str) -> Vec<String> {
// Pattern: @node:node-id
// Pattern: [[node-id]]
}
fn default_metadata(&self) -> Value {
json!({
"markdown_enabled": true,
"auto_save": true,
"word_wrap": true
})
}
}Mention Extraction Patterns:
@node:node-id- Explicit node references[[node-id]]- Wiki-style node links- Use regex crate for pattern matching
Dependencies:
- regex for mention extraction
- serde_json for metadata
- Node struct from Define Node data structures and models #99
Testing Requirements:
- Test empty content validation
- Test mention extraction with various patterns
- Test markdown validation (if implemented)
- Test default metadata generation
- Test behavior with edge cases (special characters, etc.)
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
- Embeddings: Leave
embedding_vectorasNone- NLP integration comes in Semantic search: validation, benchmarks, and documentation #107 and Initialize packages/nlp-engine with embedding service #108 - Regex: Use
lazy_staticfor compiled regex patterns to avoid recompilation - Validation: Focus on essential validation; markdown parsing can be basic initially
- Testing: Use standard Rust test framework with
#[cfg(test)]modules
This provides the foundation for text content management in NodeSpace.
Activity