Python dependency hash-locking and supply-chain policy¶
VMAFx enforces cryptographic artifact hashes (--require-hashes) for all Python dependency installations across the repository. This guarantees reproducible, hermetic builds, protects against upstream PyPI package mutation or dependency confusion, and satisfies OpenSSF Scorecard supply-chain integrity criteria.
Overview¶
All Python dependencies are declared in input requirements files (.in, pyproject.toml, docs/requirements.txt) and deterministically locked with SHA-256 artifact digests into lock files (requirements/locks/*.txt, */*-lock.txt).
The central authority is requirements/locks/manifest.json, which pairs every lock file with its source files and compilation arguments using a reviewed, pinned version of uv (uv_version in requirements/locks/manifest.json). Both check and write reject a manifest input whose uv pin differs from uv_version, so a Renovate PR that bumps the pin must update uv_version in the same change to pass.
The checker recognizes uv by its case-insensitive, PEP 503-normalized package name. It checks == and === pins with optional extras, whitespace, and environment markers. In .in and .txt files it joins backslash-continued lines and reports the first physical line. In TOML files it checks strings in project.dependencies, project.optional-dependencies groups, dependency-groups arrays, and build-system.requires. It reports the dotted TOML key and skips dependency group include tables. Malformed TOML fails the check.
Guides point at that field and never restate the number: check_python_dependency_locks.py check refuses any Markdown line that echoes a uv version (with optional leading v, e.g. vX.Y.Z or X.Y.Z) within 40 characters of uv_version, vmafx-uv-version (in either order), or uv directly followed by a version pin in prose or code (uv X.Y.Z, uv vX.Y.Z, uv==X.Y.Z, uv@X.Y.Z, pinned uv X.Y.Z, or a quoted uv before a quoted version), outside CHANGELOG.md, changelog.d/, docs/changelog-archive/, the dated records in docs/research/, docs/state.md, docs/rebase-notes.md and docs/rebase-notes.d/, and the decision records under docs/adr/. Soft-wrapped two-line echoes (where the tool name and version number are split across a line break) are a known gap and are not caught by the single-line scanner.
The manifest validates every path it names:
- Outputs, inputs and alias consumer bindings are local repo-relative paths under both POSIX and Windows path semantics.
- Drive/UNC or POSIX absolutes, traversal, remote references and surrounding whitespace fail validation.
- Each install command may name the lock's repository output or one of its explicit
install_aliases. Aliases exist only for reviewed paths created by container copies or platform scripts. - Each alias is bound to an explicit repo-relative consumer path and context, so unrelated workflows cannot consume alias paths.
- Consumer identity is exact after separator normalization: a nested
evil/scripts/setup/ubuntu.shpath does not inherit the alias authority assigned toscripts/setup/ubuntu.sh. The checker never trusts a matching basename or suffix, and it rejects unreferenced aliases.
Architecture¶
Input manifests (.in, pyproject.toml)
│
▼
uv pip compile (pinned uv_version) ───► Manifest Writer (make python-locks-write)
│
▼
Committed hash-lock files (*.txt, *-lock.txt)
│
├─────────────────────────────────────────┐
▼ ▼
CI Workflows & Dockerfiles Local Workstation (make lint-tools, cythonize-deps)
(pip install --require-hashes -r ...) (pip install --require-hashes -r ...)
Available targets¶
| Command | Purpose |
|---|---|
make python-locks-check | Validates that all lock files match their inputs and that every executed pip install in the repo uses --require-hashes or local --no-deps. Offline, fast. |
make python-locks-write | Networked refresh: runs the pinned uv compiler to update all lock files and re-stamp metadata headers. |
make lint-tools | Installs project linting tools (ruff, black, mypy) into .venv from requirements/locks/dev-linters.txt using --require-hashes. |
make cythonize-deps | Installs C-extension build dependencies (Cython, numpy, setuptools, packaging) from requirements/locks/cythonize.txt using --require-hashes. |
python3 -m pip install --require-hashes -r requirements/locks/nox.txt | Installs the reviewed Nox release and its transitive dependencies before running local package sessions. |
Automatic lock refresh¶
ADR-3560 records automatic refresh when a dependency-update branch changes a manifest input. The workflow publishes manifest outputs as a signed-off release-bot commit. The DCO exemption covers only live entries among the 30 exact paths in .config/lint-exceptions.d/dco-python-lock-refresh.toml; a new output needs a new operator grant. If the branch moves or is deleted, publication fails without overwriting it. The next input change runs refresh again; otherwise rerun it against the current tip.
How to add or update a dependency¶
- Update the source specification:
- For developer linters: edit
requirements/locks/dev-linters.in. - For documentation: edit
docs/requirements.txt. - For python package: edit
python/pyproject.tomlorpython/requirements-*.in. - For MCP server: edit
mcp-server/vmaf-mcp/pyproject.toml. - For AI / training: edit
ai/pyproject.toml. -
For a Nox package session: edit that package's
pyproject.tomland its manifest entry; use an overlay.infile only for test tools not declared by the package. -
Regenerate lock files:
This invokes scripts/ci/check_python_dependency_locks.py write with the reviewed uv release. It compiles each lock target in a temporary directory, writes the SHA-256 fingerprint header, and verifies all locks.
The fingerprint (# vmafx-input-sha256:) covers the compile arguments and every input file byte for byte, with one exception: in a pyproject.toml input, the version = ... line of the [project] table is left out (ADR-1344). release-please rewrites that line on every release PR, and the project's own version never changes what the resolver picks. A version key in any other table, and every dependency change, still makes the lock stale.
- Verify locally:
- Verify package Python floors:
Declared requires-python floors in tracked pyproject.toml files must honestly reflect the minimum Python version required by the package's direct dependencies and all optional extra groups (ADR-3335).
The verification script scripts/ci/check_python_floors.py verifies this property by compiling each tracked package's requirements in an isolated directory with all extras at its declared floor. The check is kept separate from make lint because dependency resolution requires network access.
[!NOTE] Resolve-proven vs run-proven gap: While the check guarantees that the dependency tree resolves without conflict at the declared floor, repository CI executes test suites under Python 3.14. The declared floors are resolve-proven rather than run-proven across older interpreters.
Sdist packages and PEP 517 build isolation¶
When pip installs a pure source distribution (.tar.gz sdist) under --require-hashes, its default PEP 517 build isolation attempts to spawn a temporary environment and download unhashed build backends (setuptools, wheel) from PyPI.
To support pure sdists (e.g. mkdocs-minify-plugin dependencies) securely:
- Pinned versions of
setuptoolsandwheelare declared indocs/requirements.txtand hashed intodocs/requirements-lock.txt. - Installation commands must pass
--no-build-isolation:
Enforcement and CI gates¶
- Pre-commit:
check-python-dependency-locksruns on commits touching Python manifests, lock files, workflows, Dockerfiles, setup scripts, Makefile, or Markdown files (excluding the dated records listed under the scanner below). - Guide uv version echo scanner:
check_python_dependency_locks.py checkscans Markdown guides outside the dated records (CHANGELOG.md,changelog.d/,docs/changelog-archive/,docs/research/,docs/state.md,docs/rebase-notes.md,docs/rebase-notes.d/,docs/adr/) and refuses lines echoing the uv version:uv_versionorvmafx-uv-versionwithin 40 characters of a version (with optional leadingv, e.g.vX.Y.ZorX.Y.Z) in either order, anduvdirectly followed by a version pin in prose or code (uv X.Y.Z,uv vX.Y.Z,uv==X.Y.Z,uv@X.Y.Z,pinned uv X.Y.Z, or a quoteduvbefore a quoted version). Soft-wrapped two-line echoes across a newline are a known gap. - Install-surface scanner: executable pip calls and literal
session.install(...)calls innoxfile.pymust reference a manifest-owned lock exactly. Dynamic Nox arguments and unmanifested requirement paths fail closed. Plain and annotated aliases plus literalgetattr(session, "install")aliases stay in the same scan. - Workflow checkout-order scanner: repo-local requirements, packages, helper scripts and local actions must follow an unconditional root checkout pinned to a full commit SHA. Without PyYAML, the fallback parser accepts only its audited block-style subset (including simple quoted
jobs, job-id andstepskeys) and rejects inline/flow-style mappings instead of treating an unparsed workflow as empty. - CI Impact Planner: changes to
requirements/trigger thepythonCI lane in.github/ci-impact.json. - Bot PR exemption: automated Renovate and Dependabot PRs updating the exact dependency allowlist are classified as dependency-only. Generic basename-wide
*.inormanifest.jsonmatching is forbidden, so source templates such ascore/include/libvmaf/version.h.inremain fully gated. - Renovate configuration:
renovate.jsonproposes updates against the source inputs (.in,pyproject.toml,docs/requirements.txt) and ignores compiled lock files.