~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: address review feedback on CI consolidation PR (#2207)
LearningCircuit876d77320c85
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERSindex 267605a3bc..276def2f9a 100644--- a/.github/CODEOWNERS+++ b/.github/CODEOWNERS@@ -53,7 +53,6 @@# Test workflows (excluding security-tests.yml)/.github/workflows/tests.yml @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti-/.github/workflows/api-tests.yml @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti/.github/workflows/infrastructure-tests.yml @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti/.github/workflows/library-tests.yml @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti/.github/workflows/llm-tests.yml @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpettidiff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.ymldeleted file mode 100644index 5c92226948..0000000000--- a/.github/workflows/api-tests.yml+++ /dev/null@@ -1,232 +0,0 @@-name: API Tests--on:- pull_request:- types: [opened, synchronize, reopened]- workflow_dispatch:--permissions:- contents: read--jobs:- api-tests:- runs-on: ubuntu-latest- name: REST API Tests- if: |- github.event_name == 'workflow_dispatch' ||- (github.event_name == 'pull_request' && (github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'dev'))-- services:- # Add any external services the API needs for testing- redis:- image: redis:alpine@sha256:8360960f5fb56a282d78686203dd875862cd4b52a4184c17ac753690252d6d31 # redis:alpine- options: >-- --health-cmd "redis-cli ping"- --health-interval 10s- --health-timeout 5s- --health-retries 5-- 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.12'-- - name: Set up PDM- uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4- with:- python-version: '3.12'-- - name: Install system dependencies for SQLCipher- run: |- sudo apt-get update- sudo apt-get install -y libsqlcipher-dev-- - name: Install dependencies- run: |- # Install in development mode to ensure all modules are available- pdm sync -d- # Install additional dependencies for HTTP examples- pdm add beautifulsoup4- # Verify the package is installed correctly- pdm run python -c "import local_deep_research; print('Package imported:', local_deep_research.__file__)"- pdm run python -c "import local_deep_research.utilities.search_cache; print('Search cache module imported successfully')"- pdm run python -c "import bs4; print('BeautifulSoup imported successfully')"-- - name: Start server for API unit tests- run: |- export CI=true- export LDR_USE_FALLBACK_LLM=true- export DISABLE_RATE_LIMITING=true- export PYTHONPATH=$PWD/src:$PYTHONPATH- echo "Starting server for API unit tests..."- pdm run python -m local_deep_research.web.app 2>&1 | tee server.log &- SERVER_PID=$!-- # Wait for server to start- for i in {1..30}; do- if curl -s http://localhost:5000/api/v1/health > /dev/null; then- echo "Server started successfully after $i seconds"- break- fi- if ! kill -0 $SERVER_PID 2>/dev/null; then- echo "Server process died!"- echo "Server log:"- cat server.log- exit 1- fi- sleep 1- done-- # Final check- if ! curl -s http://localhost:5000/api/v1/health > /dev/null; then- echo "Server failed to start after 30 seconds"- echo "Server log:"- cat server.log- exit 1- fi-- # Save PID for cleanup- echo $SERVER_PID > server.pid-- - name: Run API unit tests- run: |- export LDR_USE_FALLBACK_LLM=true- pdm run pytest tests/api_tests/ -v --cov=src/local_deep_research/api --cov-report=term-- - name: Run Programmatic API tests- run: |- export LDR_USE_FALLBACK_LLM=true- pdm run pytest tests/programmatic_access/ -v --cov=src/local_deep_research/api --cov-append --cov-report=term-- - name: Stop server after unit tests- if: always()- run: |- if [ -f server.pid ]; then- kill "$(cat server.pid)" || true- rm server.pid- fi-- - name: Setup data directory- run: |- mkdir -p data- echo "Created data directory for tests"-- - name: Test server import- run: |- echo "Testing if server module can be imported..."- pdm run python -c "from local_deep_research.web.app import app; print('Import successful')" || echo "Import failed: $?"-- - name: Run API integration tests with health checks- run: |- # Start server in background for API testing- echo "Starting web server..."- echo "Current directory: $(pwd)"- echo "Python executable: $(which python)"- echo "PDM executable: $(which pdm)"-- # Try to start the server with more debugging- export CI=true- export PYTHONUNBUFFERED=1- export FLASK_ENV=testing- export FLASK_DEBUG=1- export LDR_USE_FALLBACK_LLM=true-- # First check if the command exists- echo "Checking PDM scripts..."- pdm run --list || echo "PDM run --list failed"-- # Try running the server directly with Python to see the error- echo "Attempting direct Python startup..."- export DISABLE_RATE_LIMITING=true- pdm run python -m local_deep_research.web.app 2>&1 | tee server_direct.log &- DIRECT_PID=$!- sleep 2-- if kill -0 $DIRECT_PID 2>/dev/null; then- echo "Direct Python startup succeeded, killing it"- kill $DIRECT_PID- else- echo "Direct Python startup failed, checking log:"- cat server_direct.log- fi-- # Now try with pdm run ldr-web- echo "Starting server with pdm run python..."- export PYTHONPATH=$PWD/src:$PYTHONPATH- pdm run python -m local_deep_research.web.app 2>&1 | tee server.log &- SERVER_PID=$!-- # Give server a moment to start logging- sleep 2-- # Check if server process is still alive- if ! kill -0 $SERVER_PID 2>/dev/null; then- echo "Server process died immediately!"- echo "Server log:"- cat server.log- exit 1- fi-- # Wait for server to start with health check- echo "Waiting for server to start..."- for i in {1..30}; do- if curl -s http://localhost:5000/api/v1/health > /dev/null; then- echo "Server started successfully after $i seconds"- break- fi- if ! kill -0 $SERVER_PID 2>/dev/null; then- echo "Server process died!"- echo "Server log:"- cat server.log- exit 1- fi- echo "Waiting for server... ($i/30)"- echo "Checking port 5000: $(netstat -tuln | grep 5000 || echo 'Not listening')"- sleep 1- done-- # Final check- if ! curl -s http://localhost:5000/api/v1/health > /dev/null; then- echo "Server failed to start after 30 seconds"- echo "Server log:"- cat server.log- exit 1- fi-- # Run health checks- pdm run python "${{ github.workspace }}/tests/health_check/test_endpoints_health.py"-- # Run API tests- pdm run python "${{ github.workspace }}/tests/api_tests/test_rest_api.py"-- # Run HTTP API Examples Tests- echo "=== Testing HTTP API Examples ==="- export LDR_USE_FALLBACK_LLM=true- export PYTHONPATH="${{ github.workspace }}/src:$PYTHONPATH"-- pdm run python "${{ github.workspace }}/tests/api_tests/test_http_examples.py" || {- echo "❌ HTTP API Examples tests failed"- exit 1- }- echo "🎉 All HTTP API Examples tests passed!"-- # Clean up- kill $SERVER_PID || true-- - name: Upload API test results- if: always()- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0- with:- name: api-test-results- path: tests/api_tests/results/diff --git a/.github/workflows/mypy-type-check.yml b/.github/workflows/mypy-type-check.ymlindex 94c8296dff..5efefead0d 100644--- a/.github/workflows/mypy-type-check.yml+++ b/.github/workflows/mypy-type-check.yml@@ -38,6 +38,16 @@ jobs:run: |pip install pdm==2.26.2+ - name: Cache PDM dependencies+ uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3+ with:+ path: |+ ~/.cache/pdm+ .venv+ key: pdm-${{ runner.os }}-${{ hashFiles('pdm.lock') }}+ restore-keys: |+ pdm-${{ runner.os }}-+- name: Install project dependenciesrun: |pdm install --prod --no-selfdiff --git a/.github/workflows/puppeteer-e2e-tests.yml b/.github/workflows/puppeteer-e2e-tests.ymlindex de0259cccf..321cf344d2 100644--- a/.github/workflows/puppeteer-e2e-tests.yml+++ b/.github/workflows/puppeteer-e2e-tests.yml@@ -35,6 +35,11 @@ jobs:LABEL_NAME: ${{ github.event.label.name || 'manual' }}steps:+ - name: Harden the runner (Audit all outbound calls)+ uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2+ with:+ egress-policy: audit+- name: Checkout repositoryuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:diff --git a/docs/CI_CD_INFRASTRUCTURE.md b/docs/CI_CD_INFRASTRUCTURE.mdindex 83417a1e9e..5e92b4ca2a 100644--- a/docs/CI_CD_INFRASTRUCTURE.md+++ b/docs/CI_CD_INFRASTRUCTURE.md@@ -83,7 +83,6 @@ pre-commit install-hooks| Workflow | Trigger | Purpose ||----------|---------|---------|| `docker-tests.yml` | PR, push | Consolidated Docker tests: pytest + coverage, UI tests (51 Puppeteer tests), LLM tests, infrastructure tests (single Docker build shared across all jobs). Includes tests previously in critical-ui-tests, extended-ui-tests, metrics-analytics-tests, library-ui-tests, mobile-ui-tests, and news-tests workflows. |-| `api-tests.yml` | PR, push | API endpoint testing || `e2e-research-test.yml` | PR, push | End-to-end research flow || `fuzz.yml` | Schedule | Fuzzing tests |diff --git a/src/local_deep_research/web/static/js/components/details.js b/src/local_deep_research/web/static/js/components/details.jsindex 85e81e2973..26f6ed726a 100644--- a/src/local_deep_research/web/static/js/components/details.js+++ b/src/local_deep_research/web/static/js/components/details.js@@ -555,7 +555,6 @@const container = document.getElementById('phase-breakdown');container.innerHTML = '';-Object.entries(timelineData.phase_stats).forEach(([phaseName, stats]) => {const item = document.createElement('div');item.className = 'ldr-phase-stat-item';diff --git a/tests/api_tests/test_http_examples.py b/tests/api_tests/test_http_examples.pyindex 9320e63531..d5d22a0867 100644--- a/tests/api_tests/test_http_examples.py+++ b/tests/api_tests/test_http_examples.py@@ -1,144 +1,156 @@-#!/usr/bin/env python3"""-CI Test for HTTP API Examples+Tests for HTTP API example scripts.-This script tests the HTTP API examples to ensure they work correctly in CI.-It runs the examples with proper error handling and timeouts.+Validates that the example scripts under examples/api_usage/http/ exist,+are syntactically valid Python, and define the expected entry points.-Requirements:-- LDR server running with fallback LLM-- Beautiful Soup installed+The actual API functionality exercised by these examples is already covered+by test_rest_api.py and test_endpoints_health.py via the Flask test client."""-import sys-import os-import subprocess-import time-import requests+import astfrom pathlib import Path-# Add src directory to Python path-sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src"))---def check_server_health(base_url="http://localhost:5000", timeout=30):- """Check if the LDR server is running and healthy."""- print(f"Checking server health at {base_url}...")-- start_time = time.time()- while time.time() - start_time < timeout:- try:- response = requests.get(f"{base_url}/auth/check", timeout=5)- if response.status_code in [- 200,- 401,- ]: # 401 is expected when not authenticated- print("✅ Server is healthy")- return True- except requests.exceptions.ConnectionError:- pass-- print(- f"Waiting for server... ({int(time.time() - start_time)}/{timeout}s)"- )- time.sleep(1)+import pytest++# Root of the repository+REPO_ROOT = Path(__file__).parent.parent.parent+EXAMPLES_DIR = REPO_ROOT / "examples" / "api_usage" / "http"++# All example scripts that should be tested — single source of truth+EXAMPLE_SCRIPTS = [+ "simple_working_example.py",+ "advanced/http_api_examples.py",+ "advanced/simple_http_example.py",+]+++def _parse_example(relative_path: str) -> tuple[Path, str, ast.Module]:+ """Read and parse an example file, failing if it doesn't exist.++ Returns (path, source_text, ast_tree).+ """+ path = EXAMPLES_DIR / relative_path+ if not path.is_file():+ pytest.fail(f"Example not found: {path}")++ source = path.read_text(encoding="utf-8")+ tree = ast.parse(source, filename=str(path))+ return path, source, tree- print("❌ Server health check failed")++def _has_main_guard(tree: ast.Module) -> bool:+ """Check if an AST contains an ``if __name__ == '__main__':`` guard."""+ for node in ast.walk(tree):+ if not isinstance(node, ast.If):+ continue+ test = node.test+ if not isinstance(test, ast.Compare):+ continue+ if len(test.ops) != 1 or not isinstance(test.ops[0], ast.Eq):+ continue+ # Match both orderings:+ # __name__ == "__main__"+ # "__main__" == __name__+ left = test.left+ comparators = test.comparators+ if len(comparators) != 1:+ continue+ right = comparators[0]+ if (+ isinstance(left, ast.Name)+ and left.id == "__name__"+ and isinstance(right, ast.Constant)+ and right.value == "__main__"+ ) or (+ isinstance(right, ast.Name)+ and right.id == "__name__"+ and isinstance(left, ast.Constant)+ and left.value == "__main__"+ ):+ return Truereturn False-def run_example(example_path, timeout=300):- """Run a single HTTP example with timeout."""- print(f"\n=== Testing {example_path.name} ===")+class TestHttpExamplesExist:+ """Verify that expected HTTP example files are present."""- try:- # Run the example with timeout- result = subprocess.run(- [sys.executable, str(example_path)],- capture_output=True,- text=True,- timeout=timeout,- env={**os.environ, "LDR_USE_FALLBACK_LLM": "true"},+ def test_examples_directory_exists(self):+ assert EXAMPLES_DIR.is_dir(), (+ f"Examples directory not found: {EXAMPLES_DIR}")- print(f"Exit code: {result.returncode}")- if result.stdout:- print(f"STDOUT:\n{result.stdout}")- if result.stderr:- print(f"STDERR:\n{result.stderr}")-- # Check for success indicators- success_indicators = [- "✅ User created successfully",- "🎉 SUCCESS! API is working correctly",- "✅ Login successful",- "Research started successfully!",+ @pytest.mark.parametrize("relative_path", EXAMPLE_SCRIPTS)+ def test_example_file_exists(self, relative_path):+ path = EXAMPLES_DIR / relative_path+ assert path.is_file(), f"Missing example: {path}"+++class TestHttpExamplesSyntax:+ """Verify that example scripts are syntactically valid Python."""++ @pytest.mark.parametrize("relative_path", EXAMPLE_SCRIPTS)+ def test_example_parses(self, relative_path):+ """Each example file must be valid Python (no syntax errors)."""+ _path, _source, tree = _parse_example(relative_path)+ assert tree is not None++ @pytest.mark.parametrize("relative_path", EXAMPLE_SCRIPTS)+ def test_example_has_main_function(self, relative_path):+ """Each example script should define a main() function."""+ _path, _source, tree = _parse_example(relative_path)++ function_names = [+ node.name+ for node in ast.walk(tree)+ if isinstance(node, ast.FunctionDef)]+ assert "main" in function_names, (+ f"{relative_path} should define a main() function"+ )- if result.returncode == 0 and any(- indicator in result.stdout for indicator in success_indicators- ):- print(f"✅ {example_path.name} passed")- return True- else:- print(f"❌ {example_path.name} failed")- return False-- except subprocess.TimeoutExpired:- print(f"❌ {example_path.name} timed out after {timeout} seconds")- return False- except Exception as e:- print(f"❌ {example_path.name} failed with exception: {e}")- return False---def main():- """Run all HTTP API examples tests."""- print("=== HTTP API Examples CI Test ===")-- # Check server health first- if not check_server_health():- sys.exit(1)-- # Define examples to test- examples_dir = (- Path(__file__).parent.parent.parent / "examples" / "api_usage" / "http"- )- advanced_dir = examples_dir / "advanced"- examples_to_test = [- "simple_working_example.py",- advanced_dir / "http_api_examples.py",- # Note: We skip simple_http_example.py in CI as it takes too long- ]-- results = {}-- for example_name in examples_to_test:- example_path = examples_dir / example_name- if not example_path.exists():- print(f"⚠️ Example {example_name} not found, skipping")- continue+ @pytest.mark.parametrize("relative_path", EXAMPLE_SCRIPTS)+ def test_example_has_main_guard(self, relative_path):+ """Each example script should have an if __name__ == '__main__' guard."""+ _path, _source, tree = _parse_example(relative_path)- results[example_name] = run_example(example_path)+ assert _has_main_guard(tree), (+ f"{relative_path} should have an if __name__ == '__main__' guard"+ )- # Summary- print("\n=== Test Summary ===")- passed = sum(results.values())- total = len(results)- for example, success in results.items():- status = "✅ PASS" if success else "❌ FAIL"- print(f"{status} {example}")+class TestAdvancedExampleStructure:+ """Verify the advanced example defines expected helper classes/functions."""- print(f"\nTotal: {passed}/{total} examples passed")+ def test_ldr_client_class_defined(self):+ """The advanced example should define an LDRClient class."""+ _path, _source, tree = _parse_example("advanced/http_api_examples.py")- if passed == total:- print("🎉 All HTTP API examples tests passed!")- return 0- else:- print("❌ Some HTTP API examples tests failed!")- return 1+ class_names = [+ node.name+ for node in ast.walk(tree)+ if isinstance(node, ast.ClassDef)+ ]+ assert "LDRClient" in class_names, (+ "Advanced example should define LDRClient class"+ )++ def test_example_functions_defined(self):+ """The advanced example should define the documented example functions."""+ _path, _source, tree = _parse_example("advanced/http_api_examples.py")+ function_names = {+ node.name+ for node in ast.walk(tree)+ if isinstance(node, ast.FunctionDef)+ }-if __name__ == "__main__":- sys.exit(main())+ expected_examples = [+ "example_quick_research",+ "example_settings_management",+ "example_research_history",+ ]+ for fn in expected_examples:+ assert fn in function_names, (+ f"Advanced example should define {fn}()"+ )