Files changed: - .gitea/workflows/ci.yml - .gitea/workflows/converters.yml - .gitea/workflows/nightly.yml - .gitea/workflows/release.yml - .gitea/workflows/tracker-live.yml - CHANGES.md - INSTALL.md - VERSION - docs/dev/development.md - docs/how-to/set-up-the-mcp-server.md - instructions/dev/dependency-locks.md - instructions/dev/publish-and-ci.md - instructions/dev/stack-mode.md - instructions/dev/tracker-testing.md - instructions/mcp-read-server.md - instructions/preflight.md - tools/CONTRACT.md - tools/README.md - tools/chemenu/commands/dist_cmd.py - tools/chemenu/commands/doctor.py - tools/chemenu/install_doc.py - tools/chemenu/prerequisites.py - tools/chemenu/tests/test_dependency_locks.py - tools/chemenu/tests/test_dist_cmd.py - tools/chemenu/tests/test_doctor.py - tools/chemenu/tests/test_install_doc.py - tools/chemenu/tests/test_preflight.py - tools/chemenu/tests/test_preflight_pwsh.py - tools/lock_requirements.py - tools/preflight.ps1 - tools/preflight.sh - tools/prerequisites.txt - tools/requirements-browser.lock - tools/requirements-browser.txt - tools/requirements-dev.lock - tools/requirements-dev.txt - tools/requirements-mcp.lock - tools/requirements-mcp.txt - tools/requirements.lock - tools/requirements.txt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015uxGFdBAmyA23g1isCtGEY
7.6 KiB
type, name, description
| type | name | description |
|---|---|---|
| types/instruction.md | dependency-locks | How the Python packages of the stack are pinned and moved - the four lock files under tools/, regenerating them with the 7-day cooldown, lifting one package at once for a security fix without ever lowering it again, checking that no locked package was too young, and what a red nightly audit or fresh-resolution run asks for. |
Pin the stack's packages, and move them on purpose
Every Python package the stack or its CI installs comes from a lock under tools/: exact
versions with SHA-256 hashes, transitive packages included, installed with
pip install --require-hashes. Before Gitea #245 the requirement files carried lower bounds
only, CI installed whatever was newest that morning, and an instance kept the packages of the day
it was set up - CI went red after four quiet weeks when pytest 9.2 and typer 0.29.1 came out
(#243), and a compromised release would have reached the next install unchecked. Pins answer both
sides of faster attacks: nothing new flows in unchecked, and a known hole is closed by a
deliberate lift, at once.
Contents
The files
| Source (lower bounds) | Lock | Installed by | Ships |
|---|---|---|---|
tools/requirements.txt |
tools/requirements.lock |
the preflight, every run whose stamp differs | yes |
tools/requirements-mcp.txt |
tools/requirements-mcp.lock |
the user, by hand (command in the source's head); CI | yes |
tools/requirements-browser.txt |
tools/requirements-browser.lock |
the preflight, --with browser and after |
yes |
tools/requirements-dev.txt |
tools/requirements-dev.lock |
CI and a developer: pytest, pytest-cov, radicale, pip-audit, uv | no (TOOLS_DEV_ONLY) |
tools/lock_requirements.py (dev-only) is the one way a lock is written. It resolves the four in
that order, each constrained by every lock above it (-c), because all of them land in one venv:
a package in two locks has one version, and a later pip install -r never moves a package an
earlier lock placed. test_dependency_locks.py holds every property below on each push.
The locks resolve for the Python minimum in tools/prerequisites.txt with --universal, so one
file serves Linux, macOS and Windows across the admitted span. A source file is never installed
itself - not by the preflight, not by CI (the same test reads every workflow for it).
When to run
- A regular lift - a new package version is wanted, a source file's floor moved, or a lock is
simply due. It is a small stack package of its own: the locks, a patch bump,
publish. - A security lift - the nightly's
pip-auditstep is red, or an advisory names a locked version. Same day, one package, no cooldown. - The nightly's fresh-resolution step is red - today's regular lift would break the suite. Not a lift yet: the defect it shows is fixed first, in a package of its own, and the lift follows with it.
Steps
-
Have
uvonPATH.requirements-dev.lockcarries it; in a checkout with the test tools installed,tools/.venv/bin/uvis it. -
Regular lift - regenerate every lock:
PATH="$PWD/tools/.venv/bin:$PATH" python3 tools/lock_requirements.pyIt sets
--exclude-newerto now minus 7 days: a file uploaded later is not considered. A compromised release is usually found and pulled within hours to days; the cooldown lets that happen before a lock can take one. Exceptions from an earlier security lift are carried over while still younger than the cutoff and dropped once it passes them (step 3). -
Security lift - one package, at once.
pip-auditnames the package and the first fixed version X:-
Raise the floor in its source file to
<name>>=X. It stays there for good - it is simply true that vulnerable versions are no longer taken, and it is what keeps every later lift from lowering the package again. -
Regenerate with an exception for that package alone, up to X's upload time plus a minute (PyPI's JSON API shows it as
upload_time_iso_8601per file):PATH="$PWD/tools/.venv/bin:$PATH" python3 tools/lock_requirements.py \ --exception <name>=<upload time of X + 1 minute, e.g. 2026-11-17T09:31:00Z>
uv writes the exception into each lock's head beside the cutoff. The invariant: no later lift lowers the package below X. While X is younger than the cooldown, the script carries the exception into the next regular lift; once the cutoff has passed X, the exception is no longer needed and drops out, and the floor stays. Without both, a lift would fail loudly - "No solution ... filtered by
exclude-newer" - rather than lower the package silently: that is the floor doing its job, not a reason to remove it. -
-
Check the result.
cd tools && .venv/bin/python -m pytest -q chemenu/tests/test_dependency_locks.pyIt holds: an exact version and at least one SHA-256 per package; every source requirement pinned at or above its floor; one version per package across the four locks; each lock constrained by the ones before it; and no package younger than 7 days - the lock's
--exclude-newerlies at least 7 days before the lock's last commit (before now, while the file differs fromHEAD). A security lift's package is the one exception, visible as--exclude-newer-packagein the head. Read the diff as well: a package that moved a major version, or one new in a lock, is worth a line in the changelog entry. -
Install and run the suite against the new locks - the preflight installs
requirements.lockby itself once its hash changed; the other two by hand:tools/preflight.sh tools/.venv/bin/python -m pip install --require-hashes -r tools/requirements-mcp.lock tools/.venv/bin/python -m pip install --require-hashes -r tools/requirements-dev.lock cd tools && .venv/bin/python -m pytest -q -
Bump and publish. A lock under
tools/reaches every instance - its next preflight moves the venv to it - so it is a patch bump (version-parts.md) with a changelog entry naming the lift, then publish-and-ci.md. A lift that touchesrequirements.lockalso starts theConvertersworkflow.
Decision points
- The nightly's
pip-auditstep is red, but no fixed version exists yet? Nothing to lift. Name the advisory and whether the stack reaches the vulnerable code in the topic issue, and check again when a fix is released. - A regular lift fails with "No solution found ... filtered by
exclude-newer"? A floor in a source file names a version younger than the cutoff - usually a security lift whose exception was lost. Restore the exception from the lock's head ingit log -p; never lower the floor. - A package wants a Python outside the span? The resolution for the minimum fails or picks an
old version. The span is a design decision in
tools/prerequisites.txt, not something a lift moves; take it tostack-dev. - A new dependency? Add it to the source file that matches who needs it, with a floor, then
regenerate. A package only the origin repository's tests need goes into
requirements-dev.txt, never into a lock that ships.
Scope
The origin repository only - dist export ships the three runtime locks, not this file, the
script or the dev lock. The span of Python versions itself is tools/prerequisites.txt and
instructions/preflight.md; reasons for the design are Gitea #245.