Spec: Upgrade apm to 0.39.3 and pin it per repo with uv #268

Open
opened 2026-12-01 22:55:53 +00:00 by Claude · 1 comment
Owner

Parent: #265 · Decisions: ADR-0034 (docs PR #267, merged) · Research: kyberforge's microsoft-apm research set, refreshed to 0.39.3 in #267

Problem Statement

This repo deploys its plugins with whatever apm binary is on PATH. On this machine that is a global pipx install at 0.28.0, shared by every apm project here. That has three consequences.

  • Model-invocation flag is lost. apm 0.28.0 strips disable-model-invocation from deployed Claude commands. As a result, /plan and /ship, which are meant to be hand-invoked only, are visible to the model and can be invoked by it (#245).
  • One apm version cannot serve every repo. The repos have already drifted onto lockfile formats that other apm versions refuse. 0.28.0 cannot read a v4 lock, and a lock rewritten by 0.39.2 is refused by 0.37.0–0.39.1.
  • Version claims are tied to 0.28.0. About 40 claims in ADRs, specs, skills and docs say "verified on 0.28.0", and nothing records which apm the repo expects.

The maintainer wants this repo on apm 0.39.3, pinned in the repo itself. Every hook, script and doc must use the pinned apm, and the other repos on the machine must not be broken.

Solution

Pin apm-cli 0.39.3 per repo with uv: a dev dependency in a root pyproject.toml, plus a committed uv.lock. Repo scripts call it through uv run --frozen.

The work ships in a fixed order (ADR-0034), because the deployed SessionStart hook comes from the main commit that the lock records:

  1. Spike. Run 0.39.3 against a worktree and record what it changes and which gates still pass.
  2. Hook first. The kyberforge SessionStart hook learns to find the right apm: the repo pin, else the global one, else nothing. It never reports "up to date" from an apm older than 0.39.2. It ships as a kyberforge release, with a tag.
  3. Cutover. One PR adds the pin, switches the scripts and tests, and commits the regenerated v4 lock along with any changes apm itself writes.
  4. Gate and waiver fixes, only if the spike shows they are needed. Otherwise this folds into 3.
  5. Docs and setup. Setup becomes uv sync --frozen plus apm install, once per checkout. The apm-install and apm-workflow skills cover both repo-pinned and global apm.
  6. Re-verify the 0.28.0 claims against the refreshed research set.

The global pipx apm 0.28.0 stays installed and unchanged. Ansible still uses it. Whichever of ansible-homelab-mono#1078 and Kamino#499 lands last uninstalls it.

User Stories

  1. As the maintainer, I want /plan and /ship deployed with disable-model-invocation: true, so that the model cannot start a plan or a ship on its own.
  2. As the maintainer, I want this repo's apm version recorded in the repo, so that every checkout and every hook runs the same apm.
  3. As the maintainer, I want the pinned apm locked with hashes for all its transitive dependencies, so that an upstream re-release cannot change what runs.
  4. As the maintainer, I want the repo to keep working when the global pipx apm is removed from PATH, so that the global install can eventually be uninstalled.
  5. As the maintainer, I want the global pipx apm left installed and at 0.28.0, so that the ansible repo keeps working until it migrates.
  6. As the maintainer, I want a spike to run 0.39.3 against a throwaway worktree before any code changes, so that unknown rewrites and gate failures are found before they land.
  7. As the maintainer, I want the spike to record every file 0.39.3 rewrites, including .claude/settings.json, .claude/apm-hooks.json, CLAUDE.md, AGENTS.md and the lock, so that the cutover PR knows what to expect and commit.
  8. As the maintainer, I want the spike to say whether the audit-ci waiver and the outdated phrase still match 0.39.3 output, so that I know whether the gate scripts need changes.
  9. As the maintainer, I want the SessionStart hook to use the repo-pinned apm when the project pins one, so that staleness checks run on the version the lock was written with.
  10. As a consumer-repo user with no uv pin, I want the hook to fall back to the apm on PATH, so that installing a new kyberforge does not break my sessions.
  11. As a user with no apm at all, I want the hook to exit silently, so that sessions start normally.
  12. As a user, I want the hook never to run a uv sync or install anything, so that session start stays fast and does not use the network unexpectedly.
  13. As a user on an apm older than 0.39.2, I want the hook to say my apm is too old instead of "up to date", so that a refused v4 lock does not silently hide staleness.
  14. As a user, I want the hook's advice to name the exact command to run, uv run apm install or apm install, so that I do not run the wrong binary against the lock.
  15. As the maintainer, I want the hook change released as a tagged kyberforge version before the cutover, so that the deployed hook already understands the pin when the v4 lock lands.
  16. As the maintainer, I want the executables.allow key for kyberforge to follow its version bump, so that the allow-key sync gate passes.
  17. As the maintainer, I want the pre-push apm audit --ci and apm pack --check-clean gates to call the pinned apm from any directory, so that per-plugin runs use the same version as the root run.
  18. As the maintainer, I want a repo-side check that fails clearly when the resolved apm is below 0.39.2, so that apm's missing minimum-version mechanism is covered by the repo.
  19. As the maintainer, I want .venv/ ignored, so that the uv environment is never committed or swept by repo-wide hooks.
  20. As the maintainer, I want the cutover PR to commit the regenerated v4 apm.lock.yaml, so that the lock matches the pinned apm. This is the one sanctioned exception to discarding lock churn on a branch.
  21. As the maintainer, I want any .claude/settings.json changes the cutover PR commits to come only from an apm run, never from hand edits, so that audit --ci drift stays clean.
  22. As a contributor on a fresh clone, I want the README to say to run uv sync --frozen and apm install once, so that pre-push works offline afterwards.
  23. As a contributor, I want AGENTS.md, gates.md and the pre-commit config comments to describe the pinned invocation, so that no instruction tells me to run bare apm against a lock it cannot read.
  24. As a consumer-repo author, I want the apm-install skill to explain how to pin apm per repo with uv, as well as the global installs, so that I can follow the same pattern.
  25. As a consumer-repo author, I want the apm-workflow skill to tell me which apm invocation to use in my repo, so that commands it suggests work whether or not my repo pins apm.
  26. As a reader of ADRs 0017, 0019, 0021, 0026, 0029 and 0033, I want each "verified on 0.28.0" claim either re-verified on 0.39.3 or amended, so that the records stay true.
  27. As a reader of gates.md and LESSONS.md, I want the version-specific claims updated, so that gate behaviour is described for the apm that actually runs.
  28. As a kyberforge or delivery skill user, I want the skills' compatibility notes and references updated to 0.39.3, so that authoring advice matches deploy behaviour. A prompt now keeps Claude-native keys.
  29. As the maintainer, I want every changed skill and plugin to get its version bump, and each plugin bump its release tag, so that the release gates and consumer pins stay consistent.
  30. As the maintainer, I want ADR-0034 amended to say tests stub uv on PATH, not through an APM variable, so that the ADR matches the chosen test seam.

Implementation Decisions

  • Pin form (ADR-0034). The root pyproject.toml has no build system, sets tool.uv.package = false and requires-python >= 3.11, and has a dev dependency group pinning apm-cli==0.39.3. uv.lock is committed. uvx and uv tool were rejected: one has no lock, and the other is machine-global drift.
  • Repo invocation. Repo scripts run uv run --project <repo root> --frozen apm …. --project makes the plugin-directory runs in the audit script resolve the root pin. --frozen means a hook never re-locks. No production APM override variable is added.
  • Resolution order in the SessionStart hook (shipped to consumers):
    • Use the uv-pinned apm when the project declares an apm-cli pin and uv is on PATH.
    • Otherwise use the PATH apm.
    • Otherwise exit 0.
    • Detect the pin cheaply, without parsing TOML into a sync. The hook must never run a sync, an install, or anything that can reach the network beyond today's outdated and update calls.
    • Decide the binary once, and use it for both the outdated check and the update.
  • Minimum version in the hook. When the chosen apm is below 0.39.2, the hook prints a fixed "apm too old" advice line and does not run the outdated check. Running it would read a refused v4 lock and report nothing, which looks the same as "up to date".
  • Advice strings. All user-facing advice is fixed text that names whichever binary was chosen. Command output is never interpolated.
  • Repo-side minimum. A shared check used by the repo scripts asserts that the resolved apm is at least 0.39.2 and fails with a clear message. The exact pin is the primary enforcement; this check covers misconfiguration.
  • Release sequencing. The hook ticket bumps kyberforge, its changed skill metadata.versions and the root executables.allow key, and re-packs the marketplace. Once that merges, the tag is cut with scripts/tag-plugin-releases.sh, and the push needs the maintainer's explicit yes. The cutover starts only after that kyberforge version is on main and recorded in the lock.
  • Cutover lock. The lock is regenerated by the pinned apm (v1 to v4) and committed deliberately. Any .claude/settings.json or .claude/apm-hooks.json content apm writes is committed as apm output, per ADR-0019 and the AGENTS.md settings rule.
  • Gate scripts. The audit-ci waiver and the outdated phrase are believed unchanged, based on the 0.39.3 source. 0.39.3 still prints "apm.yml declares dependencies but apm.lock.yaml is absent", "N of M check(s) failed" and "N outdated dependencies found". The spike confirms this against real output. The waiver must not assume a fixed check total, because the 0.39.x baseline check count varies.
  • Offline guarantee. After one online uv sync --frozen and one online apm install per checkout, every pre-push hook runs without network. apm 0.39's first install records commit verdicts, so it also needs the network once.
  • Docs. README prerequisites add uv. Setup, AGENTS.md session rules, gates.md "Pushing without a network" and the pre-commit comments switch to the pinned invocation. The apm-install skill gains the per-repo uv pin. The apm-workflow skill tells the reader to use the repo's pinned invocation when one exists.
  • Re-verification. Each "verified on 0.28.0" claim is re-checked against a live 0.39.3 run or the refreshed research set. Where it still holds, it is updated; where it does not, it is amended. Dated ADRs get forward notes rather than rewrites, matching the ADR-0019 and ADR-0033 amendments already made.
  • ADR-0034 amendment. It records that the test seam is a PATH stub of uv, not an APM env override.

Testing Decisions

  • What a good test is. It drives a script or hook as a black box and asserts only exit code and output. It never asserts how the script finds apm internally.
  • Seam A, the SessionStart hook. Extend the existing hook test, which runs the hook with fake binaries first on PATH. Add a fake uv next to the fake apm.
    • Cover these cases: pinned and uv present; pinned but no uv; no pin with PATH apm; no apm at all; PATH apm below 0.39.2; stale and current outputs on each path.
    • Assert that uv sync is never called.
    • Keep the existing real-apm probe, pointed at the pinned apm.
    • Prior art: the hook test's existing make_apm fake and its "inert when apm absent" case.
  • Seam B, the repo gate scripts. Extend the existing git-env test, which stubs apm on PATH. Add a fake uv that records its arguments and the environment, and execs the stub apm. Assert that the git-env scrub still applies, that --project names the repo root even from a plugin directory, and that the minimum-version check fails clearly on an old apm.
  • Seam C, end to end. With the global pipx apm removed from PATH, not uninstalled, run uv sync --frozen, uv run apm install, the full pre-push hook set and the SessionStart hook. All must pass. Check that the deployed /plan and /ship commands carry disable-model-invocation: true. Re-run pre-push under a no-network namespace after the one-time setup, the same way as the ADR-0019 offline verification.
  • The instructions-author bats suite calls real apm. Switch it to the pinned apm so it tests 0.39.3, not the global 0.28.0. A skip under --strict is still an error.

Out of Scope

  • Moving ansible-homelab-mono onto its own pin: #1078.
  • Moving Kamino onto its own pin: Kamino#499.
  • Uninstalling or upgrading the global pipx apm. Whichever of those two lands last uninstalls it.
  • Adopting new 0.39 features such as content-pinned hook approvals, managed_section AGENTS.md mode, or apm audit -f json parsing, beyond what the gates need.
  • Consumer-side minimum-version enforcement beyond the hook's "too old" advice.
  • The personal ~/.claude/commands/next.md copy (#227, #240).

Further Notes

  • Order is a hard constraint. If the v4 lock lands before the new hook is released, the deployed hook runs PATH apm 0.28.0. 0.28.0 refuses the lock, and the hook silently stops detecting staleness, which is the failure ADR-0019 exists to prevent.
  • Bare apm fails closed. The global 0.28.0 stays on PATH, so any instruction or habit that runs bare apm in this repo after the cutover will be refused against the v4 lock. That is the intended fail-closed outcome. It is also why the docs ticket has to catch every bare instruction.
  • No CI runs this repo. The only place the gates run is the maintainer's dev machine, so a single-PR cutover is safe.
  • Spike risks to resolve:
    • how audit --ci judges the merged hook entries, now that ownership lives in .claude/apm-hooks.json;
    • whether 0.39 rewrites CLAUDE.md or AGENTS.md; the source says hand-authored root files are protected;
    • any new checks that fail inside plugin package directories.
  • Tag pushes need the maintainer's explicit yes (ADR-0032, ADR-0033).
Parent: #265 · Decisions: ADR-0034 (docs PR #267, merged) · Research: kyberforge's `microsoft-apm` research set, refreshed to 0.39.3 in #267 ## Problem Statement This repo deploys its plugins with whatever apm binary is on PATH. On this machine that is a global pipx install at 0.28.0, shared by every apm project here. That has three consequences. - **Model-invocation flag is lost.** apm 0.28.0 strips `disable-model-invocation` from deployed Claude commands. As a result, `/plan` and `/ship`, which are meant to be hand-invoked only, are visible to the model and can be invoked by it (#245). - **One apm version cannot serve every repo.** The repos have already drifted onto lockfile formats that other apm versions refuse. 0.28.0 cannot read a v4 lock, and a lock rewritten by 0.39.2 is refused by 0.37.0–0.39.1. - **Version claims are tied to 0.28.0.** About 40 claims in ADRs, specs, skills and docs say "verified on 0.28.0", and nothing records which apm the repo expects. The maintainer wants this repo on apm 0.39.3, pinned in the repo itself. Every hook, script and doc must use the pinned apm, and the other repos on the machine must not be broken. ## Solution Pin apm-cli 0.39.3 per repo with uv: a dev dependency in a root `pyproject.toml`, plus a committed `uv.lock`. Repo scripts call it through `uv run --frozen`. The work ships in a fixed order (ADR-0034), because the deployed SessionStart hook comes from the `main` commit that the lock records: 1. **Spike.** Run 0.39.3 against a worktree and record what it changes and which gates still pass. 2. **Hook first.** The kyberforge SessionStart hook learns to find the right apm: the repo pin, else the global one, else nothing. It never reports "up to date" from an apm older than 0.39.2. It ships as a kyberforge release, with a tag. 3. **Cutover.** One PR adds the pin, switches the scripts and tests, and commits the regenerated v4 lock along with any changes apm itself writes. 4. **Gate and waiver fixes,** only if the spike shows they are needed. Otherwise this folds into 3. 5. **Docs and setup.** Setup becomes `uv sync --frozen` plus `apm install`, once per checkout. The apm-install and apm-workflow skills cover both repo-pinned and global apm. 6. **Re-verify the 0.28.0 claims** against the refreshed research set. The global pipx apm 0.28.0 stays installed and unchanged. Ansible still uses it. Whichever of ansible-homelab-mono#1078 and Kamino#499 lands last uninstalls it. ## User Stories 1. As the maintainer, I want `/plan` and `/ship` deployed with `disable-model-invocation: true`, so that the model cannot start a plan or a ship on its own. 2. As the maintainer, I want this repo's apm version recorded in the repo, so that every checkout and every hook runs the same apm. 3. As the maintainer, I want the pinned apm locked with hashes for all its transitive dependencies, so that an upstream re-release cannot change what runs. 4. As the maintainer, I want the repo to keep working when the global pipx apm is removed from PATH, so that the global install can eventually be uninstalled. 5. As the maintainer, I want the global pipx apm left installed and at 0.28.0, so that the ansible repo keeps working until it migrates. 6. As the maintainer, I want a spike to run 0.39.3 against a throwaway worktree before any code changes, so that unknown rewrites and gate failures are found before they land. 7. As the maintainer, I want the spike to record every file 0.39.3 rewrites, including `.claude/settings.json`, `.claude/apm-hooks.json`, CLAUDE.md, AGENTS.md and the lock, so that the cutover PR knows what to expect and commit. 8. As the maintainer, I want the spike to say whether the audit-ci waiver and the outdated phrase still match 0.39.3 output, so that I know whether the gate scripts need changes. 9. As the maintainer, I want the SessionStart hook to use the repo-pinned apm when the project pins one, so that staleness checks run on the version the lock was written with. 10. As a consumer-repo user with no uv pin, I want the hook to fall back to the apm on PATH, so that installing a new kyberforge does not break my sessions. 11. As a user with no apm at all, I want the hook to exit silently, so that sessions start normally. 12. As a user, I want the hook never to run a uv sync or install anything, so that session start stays fast and does not use the network unexpectedly. 13. As a user on an apm older than 0.39.2, I want the hook to say my apm is too old instead of "up to date", so that a refused v4 lock does not silently hide staleness. 14. As a user, I want the hook's advice to name the exact command to run, `uv run apm install` or `apm install`, so that I do not run the wrong binary against the lock. 15. As the maintainer, I want the hook change released as a tagged kyberforge version before the cutover, so that the deployed hook already understands the pin when the v4 lock lands. 16. As the maintainer, I want the `executables.allow` key for kyberforge to follow its version bump, so that the allow-key sync gate passes. 17. As the maintainer, I want the pre-push `apm audit --ci` and `apm pack --check-clean` gates to call the pinned apm from any directory, so that per-plugin runs use the same version as the root run. 18. As the maintainer, I want a repo-side check that fails clearly when the resolved apm is below 0.39.2, so that apm's missing minimum-version mechanism is covered by the repo. 19. As the maintainer, I want `.venv/` ignored, so that the uv environment is never committed or swept by repo-wide hooks. 20. As the maintainer, I want the cutover PR to commit the regenerated v4 `apm.lock.yaml`, so that the lock matches the pinned apm. This is the one sanctioned exception to discarding lock churn on a branch. 21. As the maintainer, I want any `.claude/settings.json` changes the cutover PR commits to come only from an apm run, never from hand edits, so that `audit --ci` drift stays clean. 22. As a contributor on a fresh clone, I want the README to say to run `uv sync --frozen` and `apm install` once, so that pre-push works offline afterwards. 23. As a contributor, I want AGENTS.md, gates.md and the pre-commit config comments to describe the pinned invocation, so that no instruction tells me to run bare `apm` against a lock it cannot read. 24. As a consumer-repo author, I want the apm-install skill to explain how to pin apm per repo with uv, as well as the global installs, so that I can follow the same pattern. 25. As a consumer-repo author, I want the apm-workflow skill to tell me which apm invocation to use in my repo, so that commands it suggests work whether or not my repo pins apm. 26. As a reader of ADRs 0017, 0019, 0021, 0026, 0029 and 0033, I want each "verified on 0.28.0" claim either re-verified on 0.39.3 or amended, so that the records stay true. 27. As a reader of gates.md and LESSONS.md, I want the version-specific claims updated, so that gate behaviour is described for the apm that actually runs. 28. As a kyberforge or delivery skill user, I want the skills' compatibility notes and references updated to 0.39.3, so that authoring advice matches deploy behaviour. A prompt now keeps Claude-native keys. 29. As the maintainer, I want every changed skill and plugin to get its version bump, and each plugin bump its release tag, so that the release gates and consumer pins stay consistent. 30. As the maintainer, I want ADR-0034 amended to say tests stub `uv` on PATH, not through an `APM` variable, so that the ADR matches the chosen test seam. ## Implementation Decisions - **Pin form (ADR-0034).** The root `pyproject.toml` has no build system, sets `tool.uv.package = false` and `requires-python >= 3.11`, and has a `dev` dependency group pinning `apm-cli==0.39.3`. `uv.lock` is committed. uvx and `uv tool` were rejected: one has no lock, and the other is machine-global drift. - **Repo invocation.** Repo scripts run `uv run --project <repo root> --frozen apm …`. `--project` makes the plugin-directory runs in the audit script resolve the root pin. `--frozen` means a hook never re-locks. No production `APM` override variable is added. - **Resolution order in the SessionStart hook (shipped to consumers):** - Use the uv-pinned apm when the project declares an apm-cli pin and uv is on PATH. - Otherwise use the PATH apm. - Otherwise exit 0. - Detect the pin cheaply, without parsing TOML into a sync. The hook must never run a sync, an install, or anything that can reach the network beyond today's outdated and update calls. - Decide the binary once, and use it for both the outdated check and the update. - **Minimum version in the hook.** When the chosen apm is below 0.39.2, the hook prints a fixed "apm too old" advice line and does not run the outdated check. Running it would read a refused v4 lock and report nothing, which looks the same as "up to date". - **Advice strings.** All user-facing advice is fixed text that names whichever binary was chosen. Command output is never interpolated. - **Repo-side minimum.** A shared check used by the repo scripts asserts that the resolved apm is at least 0.39.2 and fails with a clear message. The exact pin is the primary enforcement; this check covers misconfiguration. - **Release sequencing.** The hook ticket bumps kyberforge, its changed skill `metadata.version`s and the root `executables.allow` key, and re-packs the marketplace. Once that merges, the tag is cut with `scripts/tag-plugin-releases.sh`, and the push needs the maintainer's explicit yes. The cutover starts only after that kyberforge version is on `main` and recorded in the lock. - **Cutover lock.** The lock is regenerated by the pinned apm (v1 to v4) and committed deliberately. Any `.claude/settings.json` or `.claude/apm-hooks.json` content apm writes is committed as apm output, per ADR-0019 and the AGENTS.md settings rule. - **Gate scripts.** The audit-ci waiver and the outdated phrase are believed unchanged, based on the 0.39.3 source. 0.39.3 still prints "apm.yml declares dependencies but apm.lock.yaml is absent", "N of M check(s) failed" and "N outdated dependencies found". The spike confirms this against real output. The waiver must not assume a fixed check total, because the 0.39.x baseline check count varies. - **Offline guarantee.** After one online `uv sync --frozen` and one online `apm install` per checkout, every pre-push hook runs without network. apm 0.39's first install records commit verdicts, so it also needs the network once. - **Docs.** README prerequisites add uv. Setup, AGENTS.md session rules, gates.md "Pushing without a network" and the pre-commit comments switch to the pinned invocation. The apm-install skill gains the per-repo uv pin. The apm-workflow skill tells the reader to use the repo's pinned invocation when one exists. - **Re-verification.** Each "verified on 0.28.0" claim is re-checked against a live 0.39.3 run or the refreshed research set. Where it still holds, it is updated; where it does not, it is amended. Dated ADRs get forward notes rather than rewrites, matching the ADR-0019 and ADR-0033 amendments already made. - **ADR-0034 amendment.** It records that the test seam is a PATH stub of `uv`, not an `APM` env override. ## Testing Decisions - **What a good test is.** It drives a script or hook as a black box and asserts only exit code and output. It never asserts how the script finds apm internally. - **Seam A, the SessionStart hook.** Extend the existing hook test, which runs the hook with fake binaries first on PATH. Add a fake `uv` next to the fake `apm`. - Cover these cases: pinned and uv present; pinned but no uv; no pin with PATH apm; no apm at all; PATH apm below 0.39.2; stale and current outputs on each path. - Assert that `uv sync` is never called. - Keep the existing real-apm probe, pointed at the pinned apm. - Prior art: the hook test's existing `make_apm` fake and its "inert when apm absent" case. - **Seam B, the repo gate scripts.** Extend the existing git-env test, which stubs apm on PATH. Add a fake `uv` that records its arguments and the environment, and execs the stub apm. Assert that the git-env scrub still applies, that `--project` names the repo root even from a plugin directory, and that the minimum-version check fails clearly on an old apm. - **Seam C, end to end.** With the global pipx apm removed from PATH, not uninstalled, run `uv sync --frozen`, `uv run apm install`, the full pre-push hook set and the SessionStart hook. All must pass. Check that the deployed `/plan` and `/ship` commands carry `disable-model-invocation: true`. Re-run pre-push under a no-network namespace after the one-time setup, the same way as the ADR-0019 offline verification. - **The instructions-author bats suite** calls real apm. Switch it to the pinned apm so it tests 0.39.3, not the global 0.28.0. A skip under `--strict` is still an error. ## Out of Scope - Moving ansible-homelab-mono onto its own pin: #1078. - Moving Kamino onto its own pin: Kamino#499. - Uninstalling or upgrading the global pipx apm. Whichever of those two lands last uninstalls it. - Adopting new 0.39 features such as content-pinned hook approvals, `managed_section` AGENTS.md mode, or `apm audit -f json` parsing, beyond what the gates need. - Consumer-side minimum-version enforcement beyond the hook's "too old" advice. - The personal `~/.claude/commands/next.md` copy (#227, #240). ## Further Notes - **Order is a hard constraint.** If the v4 lock lands before the new hook is released, the deployed hook runs PATH apm 0.28.0. 0.28.0 refuses the lock, and the hook silently stops detecting staleness, which is the failure ADR-0019 exists to prevent. - **Bare `apm` fails closed.** The global 0.28.0 stays on PATH, so any instruction or habit that runs bare `apm` in this repo after the cutover will be refused against the v4 lock. That is the intended fail-closed outcome. It is also why the docs ticket has to catch every bare instruction. - **No CI runs this repo.** The only place the gates run is the maintainer's dev machine, so a single-PR cutover is safe. - **Spike risks to resolve:** - how `audit --ci` judges the merged hook entries, now that ownership lives in `.claude/apm-hooks.json`; - whether 0.39 rewrites CLAUDE.md or AGENTS.md; the source says hand-authored root files are protected; - any new checks that fail inside plugin package directories. - Tag pushes need the maintainer's explicit yes (ADR-0032, ADR-0033).
Claude added the Kind/Enhancement
Priority
Medium
3
labels 2026-12-01 22:55:53 +00:00
Author
Owner

Spike #269 findings: apm 0.39.3 against a throwaway worktree of main (0ad15c8)

Setup. I used a scratch uv project: no build-system, [tool.uv] package = false, requires-python >=3.11, dev group apm-cli==0.39.3. I ran apm as uv run --project <scratch> --frozen apm, with cwd set to a detached git worktree of main. To run the repo's own gate scripts unmodified, I put a PATH shim named apm in front that execs that same command. The global pipx apm was not used.

1. Runs (exit code + relevant output)

Run Exit Output
apm install (first, online) 0 34 deps in 80.7s. Upgraded apm.lock.yaml to lockfile_version "4". 2 package(s) have executable primitives parked pending approval: delivery and kyberforge print hooks skipped (not approved in executables.allow). Also 12 dependencies unpinned (info only).
apm audit --ci at root 0 All 15 check(s) passed. It passes even with both hooks parked, because exec-status-current agrees with gated_pending_approval.
audit --ci in ansible, bin, core, git, gitea, k8s, kyberforge, lint 0 All 2 check(s) passed
audit --ci in delivery, gitops, mattpocock, plan 1 Only lockfile-exists fails, with detail apm.yml declares dependencies but apm.lock.yaml is absent and the line [x] 1 of 1 check(s) failed.
scripts/apm-audit-ci.sh (via shim) 0 Waives exactly those 4 dirs.
scripts/apm-pack-check-clean.sh (via shim; runs apm pack --check-versions --check-clean --dry-run) 0 Version alignment OK (12 packages match). Marketplace working tree clean. Warns twice: dependency Mortis/Holocron contributed hooks config that is not attested in apm.lock.yaml; it will NOT be packed (info).

2. Files rewritten or created

The first install ran with main's apm.yml unchanged.

  • .claude/settings.json: CHANGED, rewritten to {}. The PreToolUse guard and the SessionStart entries are gone, because the hooks were parked.
  • .claude/apm-hooks.json: DELETED.
  • .claude/hooks/: not deployed. Neither guard.py nor check-apm-current.sh was written.
  • apm.lock.yaml: CHANGED.
    • lockfile_version '1' → '4', and apm_version 0.28.0 → 0.39.3.
    • New top-level manifest_targets: [claude].
    • New per-dependency fields: package_targets and carried_licenses (path, source, hash).
    • Every content_hash changed.
    • Every skill gains a LICENSE entry in deployed_files and in deployed_file_hashes.
    • The hashes of plan.md and ship.md changed.
    • The diff is about +1145/−118. No fields were removed.
    • While the hooks were parked, delivery and kyberforge had exec_status: gated_pending_approval and their hook files were dropped from the lock.
  • Root CLAUDE.md: unchanged. Root AGENTS.md: unchanged.
  • .claude/commands (gitignored; compared with diff -r against the main checkout): plan.md and ship.md each gain one line, disable-model-invocation: true. next.md is unchanged.
  • .claude/skills: each of 65 skill dirs gains a LICENSE file, carried from the package. skill-author/assets/templates/LICENSE is added too, because the template dir contains a SKILL.md. No other content changed.
  • .claude/agents: unchanged.
  • .apm-local/installation: new. It is self-ignored by its own .gitignore.

After fixing the approvals (see §6): settings.json and apm-hooks.json came back byte-identical to main, .claude/hooks/* was redeployed, and exec_status: deployed was restored. The only tracked diffs left were apm.lock.yaml and apm.yml.

3. /plan and /ship

Yes. On 0.39.3 the deployed .claude/commands/plan.md and ship.md both carry disable-model-invocation: true. The 0.28.0 copies in the main checkout lack it.

4. scripts/apm-audit-ci.sh patterns

Both still match, in all 4 failing plugin dirs:

  • the lockfile-absent detail string;
  • the 1 of 1 check(s) failed line.

No new check fails in any plugin dir. Passing plugin dirs now run 2 checks. Only the "Verified against apm 0.28.0" comment is out of date.

5. apm outdated vs the SessionStart grep

apm outdated exits 0 in every case and still has no --json.

Case How I produced it Output Hook regex outdated dependenc(y|ies) found
Stale, plural Natural: main's committed lock records 3b0dcc32 and origin/main is 0ad15c8 [!] 12 outdated dependencies found matches, count = 12
Stale, singular After apm update --yes, I edited one resolved_commit in the lock back to 3b0dcc32 [!] 1 outdated dependency found matches, count = 1
Current Right after apm update --yes [*] All dependencies are up-to-date no match, so the hook stays silent (correct)

I also ran check-apm-current.sh end-to-end through the shim:

  • Stale: it emitted the "1 package(s) behind ... refreshed automatically" JSON and apm update --yes succeeded.
  • Current: no output, exit 0.

apm outdated takes about 3.6s through uv run.

6. Hook entries, audit --ci and approvals

Re-approval IS required. This is the main finding.

Under 0.39.3 the root apm.yml keys kyberforge#2.2.1 and delivery#0.8.0 no longer match the package identities. apm approve --list names the identities as git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.2.1 and shows hooks[x:default-deny] bin[x:default-deny]. So the first 0.39 install silently strips both hooks while root audit --ci stays green.

I tested two fixes. Both deploy both hooks and leave settings.json and apm-hooks.json identical to main. Both pass root audit --ci with All 15 check(s) passed, including hook-approval-pins, exec-status-current and local-bundle-hooks.

  • (a) Type-level grant under the full identity, e.g. git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.2.1: {hooks: true, bin: true}.
    • The #version suffix is still version-blind, so the version-in-key convention survives.
    • Every install warns executable approvals are not pinned to content.
  • (b) apm approve <identity>, which pins to content (hooks: {.apm/hooks/hooks.json: sha256:…}).
    • It rewrites the executables block, strips its comments, and keeps the old short keys alongside the new ones.
    • The pin covers the referenced script (0.38+), so any later change to check-apm-current.sh or guard.py parks the hook as definition-changed until someone runs apm approve again.

The SessionStart and PreToolUse entries are detected as apm-owned-entry in settings.json, and both pass.

7. Changes the hook (#270) and cutover (#271) tickets must make

Cutover (#271):

  1. In the same PR as the v4 lock, rewrite root apm.yml executables.allow to full-identity keys: git.rkdr.net/Mortis/Holocron/plugins/{kyberforge,delivery}#<version>. Choose (a) type-level or (b) content-pinned. I recommend (a): (b) forces a re-approve on every hook edit. Without this change, the guard and the SessionStart hook silently disappear, and no gate catches it.
  2. Update scripts/check-executables-allow-sync.sh, its tests, and its .pre-commit-config.yaml description to require the full-identity <host>/<owner>/<repo>/plugins/<name>#<version> key. Also correct the apm.yml comment that cites 0.28 _map_grants matching on a bare name.
  3. Consider adding a gate that root audit --ci does not provide: fail when apm approve --pending or the lock reports any gated_pending_approval.
  4. Commit the v4 lock as described in §2. No .claude/settings.json or apm-hooks.json change should appear; if one does, the approvals are wrong.
  5. scripts/apm-audit-ci.sh: no pattern change. Refresh the "verified against" note to 0.39.3.
  6. scripts/apm-pack-check-clean.sh: no change.

Hook (#270):

  1. No change to the outdated phrase match. Both spellings and the current case are verified on 0.39.3.
  2. If the cutover picks content-pinned approvals, the commit that changes check-apm-current.sh must also re-run apm approve for kyberforge. With type-level grants, nothing more is needed.

The worktree and scratch envs were removed afterwards. The main checkout was not modified, and global apm --version still reports 0.28.0.

## Spike #269 findings: apm 0.39.3 against a throwaway worktree of `main` (0ad15c8) **Setup.** I used a scratch uv project: no build-system, `[tool.uv] package = false`, `requires-python >=3.11`, dev group `apm-cli==0.39.3`. I ran apm as `uv run --project <scratch> --frozen apm`, with cwd set to a detached `git worktree` of `main`. To run the repo's own gate scripts unmodified, I put a PATH shim named `apm` in front that execs that same command. The global pipx apm was not used. ### 1. Runs (exit code + relevant output) | Run | Exit | Output | |---|---|---| | `apm install` (first, online) | 0 | 34 deps in 80.7s. `Upgraded apm.lock.yaml to lockfile_version "4"`. **`2 package(s) have executable primitives parked pending approval`**: delivery and kyberforge print `hooks skipped (not approved in executables.allow)`. Also `12 dependencies unpinned` (info only). | | `apm audit --ci` at root | 0 | `All 15 check(s) passed`. **It passes even with both hooks parked**, because `exec-status-current` agrees with `gated_pending_approval`. | | `audit --ci` in ansible, bin, core, git, gitea, k8s, kyberforge, lint | 0 | `All 2 check(s) passed` | | `audit --ci` in delivery, gitops, mattpocock, plan | 1 | Only `lockfile-exists` fails, with detail `apm.yml declares dependencies but apm.lock.yaml is absent` and the line `[x] 1 of 1 check(s) failed`. | | `scripts/apm-audit-ci.sh` (via shim) | 0 | Waives exactly those 4 dirs. | | `scripts/apm-pack-check-clean.sh` (via shim; runs `apm pack --check-versions --check-clean --dry-run`) | 0 | `Version alignment OK` (12 packages match). `Marketplace working tree clean`. Warns twice: `dependency Mortis/Holocron contributed hooks config that is not attested in apm.lock.yaml; it will NOT be packed` (info). | ### 2. Files rewritten or created The first install ran with `main`'s `apm.yml` unchanged. - **`.claude/settings.json`: CHANGED, rewritten to `{}`.** The PreToolUse guard and the SessionStart entries are gone, because the hooks were parked. - **`.claude/apm-hooks.json`: DELETED.** - **`.claude/hooks/`: not deployed.** Neither `guard.py` nor `check-apm-current.sh` was written. - **`apm.lock.yaml`: CHANGED.** - `lockfile_version '1'` → `'4'`, and `apm_version 0.28.0` → `0.39.3`. - New top-level `manifest_targets: [claude]`. - New per-dependency fields: `package_targets` and `carried_licenses` (path, source, hash). - Every `content_hash` changed. - Every skill gains a `LICENSE` entry in `deployed_files` and in `deployed_file_hashes`. - The hashes of `plan.md` and `ship.md` changed. - The diff is about +1145/−118. No fields were removed. - While the hooks were parked, delivery and kyberforge had `exec_status: gated_pending_approval` and their hook files were dropped from the lock. - **Root `CLAUDE.md`: unchanged. Root `AGENTS.md`: unchanged.** - **`.claude/commands` (gitignored; compared with `diff -r` against the main checkout):** `plan.md` and `ship.md` each gain one line, `disable-model-invocation: true`. `next.md` is unchanged. - **`.claude/skills`:** each of 65 skill dirs gains a `LICENSE` file, carried from the package. `skill-author/assets/templates/LICENSE` is added too, because the template dir contains a `SKILL.md`. No other content changed. - **`.claude/agents`: unchanged.** - **`.apm-local/installation`:** new. It is self-ignored by its own `.gitignore`. **After fixing the approvals (see §6):** `settings.json` and `apm-hooks.json` came back **byte-identical to `main`**, `.claude/hooks/*` was redeployed, and `exec_status: deployed` was restored. The only tracked diffs left were `apm.lock.yaml` and `apm.yml`. ### 3. `/plan` and `/ship` **Yes.** On 0.39.3 the deployed `.claude/commands/plan.md` and `ship.md` both carry `disable-model-invocation: true`. The 0.28.0 copies in the main checkout lack it. ### 4. `scripts/apm-audit-ci.sh` patterns **Both still match**, in all 4 failing plugin dirs: - the lockfile-absent detail string; - the `1 of 1 check(s) failed` line. **No new check fails in any plugin dir.** Passing plugin dirs now run 2 checks. Only the "Verified against apm 0.28.0" comment is out of date. ### 5. `apm outdated` vs the SessionStart grep `apm outdated` exits 0 in every case and still has no `--json`. | Case | How I produced it | Output | Hook regex `outdated dependenc(y\|ies) found` | |---|---|---|---| | Stale, plural | Natural: `main`'s committed lock records 3b0dcc32 and origin/main is 0ad15c8 | `[!] 12 outdated dependencies found` | matches, count = 12 | | Stale, singular | After `apm update --yes`, I edited one `resolved_commit` in the lock back to 3b0dcc32 | `[!] 1 outdated dependency found` | matches, count = 1 | | Current | Right after `apm update --yes` | `[*] All dependencies are up-to-date` | no match, so the hook stays silent (correct) | I also ran `check-apm-current.sh` end-to-end through the shim: - Stale: it emitted the "1 package(s) behind ... refreshed automatically" JSON and `apm update --yes` succeeded. - Current: no output, exit 0. `apm outdated` takes about 3.6s through `uv run`. ### 6. Hook entries, `audit --ci` and approvals **Re-approval IS required. This is the main finding.** Under 0.39.3 the root `apm.yml` keys `kyberforge#2.2.1` and `delivery#0.8.0` **no longer match** the package identities. `apm approve --list` names the identities as `git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.2.1` and shows `hooks[x:default-deny] bin[x:default-deny]`. So the first 0.39 install silently strips both hooks while root `audit --ci` stays green. I tested two fixes. Both deploy both hooks and leave `settings.json` and `apm-hooks.json` identical to `main`. Both pass root `audit --ci` with `All 15 check(s) passed`, including `hook-approval-pins`, `exec-status-current` and `local-bundle-hooks`. - **(a) Type-level grant under the full identity**, e.g. `git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.2.1: {hooks: true, bin: true}`. - The `#version` suffix is still version-blind, so the version-in-key convention survives. - Every install warns `executable approvals are not pinned to content`. - **(b) `apm approve <identity>`, which pins to content** (`hooks: {.apm/hooks/hooks.json: sha256:…}`). - It rewrites the `executables` block, strips its comments, and keeps the old short keys alongside the new ones. - The pin covers the referenced script (0.38+), so any later change to `check-apm-current.sh` or `guard.py` parks the hook as `definition-changed` until someone runs `apm approve` again. The SessionStart and PreToolUse entries are detected as `apm-owned-entry` in `settings.json`, and both pass. ### 7. Changes the hook (#270) and cutover (#271) tickets must make **Cutover (#271):** 1. **In the same PR as the v4 lock**, rewrite root `apm.yml` `executables.allow` to full-identity keys: `git.rkdr.net/Mortis/Holocron/plugins/{kyberforge,delivery}#<version>`. Choose (a) type-level or (b) content-pinned. I recommend (a): (b) forces a re-approve on every hook edit. Without this change, the guard and the SessionStart hook silently disappear, and no gate catches it. 2. Update `scripts/check-executables-allow-sync.sh`, its tests, and its `.pre-commit-config.yaml` description to require the full-identity `<host>/<owner>/<repo>/plugins/<name>#<version>` key. Also correct the `apm.yml` comment that cites 0.28 `_map_grants` matching on a bare name. 3. Consider adding a gate that root `audit --ci` does not provide: fail when `apm approve --pending` or the lock reports any `gated_pending_approval`. 4. Commit the v4 lock as described in §2. No `.claude/settings.json` or `apm-hooks.json` change should appear; if one does, the approvals are wrong. 5. `scripts/apm-audit-ci.sh`: **no pattern change**. Refresh the "verified against" note to 0.39.3. 6. `scripts/apm-pack-check-clean.sh`: **no change**. **Hook (#270):** 1. **No change to the `outdated` phrase match.** Both spellings and the current case are verified on 0.39.3. 2. If the cutover picks content-pinned approvals, the commit that changes `check-apm-current.sh` must also re-run `apm approve` for kyberforge. With type-level grants, nothing more is needed. The worktree and scratch envs were removed afterwards. The main checkout was not modified, and global `apm --version` still reports 0.28.0.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Holocron#268