The hook now picks one apm and uses it for both the outdated check and the update (ADR-0034): `uv run --project <root> --frozen --no-sync --offline apm` when the project pins apm-cli (a quoted apm-cli requirement in pyproject.toml plus a uv.lock) and uv is on PATH, else the PATH apm, else it exits silently. uv is only ever called as `uv run`; `--no-sync` keeps a plain run from syncing the environment, and `--offline` keeps uv off the network. Before the outdated check it reads `--version`. Below 0.39.2, or when the version cannot be read, it prints a fixed notice naming the chosen binary and skips the check, since an older apm refuses a lockfile v4 and would report it as up to date. All advice strings are fixed literals that name the chosen binary; no command output is interpolated. Tests use seam A: a fake uv first on a whitelisted PATH logs every call and reaches the pinned fake apm only through `uv run`. They cover pin plus uv, pin without uv, pin without uv.lock, no pin, no apm, too-old and boundary versions, stale and current output on both paths, and hostile output. ADR-0034 is amended to record that seam. Impact: kyberforge 2.2.1 -> 2.3.0, catalog 0.9.0 -> 0.9.1. Refs: #270 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
5.6 KiB
apm is pinned per repo with uv
Status: accepted (2026-12-01).
Amended 2026-12-01 (holocron#270): the hook's test seam is a PATH stub of uv, not an APM
environment override. tests/test-apm-current-hook.sh puts a fake uv first on a PATH that
excludes the machine's real uv and apm. The fake records every invocation and reaches the pinned
fake apm only through uv run, so the shipped hook carries no test-only override. The APM variable
under Invocation still applies to repo scripts, not to the hook. The hook also passes --no-sync and
--offline to uv run. A plain uv run --frozen syncs the environment before running, which is the
uv sync and the network access this contract forbids.
Context
Issue #265. apm is installed once per machine with pipx, at 0.28.0, and every repo and the
SessionStart hook (ADR-0019) call whatever apm is on PATH. Three things now fail against that:
- Lockfile format. apm 0.37 and later write lockfile v4, and apm 0.36.1 and earlier refuse it. A lock written by 0.39.2 is in turn refused by 0.37.0 through 0.39.1.
- Command keys. apm 0.39.0 and later keep Claude command keys such as
disable-model-invocation(#245). Earlier versions drop them, so a deployed command silently loses the setting. - Machine-global drift. One shared binary means every checkout's behaviour depends on what was
last installed on that machine. apm has no minimum-version field in
apm.yml, and upstream's advice is to pin a minimum in CI. This repo has no CI (ADR-0024), so the pin has to live in the repo.
Decision
Each repo pins its own apm with uv. This repo needs apm 0.39.2 or later and is pinned to 0.39.3.
-
Pin. The root
pyproject.tomlhas no build system, sets[tool.uv] package = falseandrequires-python = ">=3.11", and declares[dependency-groups] dev = ["apm-cli==0.39.3"]. A committeduv.lockfixes the transitive dependencies..venv/is gitignored. -
Invocation. Repo scripts run apm as
uv run --project <repo root> --frozen apm. AnAPMenvironment variable overrides the command, as a seam for tests. -
Minimum version, 0.39.2. It is the lowest version that reads and writes lockfile v4 and is read back by later versions, and it is at or above 0.39.0, which keeps the Claude command keys. Inside this repo the
==pin enforces it. Where apm comes fromPATH(a consumer repo that does not pin), an explicit version check enforces it. -
uv only pins apm itself. ADR-0024 stands: apm is the only supported install path for plugin content. uv installs the tool, never plugins, skills or agents.
-
Hook first. The kyberforge
SessionStarthook change ships first, with a kyberforge version bump and its release tag (ADR-0033). The cutover (the v4 lock,pyproject.toml,uv.lock, the scripts and their tests) follows as one PR. The order matters because the deployed hook comes from themaincommit thatapm.lock.yamlrecords. If the v4 lock landed first, the old hook would runPATHapm 0.28.0, which refuses the lock, and staleness detection would be lost with no error. -
The cutover PR commits a lock rewrite (v1 to v4) on purpose. It is the one sanctioned exception to the rule that
apm.lock.yamlchurn is discarded on feature branches (ADR-0019). -
Consumer hook contract. The shipped hook (
check-apm-current.sh) resolves apm in this order:uv run --frozen, when the project pinsapm-cliand uv exists.apmonPATH.- Neither: exit 0.
It never triggers a uv sync, and on a cold cache it must not touch the network inside the
SessionStarttimeout. It never reports "up to date" when it ran on an apm older than 0.39.2. Its advice strings are fixed and name the chosen binary, with no interpolation of command output. -
Global apm 0.28.0 stays. It stays installed and on
PATH, because ansible still uses it (Defame1297/ansible-homelab-mono#1078). It is not upgraded. Whichever of that issue and Mortis/Kamino#499 lands last uninstalls it: the last mover deletes. -
New setup step. The offline pre-push guarantee of ADR-0019 now needs
uv sync --frozenonce andapm installonce per checkout. The first apm 0.39 install also needs the network, to record commit verdicts.
Considered options
Global pipx apm, as today (rejected). It is the drift described above, and it cannot enforce a minimum version.
Upgrade the global apm (rejected). It would fix this repo and break ansible, which still depends on 0.28.0 behaviour, and it would leave the next repo with the same shared-binary problem.
uvx (rejected). It has no lock, so apm's transitive dependencies float between runs and the
pin only covers the top-level package.
uv tool install (rejected). It is machine-global state, the same drift as pipx under a
different name.
Consequences
- A bare
apminstruction fails closed. Any leftoverapmcall in this repo that resolves to the global 0.28.0 refuses the v4 lock instead of rewriting it. That is the intended failure, but it will surprise whoever hits it; the fix is theuv runform. - The network is needed on first sync. A fresh checkout needs it for
uv sync --frozenand again for the firstapm install. After both, the offline guarantee holds. - uv becomes a prerequisite of working in this repo. A consumer without uv falls back to
PATHapm and the version check. - Re-verification is pending. ADR-0019 and ADR-0033 state facts verified against apm 0.28.0. They are re-checked on 0.39.3 under #265, and each carries a note saying so.
Related: ADR-0019, ADR-0024, ADR-0033; #245, #265; Defame1297/ansible-homelab-mono#1078; Mortis/Kamino#499.