~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
fix(db): skip the SQLCipher integrity pragma in unencrypted-fallback mode (#6376)
Lukas Buckde12a989d5fa
diff --git a/src/local_deep_research/database/encrypted_db.py b/src/local_deep_research/database/encrypted_db.pyindex 866f0e5993..5f32a73bc4 100644--- a/src/local_deep_research/database/encrypted_db.py+++ b/src/local_deep_research/database/encrypted_db.py@@ -1324,15 +1324,21 @@ class DatabaseManager:if result.fetchone()[0] != "ok":return False- # SQLCipher integrity check- result = conn.execute(text("PRAGMA cipher_integrity_check"))- # If this returns any rows, there are HMAC failures- failures = list(result)- if failures:- logger.error(- f"Integrity check failed for {username}: {len(failures)} HMAC failures"- )- return False+ # SQLCipher integrity check. Plain SQLite (the unencrypted+ # fallback) has no cipher pages to verify and answers the+ # pragma with a closed result whose iteration raises; the+ # except below turned that into "integrity check failed"+ # for every healthy fallback database (#6357).+ if self.has_encryption:+ result = conn.execute(text("PRAGMA cipher_integrity_check"))+ # If this returns any rows, there are HMAC failures+ failures = list(result)+ if failures:+ logger.error(+ f"Integrity check failed for {username}: "+ f"{len(failures)} HMAC failures"+ )+ return Falsereturn Truediff --git a/tests/database/test_integrity_check_unencrypted_fallback.py b/tests/database/test_integrity_check_unencrypted_fallback.pynew file mode 100644index 0000000000..38383ebc9d--- /dev/null+++ b/tests/database/test_integrity_check_unencrypted_fallback.py@@ -0,0 +1,52 @@+"""``check_database_integrity`` must tell the truth in unencrypted-fallback mode.++``PRAGMA cipher_integrity_check`` ran unconditionally, also on the plain+SQLite engines used when ``LDR_BOOTSTRAP_ALLOW_UNENCRYPTED`` is set. Vanilla+SQLite answers with a closed result whose iteration raises, the ``except``+swallowed it, and every healthy fallback database reported "integrity check+failed" (#6357).+"""++from unittest.mock import patch++import pytest++MODULE = "local_deep_research.database.encrypted_db"+++def fallback_manager(tmp_path, monkeypatch):+ from local_deep_research.database.encrypted_db import DatabaseManager++ monkeypatch.setenv("LDR_BOOTSTRAP_ALLOW_UNENCRYPTED", "true")+ with (+ patch(+ f"{MODULE}.get_sqlcipher_module",+ side_effect=ImportError("No module named 'sqlcipher3'"),+ ),+ patch(f"{MODULE}.get_data_directory", return_value=tmp_path),+ ):+ manager = DatabaseManager()+ assert manager.has_encryption is False, (+ "Test requires the unencrypted fallback path"+ )+ yield manager+ manager.close_all_databases()+++def test_healthy_unencrypted_database_passes_integrity_check(+ fallback_manager,+):+ username = "fallback_user"+ fallback_manager.create_user_database(username, "test-password-123")+ fallback_manager.close_user_database(username)+ assert (+ fallback_manager.open_user_database(username, "test-password-123")+ is not None+ )++ assert fallback_manager.check_database_integrity(username) is True+++def test_unknown_user_still_fails_integrity_check(fallback_manager):+ assert fallback_manager.check_database_integrity("nobody") is False