ci(deps): pin hook revisions by SHA and install dev tools from a hashed lock #124

Merged
Defame1297 merged 2 commits from feat/supply-chain-pins into main 2026-11-14 20:08:42 +00:00
Collaborator

Refs #113

What

  • .pre-commit-config.yaml: all 7 hook repos pinned by commit SHA, release in a # frozen: vX.Y.Z comment.
  • requirements-dev.lock (new): hashed lock of requirements-dev.txt (81 entries incl. setuptools via --allow-unsafe). Installed with pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt by scripts/dev-setup.sh, images/ci and the fallback install in lint.yml / build.yml. pip refuses an unhashed package and any disagreement between the two files (tested: a bumped pin against a stale lock, a pin missing from the lock, an unhashed line).
  • scripts/lock-requirements.sh [--upgrade] regenerates the lock (pip 25.2 and pip-tools 7.6.2 pinned in a throwaway venv). It reproduces the committed lock, and replaying the lock's own header command gives an identical file.
  • renovate.json: the pip-compile manager replaces pip_requirements (the lock is the output file, requirements-dev.txt the source), and a weekly lockFileMaintenance PR (never automerged) moves transitive packages.
  • check_bot_pr_diff.py: accepts rev: <sha> # frozen: <tag>, and lock entries, sha256 hashes and plain comments; a changed # pip-compile ... header command is refused.
  • The lock is an image input (Dockerfile COPY, ci-pins.sha256, image.yml paths, molecule IGNORED, galaxy.yml build_ignore). ci image 0.2.18 -> 0.2.19. Docs updated.

Changes since the review

Rebased onto main (0.2.19, pre-push hook type kept); dropped check_requirements_lock.py, its tests and its hook; -r requirements-dev.txt next to the lock at all four install sites; pip and pip-tools pinned (7.5.2 crashed on current pip and wrote a --no-index header that cannot be replayed); --upgrade mode; Renovate pip-compile manager and bot-diff lock rule; false pinDigests comment replaced; git ls-remote advice lists both refs; the dev-setup test asserts the pip arguments; commit type ci(deps).

Tested

  • Fresh Python 3.13 venv: pip install --require-hashes -r requirements-dev.lock succeeds; all six tools at their pinned versions. --dry-run of the two-file install also passes.
  • scripts/dev-setup.sh end to end (earlier head); pre-commit run --all-files clean; 178 script tests pass; check_image_versions.py bump and pins ok.

Not verified: needs a Renovate dry run

  • The pip-compile manager on this lock. The Renovate docs do not mention --generate-hashes, do not confirm a .lock output name, and do not say how a plain .txt source is classified; they recommend disabling pip_requirements for source files (done). Run Actions > Renovate > dry_run=true and check that it proposes a requirements-dev.txt bump together with a regenerated lock. If it does not work, drop the manager and bump by hand with scripts/lock-requirements.sh [--upgrade].
  • Renovate on # frozen: revs. The docs say it keeps the frozen format; they do not say the comment's version text is rewritten.
  • The real ci image build, and CI on this head.
  • The lock was compiled with Python 3.13; dev-setup.sh accepts 3.13+ and the review dry-ran the lock on 3.14.
  • Two-PR loop: this is PR 1; the digest pin PR follows the rebuild on main.
Refs #113 ## What - `.pre-commit-config.yaml`: all 7 hook repos pinned by commit SHA, release in a `# frozen: vX.Y.Z` comment. - `requirements-dev.lock` (new): hashed lock of `requirements-dev.txt` (81 entries incl. setuptools via `--allow-unsafe`). Installed with `pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt` by `scripts/dev-setup.sh`, `images/ci` and the fallback install in `lint.yml` / `build.yml`. pip refuses an unhashed package and any disagreement between the two files (tested: a bumped pin against a stale lock, a pin missing from the lock, an unhashed line). - `scripts/lock-requirements.sh [--upgrade]` regenerates the lock (pip 25.2 and pip-tools 7.6.2 pinned in a throwaway venv). It reproduces the committed lock, and replaying the lock's own header command gives an identical file. - `renovate.json`: the `pip-compile` manager replaces `pip_requirements` (the lock is the output file, `requirements-dev.txt` the source), and a weekly `lockFileMaintenance` PR (never automerged) moves transitive packages. - `check_bot_pr_diff.py`: accepts `rev: <sha> # frozen: <tag>`, and lock entries, sha256 hashes and plain comments; a changed `# pip-compile ...` header command is refused. - The lock is an image input (Dockerfile COPY, `ci-pins.sha256`, `image.yml` paths, molecule IGNORED, `galaxy.yml` build_ignore). ci image 0.2.18 -> 0.2.19. Docs updated. ## Changes since the review Rebased onto main (0.2.19, `pre-push` hook type kept); dropped `check_requirements_lock.py`, its tests and its hook; `-r requirements-dev.txt` next to the lock at all four install sites; pip and pip-tools pinned (7.5.2 crashed on current pip and wrote a `--no-index` header that cannot be replayed); `--upgrade` mode; Renovate pip-compile manager and bot-diff lock rule; false `pinDigests` comment replaced; `git ls-remote` advice lists both refs; the dev-setup test asserts the pip arguments; commit type `ci(deps)`. ## Tested - Fresh Python 3.13 venv: `pip install --require-hashes -r requirements-dev.lock` succeeds; all six tools at their pinned versions. `--dry-run` of the two-file install also passes. - `scripts/dev-setup.sh` end to end (earlier head); `pre-commit run --all-files` clean; 178 script tests pass; `check_image_versions.py bump` and `pins` ok. ## Not verified: needs a Renovate dry run - **The `pip-compile` manager on this lock.** The Renovate docs do not mention `--generate-hashes`, do not confirm a `.lock` output name, and do not say how a plain `.txt` source is classified; they recommend disabling `pip_requirements` for source files (done). Run Actions > Renovate > dry_run=true and check that it proposes a `requirements-dev.txt` bump together with a regenerated lock. If it does not work, drop the manager and bump by hand with `scripts/lock-requirements.sh [--upgrade]`. - **Renovate on `# frozen:` revs.** The docs say it keeps the frozen format; they do not say the comment's version text is rewritten. - The real ci image build, and CI on this head. - The lock was compiled with Python 3.13; `dev-setup.sh` accepts 3.13+ and the review dry-ran the lock on 3.14. - Two-PR loop: this is PR 1; the digest pin PR follows the rebuild on main.
Claude left a comment
Owner

Review: request changes

The supply-chain work is sound. It can't merge as it stands, though, and it can be noticeably smaller.

Verified fine

  • All 7 hook SHAs match the peeled # frozen: tags upstream (git ls-remote).
  • All 81 lock entries match PyPI's file digests exactly. With pip pinned, the lock regenerates byte for byte.
  • A --dry-run --require-hashes install of the lock resolves on CPython 3.14, the Python of the ci image's Ubuntu 26.04 base.
  • All 4 install sites use --require-hashes -r requirements-dev.lock. No unhashed install path is left.
  • The new REV_LINE in check_bot_pr_diff.py held against 17 adversarial rev: lines.
  • The workflow changes add no new secret references and no ${{ github.* }} in run:.
  • The lock is wired as an image input everywhere: Dockerfile COPY, ci-pins.sha256, image.yml paths, IGNORED, build_ignore.
  • REUSE is covered. No changelog fragment is correct for a tooling-only change. The 170 script tests pass.

Must fix

  1. Rebase onto main. image.yml and .pre-commit-config.yaml conflict.
    • Main has already published ci 0.2.17 and 0.2.18, so this PR needs 0.2.19. With 0.2.17, check_image_versions.py bump fails with "version went backwards".
    • For .pre-commit-config.yaml, keep your header comment and main's default_install_hook_types: [pre-commit, commit-msg, pre-push].
  2. Every Renovate bump of requirements-dev.txt now fails.
    • pip_requirements only edits the txt, so the requirements-lock hook fails Lint.
    • If anything regenerated the lock, check_bot_pr_diff.py would reject it. That check runs from main, and the lock isn't on its allowlist.
    • So the documented minor/patch automerge policy silently stops for the Python tools.
    • Suggestion: enable Renovate's pip-compile manager on requirements-dev.lock and add a lock rule to the bot-diff gate (only name==ver, --hash=sha256: and # via lines).
    • Otherwise, make pip bumps explicitly manual and update CLAUDE.md. Either way, check it with a Renovate dry run.
  3. Transitive dependencies are never upgraded. Nothing runs pip-compile --upgrade/-P, so cryptography, urllib3, certifi and the rest stay frozen at their current versions. Item 2's manager covers this; otherwise give the script an upgrade mode.
  4. scripts/lock-requirements.sh crashes on a current Python 3.13.
    • The throwaway venv gets pip 26.1.2, and pip-tools 7.5.2 fails with AttributeError: 'PackageFinder' object has no attribute 'allow_all_prereleases'.
    • Pin pip in the venv (pip 25.2 worked and reproduced the lock), or move to pip-tools 7.6.x.
  5. .pre-commit-config.yaml:4 claims a "pinDigests rule in renovate.json" that doesn't exist.
    • Whether Renovate's pre-commit manager keeps rev: <sha> # frozen: vX in step is unverified.
    • If it treats the SHA as a bare digest, it may propose moving hooks to unreleased HEAD commits, and those bumps would automerge.

Simplification: about 240 of the roughly 350 hand-written lines can go

Drop scripts/check_requirements_lock.py, its tests and its hook. Add -r requirements-dev.txt next to the lock at the 4 install sites instead.

  • Under --require-hashes, pip already rejects missing hashes, non-== pins, -e lines and unlocked transitive dependencies.
  • With both -r files, pip also catches drift between txt and lock: a version conflict, or a pin missing from the lock. This was tested.
  • The checker is weaker than its docstring says anyway. read_pins silently skips txt lines it can't parse, so reuse == 6.3.1, pkg[extra]==1.0 and reuse~=6.3 all pass while the lock disagrees.
  • What you lose is the commit-time signal: drift then shows up in dev-setup.sh or CI instead.

Minor and nits

  • test_dev_setup.py: the pip stub is exit 0 and records no arguments. If dev-setup.sh went back to the txt or lost --require-hashes, the test would still pass.
  • The checker's environment-marker slot accepts trailing pip options (--index-url, -r). pip ignores those, so it isn't exploitable, but it contradicts the docstring.
  • lock-requirements.sh installs pip-tools without a hash, and its last line runs python3 instead of $python.
  • The hand-pinning advice git ls-remote <repo> refs/tags/<tag>^{} prints nothing for lightweight tags, which is 6 of the 7. List both refs and take ^{} when it is present.
  • Stale docs: the requirements-dev.txt header and docs/images/ci.md still say Renovate handles the bumps.
  • Commit type: repo history uses ci(...), so ci(deps): fits better than feat(ci):.
  • Scope: #113 asked the maintainer to pick between its options. That choice is being made here.

Not verified

  • How Renovate actually handles the rev: <sha> # frozen: form.
  • The real ci image build.
  • CI on the rebased branch.

🤖 Generated with Claude Code

https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG

## Review: request changes The supply-chain work is sound. It can't merge as it stands, though, and it can be noticeably smaller. ### Verified fine - All 7 hook SHAs match the peeled `# frozen:` tags upstream (`git ls-remote`). - All 81 lock entries match PyPI's file digests exactly. With pip pinned, the lock regenerates byte for byte. - A `--dry-run --require-hashes` install of the lock resolves on CPython 3.14, the Python of the ci image's Ubuntu 26.04 base. - All 4 install sites use `--require-hashes -r requirements-dev.lock`. No unhashed install path is left. - The new `REV_LINE` in `check_bot_pr_diff.py` held against 17 adversarial `rev:` lines. - The workflow changes add no new secret references and no `${{ github.* }}` in `run:`. - The lock is wired as an image input everywhere: Dockerfile COPY, `ci-pins.sha256`, `image.yml` paths, IGNORED, `build_ignore`. - REUSE is covered. No changelog fragment is correct for a tooling-only change. The 170 script tests pass. ### Must fix 1. **Rebase onto main.** `image.yml` and `.pre-commit-config.yaml` conflict. - Main has already published ci 0.2.17 and 0.2.18, so this PR needs **0.2.19**. With 0.2.17, `check_image_versions.py bump` fails with "version went backwards". - For `.pre-commit-config.yaml`, keep your header comment and main's `default_install_hook_types: [pre-commit, commit-msg, pre-push]`. 2. **Every Renovate bump of `requirements-dev.txt` now fails.** - `pip_requirements` only edits the txt, so the `requirements-lock` hook fails Lint. - If anything regenerated the lock, `check_bot_pr_diff.py` would reject it. That check runs from main, and the lock isn't on its allowlist. - So the documented minor/patch automerge policy silently stops for the Python tools. - Suggestion: enable Renovate's `pip-compile` manager on `requirements-dev.lock` and add a lock rule to the bot-diff gate (only `name==ver`, `--hash=sha256:` and `# via` lines). - Otherwise, make pip bumps explicitly manual and update CLAUDE.md. Either way, check it with a Renovate dry run. 3. **Transitive dependencies are never upgraded.** Nothing runs `pip-compile --upgrade`/`-P`, so `cryptography`, `urllib3`, `certifi` and the rest stay frozen at their current versions. Item 2's manager covers this; otherwise give the script an upgrade mode. 4. **`scripts/lock-requirements.sh` crashes on a current Python 3.13.** - The throwaway venv gets pip 26.1.2, and pip-tools 7.5.2 fails with `AttributeError: 'PackageFinder' object has no attribute 'allow_all_prereleases'`. - Pin pip in the venv (pip 25.2 worked and reproduced the lock), or move to pip-tools 7.6.x. 5. **`.pre-commit-config.yaml:4` claims a "pinDigests rule in renovate.json" that doesn't exist.** - Whether Renovate's pre-commit manager keeps `rev: <sha> # frozen: vX` in step is unverified. - If it treats the SHA as a bare digest, it may propose moving hooks to unreleased HEAD commits, and those bumps would automerge. ### Simplification: about 240 of the roughly 350 hand-written lines can go Drop `scripts/check_requirements_lock.py`, its tests and its hook. Add `-r requirements-dev.txt` next to the lock at the 4 install sites instead. - Under `--require-hashes`, pip already rejects missing hashes, non-`==` pins, `-e` lines and unlocked transitive dependencies. - With both `-r` files, pip also catches drift between txt and lock: a version conflict, or a pin missing from the lock. This was tested. - The checker is weaker than its docstring says anyway. `read_pins` silently skips txt lines it can't parse, so `reuse == 6.3.1`, `pkg[extra]==1.0` and `reuse~=6.3` all pass while the lock disagrees. - What you lose is the commit-time signal: drift then shows up in `dev-setup.sh` or CI instead. ### Minor and nits - `test_dev_setup.py`: the pip stub is `exit 0` and records no arguments. If `dev-setup.sh` went back to the txt or lost `--require-hashes`, the test would still pass. - The checker's environment-marker slot accepts trailing pip options (`--index-url`, `-r`). pip ignores those, so it isn't exploitable, but it contradicts the docstring. - `lock-requirements.sh` installs pip-tools without a hash, and its last line runs `python3` instead of `$python`. - The hand-pinning advice `git ls-remote <repo> refs/tags/<tag>^{}` prints nothing for lightweight tags, which is 6 of the 7. List both refs and take `^{}` when it is present. - Stale docs: the `requirements-dev.txt` header and `docs/images/ci.md` still say Renovate handles the bumps. - Commit type: repo history uses `ci(...)`, so `ci(deps):` fits better than `feat(ci):`. - Scope: #113 asked the maintainer to pick between its options. That choice is being made here. ### Not verified - How Renovate actually handles the `rev: <sha> # frozen:` form. - The real ci image build. - CI on the rebased branch. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
Dragonish added 1 commit 2026-11-14 16:53:40 +00:00
ci(deps): pin hook revisions by SHA and install dev tools from a hashed lock
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 1m42s
Molecule / molecule (pull_request) Successful in 5m23s
4058978353
Refs #113.

- .pre-commit-config.yaml: every hook repo is pinned by commit SHA with the release in a
  `# frozen:` comment, so a moved tag cannot change the code a hook environment is built from.
- requirements-dev.lock: hashed lock of requirements-dev.txt. Installs use
  `pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt` (dev-setup.sh,
  the ci image, the fallback install of Lint and Build): pip refuses an unhashed package and any
  disagreement between the two files.
- scripts/lock-requirements.sh regenerates the lock (pinned pip and pip-tools, --upgrade mode).
- renovate.json: the pip-compile manager replaces pip_requirements for the lock, plus a weekly,
  never automerged lock-file maintenance PR for transitive packages. Not yet dry-run on Renovate.
- check_bot_pr_diff.py accepts `rev: <sha>  # frozen: <tag>` and lock entries, hashes and plain
  comments, but not a changed pip-compile header command.
- ci image 0.2.18 -> 0.2.19 (image inputs changed).
Dragonish force-pushed feat/supply-chain-pins from 1184938f1e to 4058978353 2026-11-14 16:53:40 +00:00 Compare
Dragonish changed title from feat(ci): pin hook revisions by SHA and install dev tools from a hashed lock to ci(deps): pin hook revisions by SHA and install dev tools from a hashed lock 2026-11-14 16:53:54 +00:00
Author
Collaborator

Addressed in 4058978 (rebased, one commit, ci(deps)). 1: rebased, 0.2.19, pre-push kept. 2+3: pip-compile manager on the lock plus a weekly never-automerged lock-file-maintenance PR for transitives, and a bot-diff lock rule (entries, sha256 hashes, plain comments; a changed pip-compile header is refused). Not verified: it needs a Renovate dry run, the docs say nothing on hashes or a .lock name; fallback is scripts/lock-requirements.sh [--upgrade]. 4: pip 25.2 and pip-tools 7.6.2 pinned; 7.5.2 also wrote --no-index into the header, which Renovate would replay and fail on. Reproduces the committed lock. 5: false pinDigests comment replaced with what the docs say. Simplification taken: checker, tests and hook removed, -r txt next to the lock at all four sites (tested against drift cases). Minor: dev-setup test asserts the pip args, ls-remote advice lists both refs, docs fixed. Still open: Renovate dry run, CI on this head.

Addressed in 4058978 (rebased, one commit, ci(deps)). 1: rebased, 0.2.19, pre-push kept. 2+3: pip-compile manager on the lock plus a weekly never-automerged lock-file-maintenance PR for transitives, and a bot-diff lock rule (entries, sha256 hashes, plain comments; a changed pip-compile header is refused). Not verified: it needs a Renovate dry run, the docs say nothing on hashes or a .lock name; fallback is scripts/lock-requirements.sh [--upgrade]. 4: pip 25.2 and pip-tools 7.6.2 pinned; 7.5.2 also wrote --no-index into the header, which Renovate would replay and fail on. Reproduces the committed lock. 5: false pinDigests comment replaced with what the docs say. Simplification taken: checker, tests and hook removed, -r txt next to the lock at all four sites (tested against drift cases). Minor: dev-setup test asserts the pip args, ls-remote advice lists both refs, docs fixed. Still open: Renovate dry run, CI on this head.
Defame1297 added 1 commit 2026-11-14 19:57:51 +00:00
Merge branch 'main' into feat/supply-chain-pins
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 1m34s
Molecule / molecule (pull_request) Successful in 8m0s
6e8f5bed10
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-11-14 19:58:17 +00:00
Defame1297 merged commit fd3fceeabb into main 2026-11-14 20:08:42 +00:00
Defame1297 deleted branch feat/supply-chain-pins 2026-11-14 20:08:42 +00:00
Sign in to join this conversation.
No Reviewers
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#124