~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
chore: deprecate (but keep) dormant UploadBatch model (#4178)
LearningCircuit26cea7dac94a
diff --git a/src/local_deep_research/database/models/library.py b/src/local_deep_research/database/models/library.pyindex 0b7ae9cd88..379523ffc4 100644--- a/src/local_deep_research/database/models/library.py+++ b/src/local_deep_research/database/models/library.py@@ -5,6 +5,7 @@ Collections organize documents, with "Library" as the default collection."""import enum+import warningsfrom sqlalchemy import (JSON,@@ -142,16 +143,50 @@ class SourceType(Base):class UploadBatch(Base):"""- Tracks batches of user-uploaded files.- Groups uploads for traceability and batch operations.-- TODO: As of 2026-05 this table is dormant — no code path creates- UploadBatch rows or sets Document.upload_batch_id (declared below at- column ``upload_batch_id``). Wiring it up needs a product decision on- what defines a "batch" (per upload submit, per UI session, etc.) and- surfacing the grouping in the upload routes / UI. Schema is left in- place because it's harmless and removing it would require a migration- against every user's per-user encrypted DB.+ DEPRECATED but DO NOT DELETE. See "Why we can't drop this" below.++ A multi-round dead-code audit in 2026-05 confirmed this table is+ dormant: no code path creates ``UploadBatch`` rows or sets+ ``Document.upload_batch_id`` (declared below). Wiring it up would+ have needed a product decision on what defines a "batch" (per+ upload submit, per UI session, etc.) and surfacing the grouping in+ the upload routes / UI — neither happened. Constructing an+ ``UploadBatch`` emits a ``DeprecationWarning`` so future+ contributors don't accidentally start writing to it.++ Why we can't drop this (and the table)+ --------------------------------------+ The same audit attempted to write the table-drop migration and+ hit an irreconcilable conflict in this codebase's migration+ framework:++ * ``0001_initial_schema.py`` builds the initial schema from+ ``Base.metadata.create_all()``, so the ORM defines what+ "schema at every revision" means.+ * ``test_migrations_produce_schema_matching_models`` and+ ``test_check_schema_shows_no_missing_tables`` enforce that+ the migrated DB matches ``Base.metadata`` exactly.+ * ``test_stairway_up_down_up_per_revision`` and+ ``test_downgrade_leaves_no_residual_tables`` require that+ downgrade restores the schema that existed before the upgrade.++ The combination means you cannot drop the table from the DB+ without also removing it from the ORM, AND you cannot remove it+ from the ORM without breaking either the round-trip tests+ (because 0001 stops producing the table at pre-0010 revisions) or+ the parity tests (model and migrated schema diverge).++ A real removal needs a precursor refactor that converts+ ``0001_initial_schema.py`` to an explicit table list before the+ drop migration can be added. The benefit of finishing the drop is+ roughly 3 KB of empty-table overhead per user DB and one fewer+ ORM class. The cost is real migration risk against deployed+ encrypted DBs. The audit concluded the trade-off was not worth+ it; the deprecation here is the entire shipped fix.++ If you still want to delete this, bring fresh evidence that the+ cost/benefit has changed and read PR #4178 plus the abandoned+ "PR 11b" thread that established this constraint."""__tablename__ = "upload_batches"@@ -171,6 +206,16 @@ class UploadBatch(Base):collection = relationship("Collection", backref="upload_batches")documents = relationship("Document", backref="upload_batch")+ def __init__(self, *args, **kwargs):+ warnings.warn(+ "UploadBatch is deprecated and scheduled for removal in a "+ "follow-up release; the table is dormant and has no production "+ "writers.",+ DeprecationWarning,+ stacklevel=2,+ )+ super().__init__(*args, **kwargs)+def __repr__(self):return f"<UploadBatch(id='{self.id}', files={self.file_count}, size={self.total_size})>"diff --git a/tests/database/models/test_library_models_extended.py b/tests/database/models/test_library_models_extended.pyindex 96043576dc..ba4a826648 100644--- a/tests/database/models/test_library_models_extended.py+++ b/tests/database/models/test_library_models_extended.py@@ -739,8 +739,11 @@ class TestDocumentBlobModel:assert "DocumentBlob" in repr_str+ "ignore:UploadBatch is deprecated.*:DeprecationWarning"+)class TestUploadBatchModel:- """Tests for UploadBatch model."""+ """Tests for UploadBatch model (deprecated — see PR 11a)."""def test_create_upload_batch(self, session, collection):"""Should create an upload batch."""