docling-studio/document-parser/persistence
Pier-Jean Malandrino 70972e807a feat(#256): add /api/documents/{id}/chunks routes + ChunkService
The frontend was wired against /api/documents/{id}/chunks/* (canonical
doc-centric chunkset) but the backend never exposed those routes — the
chunk tab in the doc workspace 404'd. The domain entities (Chunk,
ChunkEdit, ChunkPush) and persistence repos already existed since #205;
what was missing was the service + API layer that connects them.

ChunkService owns all canonical chunkset invariants (sequence ordering,
soft-delete + audit log atomicity) and shares the chunker port with
AnalysisService so chunking strategy stays a single implementation.

AnalysisService grew a duck-typed promoter hook that copies the chunks
of the first successful analysis into the canonical chunkset. The hook
is idempotent so subsequent ad-hoc analyses (Studio / OCR Debug) never
overwrite hand-edited state.

Routes added (all additive, /api/documents prefix):
  GET    /{id}/chunks
  POST   /{id}/chunks
  PATCH  /{id}/chunks/{chunkId}
  DELETE /{id}/chunks/{chunkId}
  POST   /{id}/chunks/{chunkId}/split
  POST   /{id}/chunks/merge
  POST   /{id}/rechunk
  GET    /{id}/tree
  GET    /{id}/diff?store=...
  POST   /{id}/chunks/push
2026-05-07 11:09:04 +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
chunk_edit_repo.py feat(#205): promote chunks to first-class entities + audit trail 2026-05-05 09:38:39 +02:00
chunk_repo.py feat(#256): add /api/documents/{id}/chunks routes + ChunkService 2026-05-07 11:09:04 +02:00
database.py chore(#206): backfill 0.6.0 doc-centric data model 2026-05-05 09:38:39 +02:00
document_repo.py feat(#202): introduce Document lifecycle state machine 2026-05-05 09:38:39 +02:00
document_store_link_repo.py feat(#203): per (document, store) ingestion state 2026-05-05 09:38:39 +02:00
store_repo.py feat(#251): SqliteStoreRepository — update/delete/find_by_name/clear_default_except 2026-05-05 09:38:39 +02:00