Implement YAML frontmatter for chat history metadata#20
Merged
stephen-cox merged 1 commit intomainfrom Aug 7, 2025
Merged
Conversation
This update modernizes the chat history format by replacing HTML comments with YAML frontmatter for metadata storage, while maintaining full backward compatibility with existing conversation files. ## Key Features **YAML Frontmatter Format:** - Clean, structured metadata using standard YAML frontmatter delimited by `---` - Includes: conversation_id, title, timestamps, tags, summaries_count - More extensible and readable than HTML comments **Enhanced Security & Validation:** - Comprehensive metadata validation with size limits and sanitization - Safe YAML parsing prevents code injection attacks - Input validation for titles (200 chars), tags (50 items, 100 chars each) - Conversation ID sanitization prevents path traversal **Performance Improvements:** - Optimized `list_conversations()` reads only first 1KB per file vs entire files - Significant performance boost for directories with large conversation files - Efficient title extraction without parsing full markdown content **Robust Error Handling:** - Graceful fallback from YAML to HTML comment parsing for legacy files - Specific error types with meaningful logging (no more silent failures) - Comprehensive error recovery for malformed YAML, encoding issues, invalid timestamps **Comprehensive Testing:** - 9 new test cases covering edge cases, security, performance, and error handling - Tests for malformed YAML, oversized metadata, file encoding errors - Security testing for YAML injection attempts - Performance validation for large file handling ## Backward Compatibility - Existing HTML comment format fully supported - Automatic fallback mechanisms ensure no data loss - Mixed format handling (YAML + HTML comments) - Seamless migration path for existing installations ## Technical Implementation - Added `_validate_metadata()` for comprehensive input sanitization - Extracted YAML parsing into modular, testable helper methods - Enhanced logging with structured error messages and warnings - Code quality: 84% test coverage, passes all quality checks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR modernizes Nova's chat history format by implementing YAML frontmatter for metadata storage while maintaining full backward compatibility with existing conversation files.
🎯 Key Improvements
🔧 Technical Changes
New YAML Frontmatter Format:
Security & Validation:
Performance Optimization:
list_conversations()now reads only first 1KB per file vs entire filesError Handling:
except Exception:🧪 Test Coverage
Added 9 comprehensive test cases covering:
Coverage: 84% for history.py, all 35 history tests passing
📊 Migration & Compatibility
🔍 Code Quality
Test plan
🤖 Generated with Claude Code