Skip to content

feat(storage): implement storage layer with file and SQLite backends#7

Merged
milarze merged 4 commits into
mainfrom
feat/storage-layer
Jul 2, 2026
Merged

feat(storage): implement storage layer with file and SQLite backends#7
milarze merged 4 commits into
mainfrom
feat/storage-layer

Conversation

@milarze

@milarze milarze commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Overview

Implements the storage layer as specified in specifications/01-storage-layer.md. The storage layer provides file-based persistence for recipes, signals, knowledge, and session state, with SQLite support for recipes.

Changes

  • Storage traits: Abstract interfaces for RecipesStorage, SignalStorage, KnowledgeStorage, SessionStorage, and combined Storage
  • File-based implementations:
    • FileRecipesDb: Append-only JSONL with in-memory search index
    • FileSignalLog: Daily JSONL files
    • FileKnowledgeStore: JSON files for site configs, user models, patterns
    • FileSessionStore: JSON files for session state
  • SQLite backend: SqliteRecipesDb with FTS5 full-text search
  • Config directory: Resolves via `` or ~/.do-something

Testing

  • 58 tests pass
  • Comprehensive coverage for all storage components
  • Clippy clean with -D warnings

milarze added 2 commits July 2, 2026 08:23
- Add storage traits for RecipesStorage, SignalStorage, KnowledgeStorage, SessionStorage
- Implement file-based storage (JSONL/JSON) for all components
- Add SQLite backend for recipes with FTS5 full-text search
- Support config directory resolution via $DO_SOMETHING_CONFIG or ~/.do-something
- Include comprehensive test coverage for all storage components
… only

- Remove SearchIndex, PersistedIndex, and all index-related code from
  FileRecipesDb (recipes_db.rs)
- Remove rebuild_index() from RecipesStorage trait
- Rename SQLite rebuild_index to rebuild_fts_index as a struct method
  (not part of trait)
- Add SQLite search_with_limit() for configurable result limits
- Simplify FileRecipesDb to pure append-only JSONL with O(n) search
- Fix OpenOptions import placement in signal_log.rs
- Update module documentation to clarify backend differences
- Add test for SQLite FTS rebuild
@milarze milarze force-pushed the feat/storage-layer branch from 6df25e9 to f31e5c1 Compare July 2, 2026 08:23
Security fixes:
- Add path traversal prevention in knowledge_store (domain, user_id)
- Add path traversal prevention in session_store (session_id)
- Validate inputs reject '/', '\', '..', and null bytes

Bug fixes:
- Fix race condition in FileRecipesDb with mutex lock
- Add explicit flush for write durability in all file-based stores
- Use transactions in SqliteRecipesDb for FTS consistency
- Handle URL duplicates in SqliteRecipesDb (return existing ID)

Code quality:
- Make search consistent: now searches name AND ingredients
- Add #[non_exhaustive] to StorageError enum
- Improve SQLite row parsing with explicit types

Tests: 75 tests passing (17 new tests for security and concurrency)
Comment thread src/storage/knowledge_store.rs Outdated
Comment thread src/storage/knowledge_store.rs Outdated
Comment thread src/storage/mod.rs Outdated
Comment thread src/storage/recipes_db.rs Outdated
Comment thread src/storage/recipes_db.rs Outdated
Comment thread src/storage/session_store.rs Outdated
Comment thread src/storage/signal_log.rs
- Move validate_path_component to shared file_utils module
- Use DEFAULT_TOKEN_BUDGET const instead of magic number
- Remove backend usage recommendations from docs
- Handle mutex lock poisoning gracefully without unwrap
- Add path validation documentation to signal_log
- Add file_utils tests for path component validation
@milarze milarze merged commit febd9da into main Jul 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant