~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: add vulture dead code detection as advisory release gate (#1986)
LearningCircuit9d7929e79601
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 6dc5378146..7b114212e7 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -177,9 +177,22 @@ jobs:permissions:contents: read+ # ============================================================================+ # VULTURE DEAD CODE GATE (Advisory) - Detects unreachable / unused code+ # ============================================================================+ # Scans src/ for dead code using vulture. Results are visible in the+ # Actions tab but failures do NOT block the release.+ # ============================================================================+ vulture-gate:+ needs: [version-check]+ if: needs.version-check.outputs.should_release == 'true'+ uses: ./.github/workflows/vulture-dead-code.yml+ permissions:+ contents: read+build:- needs: [version-check, release-gate, ci-gate, test-gate, e2e-test-gate, responsive-test-gate, compat-test-gate]- # test-gate (Playwright WebKit) and responsive-test-gate are advisory+ needs: [version-check, release-gate, ci-gate, test-gate, e2e-test-gate, responsive-test-gate, compat-test-gate, vulture-gate]+ # test-gate (Playwright WebKit), responsive-test-gate, and vulture-gate are advisory# release-gate, ci-gate, e2e-test-gate, and compat-test-gate are requiredif: ${{ !cancelled() && needs.release-gate.result == 'success' && needs.ci-gate.result == 'success' && needs.e2e-test-gate.result == 'success' && needs.compat-test-gate.result == 'success' }}runs-on: ubuntu-latestdiff --git a/.github/workflows/vulture-dead-code.yml b/.github/workflows/vulture-dead-code.ymlnew file mode 100644index 0000000000..0a7691da23--- /dev/null+++ b/.github/workflows/vulture-dead-code.yml@@ -0,0 +1,37 @@+name: Vulture Dead Code Detection++on:+ workflow_call: # Allows this workflow to be called by other workflows+ workflow_dispatch:++# Top-level permissions set to minimum (OSSF Scorecard Token-Permissions)+permissions: {}++jobs:+ vulture:+ runs-on: ubuntu-latest+ timeout-minutes: 5+ name: Scan for dead code+ permissions:+ contents: read++ steps:+ - name: Harden the runner (Audit all outbound calls)+ uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2+ with:+ egress-policy: audit++ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false++ - name: Set up Python+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0+ with:+ python-version: '3.11'++ - name: Install vulture+ run: pip install "vulture~=2.14"++ - name: Run vulture (src/ only)+ run: vulture src/local_deep_research/ vulture_whitelist.py --min-confidence 80diff --git a/.gitignore b/.gitignoreindex f7d5bb062b..feb1de8090 100644--- a/.gitignore+++ b/.gitignore@@ -54,6 +54,7 @@!MANIFEST.in!.pre-commit-config.yaml!eslint.config.mjs+!vulture_whitelist.py!docker-compose.ymldiff --git a/pdm.lock b/pdm.lockindex 05bd1c6bf7..562eab4621 100644--- a/pdm.lock+++ b/pdm.lock@@ -5,7 +5,7 @@groups = ["default", "dev"]strategy = ["inherit_metadata"]lock_version = "4.5.0"-content_hash = "sha256:ccdd1299161cd19b3f85762b1e22d0a6e70e9ad8b0ec607321c5512218968906"+content_hash = "sha256:925677b49db8ad0d76bff94d64410db80e4dc3a2f80eb14d9fd47ebc6f5f8a98"[[metadata.targets]]requires_python = ">=3.11,<3.15"@@ -563,13 +563,13 @@ files = [[[package]]name = "chardet"-version = "5.2.0"-requires_python = ">=3.7"+version = "6.0.0.post1"+requires_python = ">=3.10"summary = "Universal encoding detector for Python 3"groups = ["dev"]files = [- {file = "chardet-5.2.0-py3-none-any.whl", hash = "sha256:e1cf59446890a00105fe7b7912492ea04b6e6f06d4b742b2c788469e34c82970"},- {file = "chardet-5.2.0.tar.gz", hash = "sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7"},+ {file = "chardet-6.0.0.post1-py3-none-any.whl", hash = "sha256:c894a36800549adf7bb5f2af47033281b75fdfcd2aa0f0243be0ad22a52e2dcb"},+ {file = "chardet-6.0.0.post1.tar.gz", hash = "sha256:6b78048c3c97c7b2ed1fbad7a18f76f5a6547f7d34dbab536cc13887c9a92fa4"},][[package]]@@ -4414,7 +4414,7 @@ files = [[[package]]name = "pypdf"-version = "6.7.1"+version = "6.7.2"requires_python = ">=3.9"summary = "A pure-python PDF library capable of splitting, merging, cropping, and transforming PDF files"groups = ["default"]@@ -4422,8 +4422,8 @@ dependencies = ["typing-extensions>=4.0; python_version < \"3.11\"",]files = [- {file = "pypdf-6.7.1-py3-none-any.whl", hash = "sha256:a02ccbb06463f7c334ce1612e91b3e68a8e827f3cee100b9941771e6066b094e"},- {file = "pypdf-6.7.1.tar.gz", hash = "sha256:6b7a63be5563a0a35d54c6d6b550d75c00b8ccf36384be96365355e296e6b3b0"},+ {file = "pypdf-6.7.2-py3-none-any.whl", hash = "sha256:331b63cd66f63138f152a700565b3e0cebdf4ec8bec3b7594b2522418782f1f3"},+ {file = "pypdf-6.7.2.tar.gz", hash = "sha256:82a1a48de500ceea59a52a7d979f5095927ef802e4e4fac25ab862a73468acbb"},][[package]]@@ -5725,7 +5725,7 @@ files = [[[package]]name = "typer"-version = "0.24.0"+version = "0.24.1"requires_python = ">=3.10"summary = "Typer, build great CLIs. Easy to code. Based on Python type hints."groups = ["default"]@@ -5736,8 +5736,8 @@ dependencies = ["shellingham>=1.3.0",]files = [- {file = "typer-0.24.0-py3-none-any.whl", hash = "sha256:5fc435a9c8356f6160ed6e85a6301fdd6e3d8b2851da502050d1f92c5e9eddc8"},- {file = "typer-0.24.0.tar.gz", hash = "sha256:f9373dc4eff901350694f519f783c29b6d7a110fc0dcc11b1d7e353b85ca6504"},+ {file = "typer-0.24.1-py3-none-any.whl", hash = "sha256:112c1f0ce578bfb4cab9ffdabc68f031416ebcc216536611ba21f04e9aa84c9e"},+ {file = "typer-0.24.1.tar.gz", hash = "sha256:e39b4732d65fbdcde189ae76cf7cd48aeae72919dea1fdfc16593be016256b45"},][[package]]@@ -5894,7 +5894,7 @@ version = "2025.3"requires_python = ">=2"summary = "Provider of IANA time zone data"groups = ["default", "dev"]-marker = "sys_platform == \"emscripten\" or sys_platform == \"win32\" or platform_system == \"Windows\" or python_version >= \"3.9\""+marker = "sys_platform == \"win32\" or sys_platform == \"emscripten\" or platform_system == \"Windows\" or python_version >= \"3.9\""files = [{file = "tzdata-2025.3-py2.py3-none-any.whl", hash = "sha256:06a47e5700f3081aab02b2e513160914ff0694bce9947d6b76ebd6bf57cfc5d1"},{file = "tzdata-2025.3.tar.gz", hash = "sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7"},@@ -6031,6 +6031,20 @@ files = [{file = "virtualenv-20.38.0.tar.gz", hash = "sha256:94f39b1abaea5185bf7ea5a46702b56f1d0c9aa2f41a6c2b8b0af4ddc74c10a7"},]+[[package]]+name = "vulture"+version = "2.14"+requires_python = ">=3.8"+summary = "Find dead code"+groups = ["dev"]+dependencies = [+ "tomli>=1.1.0; python_version < \"3.11\"",+]+files = [+ {file = "vulture-2.14-py2.py3-none-any.whl", hash = "sha256:d9a90dba89607489548a49d557f8bac8112bd25d3cbc8aeef23e860811bd5ed9"},+ {file = "vulture-2.14.tar.gz", hash = "sha256:cb8277902a1138deeab796ec5bef7076a6e0248ca3607a3f3dee0b6d9e9b8415"},+]+[[package]]name = "weasyprint"version = "68.1"@@ -6211,13 +6225,13 @@ files = [[[package]]name = "xmltodict"-version = "1.0.3"+version = "1.0.4"requires_python = ">=3.9"summary = "Makes working with XML feel like you are working with JSON"groups = ["default"]files = [- {file = "xmltodict-1.0.3-py3-none-any.whl", hash = "sha256:35d65d5c08f2a1121df338a0c4e49ca638480fa7c1b899ded45e0759bf32e40e"},- {file = "xmltodict-1.0.3.tar.gz", hash = "sha256:3bf1f49c7836df34cf6d9cc7e690c4351f7dfff2ab0b8a1988bba4a9b9474909"},+ {file = "xmltodict-1.0.4-py3-none-any.whl", hash = "sha256:a4a00d300b0e1c59fc2bfccb53d7b2e88c32f200df138a0dd2229f842497026a"},+ {file = "xmltodict-1.0.4.tar.gz", hash = "sha256:6d94c9f834dd9e44514162799d344d815a3a4faec913717a9ecbfa5be1bb8e61"},][[package]]diff --git a/pyproject.toml b/pyproject.tomlindex 5693b7e4d5..2675d2bbbe 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -161,6 +161,7 @@ dev = ["types-toml~=0.10","types-flask~=1.1","hypothesis~=6.151",+ "vulture~=2.14",][tool.pytest.ini_options]diff --git a/src/local_deep_research/advanced_search_system/strategies/adaptive_decomposition_strategy.py b/src/local_deep_research/advanced_search_system/strategies/adaptive_decomposition_strategy.pyindex 4f475ebc1f..a2fc051aa6 100644--- a/src/local_deep_research/advanced_search_system/strategies/adaptive_decomposition_strategy.py+++ b/src/local_deep_research/advanced_search_system/strategies/adaptive_decomposition_strategy.py@@ -166,7 +166,7 @@ class AdaptiveDecompositionStrategy(BaseSearchStrategy):return final_resultdef _decide_next_step(- self, query: str, step_count: int+ self, query: str, _step_count: int) -> Optional[StepResult]:"""Decide the next step based on current knowledge.diff --git a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.pyindex 780b7fc3b3..9b32534e0c 100644--- a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py+++ b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py@@ -303,40 +303,10 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):iteration_search_dict[question] = search_resultsiteration_search_results.extend(search_results)- if False and self.use_cross_engine_filter:- self._update_progress(- f"Filtering search results for iteration {iteration}",- iteration_progress_base + 45,- {- "phase": "cross_engine_filtering",- "iteration": iteration,- },- )-- existing_link_count = len(self.all_links_of_system)- logger.info(f"Existing link count: {existing_link_count}")- filtered_search_results = self.cross_engine_filter.filter_results(- iteration_search_results,- query,- reorder=True,- reindex=True,- start_index=existing_link_count, # Start indexing after existing links- )-- self._update_progress(- f"Filtered from {len(iteration_search_results)} to {len(filtered_search_results)} results",- iteration_progress_base + 50,- {- "phase": "filtering_complete",- "iteration": iteration,- "links_count": len(self.all_links_of_system),- },- )- else:- # Use the search results as they are- filtered_search_results = iteration_search_results+ # Use the search results as they are+ filtered_search_results = iteration_search_results- # Use filtered results+ # Use filtered resultsaccumulated_search_results_across_all_iterations.extend(filtered_search_results)diff --git a/src/local_deep_research/benchmarks/metrics/visualization.py b/src/local_deep_research/benchmarks/metrics/visualization.pyindex 2a07604784..916eeafa5a 100644--- a/src/local_deep_research/benchmarks/metrics/visualization.py+++ b/src/local_deep_research/benchmarks/metrics/visualization.py@@ -122,7 +122,7 @@ def plot_parameter_importance(def plot_quality_vs_speed(quality_scores: List[float],speed_scores: List[float],- parameter_values: Optional[List[Dict[str, any]]] = None,+ _parameter_values: Optional[List[Dict[str, any]]] = None,output_file: Optional[str] = None,title: str = "Quality vs. Speed Trade-off",) -> Optional[Figure]:diff --git a/src/local_deep_research/report_generator.py b/src/local_deep_research/report_generator.pyindex ed33fc68c3..a8a5fed2f1 100644--- a/src/local_deep_research/report_generator.py+++ b/src/local_deep_research/report_generator.py@@ -441,7 +441,7 @@ class IntegratedReportGenerator:def _generate_sections(self,initial_findings: Dict,- section_research: Dict[str, List[Dict]],+ _section_research: Dict[str, List[Dict]],structure: List[Dict],query: str,) -> Dict[str, str]:diff --git a/src/local_deep_research/research_library/routes/library_routes.py b/src/local_deep_research/research_library/routes/library_routes.pyindex a8ae6c0316..f7680f33c4 100644--- a/src/local_deep_research/research_library/routes/library_routes.py+++ b/src/local_deep_research/research_library/routes/library_routes.py@@ -37,8 +37,7 @@ from ...library.download_management import ResourceFilterfrom ..services.download_service import DownloadServicefrom ..services.library_service import LibraryServicefrom ..services.pdf_storage_manager import PDFStorageManager-from ..utils import open_file_location, handle_api_error-from ...security.path_validator import PathValidator+from ..utils import handle_api_errorfrom ...utilities.db_utils import get_settings_managerfrom ...config.paths import get_library_directory@@ -587,48 +586,6 @@ def open_folder():}), 403- data = request.json- path = data.get("path")-- if not path:- return jsonify({"success": False, "error": "Path not provided"})-- try:- # Get library root path from settings (uses centralized path, respects LDR_DATA_DIR)- settings = get_settings_manager()- library_root = (- Path(- settings.get_setting(- "research_library.storage_path",- str(get_library_directory()),- )- )- .expanduser()- .resolve()- )-- # Validate the path is within library root- validated_path = PathValidator.validate_safe_path(- path, library_root, allow_absolute=False- )-- if not validated_path or not validated_path.exists():- return jsonify(- {"success": False, "error": "Invalid or non-existent path"}- )-- # Use centralized file location opener- success = open_file_location(str(validated_path))- return jsonify({"success": success})- except ValueError as e:- logger.warning(f"Path validation failed: {e}")- return jsonify({"success": False, "error": "Invalid path"})- except Exception:- logger.exception("Failed to open folder")- return jsonify(- {"success": False, "error": "An internal error has occurred."}- )-@library_bp.route("/api/download/<int:resource_id>", methods=["POST"])@login_requireddiff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.pyindex eba615d8b5..5c1ae803ec 100644--- a/src/local_deep_research/web/app_factory.py+++ b/src/local_deep_research/web/app_factory.py@@ -406,48 +406,39 @@ def create_app():# Initialize news subscription schedulertry:- # Always initialize news for now - per-user enabling will be handled in routes- if True:- # News tables are now created per-user in their encrypted databases- logger.info(- "News tables will be created in per-user encrypted databases"- )+ # News tables are now created per-user in their encrypted databases+ logger.info(+ "News tables will be created in per-user encrypted databases"+ )- # Check if scheduler is enabled BEFORE importing/initializing- # Use env registry which handles both env vars and settings- from ..settings.env_registry import get_env_setting+ # Check if scheduler is enabled BEFORE importing/initializing+ # Use env registry which handles both env vars and settings+ from ..settings.env_registry import get_env_setting- scheduler_enabled = get_env_setting("news.scheduler.enabled", True)- logger.info(f"News scheduler enabled: {scheduler_enabled}")+ scheduler_enabled = get_env_setting("news.scheduler.enabled", True)+ logger.info(f"News scheduler enabled: {scheduler_enabled}")- if scheduler_enabled:- # Only import and initialize if enabled- from ..news.subscription_manager.scheduler import (- get_news_scheduler,- )- from ..settings.manager import SettingsManager-- # Get system settings for scheduler configuration (if not already loaded)- if "settings_manager" not in locals():- settings_manager = SettingsManager()-- # Get scheduler instance and initialize with settings- scheduler = get_news_scheduler()- scheduler.initialize_with_settings(settings_manager)- scheduler.start()- app.news_scheduler = scheduler- logger.info(- "News scheduler started with activity-based tracking"- )- else:- # Don't initialize scheduler if disabled- app.news_scheduler = None- logger.info("News scheduler disabled - not initializing")- else:- logger.info(- "News module disabled - subscription scheduler not started"+ if scheduler_enabled:+ # Only import and initialize if enabled+ from ..news.subscription_manager.scheduler import (+ get_news_scheduler,)+ from ..settings.manager import SettingsManager++ # Get system settings for scheduler configuration (if not already loaded)+ if "settings_manager" not in locals():+ settings_manager = SettingsManager()++ # Get scheduler instance and initialize with settings+ scheduler = get_news_scheduler()+ scheduler.initialize_with_settings(settings_manager)+ scheduler.start()+ app.news_scheduler = scheduler+ logger.info("News scheduler started with activity-based tracking")+ else:+ # Don't initialize scheduler if disabledapp.news_scheduler = None+ logger.info("News scheduler disabled - not initializing")except Exception:logger.exception("Failed to initialize news scheduler")app.news_scheduler = Nonediff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.pyindex 4873b9ca4b..600537f456 100644--- a/src/local_deep_research/web/routes/research_routes.py+++ b/src/local_deep_research/web/routes/research_routes.py@@ -1,7 +1,5 @@import ioimport json-import platform-import subprocessfrom datetime import datetime, UTCfrom pathlib import Path@@ -954,63 +952,6 @@ def open_file_location():}), 403- data = request.json- file_path = data.get("path")-- if not file_path:- return jsonify({"status": "error", "message": "Path is required"}), 400-- # Get the user's data directory as the safe root- from ...config.paths import get_data_directory-- safe_root = Path(get_data_directory()).resolve()-- # Use centralized path validator for security- try:- from ...security.path_validator import PathValidator-- file_path = PathValidator.validate_data_path(file_path, str(safe_root))-- except Exception:- logger.exception("Path validation error")- return jsonify({"status": "error", "message": "Invalid path"}), 400-- # Check if path exists- if not file_path.exists():- return jsonify(- {"status": "error", "message": "Path does not exist"}- ), 404-- try:- if platform.system() == "Windows":- # On Windows, open the folder and select the file- if file_path.is_file():- subprocess.run(- ["explorer", "/select,", str(file_path)], check=True- )- else:- # If it's a directory, just open it- subprocess.run(["explorer", str(file_path)], check=True)- elif platform.system() == "Darwin": # macOS- # Use start_new_session to fully detach subprocess- subprocess.run(- ["open", str(file_path)], start_new_session=True, check=True- )- else: # Linux and others- # Use start_new_session to fully detach subprocess- subprocess.run(- ["xdg-open", str(file_path.parent)],- start_new_session=True,- check=True,- )-- return jsonify({"status": "success"})- except Exception:- logger.exception("Error opening a file")- return jsonify(- {"status": "error", "message": "Failed to process request"}- ), 500-@research_bp.route("/api/save_raw_config", methods=["POST"])@login_requireddiff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.pyindex ab55bf3e60..c7a502463b 100644--- a/src/local_deep_research/web/routes/settings_routes.py+++ b/src/local_deep_research/web/routes/settings_routes.py@@ -39,7 +39,6 @@ optimal experience when JavaScript is available."""import platform-import subprocessfrom typing import Any, Optional, Tuplefrom datetime import datetime, UTC, timedelta@@ -1938,53 +1937,6 @@ def open_file_location():}), 403- file_path = request.form.get("file_path")-- if not file_path:- flash("No file path provided", "error")- return redirect(url_for("settings.settings_page"))-- try:- # Use centralized path validator for security- from ...security.path_validator import PathValidator- from ...config.paths import get_data_directory-- try:- # PathValidator.validate_config_path already checks existence- resolved_path = PathValidator.validate_config_path(- file_path, get_data_directory()- )- except ValueError as e:- # The validator will raise ValueError if file doesn't exist- flash(f"Invalid file path: {str(e)}", "error")- return redirect(url_for("settings.settings_page"))-- # Get the directory containing the file- dir_path = resolved_path.parent- file_path = resolved_path # Use resolved path going forward-- # Open the directory in the file explorer- # Use subprocess.run with start_new_session to prevent zombie processes- # and file descriptor leaks from unreleased Popen handles- if platform.system() == "Windows":- subprocess.run(["explorer", str(dir_path)], check=False)- elif platform.system() == "Darwin": # macOS- subprocess.run(- ["open", str(dir_path)], start_new_session=True, check=False- )- else: # Linux- subprocess.run(- ["xdg-open", str(dir_path)], start_new_session=True, check=False- )-- flash(f"Opening folder: {dir_path}", "success")- except Exception as e:- logger.exception("Error opening folder")- flash(f"Error opening folder: {e!s}", "error")-- # Redirect back to the settings page- return redirect(url_for("settings.settings_page"))-@settings_bp.context_processordef inject_csrf_token():diff --git a/src/local_deep_research/web_search_engines/engines/meta_search_engine.py b/src/local_deep_research/web_search_engines/engines/meta_search_engine.pyindex 6c16c8656e..5f389f0a92 100644--- a/src/local_deep_research/web_search_engines/engines/meta_search_engine.py+++ b/src/local_deep_research/web_search_engines/engines/meta_search_engine.py@@ -22,7 +22,7 @@ class MetaSearchEngine(BaseSearchEngine):use_api_key_services: bool = True,max_engines_to_try: int = 3,max_filtered_results: Optional[int] = None,- engine_selection_callback=None,+ _engine_selection_callback=None,settings_snapshot: Optional[Dict[str, Any]] = None,programmatic_mode: bool = False,**kwargs,diff --git a/vulture_whitelist.py b/vulture_whitelist.pynew file mode 100644index 0000000000..1a950191aa--- /dev/null+++ b/vulture_whitelist.py@@ -0,0 +1,23 @@+"""Vulture whitelist — items listed here are ignored during dead-code scanning.++Each entry tells vulture that the name is used even though it cannot+detect a reference. Only add items that are genuine false positives+(signal handlers, event-listener signatures, abstract-method params,+intentional placeholder code, or params with keyword callers).+"""++# Signal handler callback — signature required by signal.signal()+signum # noqa: F821 (repository.py)++# SQLAlchemy 'connect' event handler — signature required by the event API+connection_record # noqa: F821 (encrypted_db.py)++# Abstract method parameters — interface contract for subclass implementations+search_data # noqa: F821 (news/core/storage.py)+news_id # noqa: F821 (news/core/storage.py)+vote_type # noqa: F821 (news/core/storage.py)++# Parameters that are unused but have keyword-argument callers (cannot rename)+bypass_cache # noqa: F821 (manager.py — callers pass bypass_cache=True)+allow_absolute # noqa: F821 (path_validator.py — callers pass allow_absolute=False)+allow_redirects # noqa: F821 (ssrf_validator.py — callers pass allow_redirects=…)