From ce11efd17c70db97d85b9cc1419e54e0b78f05cf Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Tue, 7 Oct 2025 10:54:56 +0300 Subject: [PATCH] Auto-vacuum when inserting/updating --- src/evaluations/benchmark.py | 1 - src/haiku/rag/store/repositories/document.py | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/evaluations/benchmark.py b/src/evaluations/benchmark.py index 4eb31835..055efda5 100644 --- a/src/evaluations/benchmark.py +++ b/src/evaluations/benchmark.py @@ -61,7 +61,6 @@ async def populate_db(spec: DatasetSpec) -> None: metadata=payload.metadata, ) progress.advance(task) - rag.store.vacuum() def _is_relevant_match(retrieved_uri: str | None, sample: RetrievalSample) -> bool: diff --git a/src/haiku/rag/store/repositories/document.py b/src/haiku/rag/store/repositories/document.py index ffc66a1b..dc31878d 100644 --- a/src/haiku/rag/store/repositories/document.py +++ b/src/haiku/rag/store/repositories/document.py @@ -200,6 +200,8 @@ class DocumentRepository: chunk.order = order await self.chunk_repository.create(chunk) + # Vacuum old versions after successful creation + self.store.vacuum() return created_doc except Exception: # Roll back to the captured versions and re-raise @@ -230,6 +232,8 @@ class DocumentRepository: updated_doc.id, docling_document ) + # Vacuum old versions after successful update + self.store.vacuum() return updated_doc except Exception: # Roll back to the captured versions and re-raise