Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

fix: never purge archived documents on he remove --dry-run

dex0shubhamb19643eceed3
diff --git a/hyperextract/cli/cli.py b/hyperextract/cli/cli.py
index e14db3d..68e27c8 100644
--- a/hyperextract/cli/cli.py
+++ b/hyperextract/cli/cli.py
@@ -1752,13 +1752,6 @@ def remove_items(
console.print()
if document:
- if purge_documents:
- from hyperextract.utils.document_store import SourceDocumentStore
-
- removed_files = SourceDocumentStore(path).purge(document)
- for f in removed_files:
- console.print(f"[dim]Archived document deleted: {f}[/dim]")
-
table = Table(title=f"Document Rollback Report — {document}")
table.add_column("Field")
table.add_column("Items")
@@ -1832,6 +1825,14 @@ def remove_items(
ka.dump(path)
+ # Only after the dry-run gate: purging is destructive and must never run
+ # on a preview.
+ if document and purge_documents:
+ from hyperextract.utils.document_store import SourceDocumentStore
+
+ for f in SourceDocumentStore(path).purge(document):
+ console.print(f"[dim]Archived document deleted: {f}[/dim]")
+
if report.get("index_patched", False):
# The vector index was patched in place and persisted by dump() —
# search stays usable without a rebuild.