DuckDBDocStore - EARS
Parent LLD: ./LLD.md
Construction and storage
- [x] DOC-DUCK-001: The system shall construct
DuckDBDocStorewith a requiredtable_name, optionalstorage_pathdefaulting to~/.llamabot/duckdb, and optionalembedding_modeldefaulting tominishlab/potion-base-8M. - [x] DOC-DUCK-002: The system shall persist the store to a single
{slugified table_name}.duckdbfile understorage_path. - [x] DOC-DUCK-003: When sentence-transformers or duckdb is missing, the system shall raise
ImportErrornamingpip install llamabot[duckdb].
Extensions and persistence
- [x] DOC-DUCK-010: The system shall load the DuckDB
vssandftsextensions, preferring pip-installedduckdb-core-ext-vssandduckdb-core-ext-ftswheels, and falling back toINSTALL/LOADif the wheels are absent. - [x] DOC-DUCK-011: The system shall set
hnsw_enable_experimental_persistence = truebefore attaching a disk-backed database so HNSW indexes can be stored in the file. - [x] DOC-DUCK-012: The optional
duckdbextra shall pin DuckDB 2.x and matching VSS/FTS extension wheels. - [x] DOC-DUCK-013: The system shall checkpoint after writes and on
close(), and shall support use as a context manager, because DuckDB WAL recovery for HNSW indexes is experimental.
Document store API
- [x] DOC-DUCK-020: The system shall implement
append,extend,retrieve, andreset. - [x] DOC-DUCK-021: When a document is already stored, the system shall skip appending it again.
- [x] DOC-DUCK-022: When the store is empty,
retrieveshall return an empty list. - [x] DOC-DUCK-023: After
reset,retrieveshall return no previously stored documents. - [x] DOC-DUCK-024: After close and reopen on the same
storage_pathandtable_name, the system shall retrieve previously stored documents. - [x] DOC-DUCK-025: When the FTS index is not incremental, after close, reopen, and append of a new document, BM25 retrieve shall return that document.
Hybrid retrieval
- [x] DOC-DUCK-030: The system shall rank documents with DuckDB FTS BM25 and vector distance, then fuse the rankings with reciprocal rank fusion.
- [x] DOC-DUCK-031: When a query matches a rare keyword in one document and a semantic paraphrase in another,
retrieveshall return both documents. - [x] DOC-DUCK-032: When a query contains quotes or punctuation, FTS retrieve shall still match the remaining alphanumeric tokens.