docling-studio/document-parser/persistence
Pier-Jean Malandrino 4c30e5eb8f feat(#203): per (document, store) ingestion state
Introduces the data layer for multi-store ingestion. Documents can now
live in multiple stores, each with its own Ingested/Stale/Failed state.
The doc-level lifecycle (#202) becomes the aggregate over all per-store
links, computed by a pure domain function.

Domain
- Store entity (name, slug, kind, embedder, config, is_default)
- DocumentStoreLink entity with mark_ingested / mark_stale / mark_failed
  helpers
- StoreKind and DocumentStoreLinkState enums
- aggregate_lifecycle(): pure function — Failed > Stale > Ingested
  > fallback (the doc's pre-link Uploaded/Parsed/Chunked state)

Persistence
- New tables 'stores' and 'document_store_links' with the right indexes
  (doc_id, store_id, state) and a UNIQUE (doc, store) on the link
- Default 'opensearch' store seeded idempotently in init_db, embedder
  pulled from DEFAULT_EMBEDDER (fallback bge-m3)
- SqliteStoreRepository (find_by_slug, find_by_id, get_default, …)
- SqliteDocumentStoreLinkRepository with ON CONFLICT … DO UPDATE upsert

Ports
- StoreRepository and DocumentStoreLinkRepository protocols added

Tests
- 14 new tests: seed idempotency, insert/find round-trips, UNIQUE
  constraint, cascade delete with the document, every link state
  round-trips, aggregation rule with all branches

Refs #203
2026-04-29 17:08:34 +02:00
..
__init__.py Radical architecture change, migration to a more lightweight 2026-03-17 16:06:27 +01:00
analysis_repo.py feat(reasoning): reasoning-trace viewer v1 with SQLite-backed graph 2026-04-29 14:00:00 +02:00
database.py feat(#203): per (document, store) ingestion state 2026-04-29 17:08:34 +02:00
document_repo.py feat(#202): introduce Document lifecycle state machine 2026-04-29 15:34:25 +02:00
document_store_link_repo.py feat(#203): per (document, store) ingestion state 2026-04-29 17:08:34 +02:00
store_repo.py feat(#203): per (document, store) ingestion state 2026-04-29 17:08:34 +02:00