feat: cut this repo over to apm-cli 0.39.3 pinned with uv (#271) #275

Merged
Defame1297 merged 14 commits from feat/271-uv-pinned-apm-cutover into main 2026-12-03 08:09:14 +00:00
Owner

Closes #271. Part of spec #268 and milestone 18. The decisions are recorded in ADR-0034, and the spike findings are in #268 (comment).

What changed

  • Pin. A root pyproject.toml with no build system, [tool.uv] package = false, Python ≥3.11 and a dev group pinning apm-cli==0.39.3. uv.lock is committed and .venv/ is ignored.

  • Approval keys (maintainer's option A). Under 0.39.3, the short keys kyberforge#… and delivery#… no longer match, so both hooks were silently parked. The keys are now the full package identity with type-level grants and the version suffix kept, for example git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.3.0: {hooks: true, bin: true}. apm approve was not run, so no content pins were made.

  • Allow-sync gate.

    • check-executables-allow-sync.sh builds the expected key from the git: and path: entries in root apm.yml.
    • It refuses dependency URLs that carry a port. It is verified only for https on a lowercase host, and the docs say so.
    • New: it fails the push when apm.lock.yaml records any exec_status: gated_*. Root audit --ci does not catch a parked hook, as the spike's §7.3 found.
  • Gate scripts.

    • The new scripts/lib/apm.sh spells the invocation once: uv run --project <repo root> --frozen apm. It resolves --project from its own location, keeps the git-env scrub, and lets the APM environment variable override the command.
    • It enforces 0.39.2 as the minimum version. The version is parsed from stdout only and anchored to apm's CLI version X.Y.Z banner, because uv's own Using CPython 3.14.6 line was being read as apm's version.
    • apm-audit-ci.sh and apm-pack-check-clean.sh both use the helper. The audit waiver strings still match 0.39.3, so the matching logic is unchanged.
    • The gates use plain --frozen, as ADR-0034 specifies for repo scripts. Only the SessionStart hook adds --no-sync --offline. After a pull that bumps the pin, the gates therefore sync to the new apm instead of certifying the tree with the old one.
  • Deliberate lock rewrite. This is the one exception to discarding lock churn on a branch. apm.lock.yaml was regenerated by the pinned 0.39.3:

    • lockfile v4 with apm_version: 0.39.3 and manifest_targets;
    • package_targets and carried_licenses per package;
    • new content_hash values and LICENSE entries.

    The ticket's precondition was not literally met: main's lock still recorded kyberforge 2.2.1 at 3b0dcc32. So the lock was regenerated with apm update --yes, which moved every first-party entry to feef6d8. That commit is tagged kyberforge-v2.3.0. The outcome the precondition protects, the new hook being deployed before the v4 lock, still holds.

  • apm-written files. .claude/settings.json and .claude/apm-hooks.json differ from main in one way only: the hook timeout went from 380 to 400. This is kyberforge 2.3.0's hooks.json being picked up. It is not a sign of wrong approvals, and nothing was hand-edited.

  • Tests.

    • New tests/test-apm-gate-invocation.sh covers seam B (fake uv plus a stub apm): 37/37.
    • test-check-executables-allow-sync.sh: 63/63.
    • The instructions-author bats suite now runs against the pinned apm and fails instead of skipping under --strict. Three of its assertions were updated to 0.39.3 behaviour; the skill text itself is fixed in #273.
    • The real-apm probe uses the pinned apm, offline.
  • Docs. README gains the uv prerequisite and the uv sync --frozen step. gates.md now describes the invocation and the full-identity keys, and the apm.yml and pre-commit descriptions were updated to match.

Verification

  • uv run --frozen apm --version reports 0.39.3.
  • /plan and /ship are deployed with disable-model-invocation: true.
  • Seam C. With the global pipx apm taken off PATH (not uninstalled):
    • uv sync --frozen and uv run --frozen apm install both exit 0;
    • the full pre-push set passes 11/11;
    • the SessionStart hook takes the uv path and prints no too-old line.
  • Offline. Under unshare -rn, the pre-push set passes 11/11.
  • Other checks.
    • Root apm audit --ci passes all 15 checks.
    • Both hooks show exec_status: deployed.
    • run-tests.sh --strict passes 25 suites.
    • pre-commit passes, and the pre-push stage passed on push.
  • The global pipx apm still reports 0.28.0.
  • Review. Two clean-context rounds. Round 1 had one blocking finding, the version check parsing uv's Python version, now fixed. Round 2 had no blocking findings, and its non-blocking items were applied.

Notes

  • Existing checkouts. The first 0.39 install refuses .claude/skills deployed by 0.28 with "no trustworthy local deployment baseline". Move .claude/{skills,agents,commands} aside before running uv run --frozen apm install. #272 documents this.
  • Timing. Root audit --ci takes about 70 s through uv run.
  • Follow-ups. #272 covers the remaining "0.28.0" claims and the AGENTS.md and gates.md setup sections. #273 covers the plugin skill text. Both are stacked on this branch.
  • Interim. This repo's SessionStart hook stops printing the too-old notice once this PR merges and the environment is synced.

🤖 Generated with Claude Code

https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi

Closes #271. Part of spec #268 and milestone 18. The decisions are recorded in ADR-0034, and the spike findings are in https://git.rkdr.net/Mortis/Holocron/issues/268#issuecomment-17805. ## What changed - **Pin.** A root `pyproject.toml` with no build system, `[tool.uv] package = false`, Python ≥3.11 and a dev group pinning `apm-cli==0.39.3`. `uv.lock` is committed and `.venv/` is ignored. - **Approval keys (maintainer's option A).** Under 0.39.3, the short keys `kyberforge#…` and `delivery#…` no longer match, so both hooks were silently parked. The keys are now the full package identity with type-level grants and the version suffix kept, for example `git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.3.0: {hooks: true, bin: true}`. `apm approve` was not run, so no content pins were made. - **Allow-sync gate.** - `check-executables-allow-sync.sh` builds the expected key from the `git:` and `path:` entries in root `apm.yml`. - It refuses dependency URLs that carry a port. It is verified only for https on a lowercase host, and the docs say so. - New: it fails the push when `apm.lock.yaml` records any `exec_status: gated_*`. Root `audit --ci` does not catch a parked hook, as the spike's §7.3 found. - **Gate scripts.** - The new `scripts/lib/apm.sh` spells the invocation once: `uv run --project <repo root> --frozen apm`. It resolves `--project` from its own location, keeps the git-env scrub, and lets the `APM` environment variable override the command. - It enforces 0.39.2 as the minimum version. The version is parsed from stdout only and anchored to apm's `CLI version X.Y.Z` banner, because uv's own `Using CPython 3.14.6` line was being read as apm's version. - `apm-audit-ci.sh` and `apm-pack-check-clean.sh` both use the helper. The audit waiver strings still match 0.39.3, so the matching logic is unchanged. - The gates use plain `--frozen`, as ADR-0034 specifies for repo scripts. Only the SessionStart hook adds `--no-sync --offline`. After a pull that bumps the pin, the gates therefore sync to the new apm instead of certifying the tree with the old one. - **Deliberate lock rewrite.** This is the one exception to discarding lock churn on a branch. `apm.lock.yaml` was regenerated by the pinned 0.39.3: - lockfile v4 with `apm_version: 0.39.3` and `manifest_targets`; - `package_targets` and `carried_licenses` per package; - new `content_hash` values and `LICENSE` entries. The ticket's precondition was not literally met: `main`'s lock still recorded kyberforge 2.2.1 at 3b0dcc32. So the lock was regenerated with `apm update --yes`, which moved every first-party entry to feef6d8. That commit is tagged `kyberforge-v2.3.0`. The outcome the precondition protects, the new hook being deployed before the v4 lock, still holds. - **apm-written files.** `.claude/settings.json` and `.claude/apm-hooks.json` differ from `main` in one way only: the hook timeout went from 380 to 400. This is kyberforge 2.3.0's `hooks.json` being picked up. It is not a sign of wrong approvals, and nothing was hand-edited. - **Tests.** - New `tests/test-apm-gate-invocation.sh` covers seam B (fake `uv` plus a stub apm): 37/37. - `test-check-executables-allow-sync.sh`: 63/63. - The instructions-author bats suite now runs against the pinned apm and fails instead of skipping under `--strict`. Three of its assertions were updated to 0.39.3 behaviour; the skill text itself is fixed in #273. - The real-apm probe uses the pinned apm, offline. - **Docs.** README gains the uv prerequisite and the `uv sync --frozen` step. `gates.md` now describes the invocation and the full-identity keys, and the `apm.yml` and pre-commit descriptions were updated to match. ## Verification - `uv run --frozen apm --version` reports 0.39.3. - `/plan` and `/ship` are deployed with `disable-model-invocation: true`. - **Seam C.** With the global pipx apm taken off PATH (not uninstalled): - `uv sync --frozen` and `uv run --frozen apm install` both exit 0; - the full pre-push set passes 11/11; - the SessionStart hook takes the uv path and prints no too-old line. - **Offline.** Under `unshare -rn`, the pre-push set passes 11/11. - **Other checks.** - Root `apm audit --ci` passes all 15 checks. - Both hooks show `exec_status: deployed`. - `run-tests.sh --strict` passes 25 suites. - pre-commit passes, and the pre-push stage passed on push. - The global pipx apm still reports 0.28.0. - **Review.** Two clean-context rounds. Round 1 had one blocking finding, the version check parsing uv's Python version, now fixed. Round 2 had no blocking findings, and its non-blocking items were applied. ## Notes - **Existing checkouts.** The first 0.39 install refuses `.claude/skills` deployed by 0.28 with "no trustworthy local deployment baseline". Move `.claude/{skills,agents,commands}` aside before running `uv run --frozen apm install`. #272 documents this. - **Timing.** Root `audit --ci` takes about 70 s through `uv run`. - **Follow-ups.** #272 covers the remaining "0.28.0" claims and the AGENTS.md and gates.md setup sections. #273 covers the plugin skill text. Both are stacked on this branch. - **Interim.** This repo's SessionStart hook stops printing the too-old notice once this PR merges and the environment is synced. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Claude added this to the Spec: Upgrade apm to 0.39.3 and pin it per repo with uv milestone 2026-12-02 11:06:43 +00:00
Claude added 13 commits 2026-12-02 11:06:44 +00:00
apm 0.39.3 matches executable grants on the package identity
<host>/<owner>/<repo>/<path>. The bare kyberforge#<version> and
delivery#<version> keys that 0.28.0 matched no longer match, so the first
0.39 install parks both hooks and rewrites .claude/settings.json without
them, while root apm audit --ci stays green (spike #269, on #268).

Rename both keys to git.rkdr.net/Mortis/Holocron/plugins/<name>#<version>
with type-level grants, as `apm approve --list` names them on 0.39.3. Keep
the version suffix convention; apm strips it before matching. Do not use
`apm approve`, which would content-pin, strip the block's comments and
park the hook on every script edit.

check-executables-allow-sync now derives each expected key from root
apm.yml's git + path dependency entry for the plugin, fails a bare key with
a message saying why, and fails a shipping plugin with no such entry. Both
readers carry the change, and the test covers URL and path spellings.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Add a root pyproject.toml with no build system, uv package mode off,
Python 3.11 or later, and a dev dependency group pinning apm-cli==0.39.3,
as ADR-0034 decides. Commit the uv.lock that hashes apm-cli and its
transitive dependencies, and ignore uv's .venv/.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Add scripts/lib/apm.sh, the one place the repo spells its apm command:
`uv run --project <repo root> --frozen apm`. --project comes from the
helper's own location, so it names the repo root even when apm runs inside
plugins/<name>/. Sourcing it keeps the git-env scrub (#204), and
require_apm_version fails with a clear message, naming `uv sync --frozen`,
when the resolved apm is below 0.39.2, unreadable, or uv is missing. APM
overrides the command, as ADR-0034 provides.

apm-audit-ci.sh and apm-pack-check-clean.sh use it. The audit script's
matching logic is unchanged; only its verified-against note now records
0.39.3.

tests/test-apm-gate-invocation.sh is seam B: a fake uv and a stub apm
first on a PATH without the real ones. It proves the command shape,
--project from a plugin directory, the scrub, and the version floor.
test-apm-hooks-git-env.sh reaches its stub through a fake uv, and the
real-apm probe in test-apm-current-hook.sh now runs the pinned apm.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
need_apm now runs apm through scripts/lib/apm.sh, so the suite exercises
the repo-pinned 0.39.3 and never a PATH apm. In this repo a missing uv or
an apm below 0.39.2 fails rather than skips, so run-tests.sh --strict
cannot pass without running these tests. Outside the repo it still falls
back to PATH apm and skips without one.

Three assertions pinned 0.28.0 behaviour and are updated to 0.39.3's:
compile --target claude writes a CLAUDE.md that imports AGENTS.md, an
unquoted applyTo fails install closed and deploys nothing, and compile
warns when applyTo matches no file. The skill's own text still describes
the 0.28.0 behaviour; that is left for a skill update.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Written by `uv run --frozen apm update --yes` on apm 0.39.3: lockfile
version 4, apm_version 0.39.3, and every dependency resolved to main at
feef6d8, which records kyberforge 2.3.0 from #270. This is the one
sanctioned exception to discarding lock churn on a feature branch
(ADR-0034, ADR-0019).

With the full-identity approvals both hooks stay deployed (exec_status
deployed). .claude/settings.json and .claude/apm-hooks.json keep the
PreToolUse guard and SessionStart entries; their only change is
kyberforge 2.3.0's hook timeout, 380 to 400. No apm-owned file was edited
by hand.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
README: uv replaces the global apm as a prerequisite, setup starts with
`uv sync --frozen`, and the offline note names both one-time steps.
gates.md: the apm hooks run through scripts/lib/apm.sh with plain
--frozen (and why the gates, unlike the SessionStart hook, keep the
sync), and check-executables-allow-sync expects the full package
identity apm 0.39 matches on.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
require_apm_version merged stderr into the --version output and took the
first X.Y.Z. When `uv run --frozen` syncs first, uv prints
`Using CPython 3.14.6` on stderr, so the check parsed 3.14.6 and passed
whatever apm reported. It now reads stdout only, matches apm's
`version X.Y.Z` banner, and shows the captured stderr only on failure.

The fake uv in the seam B test now writes that line to stderr, so the
regression stays pinned. Resolve the repo root with CDPATH cleared.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
How apm 0.39 writes a port into a package identity is unverified, so a
key derived from a git: URL with a port could be wrong while looking
right. The gate now fails clearly on one, naming `apm approve --list` as
the way to read the real identity. The script and gates.md record that
only an https URL on a lowercase host was checked against apm.

The test drops its GNU-only `sed -i` for a python3 rewrite, and covers
ssh:// and https URLs with a port under both readers.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
The probe moves HOME to an empty dir, which also moved uv's cache and its
managed Pythons, leaving uv cold. Pin UV_CACHE_DIR and
UV_PYTHON_INSTALL_DIR to the real ones resolved beforehand, and set
UV_OFFLINE so the probe runs the synced pin and never fetches. Verified
under `unshare -rn`.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Match `CLI version X.Y.Z`, the banner apm prints, instead of any
`version X.Y.Z`, so other version-like text on stdout is not taken for
apm's version. Fail clearly when APM holds only whitespace, instead of
running an empty command.

The seam B test now pins both properties. The fake uv also writes a
banner-shaped `uv CLI version 0.0.1` to stderr, so a parser reading the
merged stream fails it (23 failures with the round-1 bug restored). A
stub that prints `version 0.40.0` before a 0.28.0 banner must still fail.
The git-env test's stub prints the real banner.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
A comment and the name-mismatch message still described the bare
<name>#<version> key. Both now say <identity>#<version>, and that the
directory name is what finds the identity, through the root dependency
entry's `path: plugins/<dir>`.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
apm records each dependency's executables decision as `exec_status:` in
the lock. A gated_* value means the trust gate parked that package's
hooks, bin or MCP servers. Root `apm audit --ci` still passes in that
state, so a wrong key would leave the SessionStart hook or the delivery
guard uninstalled with every gate green (spike #269, section 7.3).

check-executables-allow-sync now scans the lock's dependencies and fails
on any gated_* entry, naming its identity and status, with a Why/Fix
block that starts from `apm approve --list`. It runs even when no plugin
here ships executables. The test covers deployed, two gated_* values
under both readers, the no-plugin case, and that neither the next
dependency nor the deployments: section is misreported. gates.md and the
hook description note it.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
The helper now seeds APM_CMD empty, and a bare "${APM_CMD[@]}" on an
array that can be empty fails under `set -u` on bash 3.2. The bash-4
construct scan in tests/test-vale-wrap.sh caught it at pre-push. Use the
guarded expansion that run_apm already uses.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Defame1297 added 1 commit 2026-12-02 12:18:48 +00:00
The lock committed in e87bd67 was written by `apm update` over an
apm_modules/ that apm 0.28.0 had populated. The 22 pinned third-party
dependencies (fluxcd gitops skills and mattpocock skills) were reused
from that cache, so the lock lacked their carried_licenses and LICENSE
deployment records. A fresh install writes them, which left the
committed lock out of step with every new checkout and failed
apm-pack-check-clean there on a content-hash mismatch.

Regenerated with `uv run --frozen apm install` after moving apm_modules/
aside: +331/-1, only carried_licenses for those 22 dependencies, their 22
LICENSE deployment records, and generated_at. A second fresh install into
another empty apm_modules/ left the lock byte-identical. Still the
sanctioned lock rewrite (ADR-0034); no tracked .claude/ file changed.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Defame1297 approved these changes 2026-12-03 08:09:09 +00:00
Defame1297 merged commit 38ca0a9433 into main 2026-12-03 08:09:14 +00:00
Defame1297 deleted branch feat/271-uv-pinned-apm-cutover 2026-12-03 08:09:14 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Holocron#275