~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
ci: request tests for automated dependency PRs (#7757)
LearningCircuit2bff44da1ce2
diff --git a/.file-whitelist.txt b/.file-whitelist.txtindex 4bb46bdeb2..22e968d874 100644--- a/.file-whitelist.txt+++ b/.file-whitelist.txt@@ -73,6 +73,7 @@^requirements/ci-health\.in$^requirements/gitleaks-tests\.in$^requirements/mcp-extra\.in$+^requirements/pre-commit-update\.in$^requirements/semgrep\.in$^requirements/towncrier\.in$^requirements/twine\.in$diff --git a/.github/SECURITY_SCORECARD.md b/.github/SECURITY_SCORECARD.mdindex ec0730547e..1c4e9e9243 100644--- a/.github/SECURITY_SCORECARD.md+++ b/.github/SECURITY_SCORECARD.md@@ -79,7 +79,7 @@ The remaining pip commands use exact version pinning.| semgrep.yml | Install step | `python -m pip install --require-hashes --only-binary=:all: -r requirements/semgrep.txt` | Hash-pinned (Semgrep 1.181.0) || dependency-review.yml | Install step | `python -m pip install --require-hashes --only-binary=:all: -r requirements/dependency-review.txt` | Hash-pinned || release-gate.yml | Twine check | `python -m pip install --require-hashes --only-binary=:all: -r requirements/twine.txt` | Hash-pinned |-| update-precommit-hooks.yml | 35-38 | `pip install pip==25.0` `pip install pre-commit-update==0.6.1` | **Hash-pinned** |+| update-precommit-hooks.yml | Install step | `bash .github/scripts/install-precommit-update.sh` | Hash-pinned (`requirements/pre-commit-update.txt`) || validate-image-pinning.yml | 67 | `pip install pyyaml==6.0.2` | Version-pinned |> **Note:** `backwards-compatibility.yml` installs its tooling with `pdm install --dev`diff --git a/.github/actions/request-dependency-ci/action.yml b/.github/actions/request-dependency-ci/action.ymlnew file mode 100644index 0000000000..cd6c3aa008--- /dev/null+++ b/.github/actions/request-dependency-ci/action.yml@@ -0,0 +1,40 @@+name: Request dependency PR checks+description: Reconcile CI approval and test selection for dependency updates.++inputs:+ branch:+ description: Dependency update branch.+ required: true+ ecosystem:+ description: One of npm, pdm, pre-commit, or dependabot.+ required: true+ npm-directory:+ description: Updated npm directory, when applicable.+ default: '.'+ npm-directories:+ description: Optional JSON list of npm directories for a combined update.+ default: ''+ pull-request-number:+ description: Optional pull request number from a PR event.+ default: ''+ head-sha:+ description: Optional head commit from a PR event.+ default: ''+ token:+ description: Credential for workflow approval and test requests.+ required: true++runs:+ using: composite+ steps:+ - name: Reconcile dependency PR checks+ shell: bash+ env:+ GH_TOKEN: ${{ inputs.token }}+ DEPENDENCY_BRANCH: ${{ inputs.branch }}+ DEPENDENCY_ECOSYSTEM: ${{ inputs.ecosystem }}+ DEPENDENCY_NPM_DIRECTORY: ${{ inputs.npm-directory }}+ DEPENDENCY_NPM_DIRECTORIES: ${{ inputs.npm-directories }}+ DEPENDENCY_PR_NUMBER: ${{ inputs.pull-request-number }}+ DEPENDENCY_HEAD_SHA: ${{ inputs.head-sha }}+ run: python3 "$GITHUB_ACTION_PATH/scripts/request_ci.py"diff --git a/.github/actions/request-dependency-ci/scripts/request_ci.py b/.github/actions/request-dependency-ci/scripts/request_ci.pynew file mode 100644index 0000000000..4c12a77c9c--- /dev/null+++ b/.github/actions/request-dependency-ci/scripts/request_ci.py@@ -0,0 +1,335 @@+"""Reconcile dependency PR checks using GitHub metadata."""++from __future__ import annotations++import json+import os+from pathlib import PurePosixPath+import re+import subprocess+import time+from urllib.parse import quote, urlencode+++CORE_WORKFLOWS = {+ ".github/workflows/check-env-vars.yml",+ ".github/workflows/codeql.yml",+ ".github/workflows/dependency-review.yml",+ ".github/workflows/docker-tests.yml",+ ".github/workflows/file-whitelist-check.yml",+ ".github/workflows/gitleaks.yml",+ ".github/workflows/osv-scanner.yml",+ ".github/workflows/pre-commit.yml",+ ".github/workflows/mypy-type-check.yml",+ ".github/workflows/security-file-write-check.yml",+}+SELECTORS = {+ "tests": {"test:ui-full-shards"},+ "tests/puppeteer": {"test:puppeteer"},+ "tests/ui_tests": {"test:ui-full-shards"},+ "tests/ui_tests/playwright": {"test:notes", "test:webkit"},+}+SELECTOR_WORKFLOWS = {+ "test:puppeteer": ".github/workflows/puppeteer-e2e-tests.yml",+ "test:ui-full-shards": ".github/workflows/ui-full-shards.yml",+ "test:notes": ".github/workflows/playwright-notes-tests.yml",+ "test:webkit": ".github/workflows/playwright-webkit-tests.yml",+}+DEPENDABOT_FILES = {+ "pdm.lock",+ "pyproject.toml",+ "requirements/bandit.in",+ "requirements/bandit.txt",+ "requirements/bootstrap-builder.txt",+ "requirements/bootstrap-ci.txt",+ "requirements/bootstrap-runtime.txt",+ "requirements/ci-health.in",+ "requirements/ci-health.txt",+ "requirements/dependency-review.txt",+ "requirements/gitleaks-tests.in",+ "requirements/gitleaks-tests.txt",+ "requirements/mcp-extra.in",+ "requirements/mcp-extra.txt",+ "requirements/pre-commit-update.in",+ "requirements/pre-commit-update.txt",+ "requirements/semgrep.in",+ "requirements/semgrep.txt",+ "requirements/towncrier.in",+ "requirements/towncrier.txt",+ "requirements/twine.in",+ "requirements/twine.txt",+} | {+ str(PurePosixPath(directory) / filename)+ for directory in (+ ".",+ "tests",+ "tests/accessibility_tests",+ "tests/api_tests_with_login",+ "tests/infrastructure_tests",+ "tests/puppeteer",+ "tests/ui_tests",+ "tests/ui_tests/playwright",+ )+ for filename in ("package.json", "package-lock.json")+}+++class APIError(RuntimeError):+ def __init__(self, method, status):+ self.status = status+ super().__init__(f"GitHub {method} request failed (HTTP {status})")+++class GitHub:+ def request(self, method, route, payload=None):+ command = ["gh", "api", "--method", method, route]+ if payload is not None:+ command.extend(["--input", "-"])+ result = subprocess.run(+ command,+ input=json.dumps(payload) if payload is not None else None,+ capture_output=True,+ text=True,+ check=False,+ timeout=30,+ )+ if result.returncode:+ status = re.search(r"HTTP (\d{3})", result.stderr)+ raise APIError(method, int(status[1]) if status else 0)+ return json.loads(result.stdout) if result.stdout.strip() else {}++ def pages(self, route, key=None):+ separator = "&" if "?" in route else "?"+ results = []+ for page in range(1, 31):+ response = self.request(+ "GET", f"{route}{separator}per_page=100&page={page}"+ )+ batch = response[key] if key else response+ results.extend(batch)+ if len(batch) < 100:+ return results+ raise RuntimeError("GitHub pagination limit reached")+++def expected_files(ecosystem, directory):+ if ecosystem == "pdm":+ return {"pdm.lock"}+ if ecosystem == "pre-commit":+ return {".pre-commit-config.yaml"}+ if ecosystem == "dependabot":+ return DEPENDABOT_FILES+ if ecosystem != "npm":+ raise ValueError("Unknown dependency ecosystem")+ path = PurePosixPath(directory)+ if path.is_absolute() or ".." in path.parts or "\\" in directory:+ raise ValueError("Invalid npm directory")+ if str(path) != "." and path.parts[0] != "tests":+ raise ValueError("Unsupported npm directory")+ return {str(path / name) for name in ("package.json", "package-lock.json")}+++def selected_labels(files):+ labels = set()+ for filename in files:+ path = PurePosixPath(filename)+ if path.name in {"package.json", "package-lock.json"}:+ labels.update(SELECTORS.get(str(path.parent), set()))+ return labels+++def validate_pr(pr, repo, branch, ecosystem):+ author = (+ "dependabot[bot]"+ if ecosystem == "dependabot"+ else "github-actions[bot]"+ )+ return (+ pr["state"] == "open"+ and pr["base"]["ref"] == "main"+ and pr["user"]["login"] == author+ and pr["head"]["ref"] == branch+ and (pr["head"].get("repo") or {}).get("full_name") == repo+ and re.fullmatch(r"[a-f0-9]{40}", pr["head"]["sha"]) is not None+ )+++def reconcile(+ client,+ repo,+ branch,+ ecosystem,+ directory=".",+ number=None,+ expected_head=None,+ *,+ directories=None,+ attempts=36,+ sleep=time.sleep,+):+ if not re.fullmatch(r"[\w.-]+/[\w.-]+", repo) or not branch:+ raise ValueError("Repository and branch are required")+ if directories is None:+ allowed = expected_files(ecosystem, directory)+ else:+ if (+ ecosystem != "npm"+ or not isinstance(directories, list)+ or not directories+ or not all(isinstance(item, str) for item in directories)+ ):+ raise ValueError("Invalid npm directory list")+ allowed = set().union(+ *(expected_files("npm", item) for item in directories)+ )+ prefix = f"repos/{repo}"+ if number is None:+ query = urlencode(+ {+ "state": "open",+ "base": "main",+ "head": f"{repo.split('/')[0]}:{branch}",+ }+ )+ pulls = client.pages(f"{prefix}/pulls?{query}")+ if not pulls:+ return "No open dependency PR for this update"+ if len(pulls) != 1:+ raise RuntimeError("Expected one dependency PR")+ number = pulls[0]["number"]+ if not isinstance(number, int) or isinstance(number, bool) or number <= 0:+ raise ValueError("Invalid pull request number")+ pull_route = f"{prefix}/pulls/{number}"+ pr = client.request("GET", pull_route)+ if not validate_pr(pr, repo, branch, ecosystem):+ raise RuntimeError("PR metadata did not match the dependency update")+ head = pr["head"]["sha"]+ if expected_head and head != expected_head:+ return "A newer PR revision owns validation"+ files = {+ item[key]+ for item in client.pages(f"{pull_route}/files")+ for key in ("filename", "previous_filename")+ if item.get(key)+ }+ if not files:+ raise RuntimeError("PR files did not match the dependency update")+ if not files <= allowed:+ if ecosystem == "dependabot":+ return "This dependency update requires manual CI approval"+ raise RuntimeError("PR files did not match the dependency update")+ labels = selected_labels(files)+ browser_workflows = {SELECTOR_WORKFLOWS[label] for label in labels}+ query = urlencode(+ {"event": "pull_request", "branch": branch, "head_sha": head}+ )+ runs_route = f"{prefix}/actions/runs?{query}"+ requested = set()+ approved = set()+ seen = set()+ settled = 0+ for attempt in range(attempts):+ current = client.request("GET", pull_route)+ if (+ not validate_pr(current, repo, branch, ecosystem)+ or current["head"]["sha"] != head+ ):+ raise RuntimeError("PR revision changed; retry validation")+ runs = [+ run+ for run in client.pages(runs_route, "workflow_runs")+ if run["head_sha"] == head+ and run["head_branch"] == branch+ and run["event"] == "pull_request"+ and (run.get("head_repository") or {}).get("full_name") == repo+ and any(+ pull.get("number") == number+ for pull in run.get("pull_requests") or []+ )+ ]+ registered = {run["path"].split("@", 1)[0] for run in runs}+ selected = {+ run["path"].split("@", 1)[0]+ for run in runs+ if run["path"].split("@", 1)[0] in browser_workflows+ and run["conclusion"] not in {"skipped", "action_required"}+ and any(+ job["conclusion"] != "skipped"+ for job in client.pages(+ f"{prefix}/actions/runs/{run['id']}/jobs", "jobs"+ )+ )+ }+ pending = False+ for run in runs:+ if run["conclusion"] != "action_required":+ continue+ pending = True+ if run["id"] in approved:+ continue+ try:+ client.request(+ "POST", f"{prefix}/actions/runs/{run['id']}/approve"+ )+ except APIError as error:+ if error.status not in {403, 409}:+ raise+ latest = client.request(+ "GET", f"{prefix}/actions/runs/{run['id']}"+ )+ if latest["conclusion"] == "action_required":+ raise+ approved.add(run["id"])+ for label in sorted(labels - requested):+ if SELECTOR_WORKFLOWS[label] in selected:+ requested.add(label)+ continue+ route = f"{prefix}/issues/{number}/labels"+ try:+ client.request("DELETE", f"{route}/{quote(label, safe='')}")+ except APIError as error:+ if error.status != 404:+ raise+ client.request("POST", route, {"labels": [label]})+ requested.add(label)+ ids = {run["id"] for run in runs}+ if (+ CORE_WORKFLOWS <= registered+ and browser_workflows <= selected+ and not pending+ and ids == seen+ ):+ settled += 1+ if settled >= 2:+ return "Dependency PR checks are registered and approved"+ else:+ settled = 0+ seen = ids+ if attempt + 1 < attempts:+ sleep(5)+ raise RuntimeError(+ "Dependency PR checks did not become ready; retry validation"+ )+++def main():+ if not os.environ.get("GH_TOKEN"):+ raise RuntimeError("The dependency CI credential is required")+ raw_number = os.environ.get("DEPENDENCY_PR_NUMBER", "")+ result = reconcile(+ GitHub(),+ os.environ["GITHUB_REPOSITORY"],+ os.environ["DEPENDENCY_BRANCH"],+ os.environ["DEPENDENCY_ECOSYSTEM"],+ os.environ.get("DEPENDENCY_NPM_DIRECTORY", "."),+ int(raw_number) if raw_number else None,+ os.environ.get("DEPENDENCY_HEAD_SHA"),+ directories=json.loads(+ os.environ.get("DEPENDENCY_NPM_DIRECTORIES") or "null"+ ),+ )+ print(result) # noqa: T201 - Report the action's status.+++if __name__ == "__main__":+ main()diff --git a/.github/labels.yml b/.github/labels.ymlindex 5b41ee1596..e5fc764d24 100644--- a/.github/labels.yml+++ b/.github/labels.yml@@ -189,6 +189,9 @@# Workflow/control labels. These are deliberately excluded from the AI# reviewer's output allowlist.+- name: 'test:webkit'+ color: '0e8a16'+ description: 'Requests the desktop and mobile Safari Playwright suites.'- name: code-ready-preliminarycolor: 'c2e0c6'description: 'Preliminary readiness. Not human-verified; re-check before code-ready.'diff --git a/.github/scripts/install-precommit-update.sh b/.github/scripts/install-precommit-update.shnew file mode 100644index 0000000000..5d387b8e1f--- /dev/null+++ b/.github/scripts/install-precommit-update.sh@@ -0,0 +1,5 @@+#!/usr/bin/env bash+set -euo pipefail++python -m pip install --require-hashes --only-binary=:all: \+ -r requirements/pre-commit-update.txtdiff --git a/.github/workflows/README.md b/.github/workflows/README.mdindex 9c7ac1e6eb..cd90a382eb 100644--- a/.github/workflows/README.md+++ b/.github/workflows/README.md@@ -35,6 +35,45 @@ reverted: every PR paid a red required check until a maintainer applied alabel, and bot-applied labels could not even start the suite. Readinesslabels remain as review markers; they no longer have any CI effect.+## Dependency update validation++NPM, PDM, and pre-commit update workflows finish with a separate `request-ci`+job. It locates the open PR for the update branch and reconciles its checks,+including on unchanged retries. The combined NPM PR is checked against the+discovered directories, and browser suites are selected for the manifests+that actually changed.++`request-dependency-ci` uses the existing `AUTO_MERGE_PAT_TOKEN` in that job.+Reusable NPM/PDM callers must pass the credential. The job uses the workflow's+own revision and reads PR metadata; it does not install project dependencies.+It waits for the common PR workflows supplying the required checks to register,+approves pending runs for eligible manifest-only updates, and verifies that the+expected checks are present.+Run matching uses the PR's repository, number, branch, and current commit.+Incomplete registration fails with a retryable error instead of reporting a+successful request. The required pytest suite retains its automatic PR trigger.++Dependabot PRs use the same baseline pytest policy. `dependency-pr-checks.yml`+also selects the relevant browser suites from changed npm manifests using+the base workflow revision. Existing results for the same PR commit are reused.+Automatic approval uses an explicit list of Python manifests, existing CI+requirements inputs and locks, and npm manifests in the configured directories.+PRs containing other paths, including workflow/action definitions and container+build files, wait for manual CI approval; no test-selection labels are changed.+New manifest locations require updating the list through review. The custom PDM+updater runs `pdm lock` and stages only `pdm.lock`, so its narrower list matches+its output; Dependabot's Python list includes `pyproject.toml` as well.++| Updated directory | Additional test requests |+| --- | --- |+| `tests/` or `tests/ui_tests/` | `test:ui-full-shards` |+| `tests/puppeteer/` | `test:puppeteer` |+| `tests/ui_tests/playwright/` | `test:notes`, `test:webkit` |++These requests use the existing suites, including their normal CI time and API+quota usage. Other npm directories retain their normal pytest, JavaScript,+infrastructure, and accessibility checks.+## Update NPM Dependencies Workflow**File**: `update-npm-dependencies.yml`@@ -85,7 +124,8 @@ no PR is opened.- Only auto-fixes moderate+ severity vulnerabilities- Preserves compatible version updates (no major version bumps)- Runs security audit before and after updates-- Requires tests to pass before creating PR+- Runs the matrix's configured build/test command before creating a PR, then+ reconciles the PR's checks and additional browser selections### Manual UsageYou can manually trigger this workflow:diff --git a/.github/workflows/ci-policy-tests.yml b/.github/workflows/ci-policy-tests.ymlindex 2fd822fd22..10df00f291 100644--- a/.github/workflows/ci-policy-tests.yml+++ b/.github/workflows/ci-policy-tests.yml@@ -4,6 +4,7 @@ on:pull_request:paths:- ".github/workflows/**"+ - ".github/actions/request-dependency-ci/**"- ".github/scripts/check_release_scan_evidence.py"# The release-scan suite loads both release-exception checkers.- ".github/scripts/check_code_scanning_alerts.py"@@ -18,9 +19,13 @@ on:- "tests/ci/standalone/test_osv_scan.py"- "tests/ci/standalone/test_library_embedding_fixture.py"- "scripts/refresh_pip_urllib3.py"+ - ".github/scripts/install-precommit-update.sh"+ - "requirements/pre-commit-update.in"+ - "requirements/pre-commit-update.txt"- "requirements/bootstrap-*.txt"- "requirements/pip-vendor-refresh.txt"- "tests/ci/standalone/test_pip_vendor_refresh.py"+ - "tests/ci/test_automatic_dependency_tests.py"workflow_dispatch:permissions:@@ -43,10 +48,19 @@ jobs:uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0with:python-version: '3.12'+ - name: Test pre-commit updater installation in a clean environment+ run: |+ python -m venv "$RUNNER_TEMP/precommit-update"+ export PATH="$RUNNER_TEMP/precommit-update/bin:$PATH"+ bash .github/scripts/install-precommit-update.sh+ pre-commit-update --help+ python -m pip check- name: Test CI policies without loading the applicationrun: python -m unittest discover -s tests/ci/standalone -p 'test_release_scan*.py' -v- name: Test pytest scheduling and required-check behaviorrun: python -m unittest discover -s tests/ci/standalone -p 'test_pytest_scheduling.py' -v+ - name: Test dependency PR check reconciliation+ run: python -m unittest discover -s tests/ci -p 'test_automatic_dependency_tests.py' -v- name: Test OSV scan completion and reportingrun: python -m unittest discover -s tests/ci/standalone -p 'test_osv_scan.py' -v- name: Test library model preparation and offline server setupdiff --git a/.github/workflows/dependency-pr-checks.yml b/.github/workflows/dependency-pr-checks.ymlnew file mode 100644index 0000000000..ca14d73aab--- /dev/null+++ b/.github/workflows/dependency-pr-checks.yml@@ -0,0 +1,42 @@+name: Dependency PR check selection++on:+ # Metadata routing uses the base workflow revision.+ # zizmor: ignore[dangerous-triggers]+ pull_request_target:+ types: [opened, synchronize, reopened]+ branches: [main]++permissions: {}++concurrency:+ group: dependency-pr-checks-${{ github.event.pull_request.number }}+ cancel-in-progress: true++jobs:+ request-ci:+ if: >-+ github.event.pull_request.user.login == 'dependabot[bot]' &&+ github.event.pull_request.head.repo.full_name == github.repository+ runs-on: ubuntu-latest+ timeout-minutes: 10+ permissions:+ contents: read+ steps:+ - name: Harden runner+ uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2+ with:+ egress-policy: audit+ - name: Checkout workflow code+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ ref: ${{ github.event.pull_request.base.sha }}+ - name: Reconcile PR checks+ uses: $/.github/actions/request-dependency-ci+ with:+ branch: ${{ github.event.pull_request.head.ref }}+ ecosystem: dependabot+ pull-request-number: ${{ github.event.pull_request.number }}+ head-sha: ${{ github.event.pull_request.head.sha }}+ token: ${{ secrets.AUTO_MERGE_PAT_TOKEN }}diff --git a/.github/workflows/playwright-webkit-tests.yml b/.github/workflows/playwright-webkit-tests.ymlindex 64b62326d8..11100967ca 100644--- a/.github/workflows/playwright-webkit-tests.yml+++ b/.github/workflows/playwright-webkit-tests.yml@@ -1,6 +1,9 @@name: Playwright WebKit Testson:+ pull_request:+ types: [labeled]+ branches: [main]workflow_call: # Called by release pipelineworkflow_dispatch: # Manual triggerschedule:@@ -11,6 +14,7 @@ permissions: {} # Minimal top-level for OSSF Scorecard Token-Permissionsjobs:# Shared setup: start server, register user, then run Desktop Safari testsdesktop-safari:+ if: github.event_name != 'pull_request' || github.event.label.name == 'test:webkit'runs-on: ubuntu-latestpermissions:contents: read@@ -181,6 +185,7 @@ jobs:# Mobile Safari tests run in parallel on a separate runnermobile-safari:+ if: github.event_name != 'pull_request' || github.event.label.name == 'test:webkit'runs-on: ubuntu-latestpermissions:contents: readdiff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.ymlindex 8d61e45671..6a68f53a9a 100644--- a/.github/workflows/update-dependencies.yml+++ b/.github/workflows/update-dependencies.yml@@ -6,6 +6,10 @@ on:description: Arguments to pass to pdmtype: stringdefault: ''+ secrets:+ AUTO_MERGE_PAT_TOKEN:+ description: Automation token used to approve CI and request PR tests.+ required: trueworkflow_dispatch:inputs:pdm_args:@@ -71,3 +75,28 @@ jobs:draft: falsebase: mainreviewers: djpetti,HashedViking,LearningCircuit++ request-ci:+ name: Request dependency PR checks+ needs: update+ if: ${{ !cancelled() }}+ runs-on: ubuntu-latest+ timeout-minutes: 10+ permissions:+ contents: read+ steps:+ - name: Harden runner+ uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2+ with:+ egress-policy: audit+ - name: Checkout workflow code+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ ref: ${{ github.workflow_sha }}+ - name: Reconcile PR checks+ uses: $/.github/actions/request-dependency-ci+ with:+ branch: update-dependencies-${{ github.run_number }}+ ecosystem: pdm+ token: ${{ secrets.AUTO_MERGE_PAT_TOKEN }}diff --git a/.github/workflows/update-npm-dependencies.yml b/.github/workflows/update-npm-dependencies.ymlindex 4e0833cfdf..5e62647c22 100644--- a/.github/workflows/update-npm-dependencies.yml+++ b/.github/workflows/update-npm-dependencies.yml@@ -6,6 +6,10 @@ on:description: Arguments to pass to npm updatetype: stringdefault: --save+ secrets:+ AUTO_MERGE_PAT_TOKEN:+ description: Automation token used to approve CI and request PR tests.+ required: trueworkflow_dispatch:inputs:npm_args:@@ -482,3 +486,29 @@ jobs:draft: falsebase: mainreviewers: djpetti,HashedViking,LearningCircuit++ request-ci:+ name: Request dependency PR checks+ needs: [discover, pr]+ if: ${{ !cancelled() && needs.discover.result == 'success' }}+ runs-on: ubuntu-latest+ timeout-minutes: 10+ permissions:+ contents: read+ steps:+ - name: Harden runner+ uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2+ with:+ egress-policy: audit+ - name: Checkout workflow code+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ ref: ${{ github.workflow_sha }}+ - name: Reconcile PR checks+ uses: $/.github/actions/request-dependency-ci+ with:+ branch: update-npm-dependencies-${{ github.run_number }}+ ecosystem: npm+ npm-directories: ${{ toJSON(fromJSON(needs.discover.outputs.matrix).*.path) }}+ token: ${{ secrets.AUTO_MERGE_PAT_TOKEN }}diff --git a/.github/workflows/update-precommit-hooks.yml b/.github/workflows/update-precommit-hooks.ymlindex 803143666e..7f6d013045 100644--- a/.github/workflows/update-precommit-hooks.yml+++ b/.github/workflows/update-precommit-hooks.yml@@ -28,14 +28,10 @@ jobs:- name: 🐍 Setup Pythonuses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0with:- python-version: '3.x'+ python-version: '3.12'- name: 📦 Install pre-commit-update- run: |- python -m pip install pip==25.0 \- --hash=sha256:b6eb97a803356a52b2dd4bb73ba9e65b2ba16caa6bcb25a7497350a4e5859b65- pip install pre-commit-update==0.6.1 \- --hash=sha256:db00891b3384776daaaa5721fd54a448ded19daf87635a3c77b7508eaf7d1634+ run: bash .github/scripts/install-precommit-update.sh- name: 🔄 Update pre-commit hooks (stable versions only)run: |@@ -76,3 +72,28 @@ jobs:draft: falsebase: mainreviewers: djpetti,HashedViking,LearningCircuit++ request-ci:+ name: Request dependency PR checks+ needs: update+ if: ${{ !cancelled() }}+ runs-on: ubuntu-latest+ timeout-minutes: 10+ permissions:+ contents: read+ steps:+ - name: Harden runner+ uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2+ with:+ egress-policy: audit+ - name: Checkout workflow code+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ ref: ${{ github.workflow_sha }}+ - name: Reconcile PR checks+ uses: $/.github/actions/request-dependency-ci+ with:+ branch: update-precommit-hooks-${{ github.run_number }}+ ecosystem: pre-commit+ token: ${{ secrets.AUTO_MERGE_PAT_TOKEN }}diff --git a/.gitignore b/.gitignoreindex 732f2f77b1..e4f5f9f53b 100644--- a/.gitignore+++ b/.gitignore@@ -33,6 +33,7 @@ src/local_deep_research/web/static/css/themes.css!requirements/ci-health.in!requirements/gitleaks-tests.in!requirements/mcp-extra.in+!requirements/pre-commit-update.in# Templates, Jinja2, XML — explicit paths# NOTE: .env.template has a leading-dot basename, so the `.*` catch-alldiff --git a/docs/ci/workflow-status.md b/docs/ci/workflow-status.mdindex 862757f71d..7fadca34fc 100644--- a/docs/ci/workflow-status.md+++ b/docs/ci/workflow-status.md@@ -29,7 +29,7 @@<!-- BEGIN GENERATED -->-**77 workflows:** 1 disabled · 2 stale · 1 manual-only · 73 active+**78 workflows:** 1 disabled · 2 stale · 1 manual-only · 74 active## ⚠ Disabled workflows@@ -90,7 +90,7 @@| `mypy-type-check.yml` | last 30 days | PR, workflow_call, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/mypy-type-check.yml) || `notes-concurrency.yml` | last 30 days | workflow_call, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/notes-concurrency.yml) || `playwright-notes-tests.yml` | last 30 days | PR, workflow_call, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/playwright-notes-tests.yml) |-| `playwright-webkit-tests.yml` | last 30 days | workflow_call, manual, schedule(0 2 * * *) | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/playwright-webkit-tests.yml) |+| `playwright-webkit-tests.yml` | last 30 days | PR, workflow_call, manual, schedule(0 2 * * *) | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/playwright-webkit-tests.yml) || `pre-commit.yml` | last 30 days | PR, workflow_call, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/pre-commit.yml) || `prerelease-docker.yml` | last 30 days | workflow_call | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/prerelease-docker.yml) || `puppeteer-e2e-tests.yml` | last 30 days | PR, workflow_call, manual, schedule(0 2 * * 0) | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/puppeteer-e2e-tests.yml) |@@ -124,6 +124,7 @@| `check-workflow-status.yml` | last 30 days | PR, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/check-workflow-status.yml) || `ci-policy-tests.yml` | last 30 days | PR, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ci-policy-tests.yml) || `danger-zone-alert.yml` | last 30 days | PR | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/danger-zone-alert.yml) |+| `dependency-pr-checks.yml` | never | PR-target | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/dependency-pr-checks.yml) || `dependency-review.yml` | last 30 days | PR, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/dependency-review.yml) || `e2e-research-test.yml` | last 30 days | PR | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/e2e-research-test.yml) || `fastapi-migration-quality.yml` | last 30 days | PR, manual | [](https://github.com/LearningCircuit/local-deep-research/actions/workflows/fastapi-migration-quality.yml) |diff --git a/requirements/README.md b/requirements/README.mdindex 8566f7c516..c2d5efadbb 100644--- a/requirements/README.md+++ b/requirements/README.md@@ -12,6 +12,11 @@ Both tool installs require binary wheels. The application wheel and sdist checkscontinue to use fresh pip resolution of the shipped package metadata; these CItool locks do not constrain application dependencies.+The weekly pre-commit hook updater uses `pre-commit-update` 0.6.1 on Python+3.12 with the complete binary-only, hash-verified `pre-commit-update.txt` lock.+CI Policy Tests checks the shared installer in a fresh virtual environment,+including the command's help output and `pip check`.+The release-gate pip verification installs the built wheel's `[mcp]` extra ontop of that fresh-resolution base environment so the `ldr-mcp` entry point canresolve. The extra's dependency tree is hash-verified from the completediff --git a/requirements/pre-commit-update.in b/requirements/pre-commit-update.innew file mode 100644index 0000000000..6cfe56cf26--- /dev/null+++ b/requirements/pre-commit-update.in@@ -0,0 +1,3 @@+# Python 3.12 on Linux. Regenerate using pip-tools 7.6.1:+# pip-compile --generate-hashes --strip-extras --no-emit-index-url --no-emit-trusted-host --index-url=https://pypi.org/simple --pip-args=--only-binary=:all: requirements/pre-commit-update.in+pre-commit-update==0.6.1diff --git a/requirements/pre-commit-update.txt b/requirements/pre-commit-update.txtnew file mode 100644index 0000000000..956fdab632--- /dev/null+++ b/requirements/pre-commit-update.txt@@ -0,0 +1,95 @@+#+# This file is autogenerated by pip-compile with Python 3.12+# by the following command:+#+# pip-compile --generate-hashes --strip-extras --no-emit-index-url --no-emit-trusted-host --index-url=https://pypi.org/simple --pip-args=--only-binary=:all: requirements/pre-commit-update.in+#+--only-binary :all:++click==8.5.0 \+ --hash=sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360+ # via pre-commit-update+gitdb==4.0.12 \+ --hash=sha256:67073e15955400952c6565cc3e707c554a4eea2e428946f7a4c162fab9bd9bcf+ # via gitpython+gitpython==3.2.1 \+ --hash=sha256:d66b0832aa8755c1a84892937282df0befb16c97e5a64aeebd68be9c5e323f53+ # via pre-commit-update+packaging==26.3 \+ --hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c+ # via pre-commit-update+pre-commit-update==0.6.1 \+ --hash=sha256:db00891b3384776daaaa5721fd54a448ded19daf87635a3c77b7508eaf7d1634+ # via -r requirements/pre-commit-update.in+ruamel-yaml==0.19.1 \+ --hash=sha256:27592957fedf6e0b62f281e96effd28043345e0e66001f97683aa9a40c667c93+ # via pre-commit-update+smmap==5.0.3 \+ --hash=sha256:c106e05d5a61449cf6ba9a1e650227ecfb141590d2a98412103ff35d89fc7b2f+ # via gitdb+tomli==2.5.0 \+ --hash=sha256:069435bd5480429b98c5e5afb02ab21c219b6f0064680671c6dc0d46817346ea \+ --hash=sha256:0dc598040da8d42cf20f0be588ed7004f46db12a0ac6c32e03a59dccedaaadcd \+ --hash=sha256:1245a6638fc4bb0a60af38a7d45413db34a13842027c77597c712c998c62fdf0 \+ --hash=sha256:19b0dd8749f4ea2f112c5fcfb3c5248390c899d7e2e173f1d91abee1fa0ff391 \+ --hash=sha256:1f4a40d03fb9f63424f0979855bdeaf44dd7696b8d59501822c10ed30ba532df \+ --hash=sha256:20aa36de8f2cf87237143bc1fa1aae8d6612c09118f4da21c6a684db5dd1f6f9 \+ --hash=sha256:21e4cae4114aba25aa0d4f85cdf486d290fb35c0954d7bba536248da64d43066 \+ --hash=sha256:22185fad8a1e622f064e78008018a0dd3323550dcb479cb7a1d296888d74024f \+ --hash=sha256:2419c2a189551987b59d80e63ec355671283336f41c6b9b89462df679c7d0c57 \+ --hash=sha256:32a7b79ac57a2e83670ce329ccf675798bc5a2094783a63676866b70503f2e2b \+ --hash=sha256:3f89d10c1ff6a38d992c27fc8a4816af71a909e08a40ec66934240b1e74347c3 \+ --hash=sha256:463b16086865b97facd8d0b3fb4cb7c544e3f58d2a69dc3113d6db9653fdb043 \+ --hash=sha256:49096930c8d886c9bbdab62d2d0d17ce823ddeea522309a190b36245d5b49e01 \+ --hash=sha256:521345fd1f19d45b8df87657aaa38b6f2ca3800059fadf428e7ebf479a383646 \+ --hash=sha256:57b1c3b01fab802e2899bc3d168dca320e14165e2fd9fd584760fb4ca5826859 \+ --hash=sha256:5d8bac3d603c97e6854424e5b2b5b741bdbde387e09f162fb0446812b4a8362b \+ --hash=sha256:610b27d99f28ec5f191c7064a48f3ddb179a1fe6ca73d571483ae859f57b605e \+ --hash=sha256:61ea1ebe1e55a34ea8199cc8dbff398d35027b82271c8ac4802fd3a1fd5b1bcc \+ --hash=sha256:62fc1bc8eb03e3a9cadfca713d65614ed8e09d974a283295ffe3a831976b4dc5 \+ --hash=sha256:6664b7ae7af7294256c53960a6103077f4914cec8ff98479c352f622c6f6b2f0 \+ --hash=sha256:667e521b37a6c5ccaa044202c235b530f90177ffe2cd4a64ecc213c7dd535feb \+ --hash=sha256:69491c143d2fe063046e0301e62a810bed338fa4d1ce0fd870c27dc1e09b0d84 \+ --hash=sha256:6cf74416bdc94ae458b14e37286c1073081850ac8459a00d0c5efef5d44294c6 \+ --hash=sha256:6e95c7614e705bfe2b04b27aa124adec59752d15813df37e2156747cab3a006b \+ --hash=sha256:6f041843c4d3a37245c0c056fd955b186bf8b1fb85690cbe40b81230891dc34b \+ --hash=sha256:752e8b1aa6a4367ef8bf6a1a1e005540f7ed055ba36d7193796812ca5404eb52 \+ --hash=sha256:75dbcde8751b0a960aa3de173aa5e894d590755c6d7758b7e774c06f1dc3cbdd \+ --hash=sha256:7ac2027d37c3afbdf4bdd377f2676f6f1d2122a5be1f1137b49dced590b37e75 \+ --hash=sha256:7ad1ea345759240d6463efa0ed1c704402752e49aa21476620738d74d72d8aa1 \+ --hash=sha256:86665cee9c4835b7a7f1e8ec2c719b5258d4dc782887aded5a8ae7352a96843b \+ --hash=sha256:8ff3a2ca028c7eee0c777f9a092038d0a594a9fa04e215f929a22c329e2cb142 \+ --hash=sha256:91294a9fb94a75542f6e46e4a2ae709bd8d9b51134098cae5cf3bea5478b6d03 \+ --hash=sha256:943276cf269e0071948d9ff697159c1735e623c1151d88abb09b74659ef0cbea \+ --hash=sha256:96243987194634bd411066ce40c952e108f86af04db533ecd8ac3ff2a85b1885 \+ --hash=sha256:984012f71908165449a951de2050d52f276bfe3aa5d5f570f63ddad814370374 \+ --hash=sha256:9b03d7dc168353b4132965bde20feceabaa470e570c6f59660dfae59b1f9eeb3 \+ --hash=sha256:9dbb18c1cfb2f6517942fc9314437f66aa06d94436ffb1f06102ef3572f35276 \+ --hash=sha256:9ebf8d19b17bd0daeb7b7dec81a946a439b753942fd0210d6e96c532249eea6b \+ --hash=sha256:a525685c2f97da40762b8695eb7aa0af4c8344ca1905c73e4e29cb04d34607dc \+ --hash=sha256:abdbf6313b8d9efe157edeb7ab6eae4de064b1300ad31abf73755154b30abe68 \+ --hash=sha256:b69564772b5c8f22ea5f498dff08cfa825045b4d4c4400529000bdf818aa3b2a \+ --hash=sha256:b8ade5023067f99fe72b88accd30d0ea05a158e9e32a11f124e731ea9695313f \+ --hash=sha256:bbaefc84548d754be821bba7c4141c4787dda182f9e77f2f87b71213529efa7b \+ --hash=sha256:bd05de8c1698f8413dd7d869492693a0bf2211543b787ac78cd5e7536af1a6d7 \+ --hash=sha256:bf0b5e8e0f68ebb494356e577c06c139161efd8d3b9050f93b39b7c26cc54ff0 \+ --hash=sha256:c414be4ed9d3cac80c42e348fa5a956117d1a48227f48026e31f59cb4a7671eb \+ --hash=sha256:c47300f9bf791808f77d82747691c4bb09cb14bdf3060cca99b42cdc4361d5a7 \+ --hash=sha256:c4dc1c1781f2f716de763d1e9a7b34c6a894e167e291c7c5d16c72f7a9538545 \+ --hash=sha256:c804ae44fe7b4bab5da295e4f980a1ff04670bca9d23fe0a4e887e08ebd741a8 \+ --hash=sha256:cfac177ebd6236003846ea339981f71457cb6eb748f23381eb257e45092e3980 \+ --hash=sha256:d2ba24db8a9376921b5e87b4762b9adb0f3f1deaea68f2b8b0bb2c11efb9c3e7 \+ --hash=sha256:d3182ee2d887e507bd67319a0a61105d1dd33facc111329559a233b772c1a105 \+ --hash=sha256:d747252933c8a65ef6bd8da0fbb7ce28a90eb6119d8cd00772cd528aa07b68d5 \+ --hash=sha256:d7e369fd63331746182360977b1892bfc215476a30d61612d732425311639f56 \+ --hash=sha256:e12bbcd32897272fb05929110362ae9ff4c1b9bb26bd9e971e71dcd3275b4c3d \+ --hash=sha256:e7ad033e27a516a233bea839cdb77b80146facb3b4f40bf02cd0cac165cdd5c2 \+ --hash=sha256:e9e15b4a6c7dd6b85b5fbab29488a73f1f70de516942308daa266bf0e0aeb0d4 \+ --hash=sha256:ed53f7e89bb04f6d9e8e7799112360b0c4d5cbff067de0814c98c37c39b920f7 \+ --hash=sha256:eff8babca5a7999bc137acbc7482a8b7e17ffca5075ab41f5d770ab408c7bfef \+ --hash=sha256:f15e3e0b835a6d68b10c86bf80a3149780498d6911c93c3ffd1861d19f9200f1 \+ --hash=sha256:f3fcbc57b1791fa6cbe5d8434179d51de12be1a4811469529f47f6e7487a2571 \+ --hash=sha256:f4b653094e18f9031102d3a1da5c729c8f222d85225b18037dac621695e46e1a \+ --hash=sha256:f79203b3965b4000e91808aaa7c040206093f2b8bf86f455982f2274c9ccf442 \+ --hash=sha256:fd4dc129784e0c5335bd4e61dfcc4487499a013419e655cf2da1d091b7e0efdc+ # via pre-commit-updatediff --git a/tests/ci/test_automatic_dependency_tests.py b/tests/ci/test_automatic_dependency_tests.pynew file mode 100644index 0000000000..56e93402d9--- /dev/null+++ b/tests/ci/test_automatic_dependency_tests.py@@ -0,0 +1,565 @@+"""Dependency PR reconciliation tests using local metadata fixtures."""++from copy import deepcopy+import json+import os+from pathlib import Path+import runpy+from types import SimpleNamespace+import unittest+from unittest.mock import patch+++ROOT = Path(__file__).resolve().parents[2]+# Keep generated bytecode out of the action files scanned by CI policy tests.+ci = SimpleNamespace(+ **runpy.run_path(+ str(+ ROOT / ".github/actions/request-dependency-ci/scripts/request_ci.py"+ )+ )+)+HEAD = "a" * 40+BRANCH = "update-npm-dependencies-52-tests-infrastructure_tests"+CORE_APPROVALS = [1, 2, 3, *range(20, 27)]+++def workflow_run(number, filename, conclusion="action_required", **changes):+ return {+ "id": number,+ "path": f".github/workflows/{filename}",+ "head_sha": HEAD,+ "head_branch": BRANCH,+ "head_repository": {"full_name": "example/project"},+ "pull_requests": [{"number": 7740}],+ "event": "pull_request",+ "status": "in_progress" if conclusion is None else "completed",+ "conclusion": conclusion,+ **changes,+ }+++def core_runs():+ return [+ workflow_run(1, "docker-tests.yml"),+ workflow_run(2, "pre-commit.yml"),+ workflow_run(3, "mypy-type-check.yml"),+ *[+ workflow_run(number, filename)+ for number, filename in enumerate(+ [+ "codeql.yml",+ "security-file-write-check.yml",+ "check-env-vars.yml",+ "gitleaks.yml",+ "osv-scanner.yml",+ "file-whitelist-check.yml",+ "dependency-review.yml",+ ],+ 20,+ )+ ],+ ]+++class GitHubFixture:+ def __init__(self, snapshots=None):+ self.pr = {+ "number": 7740,+ "state": "open",+ "base": {"ref": "main"},+ "user": {"login": "github-actions[bot]"},+ "head": {+ "ref": BRANCH,+ "sha": HEAD,+ "repo": {"full_name": "example/project"},+ },+ }+ self.files = [+ {"filename": "tests/infrastructure_tests/package-lock.json"}+ ]+ self.snapshots = snapshots if snapshots is not None else [core_runs()]+ self.polls = 0+ self.approved = []+ self.labels = []+ self.mutations = []+ self.extra_runs = []+ self.failure = None+ self.no_pr = False+ self.move_on_poll = None+ self.queries = []+ self.jobs = {}++ def pages(self, route, key=None):+ self.queries.append(route)+ if "/pulls?" in route:+ return [] if self.no_pr else [deepcopy(self.pr)]+ if route.endswith("/files"):+ return deepcopy(self.files)+ if route.endswith("/jobs"):+ return self.jobs.get(+ int(route.split("/")[-2]), [{"conclusion": None}]+ )+ if "/actions/runs?" in route:+ if self.polls == self.move_on_poll:+ self.pr["head"]["sha"] = "b" * 40+ index = min(self.polls, len(self.snapshots) - 1)+ runs = deepcopy(self.snapshots[index] + self.extra_runs)+ self.polls += 1+ for run in runs:+ if run["id"] in self.approved:+ run["conclusion"] = None+ return runs+ raise AssertionError(route)++ def request(self, method, route, payload=None):+ if method != "GET":+ self.mutations.append((method, route, payload))+ if self.failure and self.failure[0] == method:+ _, status = self.failure+ self.failure = None+ raise ci.APIError(method, status)+ if method == "GET" and "/pulls/" in route:+ return deepcopy(self.pr)+ if method == "POST" and route.endswith("/approve"):+ self.approved.append(int(route.split("/")[-2]))+ return {}+ if method == "DELETE":+ raise ci.APIError(method, 404)+ if method == "POST" and route.endswith("/labels"):+ label = payload["labels"][0]+ self.labels.append(label)+ workflows = {+ "test:puppeteer": "puppeteer-e2e-tests.yml",+ "test:ui-full-shards": "ui-full-shards.yml",+ "test:notes": "playwright-notes-tests.yml",+ "test:webkit": "playwright-webkit-tests.yml",+ }+ self.extra_runs.append(+ workflow_run(100 + len(self.labels), workflows[label], None)+ )+ return {}+ raise AssertionError((method, route))+++def reconcile(client, **changes):+ options = {+ "directory": "tests/infrastructure_tests",+ "attempts": 8,+ "sleep": lambda _: None,+ }+ options.update(changes)+ return ci.reconcile(client, "example/project", BRANCH, "npm", **options)+++class DependencyCITests(unittest.TestCase):+ def test_standard_checks_are_approved(self):+ client = GitHubFixture()+ reconcile(client)+ self.assertEqual(client.approved, CORE_APPROVALS)+ self.assertEqual(client.labels, [])+ self.assertGreaterEqual(client.polls, 3)+ self.assertTrue(+ all(+ f"head_sha={HEAD}" in route and "event=pull_request" in route+ for route in client.queries+ if "/actions/runs?" in route+ )+ )++ def test_delayed_workflows_are_discovered(self):+ runs = core_runs()+ client = GitHubFixture(+ [+ [],+ runs[:1],+ runs,+ runs + [workflow_run(4, "check-workflow-status.yml")],+ ]+ )+ reconcile(client)+ self.assertEqual(client.approved, CORE_APPROVALS + [4])++ def test_missing_core_workflows_do_not_report_success(self):+ for runs in ([], core_runs()[:1], core_runs()[:2], core_runs()[:-1]):+ with self.subTest(runs=runs):+ with self.assertRaisesRegex(+ RuntimeError, "did not become ready"+ ):+ reconcile(GitHubFixture([runs]), attempts=3)++ def test_other_revisions_and_events_are_ignored(self):+ runs = core_runs() + [+ workflow_run(10, "other.yml", head_sha="b" * 40),+ workflow_run(11, "other.yml", head_branch="other"),+ workflow_run(12, "other.yml", event="push"),+ workflow_run(+ 13, "other.yml", head_repository={"full_name": "example/other"}+ ),+ workflow_run(14, "other.yml", pull_requests=[{"number": 42}]),+ workflow_run(15, "other.yml", head_repository=None),+ workflow_run(16, "other.yml", pull_requests=[]),+ ]+ client = GitHubFixture([runs])+ reconcile(client)+ self.assertEqual(client.approved, CORE_APPROVALS)++ def test_finished_checks_are_not_restarted(self):+ runs = [dict(run, conclusion="failure") for run in core_runs()]+ client = GitHubFixture([runs])+ reconcile(client)+ self.assertEqual(client.approved, [])++ def test_other_pr_runs_cannot_satisfy_registration(self):+ runs = [+ dict(run, pull_requests=[{"number": 42}]) for run in core_runs()+ ]+ client = GitHubFixture([runs])+ with self.assertRaisesRegex(RuntimeError, "did not become ready"):+ reconcile(client, attempts=3)+ self.assertEqual(client.approved, [])++ def test_late_baseline_workflow_is_still_reconciled(self):+ runs = core_runs()+ early = [run for run in runs if run["id"] != 20]+ client = GitHubFixture([early, early, early, runs])+ reconcile(client)+ self.assertCountEqual(client.approved, CORE_APPROVALS)+ self.assertGreaterEqual(client.polls, 6)++ def test_unchanged_update_can_retry_failed_approval(self):+ client = GitHubFixture()+ client.failure = ("POST", 500)+ with self.assertRaises(ci.APIError):+ reconcile(client)+ reconcile(client)+ self.assertEqual(client.approved, CORE_APPROVALS)++ def test_no_open_pr_is_a_successful_noop(self):+ client = GitHubFixture()+ client.no_pr = True+ self.assertIn("No open", reconcile(client))+ self.assertEqual(client.polls, 0)++ def test_pr_metadata_must_match(self):+ changes = [+ {"state": "closed"},+ {"base": {"ref": "other"}},+ {"user": {"login": "contributor"}},+ {"head": {"ref": BRANCH, "sha": HEAD, "repo": None}},+ ]+ for change in changes:+ with self.subTest(change=change):+ client = GitHubFixture()+ client.pr.update(change)+ with self.assertRaisesRegex(RuntimeError, "metadata"):+ reconcile(client)+ self.assertEqual(client.approved, [])++ def test_expected_manifest_files_are_required(self):+ for files in (+ [],+ [{"filename": "src/module.py"}],+ [+ {+ "filename": "tests/infrastructure_tests/package.json",+ "previous_filename": "other.json",+ }+ ],+ ):+ with self.subTest(files=files):+ client = GitHubFixture()+ client.files = files+ with self.assertRaisesRegex(RuntimeError, "PR files"):+ reconcile(client)++ def test_changed_revision_stops_reconciliation(self):+ client = GitHubFixture()+ client.move_on_poll = 0+ with self.assertRaisesRegex(RuntimeError, "revision changed"):+ reconcile(client)++ def test_browser_projects_select_matching_suites(self):+ projects = {+ "tests": {"test:ui-full-shards"},+ "tests/puppeteer": {"test:puppeteer"},+ "tests/ui_tests": {"test:ui-full-shards"},+ "tests/ui_tests/playwright": {"test:notes", "test:webkit"},+ }+ for directory, labels in projects.items():+ with self.subTest(directory=directory):+ client = GitHubFixture()+ client.files = [{"filename": f"{directory}/package-lock.json"}]+ reconcile(client, directory=directory)+ self.assertEqual(set(client.labels), labels)++ def test_existing_browser_run_is_reused(self):+ runs = core_runs() + [workflow_run(4, "puppeteer-e2e-tests.yml", None)]+ client = GitHubFixture([runs])+ client.files = [{"filename": "tests/puppeteer/package-lock.json"}]+ reconcile(client, directory="tests/puppeteer")+ self.assertEqual(client.labels, [])+ self.assertEqual(client.approved, CORE_APPROVALS)++ def test_combined_npm_changes_select_matching_suites(self):+ client = GitHubFixture()+ client.files = [+ {"filename": "package-lock.json"},+ {"filename": "tests/puppeteer/package-lock.json"},+ {"filename": "tests/ui_tests/playwright/package.json"},+ ]+ reconcile(+ client,+ directories=[".", "tests/puppeteer", "tests/ui_tests/playwright"],+ )+ self.assertEqual(+ set(client.labels), {"test:puppeteer", "test:notes", "test:webkit"}+ )++ def test_combined_npm_changes_must_match_discovered_directories(self):+ client = GitHubFixture()+ client.files = [{"filename": "tests/puppeteer/package-lock.json"}]+ with self.assertRaisesRegex(RuntimeError, "PR files"):+ reconcile(client, directories=["."])+ self.assertEqual(client.approved, [])++ def test_combined_npm_directory_list_is_validated(self):+ for directories in ([], "tests", [{}], ["src"]):+ with self.subTest(directories=directories):+ with self.assertRaises(ValueError):+ reconcile(GitHubFixture(), directories=directories)++ def test_skipped_browser_runs_do_not_replace_test_selection(self):+ runs = core_runs() + [+ workflow_run(4, "puppeteer-e2e-tests.yml", "skipped")+ ]+ client = GitHubFixture([runs])+ client.files = [{"filename": "tests/puppeteer/package-lock.json"}]+ reconcile(client, directory="tests/puppeteer")+ self.assertEqual(client.labels, ["test:puppeteer"])++ def test_queued_browser_jobs_are_already_selected(self):+ runs = core_runs() + [+ workflow_run(4, "puppeteer-e2e-tests.yml", None, status="queued")+ ]+ client = GitHubFixture([runs])+ client.files = [{"filename": "tests/puppeteer/package-lock.json"}]+ reconcile(client, directory="tests/puppeteer")+ self.assertEqual(client.labels, [])++ def test_browser_workflow_with_only_skipped_jobs_needs_selection(self):+ runs = core_runs() + [workflow_run(4, "puppeteer-e2e-tests.yml", None)]+ client = GitHubFixture([runs])+ client.jobs[4] = [{"conclusion": "skipped"}]+ client.files = [{"filename": "tests/puppeteer/package-lock.json"}]+ reconcile(client, directory="tests/puppeteer")+ self.assertEqual(client.labels, ["test:puppeteer"])++ def test_unapproved_browser_run_still_needs_test_selection(self):+ runs = core_runs() + [workflow_run(4, "puppeteer-e2e-tests.yml")]+ client = GitHubFixture([runs])+ client.files = [{"filename": "tests/puppeteer/package-lock.json"}]+ reconcile(client, directory="tests/puppeteer")+ self.assertEqual(client.labels, ["test:puppeteer"])+ self.assertEqual(client.approved, CORE_APPROVALS + [4])++ def test_browser_selection_can_retry_label_failure(self):+ client = GitHubFixture()+ client.files = [{"filename": "tests/puppeteer/package-lock.json"}]+ client.failure = ("DELETE", 503)+ with self.assertRaises(ci.APIError):+ reconcile(client, directory="tests/puppeteer")+ reconcile(client, directory="tests/puppeteer")+ self.assertEqual(client.labels, ["test:puppeteer"])++ def test_grouped_dependabot_changes_select_all_matching_suites(self):+ client = GitHubFixture()+ client.pr["user"]["login"] = "dependabot[bot]"+ client.files = [+ {"filename": "tests/puppeteer/package-lock.json"},+ {"filename": "tests/ui_tests/playwright/package.json"},+ ]+ ci.reconcile(+ client,+ "example/project",+ BRANCH,+ "dependabot",+ number=7740,+ expected_head=HEAD,+ attempts=8,+ sleep=lambda _: None,+ )+ self.assertEqual(+ set(client.labels), {"test:puppeteer", "test:notes", "test:webkit"}+ )+ self.assertEqual(client.approved, CORE_APPROVALS)++ def test_dependabot_manifest_updates_are_approved(self):+ for files in (+ ["pyproject.toml", "pdm.lock"],+ [+ "requirements/pre-commit-update.in",+ "requirements/pre-commit-update.txt",+ ],+ ["requirements/bootstrap-runtime.txt"],+ ["package.json", "package-lock.json"],+ [+ "tests/accessibility_tests/package-lock.json",+ "tests/api_tests_with_login/package.json",+ "tests/infrastructure_tests/package-lock.json",+ ],+ ):+ with self.subTest(files=files):+ client = GitHubFixture()+ client.pr["user"]["login"] = "dependabot[bot]"+ client.files = [{"filename": filename} for filename in files]+ result = ci.reconcile(+ client,+ "example/project",+ BRANCH,+ "dependabot",+ attempts=8,+ sleep=lambda _: None,+ )+ self.assertIn("registered and approved", result)+ self.assertEqual(client.approved, CORE_APPROVALS)+ self.assertEqual(client.labels, [])++ def test_unlisted_dependabot_files_wait_for_manual_approval(self):+ for filename in (+ ".github/workflows/pre-commit.yml",+ ".github/actions/example/action.yml",+ "src/module.py",+ "README.md",+ "Dockerfile",+ "requirements/README.md",+ "requirements/new-tool.txt",+ "requirements/pip-vendor-refresh.txt",+ "other/package-lock.json",+ ):+ for mixed in (False, True):+ with self.subTest(filename=filename, mixed=mixed):+ client = GitHubFixture()+ client.pr["user"]["login"] = "dependabot[bot]"+ client.files = [{"filename": filename}]+ if mixed:+ client.files.append(+ {"filename": "tests/puppeteer/package-lock.json"}+ )+ result = ci.reconcile(+ client,+ "example/project",+ BRANCH,+ "dependabot",+ attempts=8,+ sleep=lambda _: None,+ )+ self.assertIn("manual CI approval", result)+ self.assertEqual(client.polls, 0)+ self.assertEqual(client.mutations, [])++ def test_dependabot_renames_include_both_paths_in_the_policy(self):+ client = GitHubFixture()+ client.pr["user"]["login"] = "dependabot[bot]"+ client.files = [+ {+ "filename": "tests/puppeteer/package-lock.json",+ "previous_filename": "requirements/README.md",+ }+ ]+ result = ci.reconcile(+ client,+ "example/project",+ BRANCH,+ "dependabot",+ attempts=8,+ sleep=lambda _: None,+ )+ self.assertIn("manual CI approval", result)+ self.assertEqual(client.polls, 0)+ self.assertEqual(client.mutations, [])++ def test_custom_updaters_only_approve_their_expected_manifests(self):+ for ecosystem, manifest in (+ ("npm", "package-lock.json"),+ ("pdm", "pdm.lock"),+ ("pre-commit", ".pre-commit-config.yaml"),+ ):+ with self.subTest(ecosystem=ecosystem):+ client = GitHubFixture()+ client.files = [+ {"filename": manifest},+ {"filename": ".github/workflows/pre-commit.yml"},+ ]+ with self.assertRaisesRegex(RuntimeError, "PR files"):+ ci.reconcile(client, "example/project", BRANCH, ecosystem)+ self.assertEqual(client.polls, 0)+ self.assertEqual(client.mutations, [])++ def test_stale_dependabot_event_is_a_successful_noop(self):+ client = GitHubFixture()+ client.pr["user"]["login"] = "dependabot[bot]"+ result = ci.reconcile(+ client,+ "example/project",+ BRANCH,+ "dependabot",+ number=7740,+ expected_head="b" * 40,+ )+ self.assertIn("newer PR revision", result)+ self.assertEqual(client.polls, 0)++ def test_npm_directory_is_validated(self):+ for directory in ("/tmp", "../other", "src", "tests/../src"):+ with self.subTest(directory=directory):+ with self.assertRaises(ValueError):+ ci.expected_files("npm", directory)++ def test_other_updaters_have_their_expected_manifests(self):+ self.assertEqual(ci.expected_files("pdm", "."), {"pdm.lock"})+ self.assertEqual(+ ci.expected_files("pre-commit", "."), {".pre-commit-config.yaml"}+ )++ def test_missing_credential_is_explicit(self):+ with patch.dict(os.environ, {}, clear=True):+ with self.assertRaisesRegex(RuntimeError, "credential is required"):+ ci.main()++ def test_api_payload_uses_structured_input(self):+ with patch.object(ci.subprocess, "run") as run:+ run.return_value.returncode = 0+ run.return_value.stdout = "{}"+ ci.GitHub().request("POST", "repos/example/project", {"labels": []})+ self.assertEqual(+ json.loads(run.call_args.kwargs["input"]), {"labels": []}+ )+ self.assertNotIn("shell", run.call_args.kwargs)++ def test_workflow_request_jobs_are_independent_of_installer_jobs(self):+ for name in (+ "update-npm-dependencies.yml",+ "update-dependencies.yml",+ "update-precommit-hooks.yml",+ ):+ with self.subTest(workflow=name):+ workflow = (ROOT / ".github/workflows" / name).read_text()+ before, request_job = workflow.split("\n request-ci:\n", 1)+ update_job = before.split("\n update:\n", 1)[1]+ self.assertNotIn("AUTO_MERGE_PAT_TOKEN", update_job)+ self.assertIn("runs-on: ubuntu-latest", request_job)+ self.assertIn("ref: ${{ github.workflow_sha }}", request_job)+ self.assertNotIn("pull-request-operation", request_job)+ for install in (+ "npm ci",+ "npm install",+ "pip install",+ "pdm install",+ "pdm sync",+ ):+ self.assertNotIn(install, request_job)+++if __name__ == "__main__":+ unittest.main()diff --git a/tests/ci/test_pull_request_target_hardening.py b/tests/ci/test_pull_request_target_hardening.pyindex e502e2ba1e..c0f5d354af 100644--- a/tests/ci/test_pull_request_target_hardening.py+++ b/tests/ci/test_pull_request_target_hardening.py@@ -1,8 +1,7 @@"""Workflow-security tripwires for ``pull_request_target`` usage.-Two workflows run under ``pull_request_target`` so they can hold the-org's tokens on fork PRs (two others merely mention the trigger in-comments explaining why they avoid it). That trigger executes workflow definitions+The audited workflows use ``pull_request_target`` for repository+metadata operations. That trigger executes workflow definitionsfrom the **trusted base**, which is safe only while nothing from thePR head is ever checked out or executed: the pwn-request vector is acheckout step gaining ``ref: ${{ github.event.pull_request.head.sha }}``@@ -42,6 +41,7 @@ WORKFLOWS_DIR = Path(__file__).resolve().parents[2] / ".github" / "workflows"AUDITED_PR_TARGET_WORKFLOWS = frozenset({"ai-code-reviewer.yml",+ "dependency-pr-checks.yml","welcome-first-time.yml",})@@ -61,10 +61,12 @@ TRUSTED_CHECKOUT_REFS = frozenset(TRUSTED_CHECKOUT_REPOSITORIES = frozenset({"", "${{github.repository}}"})#: Escape hatch for a reviewed reusable-workflow call or local composite-#: action. Empty today. Adding an entry is a deliberate act, like+#: action. Adding an entry is a deliberate act, like#: extending AUDITED_PR_TARGET_WORKFLOWS: review the callee under the#: same no-head-checkout rules first — this module cannot see inside it.-ALLOWED_DELEGATIONS: frozenset[str] = frozenset()+ALLOWED_DELEGATIONS: frozenset[str] = frozenset(+ {"$/.github/actions/request-dependency-ci"}+)def _checkout_expression(value) -> str:@@ -114,7 +116,7 @@ def _checkout_steps(doc: dict) -> list[tuple[str, dict]]:def _delegation_targets(doc: dict) -> list[str]:"""Reusable-workflow calls (``jobs.<id>.uses``) and local composite- actions (a step ``uses:`` starting with ``./`` that is not itself a+ actions (a step ``uses:`` starting with ``./`` or ``$/`` that is not itself areusable-workflow file) — either could check out the PR head insidea callee this module never inspects, letting the checkout testsabove pass vacuously on a caller with no checkout steps of its own.@@ -130,7 +132,7 @@ def _delegation_targets(doc: dict) -> list[str]:if not isinstance(step, dict):continueuses = str(step.get("uses", "")).strip()- if uses.startswith("./"):+ if uses.startswith(("./", "$/")):targets.append(uses)return targets@@ -176,7 +178,7 @@ class TestPullRequestTargetHardening:"""The label/comment-only workflow was checkout-free by design;it must not grow an ``actions/checkout`` step."""for name, doc in _workflows_with_pr_target().items():- if name == "ai-code-reviewer.yml":+ if name in {"ai-code-reviewer.yml", "dependency-pr-checks.yml"}:continueassert _checkout_steps(doc) == [], (f"{name} was checkout-free by design; a checkout appeared"