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
No Branch/Tag Specified
main
research/copilot-cli-agents
research/team-structures
research/enforcement-hooks
research/team-patterns
research/existing-infra-skills
feat/66-wire-gitea-mcp-config
plan-v0.5.0
bin-v5.0.0
plan-v0.4.0
plan-v0.3.0
mattpocock-v0.5.0
bin-v4.0.0
plan-v0.2.0
plan-v0.1.0
delivery-v0.8.0
k8s-v0.2.0
gitops-v0.2.0
ansible-v0.1.0
mattpocock-v0.4.0
bin-v3.0.0
kyberforge-v2.2.1
lint-v1.1.9
gitea-v1.3.10
git-v1.3.9
core-v1.1.4
git-v1.3.8
v2.0.1
v2.0.0
v1.0.0
Labels
Clear labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Status/Needs Triage
Status/Ready for Agent
Status/Ready for Human
Wayfinder/Grilling
Wayfinder/Map
Wayfinder/Prototype
Wayfinder/Research
Wayfinder/Task
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Maintainer needs to evaluate this issue
Fully specified, ready for an AFK agent
Requires human implementation
Wayfinder ticket (HITL): decision made in conversation
Wayfinder map: index of decisions for an effort
Wayfinder ticket (HITL): cheap artifact to react to
Wayfinder ticket (AFK): research a fact a decision waits on
Wayfinder ticket: work that unblocks a decision (or build work when the map's Notes allow)
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mortis/Holocron#268
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent: #265 · Decisions: ADR-0034 (docs PR #267, merged) · Research: kyberforge's
microsoft-apmresearch set, refreshed to 0.39.3 in #267Problem 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.
disable-model-invocationfrom deployed Claude commands. As a result,/planand/ship, which are meant to be hand-invoked only, are visible to the model and can be invoked by it (#245).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 committeduv.lock. Repo scripts call it throughuv run --frozen.The work ships in a fixed order (ADR-0034), because the deployed SessionStart hook comes from the
maincommit that the lock records:uv sync --frozenplusapm install, once per checkout. The apm-install and apm-workflow skills cover both repo-pinned and global apm.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
/planand/shipdeployed withdisable-model-invocation: true, so that the model cannot start a plan or a ship on its own..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.uv run apm installorapm install, so that I do not run the wrong binary against the lock.executables.allowkey for kyberforge to follow its version bump, so that the allow-key sync gate passes.apm audit --ciandapm pack --check-cleangates to call the pinned apm from any directory, so that per-plugin runs use the same version as the root run..venv/ignored, so that the uv environment is never committed or swept by repo-wide hooks.apm.lock.yaml, so that the lock matches the pinned apm. This is the one sanctioned exception to discarding lock churn on a branch..claude/settings.jsonchanges the cutover PR commits to come only from an apm run, never from hand edits, so thataudit --cidrift stays clean.uv sync --frozenandapm installonce, so that pre-push works offline afterwards.apmagainst a lock it cannot read.uvon PATH, not through anAPMvariable, so that the ADR matches the chosen test seam.Implementation Decisions
pyproject.tomlhas no build system, setstool.uv.package = falseandrequires-python >= 3.11, and has adevdependency group pinningapm-cli==0.39.3.uv.lockis committed. uvx anduv toolwere rejected: one has no lock, and the other is machine-global drift.uv run --project <repo root> --frozen apm ….--projectmakes the plugin-directory runs in the audit script resolve the root pin.--frozenmeans a hook never re-locks. No productionAPMoverride variable is added.metadata.versions and the rootexecutables.allowkey, and re-packs the marketplace. Once that merges, the tag is cut withscripts/tag-plugin-releases.sh, and the push needs the maintainer's explicit yes. The cutover starts only after that kyberforge version is onmainand recorded in the lock..claude/settings.jsonor.claude/apm-hooks.jsoncontent apm writes is committed as apm output, per ADR-0019 and the AGENTS.md settings rule.uv sync --frozenand one onlineapm installper checkout, every pre-push hook runs without network. apm 0.39's first install records commit verdicts, so it also needs the network once.uv, not anAPMenv override.Testing Decisions
uvnext to the fakeapm.uv syncis never called.make_apmfake and its "inert when apm absent" case.uvthat records its arguments and the environment, and execs the stub apm. Assert that the git-env scrub still applies, that--projectnames the repo root even from a plugin directory, and that the minimum-version check fails clearly on an old apm.uv sync --frozen,uv run apm install, the full pre-push hook set and the SessionStart hook. All must pass. Check that the deployed/planand/shipcommands carrydisable-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.--strictis still an error.Out of Scope
managed_sectionAGENTS.md mode, orapm audit -f jsonparsing, beyond what the gates need.~/.claude/commands/next.mdcopy (#227, #240).Further Notes
apmfails closed. The global 0.28.0 stays on PATH, so any instruction or habit that runs bareapmin 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.audit --cijudges the merged hook entries, now that ownership lives in.claude/apm-hooks.json;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 groupapm-cli==0.39.3. I ran apm asuv run --project <scratch> --frozen apm, with cwd set to a detachedgit worktreeofmain. To run the repo's own gate scripts unmodified, I put a PATH shim namedapmin front that execs that same command. The global pipx apm was not used.1. Runs (exit code + relevant output)
apm install(first, online)Upgraded apm.lock.yaml to lockfile_version "4".2 package(s) have executable primitives parked pending approval: delivery and kyberforge printhooks skipped (not approved in executables.allow). Also12 dependencies unpinned(info only).apm audit --ciat rootAll 15 check(s) passed. It passes even with both hooks parked, becauseexec-status-currentagrees withgated_pending_approval.audit --ciin ansible, bin, core, git, gitea, k8s, kyberforge, lintAll 2 check(s) passedaudit --ciin delivery, gitops, mattpocock, planlockfile-existsfails, with detailapm.yml declares dependencies but apm.lock.yaml is absentand the line[x] 1 of 1 check(s) failed.scripts/apm-audit-ci.sh(via shim)scripts/apm-pack-check-clean.sh(via shim; runsapm pack --check-versions --check-clean --dry-run)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'sapm.ymlunchanged..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. Neitherguard.pynorcheck-apm-current.shwas written.apm.lock.yaml: CHANGED.lockfile_version '1'→'4', andapm_version 0.28.0→0.39.3.manifest_targets: [claude].package_targetsandcarried_licenses(path, source, hash).content_hashchanged.LICENSEentry indeployed_filesand indeployed_file_hashes.plan.mdandship.mdchanged.exec_status: gated_pending_approvaland their hook files were dropped from the lock.CLAUDE.md: unchanged. RootAGENTS.md: unchanged..claude/commands(gitignored; compared withdiff -ragainst the main checkout):plan.mdandship.mdeach gain one line,disable-model-invocation: true.next.mdis unchanged..claude/skills: each of 65 skill dirs gains aLICENSEfile, carried from the package.skill-author/assets/templates/LICENSEis added too, because the template dir contains aSKILL.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.jsonandapm-hooks.jsoncame back byte-identical tomain,.claude/hooks/*was redeployed, andexec_status: deployedwas restored. The only tracked diffs left wereapm.lock.yamlandapm.yml.3.
/planand/shipYes. On 0.39.3 the deployed
.claude/commands/plan.mdandship.mdboth carrydisable-model-invocation: true. The 0.28.0 copies in the main checkout lack it.4.
scripts/apm-audit-ci.shpatternsBoth still match, in all 4 failing plugin dirs:
1 of 1 check(s) failedline.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 outdatedvs the SessionStart grepapm outdatedexits 0 in every case and still has no--json.outdated dependenc(y|ies) foundmain's committed lock records3b0dcc32and origin/main is0ad15c8[!] 12 outdated dependencies foundapm update --yes, I edited oneresolved_commitin the lock back to3b0dcc32[!] 1 outdated dependency foundapm update --yes[*] All dependencies are up-to-dateI also ran
check-apm-current.shend-to-end through the shim:apm update --yessucceeded.apm outdatedtakes about 3.6s throughuv run.6. Hook entries,
audit --ciand approvalsRe-approval IS required. This is the main finding.
Under 0.39.3 the root
apm.ymlkeyskyberforge#2.2.1anddelivery#0.8.0no longer match the package identities.apm approve --listnames the identities asgit.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.2.1and showshooks[x:default-deny] bin[x:default-deny]. So the first 0.39 install silently strips both hooks while rootaudit --cistays green.I tested two fixes. Both deploy both hooks and leave
settings.jsonandapm-hooks.jsonidentical tomain. Both pass rootaudit --ciwithAll 15 check(s) passed, includinghook-approval-pins,exec-status-currentandlocal-bundle-hooks.git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.2.1: {hooks: true, bin: true}.#versionsuffix is still version-blind, so the version-in-key convention survives.executable approvals are not pinned to content.apm approve <identity>, which pins to content (hooks: {.apm/hooks/hooks.json: sha256:…}).executablesblock, strips its comments, and keeps the old short keys alongside the new ones.check-apm-current.shorguard.pyparks the hook asdefinition-changeduntil someone runsapm approveagain.The SessionStart and PreToolUse entries are detected as
apm-owned-entryinsettings.json, and both pass.7. Changes the hook (#270) and cutover (#271) tickets must make
Cutover (#271):
apm.ymlexecutables.allowto 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.scripts/check-executables-allow-sync.sh, its tests, and its.pre-commit-config.yamldescription to require the full-identity<host>/<owner>/<repo>/plugins/<name>#<version>key. Also correct theapm.ymlcomment that cites 0.28_map_grantsmatching on a bare name.audit --cidoes not provide: fail whenapm approve --pendingor the lock reports anygated_pending_approval..claude/settings.jsonorapm-hooks.jsonchange should appear; if one does, the approvals are wrong.scripts/apm-audit-ci.sh: no pattern change. Refresh the "verified against" note to 0.39.3.scripts/apm-pack-check-clean.sh: no change.Hook (#270):
outdatedphrase match. Both spellings and the current case are verified on 0.39.3.check-apm-current.shmust also re-runapm approvefor 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 --versionstill reports 0.28.0.