Skip to content

Assert uv.lock stays on revision 3 - #244

Merged
rhysyngsun merged 4 commits into
mainfrom
nl/uv-lock-revision-check
Nov 23, 2026
Merged

rhysyngsun merged 4 commits into
mainfrom
nl/uv-lock-revision-check

Conversation

@rhysyngsun

@rhysyngsun rhysyngsun commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Adds the uv.lock revision check, which runs from mitodl/ol-github-workflows/actions/uv-lock-revision pinned at v1.1.0. The workflow here is the reference template with its two ADAPT lines set for this repository: default branch main, expected-revision: "3".

The check is a composite action rather than a copy of the script, so a fix to it lands once in ol-github-workflows and reaches this repository as a Renovate bump of the pin, like any other action. It is a composite action rather than a reusable workflow so the check context stays uv.lock revision instead of becoming <caller job> / <called job>.

Why

uv writes a revision key into uv.lock identifying the lockfile format, and rewrites it on any command that re-resolves - uv add, uv lock --upgrade, and so a Renovate dependency bump. It moves in both directions: a newer uv raises it, an older uv lowers it and drops fields.

Nothing else catches it, because uv accepts a lockfile written by a different version:

Check Against a lockfile whose format just changed
uv lock --check passes
uv sync --locked passes

This is not hypothetical. mitodl/ol-data-platform#3315 changed one pyproject.toml and silently took two lockfiles from revision 5 back to 3, with nothing in the PR to say so.

A required-version range cannot express the constraint - uv has only ever changed the revision mid-minor (0.6.10->0.6.17, 0.8.0->0.8.4, 0.12.21->0.12.22), never at a minor boundary - and it fails everywhere uv runs rather than only where a lockfile is written. That approach was tried and withdrawn; see https://github.com/mitodl/hq/issues/14344#issuecomment-6855508426.

This repository

Checks 1 lockfile, currently on revision 3. The action globs git ls-files -z '*uv.lock', so it covers every tracked lockfile with no extra configuration.

It needs no toolchain - the only action it uses is actions/checkout, and no step runs uv - so it cannot relock anything or break a build.

expected-revision is a floor, not an equality. A lockfile at or above it passes, so a newer uv raising the revision annotates the diff rather than failing it; what fails is a lockfile dropping below the floor, or below what the default branch already has. That second rule is the point: an older uv that re-resolves writes the revision it natively emits and silently drops the fields the newer format carried.

Part of mitodl/hq#14344. Contract: docs/uv-lock-revision-contract.md

uv rewrites the `revision` key in uv.lock on any command that
re-resolves -- `uv add`, `uv lock --upgrade`, and so a Renovate
dependency bump -- to whatever the running uv natively writes. It
moves in both directions: a newer uv raises it, an older uv lowers it
and drops fields.

Nothing else catches that. uv accepts a lockfile written by a
different version, so `uv lock --check` and `uv sync --locked` both
pass against one whose format just changed underneath.

It is not hypothetical: mitodl/ol-data-platform#3315 changed one
pyproject.toml and silently took two lockfiles from revision 5 back
to 3.

Adopted from mitodl/ol-github-workflows
workflow-templates/uv-lock-revision.yml, with the two ADAPT lines set
for this repository. Verified passing against this repository's
1 lockfile(s) before opening.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZvmEumrfZcNJ8DcaT5gEg

@agent-optibot agent-optibot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Checks tracked uv.lock files against revision 3.

  • Adds: a pull request and main branch check for every tracked uv.lock file.
  • Fixes: silent lockfile format changes by failing when a file lacks revision 3.
Details for reviewers

Core files: .github/workflows/uv-lock-revision.yml


Summary of c1d9e45 · React 👍 or 👎 on my comments to tune what I raise · Commands · Review config

@agent-optibot agent-optibot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status: Code Looks Good 👍

No blocking issues found.

📌 Reviewed up to the latest commit · ⏱️ Review completed in 2 minutes

  • 🔄 re-review this PR

The check runs from mitodl/ol-github-workflows/actions/uv-lock-revision, pinned
at v1.0.0, rather than from a copy of the script. A fix to it then lands once
and arrives here as a Renovate bump of the pin.

The job keeps the name `uv.lock revision`, so the check context is unchanged.
The check runs from mitodl/ol-github-workflows/actions/uv-lock-revision, pinned
at v1.0.0, rather than from a copy of the script. A fix to it then lands once
and arrives here as a Renovate bump of the pin.

The job keeps the name `uv.lock revision`, so the check context is unchanged.
The check runs from mitodl/ol-github-workflows/actions/uv-lock-revision, pinned
at v1.0.0, rather than from a copy of the script. A fix to it then lands once
and arrives here as a Renovate bump of the pin.

The job keeps the name `uv.lock revision`, so the check context is unchanged.
@rhysyngsun
rhysyngsun merged commit 45f8295 into main Nov 23, 2026
8 checks passed
@rhysyngsun
rhysyngsun deleted the nl/uv-lock-revision-check branch November 23, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant