From 7e63f22bf8091df77c74fb9345da560e6b9013fa Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 10:57:01 +0000 Subject: [PATCH 1/6] docs: re-verify the apm 0.28.0 claims in hook and test comments Checked against apm 0.39.3 live and in its source. The apm-audit-ci description and comments now give 15 root checks and 2 plugin checks, about 70 s through uv run, manifest-parse as a named row, and the new "nothing to scan" wording. The run-bats copytree note, the #204 git-env test header and its LESSONS entry say what holds on 0.39.3. Refs #272 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- .pre-commit-config.yaml | 50 ++++++++++++++++++++------------- LESSONS.md | 2 +- scripts/apm-audit-ci.sh | 13 +++++---- tests/run-bats.sh | 3 +- tests/test-apm-hooks-git-env.sh | 5 +++- 5 files changed, 45 insertions(+), 28 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6140c3e..221bc58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -80,41 +80,48 @@ repos: - id: apm-audit-ci name: apm audit --ci - description: Run apm's producer-side CI gate over the root manifest AND each plugin package, via scripts/apm-audit-ci.sh. On the root manifest it runs ten checks -- lockfile-exists, ref-consistency, deployment-ledger-owners, deployed-files-present, no-orphaned-packages, skill-subset-consistency, config-consistency, content-integrity, includes-consent, drift -- so it is both a hidden-Unicode scan and a drift gate that replays the install and diffs it. In a plugin package it runs one, lockfile-exists, which the script waives when that package declares dependencies, because a package is not an install root (ADR-0026). The waiver never applies to the root and never covers a second failing check. It does NOT enforce an org policy; see the comment below for why. Reference:plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md + description: Run apm's producer-side CI gate over the root manifest AND each plugin package, via scripts/apm-audit-ci.sh. On the root manifest apm 0.39.3 runs fifteen checks -- lockfile-exists, ref-consistency, deployment-ledger-owners, deployed-files-present, no-orphaned-packages, lockfile-targets-current, skill-subset-consistency, config-consistency, native-mcp-ownership, content-integrity, local-bundle-hooks, hook-approval-pins, exec-status-current, includes-consent, drift -- so it is both a hidden-Unicode scan and a drift gate that replays the install and diffs it. In a plugin package it runs two, lockfile-exists and a content-integrity row that scans no package source; the script waives lockfile-exists when that package declares dependencies, because a package is not an install root (ADR-0026). The waiver never applies to the root and never covers a second failing check. It does NOT enforce an org policy; see the comment below for why. Reference:plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md entry: scripts/apm-audit-ci.sh language: system stages: [pre-push] pass_filenames: false always_run: true - # What this hook actually runs, read off apm 0.28.0's own compliance + # What this hook actually runs, read off apm 0.39.3's own compliance # table by invoking `apm audit --ci` at the repo root and in - # plugins/lint/. Long form in docs/spec/gates.md, "apm-audit-ci". + # plugins/lint/ (holocron#272; first done on 0.28.0, which ran ten + # root checks and one plugin check). Long form in docs/spec/gates.md, + # "apm-audit-ci". # - # * ROOT MANIFEST -- ten checks: lockfile-exists, ref-consistency, + # * ROOT MANIFEST -- fifteen checks: lockfile-exists, ref-consistency, # deployment-ledger-owners, deployed-files-present, - # no-orphaned-packages, skill-subset-consistency, config-consistency, - # content-integrity, includes-consent, drift. It is a drift gate: it + # no-orphaned-packages, lockfile-targets-current, + # skill-subset-consistency, config-consistency, native-mcp-ownership, + # content-integrity, local-bundle-hooks, hook-approval-pins, + # exec-status-current, includes-consent, drift. It is a drift gate: it # replays the install cache-only and diffs the scratch result against # the working tree. Root lockfile-exists is not vacuous -- the root # declares dependencies, so it reports `Lockfile present`. - # * PLUGIN MANIFESTS -- one check: lockfile-exists. Conditional, and + # * PLUGIN MANIFESTS -- two checks: lockfile-exists, and a + # content-integrity row that scans no package source (it passed with + # a planted bidi override). lockfile-exists is conditional, and # vacuous while every plugin apm.yml declares # `dependencies: {apm: [], mcp: []}`: it reports `No dependencies # declared -- lockfile not required` and arms itself the moment one # does not (verified by adding a git dependency to - # plugins/lint/apm.yml). Everything else above is root-only, because + # plugins/lint/apm.yml). Everything else in the root list is + # root-only, because # only the root install has a lockfile, a deployment ledger and # deployed files to check. Running every plugin package is what # makes lockfile-exists reachable for them at all -- the root-only # invocation audits the root manifest and nothing else. # THAT ARMING NOW HAPPENS: plugins/mattpocock declares real dependencies, # and there is no green state for it -- without a package lockfile - # lockfile-exists fails, and with one it passes and arms the other - # nine, where drift then demands the dependency's skills be deployed + # lockfile-exists fails, and with one it passes and arms the rest of + # the root set, where drift then demands the dependency's skills be deployed # INSIDE the package. A package is not an install root, so # scripts/apm-audit-ci.sh waives that single check for a package and # nothing else (ADR-0026). Dropping --ci for packages would have been - # smaller and is wrong: verified on apm 0.28.0, plain `apm audit` + # smaller and is wrong: verified on apm 0.28.0 and 0.39.3, plain `apm audit` # exits 0 on a dependency entry missing its git/path/registry field # while --ci exits 1 naming it, and malformed-dependency detection is # the whole reason packages are audited. @@ -125,13 +132,14 @@ repos: # check. Both claims were wrong. What is true is that the STANDALONE # mode differs: plain `apm audit` (--ci refuses to combine with # --file/--strip/--dry-run/PACKAGE) run in a plugin directory reports - # `No apm.lock.yaml found -- nothing to scan` and exits 0, because - # only the root has a lockfile. - # * MANIFEST-PARSE IS NOT A CHECK in apm 0.28.0's table, and an earlier - # revision of this comment named it as one. Parsing is still - # enforced -- a dependency entry missing its git/path/registry field - # fails with `Cannot parse apm.yml` -- but it fails the invocation - # before the table is built, so it never appears as a row. + # `No recognized deployed primitives found -- nothing to scan` on + # 0.39.3 (`No apm.lock.yaml found -- nothing to scan` on 0.28.0) and + # exits 0, because only the root has a lockfile. + # * MANIFEST-PARSE IS A ROW ON 0.39.3, not on 0.28.0. A dependency entry + # missing its git/path/registry field now yields a one-row table with + # a failing manifest-parse row (`Cannot parse apm.yml: ...`); 0.28.0 + # failed the invocation before building the table. A parsable + # manifest gets no such row. # * POLICY IS NOT ENFORCED. `apm audit --ci` discovers an org policy # from the git remote, and apm's discovery only understands # github.com and Azure DevOps. This repo's remote is a self-hosted @@ -146,8 +154,10 @@ repos: # serve one. A gate that can never go green is not a gate. Revisit if # this repo ever gains a policy source apm can actually reach. # - # Costs ~0.5s per package. Needs no network ONCE `apm install` has - # populated apm_modules/ -- the root marketplace has no remote package + # Takes about 70 s for the root plus every plugin through `uv run` on + # apm 0.39.3 (about 0.5 s per package on 0.28.0). Needs no network ONCE + # `uv sync --frozen` and `uv run --frozen apm install` have each run + # once -- the root marketplace has no remote package # entries, so the install replay is cache-only. On a FRESH CLONE there # is no cache: deployed-files-present fails outright, and drift and # config-consistency clone from the holocron remote. See README.md's diff --git a/LESSONS.md b/LESSONS.md index 239a4c8..d164a3a 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -154,4 +154,4 @@ Under the `run-tests` pre-push hook, git exported `GIT_DIR` to the hook, so a ba ## 2026-11-26 — A hook's GIT_DIR leaks through any tool that runs git -#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others. +#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others. *2026-12-02 (#272):* apm 0.39.3 strips `GIT_DIR` and the other repo-locating vars from its own git calls (`git_subprocess_env` in `apm_cli/utils/git_env.py`). The leak was not reproduced again on 0.39.3, and the scrub stays, because the rule is about the hook, not about one tool version. diff --git a/scripts/apm-audit-ci.sh b/scripts/apm-audit-ci.sh index 75c48f4..3f7ee4c 100755 --- a/scripts/apm-audit-ci.sh +++ b/scripts/apm-audit-ci.sh @@ -22,7 +22,8 @@ # * no apm.lock.yaml in the package -> `lockfile-exists` fails with # "apm.yml declares dependencies but apm.lock.yaml is absent" # * an apm.lock.yaml in the package -> `lockfile-exists` passes and thereby -# arms the other nine checks, and `drift` then fails demanding the +# arms the rest of the root check set (nine more on apm 0.28.0, fourteen +# on 0.39.3), and `drift` then fails demanding the # dependency's skills be DEPLOYED inside the package # (plugins//.agents/skills/...), which is meaningless for a package # and additionally litters it with an apm_modules/ tree @@ -35,10 +36,12 @@ # WHAT IS DELIBERATELY NOT WAIVED # # Dropping `--ci` in package directories would have been the smaller change and -# is WRONG. Verified on apm 0.28.0 against a scratch package whose dependency -# entry carried no git/path/registry field: `apm audit --ci` exits 1 naming the -# field, while plain `apm audit` prints "No apm.lock.yaml found -- nothing to -# scan" and exits 0. Malformed-dependency detection is the reason gates.md gives +# is WRONG. Verified on apm 0.28.0, and again on 0.39.3 (#272), against a +# scratch package whose dependency entry carried no git/path/registry field: +# `apm audit --ci` exits 1 naming the field (a failing manifest-parse row on +# 0.39.3), while plain `apm audit` exits 0 with "nothing to scan" ("No +# recognized deployed primitives found" on 0.39.3, "No apm.lock.yaml found" +# on 0.28.0). Malformed-dependency detection is the reason gates.md gives # for auditing packages at all, and a package WITH dependencies is the only kind # that can carry a malformed dependency entry -- so the check would have been # discarded precisely where it earns its keep. diff --git a/tests/run-bats.sh b/tests/run-bats.sh index 4fd0ff7..2c62794 100755 --- a/tests/run-bats.sh +++ b/tests/run-bats.sh @@ -40,7 +40,8 @@ fi # mirror's deletion reaches the default branch and `apm update` runs, apm # deploys from `.apm/` directly, `tests/` dirs and all. Nothing in apm filters # them -- its deploy-time copytree ignore callback (`ignore_non_content()` in -# apm_cli/security/gate.py, 0.28.0) drops symlinks and the .apm-pin marker and +# apm_cli/security/gate.py, 0.28.0; still so on 0.39.3, which also drops +# generated Python bytecode) drops symlinks and the .apm-pin marker and # nothing else. Every `/tests/*.bats` file under plugins/ would then # land at .claude/skills//tests/ and be discovered and run a second time, # which is ADR-0024 consequence 2 arriving here. Keeping the exclusion now is diff --git a/tests/test-apm-hooks-git-env.sh b/tests/test-apm-hooks-git-env.sh index ba540b4..78074dc 100644 --- a/tests/test-apm-hooks-git-env.sh +++ b/tests/test-apm-hooks-git-env.sh @@ -7,7 +7,10 @@ # drift replay runs `git init` / `git checkout` in a temp dir with an env copied # from os.environ, so the inherited GIT_DIR wins: `git init` wrote # core.bare=true into the shared .git/config, and a later checkout moved the -# worktree's HEAD to the lock-pinned commit. +# worktree's HEAD to the lock-pinned commit. apm 0.39.3 strips GIT_DIR from +# its own git calls (git_subprocess_env, apm_cli/utils/git_env.py); the leak +# was not reproduced again there, and this suite keeps the hooks' own scrub +# pinned as defence in depth (#272). # # The stub `apm` below reproduces that pattern -- record GIT_DIR, then `git init` # and `git checkout` inside a fresh `mktemp -d` -- and each hook script is run -- 2.43.0 From 01fe1fb767f69675b4520a0a2452af328ba28b47 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 10:57:15 +0000 Subject: [PATCH 2/6] docs: run apm only through the uv-pinned invocation README, the AGENTS.md session rules, architecture.md and the .gitignore comments now give the pinned `uv run --frozen apm` form for every apm command in this repo and the two one-time online setup steps. A new session rule says a bare `apm` reaches the global 0.28.0, which this repo does not use. README and AGENTS.md add the setup note for a checkout deployed by apm 0.28: move .claude/skills, agents and commands aside before the first 0.39 install, or apm refuses with "no trustworthy local deployment baseline". Refs #272 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- .gitignore | 6 +++--- AGENTS.md | 7 ++++--- README.md | 16 ++++++++++------ docs/spec/architecture.md | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index ecf6b9c..0d52c3e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,16 +48,16 @@ apm_modules/ .claude/hooks/ # `apm pack` bundle output. The pre-push gate runs pack with --dry-run, so this -# only appears after a bare `apm pack` during a release; it is not repo content. +# only appears after a non-dry-run `apm pack` during a release; it is not repo content. build/ # `apm pack`'s manifest for the *root* package. Emitted beside the marketplace -# manifest by a bare `apm pack`, and never tracked on any branch — the repo's +# manifest by `apm pack` run with no flags, and never tracked on any branch — the repo's # own paths hide it, since the apm-pack-check-clean pre-push hook, the only # thing that runs pack here, passes --dry-run. It is NOT write-only output: # pack reads an existing copy back in preference to apm.yml and only rewrites # it with --force, so a stale copy leaks an old version and config into every -# bundle. Pack releases with `apm pack --force`, or delete this file first. Scoped +# bundle. Pack releases with `uv run --frozen apm pack --force`, or delete this file first. Scoped # to the file, not the directory: the sibling .claude-plugin/marketplace.json is # compiled output that IS committed and must stay tracked. /.claude-plugin/plugin.json diff --git a/AGENTS.md b/AGENTS.md index e120c6a..cc3edae 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,9 +28,10 @@ Fall back to raw shell only when no skill covers it. ## Session rules - **Do not add repo-owned keys to `.claude/settings.json`.** apm treats it as its own deployed artifact and `apm audit --ci` replays the install and diffs, so anything apm would not have written is permanent drift that fails the `apm-audit-ci` pre-push hook. A hook you want here is authored in `plugins//.apm/hooks/` and deployed by apm, never hand-written into that file. The `SessionStart` entry already in it is exactly that: kyberforge authors it in `plugins/kyberforge/.apm/hooks/hooks.json` and apm merges it in, so it is apm's own output, it is what the replay expects, and it belongs in the commit — do not strip it (ADR-0019). Machine-specific settings go in the gitignored `.claude/settings.local.json`; shared enforcement goes in `.pre-commit-config.yaml`. -- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. -- **A `.apm/` edit is not live until it is on the remote's `main`.** Root `apm.yml`'s first-party dependencies resolve from the holocron remote, unpinned against the default branch, so pushing a feature branch does not deploy it (ADR-0019). `apm install` deploys from the lock; `apm update` is what re-resolves refs. -- **No pre-push hook needs the network — once `apm install` has run.** Root `apm.yml`'s marketplace has no remote package entries, so every hook resolves locally. The guarantee is a property of a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. Run `apm install` once on a new checkout and the offline guarantee holds from then on (`docs/spec/gates.md`, "Pushing without a network"). +- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. +- **A `.apm/` edit is not live until it is on the remote's `main`.** Root `apm.yml`'s first-party dependencies resolve from the holocron remote, unpinned against the default branch, so pushing a feature branch does not deploy it (ADR-0019). `uv run --frozen apm install` deploys from the lock; `uv run --frozen apm update` is what re-resolves refs. +- **Run apm only as `uv run --frozen apm …`.** The root `pyproject.toml` and `uv.lock` pin apm 0.39.3 (ADR-0034). A bare `apm` reaches the machine-global 0.28.0, which this repo does not use and which refuses the v4 `apm.lock.yaml`. +- **No pre-push hook needs the network — once the two one-time online steps have run.** A new checkout runs `uv sync --frozen`, then `uv run --frozen apm install`, each online once. Root `apm.yml`'s marketplace has no remote package entries, so every hook then resolves locally. The guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. A checkout whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by 0.28 moves those three directories aside before its first 0.39 install, or apm refuses with "no trustworthy local deployment baseline" (`docs/spec/gates.md`, "Pushing without a network"). - **A plugin `version:` bump that has merged to `main` gets its release tag.** Run `git fetch origin --tags`, then `scripts/tag-plugin-releases.sh`; exit 1 means a tag is missing, and `--apply` creates it locally and prints the push command. The script reads local tags only, so OK means present locally, not published: confirm with `git ls-remote --tags origin '-v*'` before calling it done. A tag push is an irreversible publish, not a free Propose-tier push (ADR-0032): show the maintainer the exact tags and that command, and only on their explicit yes in this conversation run exactly it yourself (named tags, never `--tags` or other refs). Agents cut release tags only with the script, which never moves or deletes one; exit 2 means stop and report it to the maintainer, never hand-fix, move or delete a tag (ADR-0033). - **This repo and Gitea are the only source of truth.** All project state, decisions, and working conventions live here. Do not use an external memory system for this project — cached state diverges from the repo and you get a split brain. Before answering any design or architecture question, check `docs/adr/` for an existing decision. diff --git a/README.md b/README.md index 1d38d35..18ff47d 100644 --- a/README.md +++ b/README.md @@ -63,18 +63,22 @@ pre-commit install -t pre-commit -t commit-msg -t pre-push **`uv sync --frozen`** installs the apm that `uv.lock` pins into `.venv/`. Every apm command in this repo runs as `uv run --frozen apm ...`. -**`apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins//.apm/` remains the only place to edit. Both steps need the network once, and `apm install` materializes `apm_modules/` (which stays gitignored). +**`uv run --frozen apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins//.apm/` remains the only place to edit. Steps 1 and 2 each need the network once per checkout; the first apm 0.39 install also records commit-reachability verdicts. The install materializes `apm_modules/` (which stays gitignored). + +**Run apm only through `uv run --frozen apm`.** A bare `apm` reaches whatever is on `PATH`; on a machine with the global pipx apm 0.28.0, that one is not used in this repo and refuses the v4 `apm.lock.yaml`. + +**An existing checkout deployed by apm 0.28 needs one more step before step 2.** Move `.claude/skills`, `.claude/agents` and `.claude/commands` aside (or delete them if they hold no edits), then run `uv run --frozen apm install`. Without that, apm 0.39 refuses to replace the 0.28-deployed files with "no trustworthy local deployment baseline", because 0.28 recorded no deployment evidence for them. apm's own message suggests a bare `apm install`; use the `uv run --frozen` form instead. **Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags. ## Keeping the install current -The first-party dependencies in root `apm.yml` are unpinned against the default branch, so deployed skills go stale whenever anyone merges. kyberforge's `SessionStart` hook keeps the install current automatically on launch, rewriting `apm.lock.yaml` in the process — an unexplained modification to it after opening a session is expected, not a bug. On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `apm install`). The committed lock records a `main` commit too, just an older one. Discarding keeps lock churn unrelated to the branch out of its diff, and keeps the deployed tree consistent with the committed lock that `apm pack --check-clean` reads. The trade-off: the session then runs the older `main` the lock records, which is accepted on a feature branch. The discard also lasts only until the next session start, when the hook finds the lock behind `main` and refreshes again. Mechanism and rationale: `docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md`. +The first-party dependencies in root `apm.yml` are unpinned against the default branch, so deployed skills go stale whenever anyone merges. kyberforge's `SessionStart` hook keeps the install current automatically on launch, rewriting `apm.lock.yaml` in the process — an unexplained modification to it after opening a session is expected, not a bug. On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). The committed lock records a `main` commit too, just an older one. Discarding keeps lock churn unrelated to the branch out of its diff, and keeps the deployed tree consistent with the committed lock that `apm pack --check-clean` reads. The trade-off: the session then runs the older `main` the lock records, which is accepted on a feature branch. The discard also lasts only until the next session start, when the hook finds the lock behind `main` and refreshes again. Mechanism and rationale: `docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md`. Note the difference between the two commands: -- `apm install` deploys from `apm.lock.yaml`. It does **not** pick up remote changes. -- `apm update` re-resolves refs. This is the command that pulls in a merged `.apm/` edit. +- `uv run --frozen apm install` deploys from `apm.lock.yaml`. It does **not** pick up remote changes. +- `uv run --frozen apm update` re-resolves refs. This is the command that pulls in a merged `.apm/` edit. ## Running tests @@ -97,7 +101,7 @@ pre-commit run --hook-stage pre-push --all-files See [`docs/spec/gates.md`](docs/spec/gates.md) for what each hook enforces and why. -**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `apm install` have each run once** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on. +**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `uv run --frozen apm install` have each run once, online** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on. ## Editing plugin content @@ -132,7 +136,7 @@ dependencies: ref: git-v1.3.9 ``` -Then run `apm install`. Without `ref:`, the entry tracks the default branch. To list a plugin's +Then run `apm install` in your own repo. Without `ref:`, the entry tracks the default branch. To list a plugin's releases, run `git ls-remote --tags https://git.rkdr.net/Mortis/Holocron.git '-v*'`; `apm outdated` also reports newer `-v` tags. diff --git a/docs/spec/architecture.md b/docs/spec/architecture.md index 447b9f3..b55680f 100644 --- a/docs/spec/architecture.md +++ b/docs/spec/architecture.md @@ -19,7 +19,7 @@ project repo (local overrides) - **Executables** (`DEPLOY_EXECUTABLES`): `providers/claude-code/statusline-command.sh` → `~/.claude/statusline-command.sh` (with `+x`) - **Directories** (`DEPLOY_DIRS`): `core/` → `~/.claude/core/` (destination fully replaced on each deploy) -Skills are **not** deployed by `install.sh`. They are distributed as plugins and installed separately — in this repo by `apm install` against the `dependencies.apm` entries in the root `apm.yml`, which lands them in `.claude/skills/` and `.claude/agents/` (ADR-0018). A consuming repo installs them the same way — apm is the only supported install path. +Skills are **not** deployed by `install.sh`. They are distributed as plugins and installed separately — in this repo by `uv run --frozen apm install` (the repo-pinned apm, ADR-0034) against the `dependencies.apm` entries in the root `apm.yml`, which lands them in `.claude/skills/` and `.claude/agents/` (ADR-0018). A consuming repo installs them the same way — apm is the only supported install path. `~/.claude/CLAUDE.md` is a thin adapter, not a content source. It imports `~/.agents/AGENTS.md` (always-on rules) and `governance.md` (always-on governance) and carries nothing else — the content index of on-demand instruction files sits in `core/AGENTS.md`, deployed to `~/.agents/AGENTS.md` and imported by it. All always-on content lives in `AGENTS.md` files so other providers can import the same source without duplication. -- 2.43.0 From 386ab7ec5dfce689850c26769b1bf47b0f9ab651 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 10:57:18 +0000 Subject: [PATCH 3/6] docs(gates): re-verify the apm gate facts on apm 0.39.3 The apm-audit-ci section now records 15 root checks and 2 plugin checks, a run of about 70 s through uv run, manifest-parse as a named row, the new plain-audit wording, and the waiver re-verified in a scratch copy of plugins/mattpocock. The setup note and "Pushing without a network" give the two one-time online steps, the pinned invocation, and the first-0.39-install refusal on a 0.28-deployed checkout. Refs #272 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- docs/spec/gates.md | 94 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 29 deletions(-) diff --git a/docs/spec/gates.md b/docs/spec/gates.md index f75c54c..f8f899f 100644 --- a/docs/spec/gates.md +++ b/docs/spec/gates.md @@ -1162,7 +1162,9 @@ plugin packages under `plugins/` — because the root-only invocation audits the **nothing else**, and `apm-pack-check-clean` does not parse plugin `dependencies:` blocks either. Verified: a malformed dependency entry passes `apm pack --check-versions --check-clean --dry-run` and fails `apm audit --ci` in that package's -directory. Costs ~0.5s per package. +directory. The whole hook, the root plus every plugin package, takes about 70 s through `uv run` on +apm 0.39.3 (measured 70-90 s, about 20 s of it the root audit). On apm 0.28.0 it cost about 0.5 s +per package. **Both apm hooks run the repo-pinned apm.** They source `scripts/lib/apm.sh`, the one place the invocation is spelled: `uv run --project --frozen apm` (ADR-0034). `--project` comes @@ -1184,34 +1186,46 @@ none. `drift`'s install replay (apm 0.28.0) runs `git init` and `git checkout` i env copied from `os.environ`, so the inherited `GIT_DIR` wins. The `init` wrote `core.bare=true` into the shared `.git/config`, and the `checkout` moved the worktree's HEAD to the lock-pinned commit (issue #204). Pre-commit runs hooks from the worktree root, so once the vars are gone plain -discovery finds the right repo. `tests/test-apm-hooks-git-env.sh` pins this for both hooks. +discovery finds the right repo. *2026-12-02 (holocron#272):* apm 0.39.3 builds the env for its own +git calls through `git_subprocess_env` in `apm_cli/utils/git_env.py`, which strips `GIT_DIR` and the +other repo-locating vars. The leak was not reproduced again on 0.39.3, and the scrub stays as +defence in depth. `tests/test-apm-hooks-git-env.sh` pins this for both hooks. **What it actually runs is asymmetric**, and the two manifest classes are not comparable. Verified by -running `apm audit --ci` (apm 0.28.0) at the repo root and in `plugins/lint/`, reading the check -names straight off its own compliance table: +running `apm audit --ci` (apm 0.39.3, holocron#272; first done on 0.28.0) at the repo root and in +`plugins/lint/`, reading the check names straight off its own compliance table: -On the **root** manifest, **10 checks**: `lockfile-exists`, `ref-consistency`, +On the **root** manifest, **15 checks**: `lockfile-exists`, `ref-consistency`, `deployment-ledger-owners`, `deployed-files-present`, `no-orphaned-packages`, -`skill-subset-consistency`, `config-consistency`, `content-integrity`, `includes-consent`, `drift`. +`lockfile-targets-current`, `skill-subset-consistency`, `config-consistency`, +`native-mcp-ownership`, `content-integrity`, `local-bundle-hooks`, `hook-approval-pins`, +`exec-status-current`, `includes-consent`, `drift`. apm 0.28.0 ran ten of these; the five it lacked +are `lockfile-targets-current`, `native-mcp-ownership`, `local-bundle-hooks`, `hook-approval-pins` +and `exec-status-current`. -On each **plugin** manifest, **1 check**: `lockfile-exists`. Conditional, and vacuous while every +On each **plugin** manifest, **2 checks**: `lockfile-exists` and `content-integrity` (0.28.0 ran +only `lockfile-exists`). The plugin-level `content-integrity` row scans no package source: on +0.39.3 it still passed with a bidi override planted in a scratch copy of `plugins/lint`. When +`lockfile-exists` fails, the table holds that one row alone. `lockfile-exists` is conditional, and vacuous while every plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No dependencies declared -- lockfile not required`. An earlier revision of this section said it would arm the moment one did not. **It has armed.** `plugins/onedev` was the first plugin package to declare a real dependency — it pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on 2026-11-11; `plugins/mattpocock` carries the same shape (pinned third-party skills, no primitives of its own) and the check fires on -it for real. Everything else in the list above is root-only, because it is the +it for real. Everything else in the root list is root-only, because it is the root install that has a lockfile, a deployment ledger and deployed files to check. **A plugin package that declares dependencies has no green state, so the hook waives exactly one -failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the same for any package that declares dependencies): +failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the same for any package that declares dependencies), and again on apm 0.39.3 in a scratch copy of `plugins/mattpocock` (holocron#272): - **Without a package `apm.lock.yaml`**, `lockfile-exists` fails — `apm.yml declares dependencies but - apm.lock.yaml is absent` — reported as `1 of 1 check(s) failed`. + apm.lock.yaml is absent` — reported as `1 of 1 check(s) failed`. Unchanged on 0.39.3. - **With one**, generated by `apm lock` in the package directory, `lockfile-exists` passes and - thereby arms the other nine checks; `drift` then fails reporting **8 unintegrated files** at - `.agents/skills//SKILL.md`, i.e. demanding the dependency's skills be *deployed inside the - package*. `apm lock` also leaves an `apm_modules/` tree inside the package. + thereby arms the rest of the root check set; `drift` then fails reporting unintegrated files at + `.agents/skills//...`, i.e. demanding the dependency's skills be *deployed inside the + package*. On 0.28.0 that was nine more checks and 8 files from onedev; on 0.39.3 it is fourteen + more checks and 74 files from mattpocock. `apm lock` also leaves an `apm_modules/` tree inside the + package. The cause is that apm treats any directory holding both `apm.yml` and `apm.lock.yaml` as an **install root**, and a plugin package is not one. `scripts/apm-audit-ci.sh` therefore waives `lockfile-exists` @@ -1220,9 +1234,10 @@ so any second failing check changes the count and the run fails normally, and ou recognise fails closed. The root manifest is never waived. Recorded as ADR-0026. **Dropping `--ci` for package directories was considered and rejected.** It is the smaller change and -it is wrong. Verified on apm 0.28.0 against a scratch package whose dependency entry carried no -`git`/`path`/`registry` field: `apm audit --ci` exits 1 naming the field, while plain `apm audit` -prints `No apm.lock.yaml found -- nothing to scan` and exits 0. Malformed-dependency detection is the +it is wrong. Verified on apm 0.28.0, and again on 0.39.3 (holocron#272), against a scratch package +whose dependency entry carried no `git`/`path`/`registry` field: `apm audit --ci` exits 1 naming the +field, while plain `apm audit` exits 0. Plain `apm audit` printed `No apm.lock.yaml found -- nothing +to scan` on 0.28.0 and prints `No recognized deployed primitives found -- nothing to scan` on 0.39.3. Malformed-dependency detection is the reason this section gives for auditing packages at all, and a package *with* dependencies is the only kind that can carry a malformed dependency entry — so dropping `--ci` would discard the check precisely where it earns its keep. @@ -1231,15 +1246,24 @@ precisely where it earns its keep. turns the waiver off. That fails the push rather than hiding a defect; re-verify against the new output and update the patterns rather than widening them. -**`manifest-parse` is not a named check** in apm 0.28.0's output, and an earlier revision of this -section listed it as one. Parsing is still enforced — a dependency entry missing its -`git`/`path`/`registry` field fails with `Cannot parse apm.yml` — but it fails the invocation before -the table is built rather than appearing as a row in it. +**`manifest-parse` is a named check on apm 0.39.3, and was not one on 0.28.0.** On 0.28.0 a +dependency entry missing its `git`/`path`/`registry` field failed the invocation with `Cannot parse +apm.yml` before the table was built. On 0.39.3 the same entry produces a one-row table, a failing +`manifest-parse` row reading `Cannot parse apm.yml: Invalid APM dependency ...`, and `1 of 1 +check(s) failed` (holocron#272). The waiver does not cover it: that row lacks the `declares +dependencies but apm.lock.yaml is absent` line the waiver also requires. A parsable manifest gets no +`manifest-parse` row, which is why it is missing from both lists above. **The hook needs a completed `apm install`.** `deployed-files-present` checks the install output on -disk, so on a fresh clone it fails with `303 deployed file(s) missing` and takes the push with it. -That is not a defect in the gate; it is the gate correctly reporting that nothing has been installed -yet. Run `apm install` before the first push from a new checkout. +disk, so on a fresh clone it fails with ` deployed file(s) missing` (303 on 0.28.0; the count +follows the lock) and takes the push with it. That is not a defect in the gate; it is the gate +correctly reporting that nothing has been installed yet. Before the first push from a new checkout, +run `uv sync --frozen` and then `uv run --frozen apm install`, each once and online. Without the +first, the hooks' plain `uv run --frozen` performs that sync itself, which needs the network. An older checkout +whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by apm 0.28 moves those +three directories aside before that first 0.39 install. Otherwise apm refuses to replace the files +with `no trustworthy local deployment baseline`, because 0.28 recorded no deployment evidence for +them. apm's message suggests a bare `apm install`; run the `uv run --frozen` form instead. It does **not** enforce an org policy. apm discovers one from the git remote and only understands github.com and Azure DevOps, so against this repo's self-hosted Gitea remote it prints: @@ -1259,10 +1283,12 @@ that can never go green is not a gate. Revisit only if this repo gains a policy or hash drift detected` — so the root invocation already covers it and nothing needs adding. What remains true is that the *standalone* mode is different: plain `apm audit` (`--ci` refuses to combine with `--file`/`--strip`/`--dry-run`/`PACKAGE`) run in a plugin directory reports -`No apm.lock.yaml found -- nothing to scan` and exits 0, because only the root has a lockfile. -Plugin manifests get `lockfile-exists` and nothing else; they are not Unicode-scanned. That holds -because no package carries an `apm.lock.yaml` — one would arm the other nine checks, `content-integrity` -among them, which is the state ADR-0026 rules out rather than a second scan worth having. +`No recognized deployed primitives found -- nothing to scan` on 0.39.3 (`No apm.lock.yaml found -- +nothing to scan` on 0.28.0) and exits 0, because only the root has a lockfile and deployed files. +Plugin manifests are not Unicode-scanned. 0.39.3 does add a `content-integrity` row in a plugin +directory, but it scans no package source (see above). That holds because no package carries an +`apm.lock.yaml`. One would arm the rest of the root check set, a scanning `content-integrity` among +them, which is the state ADR-0026 rules out rather than a second scan worth having. ### `check-executables-allow-sync` @@ -1292,6 +1318,10 @@ executables, since a third-party dependency can be parked too. A missing lock is `apm-audit-ci`'s `lockfile-exists`. It is a line scan of the shape apm writes, not a YAML parse. The rest of this section describes the 0.28.0 matching that the version-blind behaviour comes from. +*2026-12-02 (holocron#272):* the functions it names are still in apm 0.39.3's source with the same +roles. `materialize_exec_map` still stores each key under its version-blind name, and `_map_grants` +documents ordinary grants as version-blind. What changed is the name half of the key, which is now +the full identity described above. apm gates a package's `hooks/` and `bin/` on root `apm.yml`'s `executables.allow` (`apm_cli/security/executables.py`). `is_package_approved` is itself an exact dictionary lookup, but @@ -1364,7 +1394,11 @@ drift after the fact, not by a derived gate. ## Pushing without a network -No pre-push hook needs the network **once `apm install` has populated `apm_modules/`**. Every entry +No pre-push hook needs the network **once two one-time online steps have run in this checkout**: +`uv sync --frozen`, which installs the apm that `uv.lock` pins into `.venv/`, then +`uv run --frozen apm install`, which populates `apm_modules/` and the deployed tree. Every apm +call in the hooks goes through the pinned invocation in `scripts/lib/apm.sh` (ADR-0034); after the +first sync, its implied `uv` sync is a no-op that needs no network. Every entry in root `apm.yml`'s `marketplace.packages[]` resolves from a local `./plugins/` path, so `apm-pack-check-clean` never calls `git ls-remote`. @@ -1375,7 +1409,9 @@ replay the install to diff scratch against the working tree, and that replay is clone** there is no cache to replay from, so the replay clones from the holocron remote and those two checks fail offline, with `deployed-files-present` already failing for the same reason (see `apm-audit-ci` above). The offline guarantee is a property of a populated `apm_modules/`, not of the -hook set: run `apm install` once on a new checkout and it holds from then on. +hook set: run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it +holds from then on. Run apm only in that pinned form here: a bare `apm` reaches the machine-global +0.28.0, which this repo does not use and which refuses the v4 `apm.lock.yaml`. ## Plugin release tags are not a gate -- 2.43.0 From b80c26e0644891b644d77bc51d9a6dcfd32c6e44 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 10:58:09 +0000 Subject: [PATCH 4/6] docs(adr): add dated apm 0.39.3 notes to the 0.28.0 claims ADRs 0017, 0019, 0021, 0026, 0029 and 0033 get 2026-12-02 forward notes recording each 0.28.0 claim's result on apm 0.39.3: held, changed, or not re-run. ADR-0019 gains a note that the executables.allow key is now the full package identity (#271), not the bare kyberforge# form it describes. ADR-0034 consequence 4 records the re-check as done. Refs #272 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- ...nt-mirror-bridges-apm-to-host-discovery.md | 6 +++++ ...tart-hook-keeps-the-apm-install-current.md | 27 +++++++++++++++++++ ...in-descriptions-state-a-domain-boundary.md | 6 +++++ ...a-plugin-package-is-not-an-install-root.md | 9 +++++++ ...ts-resolve-through-subpath-dependencies.md | 3 +++ ...in-releases-are-tagged-plugin-v-version.md | 9 +++++++ .../0034-apm-is-pinned-per-repo-with-uv.md | 2 ++ 7 files changed, 62 insertions(+) diff --git a/docs/adr/0017-plugin-content-mirror-bridges-apm-to-host-discovery.md b/docs/adr/0017-plugin-content-mirror-bridges-apm-to-host-discovery.md index 070eceb..176e969 100644 --- a/docs/adr/0017-plugin-content-mirror-bridges-apm-to-host-discovery.md +++ b/docs/adr/0017-plugin-content-mirror-bridges-apm-to-host-discovery.md @@ -10,6 +10,12 @@ accurate about how Claude Code's installer works; what changed is that nothing c they governed; the symlink amendment's underlying gap is not — see ADR-0024's consequences. This ADR's content is kept below as the historical record; it is no longer the current model. +*Amended 2026-12-02 (holocron#272): the apm 0.28.0 mechanism under Considered options holds on apm +0.39.3, checked in source. `build_plugin_manifest` still strips `("agents", "skills", "commands", +"instructions")`, and `synthesize_plugin_json_from_apm_yml` still emits only identity fields. One +addition: for the `codex` ecosystem only, 0.39.3 adds `skills` and `mcpServers` pointers after the +strip.* + --- This ADR is a follow-on correction to ADR-0015 (Microsoft APM replaces hand-authored diff --git a/docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md b/docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md index 3ee5b82..2a43a62 100644 --- a/docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md +++ b/docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md @@ -12,6 +12,11 @@ repo-pinned `uv run --frozen` apm, else `PATH` apm, else exit 0) instead of a ba The "0.28.0" claims below (the correction near line 80, the `apm outdated` prose at about line 143, and the sidecar reproduction at about line 217) are pending re-verification on 0.39.3 under #265.* +*Amended 2026-12-02 (holocron#272): those claims are re-checked on apm 0.39.3, and the results sit +beside each claim. The version-blind matching holds, but the key's name half is now the full +package identity (#271). The `apm outdated` prose holds. The sidecar reproduction was not re-run. +In this repo every apm command named below runs as `uv run --frozen apm ...` (ADR-0034).* + ## Context The pre-existing answer was `scripts/git-hooks/post-push`, which pulled the marketplace clone and @@ -92,6 +97,18 @@ question is only what catches a missed edit. > justified by this repo's own requirement that the key track `plugins/kyberforge/apm.yml`'s > `version:`, not by an apm-level failure mode. `docs/spec/gates.md` carries the same correction. +> **Amendment (2026-12-02, holocron#272) — the key is now the full package identity.** The +> version-blind matching in the correction above holds on apm 0.39.3: `is_package_approved`, +> `materialize_exec_map` and `_map_grants` keep the same roles in its source. The bare +> `kyberforge#` key described above no longer matches on 0.39. apm 0.39 matches a grant on +> the package identity `apm approve --list` prints, so the key is +> `git.rkdr.net/Mortis/Holocron/plugins/kyberforge#` (#271). A bare key leaves the hook +> parked: the first 0.39 install drops it from `.claude/settings.json`, and root `apm audit --ci` +> still passes (spike #269). `scripts/check-executables-allow-sync.sh` therefore derives each +> expected key from root `apm.yml`'s `git:` + `path:` entry for the plugin, fails a bare key, and +> fails any `gated_*` `exec_status` in `apm.lock.yaml`. The `#` half is still a repo-level +> record. `docs/spec/gates.md`, "check-executables-allow-sync", has the details. + A comment in the `executables:` block is not enough: this repo gates generated-content drift, marketplace mirror drift and vale style drift deterministically, and a silent-staleness failure is strictly worse than any of them. So `scripts/check-executables-allow-sync.sh` runs at pre-push, @@ -158,6 +175,10 @@ silently and no refresh ran. With six packages merging independently, one-behind case rather than an edge, which means the mechanism failed most often in exactly the situation it exists for. The match is now `outdated dependenc(y|ies) found`. +> **Amendment (2026-12-02, holocron#272) — holds on apm 0.39.3.** `apm outdated --help` still lists +> no `--json` or other machine-readable flag, and `apm_cli/commands/outdated.py` still picks +> `dependency` or `dependencies` by count. + The deeper lesson is the one `post-push` already taught and this repeated: every assertion about the hook mocked `apm`, so the suite was green while the hook could not detect the common case. Mocks verify the code against its author's belief about the interface, never the interface. The suite now @@ -228,6 +249,12 @@ protecting, that nothing repo-authored goes in that file, is unchanged. > is apm output like the settings entry it describes, so it is committed for the same reason and > changes only when the owning package is renamed or moved. `.claude/hooks/` stays ignored. +> **Amendment (2026-12-02, holocron#272) — not re-run on apm 0.39.3.** The sidecar is still +> committed, and with it root `apm audit --ci` passes all 15 checks on 0.39.3. The 0.28.0 failure +> without the sidecar was not reproduced. apm 0.38 and later refuse to replace managed files that +> lack deployment evidence, so the failure without it may now look different. That was not +> established. + **Native consumers are protected by a guard, not by the gate.** A host installing holocron through `claude plugin install` auto-discovers `hooks/hooks.json` and does not consult apm's trust gate at all. The script therefore exits silently when there is no `apm.lock.yaml` in the working directory, diff --git a/docs/adr/0021-plugin-descriptions-state-a-domain-boundary.md b/docs/adr/0021-plugin-descriptions-state-a-domain-boundary.md index 2de9c9a..6261339 100644 --- a/docs/adr/0021-plugin-descriptions-state-a-domain-boundary.md +++ b/docs/adr/0021-plugin-descriptions-state-a-domain-boundary.md @@ -118,6 +118,12 @@ result against the working tree, and `content-integrity` scans for hidden Unicod the finding: both gates compare bytes, neither reads the `description` key for sense, so propagation is still not verification. +*Amended 2026-12-02 (holocron#272): on apm 0.39.3, root `apm audit --ci` runs fifteen checks, not +ten. It adds `lockfile-targets-current`, `native-mcp-ownership`, `local-bundle-hooks`, +`hook-approval-pins` and `exec-status-current`. A plugin package runs two, with `content-integrity` +added to `lockfile-exists`. None of the new checks reads the `description` key for sense, so the +finding stands. The current list is in `docs/spec/gates.md`, "apm-audit-ci".* + **And the obligation is unbounded.** Under enumeration, adding one skill to `bin`, `git` or `gitea` means editing two copies of a prose string on top of the version bumps and regeneration any skill addition already owes under this repo's release policy diff --git a/docs/adr/0026-a-plugin-package-is-not-an-install-root.md b/docs/adr/0026-a-plugin-package-is-not-an-install-root.md index 3792c66..1903136 100644 --- a/docs/adr/0026-a-plugin-package-is-not-an-install-root.md +++ b/docs/adr/0026-a-plugin-package-is-not-an-install-root.md @@ -2,6 +2,15 @@ **Status:** Accepted (2026-09-20) +*Amended 2026-12-02 (holocron#272): re-verified on apm 0.39.3 in a scratch copy of +`plugins/mattpocock`. Without a package lock, the same line and `1 of 1 check(s) failed` appear, so +the waiver is unchanged. With one from `apm lock`, the rest of the root set arms (fourteen more +checks, not nine), and `drift` fails on 74 unintegrated files under `.agents/skills/`. Two details +below changed. A plugin package whose `lockfile-exists` passes now runs two checks, with +`content-integrity` added. Plain `apm audit` now prints `No recognized deployed primitives found -- +nothing to scan`. The malformed-entry case still separates `--ci` (exit 1, now a failing +`manifest-parse` row) from plain `apm audit` (exit 0), so the rejection of dropping `--ci` stands.* + `plugins/onedev` is the first plugin package in this repo to declare a real dependency. It pins `code.onedev.io/onedev/tod#v4.3.4` so that a consumer installing `onedev` from the holocron marketplace picks up OneDev's eight TOD skills transitively — a `marketplace.packages` entry takes a diff --git a/docs/adr/0029-routing-targets-resolve-through-subpath-dependencies.md b/docs/adr/0029-routing-targets-resolve-through-subpath-dependencies.md index d919703..fb96160 100644 --- a/docs/adr/0029-routing-targets-resolve-through-subpath-dependencies.md +++ b/docs/adr/0029-routing-targets-resolve-through-subpath-dependencies.md @@ -27,6 +27,9 @@ are packages and already resolve through the `path:` branch. The name is a conve it assumes apm deploys the skill under the subpath's last segment, which it does today (verified on apm 0.28.0 for `wayfinder`), and a rename upstream is caught by the pin, not by this gate. +*Amended 2026-12-02 (holocron#272): holds on apm 0.39.3. A `uv run --frozen apm install` deploys +`mattpocock/skills/skills/engineering/wayfinder#v1.3.2` to `.claude/skills/wayfinder/`.* + **Rejected: rewording the four clauses out of route notation.** Cheap, but it turns real routing checks into SUGGESTIONs for exactly the skills most likely to be renamed upstream. diff --git a/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md b/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md index 4c4e426..52a7b30 100644 --- a/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md +++ b/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md @@ -6,6 +6,15 @@ check in Context and the apm behaviour in consequence 3) are pending re-verification on 0.39.3 under #265, once apm is pinned per repo (ADR-0034). The Decision is unchanged.* +*Amended 2026-12-02 (holocron#272): re-checked on apm 0.39.3.* +- *The tag pattern holds in source: `apm_cli/marketplace/tag_pattern.py` still lists + `{name}-v{version}`. The synthetic-repo `apm outdated` run was not repeated.* +- *Consequence 3's shorthand failure holds. A scratch install of + `git.rkdr.net/Mortis/Holocron/plugins/lint#` fails with `Repository + Mortis/Holocron/plugins/lint not found on git.rkdr.net`. The tag in that run did not exist, but + the failure comes at repository resolution, before any ref is read.* +- *The `rstrip(".git")` bug is fixed in 0.39.3, which uses `removesuffix(".git")`.* + ## Context Issue #223. Consumers that pin a holocron package need a git tag per package version. Two consumers diff --git a/docs/adr/0034-apm-is-pinned-per-repo-with-uv.md b/docs/adr/0034-apm-is-pinned-per-repo-with-uv.md index 589d7ca..4d24a70 100644 --- a/docs/adr/0034-apm-is-pinned-per-repo-with-uv.md +++ b/docs/adr/0034-apm-is-pinned-per-repo-with-uv.md @@ -92,6 +92,8 @@ different name. apm and the version check. 4. **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. + *Amended 2026-12-02 (holocron#272): done. ADRs 0017, 0019, 0021, 0026, 0029 and 0033 carry + dated notes with the 0.39.3 result for each claim.* Related: ADR-0019, ADR-0024, ADR-0033; #245, #265; Defame1297/ansible-homelab-mono#1078; Mortis/Kamino#499. -- 2.43.0 From 66443e7458ead407856505a6e79727bbbb8b1b1f Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 11:50:38 +0000 Subject: [PATCH 5/6] docs: clear a 0.28-populated apm_modules before writing the lock apm 0.39 reuses the 0.28-era third-party copies in apm_modules/ and writes a lock without their carried_licenses entries, which a fresh install contradicts and apm-pack-check-clean then fails on. README setup, gates.md and the AGENTS.md lock-churn rule now say to move apm_modules/ aside and reinstall before any 0.39 command that writes the lock. Consuming the committed lock is unaffected. Refs #272 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- AGENTS.md | 2 +- README.md | 2 ++ docs/spec/gates.md | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index cc3edae..b0729e4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,7 +28,7 @@ Fall back to raw shell only when no skill covers it. ## Session rules - **Do not add repo-owned keys to `.claude/settings.json`.** apm treats it as its own deployed artifact and `apm audit --ci` replays the install and diffs, so anything apm would not have written is permanent drift that fails the `apm-audit-ci` pre-push hook. A hook you want here is authored in `plugins//.apm/hooks/` and deployed by apm, never hand-written into that file. The `SessionStart` entry already in it is exactly that: kyberforge authors it in `plugins/kyberforge/.apm/hooks/hooks.json` and apm merges it in, so it is apm's own output, it is what the replay expects, and it belongs in the commit — do not strip it (ADR-0019). Machine-specific settings go in the gitignored `.claude/settings.local.json`; shared enforcement goes in `.pre-commit-config.yaml`. -- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. +- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. Before writing the lock with apm 0.39 in a checkout whose `apm_modules/` apm 0.28 populated, move `apm_modules/` aside and run `uv run --frozen apm install`, or the lock loses its third-party `carried_licenses` entries (`docs/spec/gates.md`, "apm-audit-ci"). - **A `.apm/` edit is not live until it is on the remote's `main`.** Root `apm.yml`'s first-party dependencies resolve from the holocron remote, unpinned against the default branch, so pushing a feature branch does not deploy it (ADR-0019). `uv run --frozen apm install` deploys from the lock; `uv run --frozen apm update` is what re-resolves refs. - **Run apm only as `uv run --frozen apm …`.** The root `pyproject.toml` and `uv.lock` pin apm 0.39.3 (ADR-0034). A bare `apm` reaches the machine-global 0.28.0, which this repo does not use and which refuses the v4 `apm.lock.yaml`. - **No pre-push hook needs the network — once the two one-time online steps have run.** A new checkout runs `uv sync --frozen`, then `uv run --frozen apm install`, each online once. Root `apm.yml`'s marketplace has no remote package entries, so every hook then resolves locally. The guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. A checkout whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by 0.28 moves those three directories aside before its first 0.39 install, or apm refuses with "no trustworthy local deployment baseline" (`docs/spec/gates.md`, "Pushing without a network"). diff --git a/README.md b/README.md index 18ff47d..cab902c 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ pre-commit install -t pre-commit -t commit-msg -t pre-push **An existing checkout deployed by apm 0.28 needs one more step before step 2.** Move `.claude/skills`, `.claude/agents` and `.claude/commands` aside (or delete them if they hold no edits), then run `uv run --frozen apm install`. Without that, apm 0.39 refuses to replace the 0.28-deployed files with "no trustworthy local deployment baseline", because 0.28 recorded no deployment evidence for them. apm's own message suggests a bare `apm install`; use the `uv run --frozen` form instead. +**Writing the lock from a checkout whose `apm_modules/` apm 0.28 populated needs a clean cache first.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an install that changes the lock), move `apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era third-party copies and writes a lock without their `carried_licenses` entries, which a fresh install then contradicts. Consuming the committed lock is unaffected and needs only the two setup steps above. + **Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags. ## Keeping the install current diff --git a/docs/spec/gates.md b/docs/spec/gates.md index f8f899f..8e42e94 100644 --- a/docs/spec/gates.md +++ b/docs/spec/gates.md @@ -1265,6 +1265,16 @@ three directories aside before that first 0.39 install. Otherwise apm refuses to with `no trustworthy local deployment baseline`, because 0.28 recorded no deployment evidence for them. apm's message suggests a bare `apm install`; run the `uv run --frozen` form instead. +**A lock written over a 0.28-populated `apm_modules/` is wrong, and this gate family catches it +late.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an +install that changes the lock) in a checkout whose `apm_modules/` apm 0.28 populated, move +`apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era +third-party copies and writes a lock without their `carried_licenses` entries. A fresh install then +adds the LICENSE files, the cached content hash no longer matches the lock, and +`apm-pack-check-clean` fails with `does not match the content hash recorded in apm.lock.yaml` +(found under #272, fixed on #271 by regenerating the lock from a fresh install). Only writing the +lock is affected: consuming the committed lock needs only the two setup steps. + It does **not** enforce an org policy. apm discovers one from the git remote and only understands github.com and Azure DevOps, so against this repo's self-hosted Gitea remote it prints: -- 2.43.0 From db34dfa728ff0996bc2433a29bbf5b1500aa3190 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 12:25:51 +0000 Subject: [PATCH 6/6] docs: apply the #272 review notes on the apm 0.39 docs - Name kyberforge's SessionStart hook as a lock writer that can write the bad lock in a 0.28-populated checkout, with the recovery steps (README, AGENTS.md, gates.md). - AGENTS.md: put the pinned-invocation rule above the lock-churn rule, make the bare-apm remark conditional on what PATH holds, and replace the two 0.28 migration notes with one pointer to gates.md "apm-audit-ci". - Use one wording for the offline guarantee: a synced .venv/ and a populated apm_modules/. - Say the #204 leak was not re-tested on 0.39.3, and narrow the claim to git_subprocess_env (gates.md, LESSONS.md, git-env test header). - State the apm-audit-ci timing as 70-90 s, drop a duplicate README sentence, give the 0.39.3 shorthand error, reflow gates.md to about 100 columns, and move the ADR-0033 note into amendment blockquote form. Refs #272 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- .pre-commit-config.yaml | 2 +- AGENTS.md | 6 +- LESSONS.md | 2 +- README.md | 11 +-- ...in-releases-are-tagged-plugin-v-version.md | 16 ++-- docs/spec/gates.md | 90 ++++++++++--------- tests/test-apm-hooks-git-env.sh | 8 +- 7 files changed, 71 insertions(+), 64 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 221bc58..1b9310b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -154,7 +154,7 @@ repos: # serve one. A gate that can never go green is not a gate. Revisit if # this repo ever gains a policy source apm can actually reach. # - # Takes about 70 s for the root plus every plugin through `uv run` on + # Takes 70-90 s for the root plus every plugin through `uv run` on # apm 0.39.3 (about 0.5 s per package on 0.28.0). Needs no network ONCE # `uv sync --frozen` and `uv run --frozen apm install` have each run # once -- the root marketplace has no remote package diff --git a/AGENTS.md b/AGENTS.md index b0729e4..cca8d20 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,10 +28,10 @@ Fall back to raw shell only when no skill covers it. ## Session rules - **Do not add repo-owned keys to `.claude/settings.json`.** apm treats it as its own deployed artifact and `apm audit --ci` replays the install and diffs, so anything apm would not have written is permanent drift that fails the `apm-audit-ci` pre-push hook. A hook you want here is authored in `plugins//.apm/hooks/` and deployed by apm, never hand-written into that file. The `SessionStart` entry already in it is exactly that: kyberforge authors it in `plugins/kyberforge/.apm/hooks/hooks.json` and apm merges it in, so it is apm's own output, it is what the replay expects, and it belongs in the commit — do not strip it (ADR-0019). Machine-specific settings go in the gitignored `.claude/settings.local.json`; shared enforcement goes in `.pre-commit-config.yaml`. -- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. Before writing the lock with apm 0.39 in a checkout whose `apm_modules/` apm 0.28 populated, move `apm_modules/` aside and run `uv run --frozen apm install`, or the lock loses its third-party `carried_licenses` entries (`docs/spec/gates.md`, "apm-audit-ci"). +- **Run apm only as `uv run --frozen apm …`.** The root `pyproject.toml` and `uv.lock` pin apm 0.39.3 (ADR-0034). A bare `apm` reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`. +- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch: it runs `uv run --frozen apm update --yes` and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. A checkout that apm 0.28 deployed or populated needs one-time migration steps, and its first session-start rewrite of the lock can be wrong: see `docs/spec/gates.md`, "apm-audit-ci". - **A `.apm/` edit is not live until it is on the remote's `main`.** Root `apm.yml`'s first-party dependencies resolve from the holocron remote, unpinned against the default branch, so pushing a feature branch does not deploy it (ADR-0019). `uv run --frozen apm install` deploys from the lock; `uv run --frozen apm update` is what re-resolves refs. -- **Run apm only as `uv run --frozen apm …`.** The root `pyproject.toml` and `uv.lock` pin apm 0.39.3 (ADR-0034). A bare `apm` reaches the machine-global 0.28.0, which this repo does not use and which refuses the v4 `apm.lock.yaml`. -- **No pre-push hook needs the network — once the two one-time online steps have run.** A new checkout runs `uv sync --frozen`, then `uv run --frozen apm install`, each online once. Root `apm.yml`'s marketplace has no remote package entries, so every hook then resolves locally. The guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. A checkout whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by 0.28 moves those three directories aside before its first 0.39 install, or apm refuses with "no trustworthy local deployment baseline" (`docs/spec/gates.md`, "Pushing without a network"). +- **No pre-push hook needs the network — once the two one-time online steps have run.** A new checkout runs `uv sync --frozen`, then `uv run --frozen apm install`, each online once. Root `apm.yml`'s marketplace has no remote package entries, so every hook then resolves locally. The guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. (`docs/spec/gates.md`, "Pushing without a network"). - **A plugin `version:` bump that has merged to `main` gets its release tag.** Run `git fetch origin --tags`, then `scripts/tag-plugin-releases.sh`; exit 1 means a tag is missing, and `--apply` creates it locally and prints the push command. The script reads local tags only, so OK means present locally, not published: confirm with `git ls-remote --tags origin '-v*'` before calling it done. A tag push is an irreversible publish, not a free Propose-tier push (ADR-0032): show the maintainer the exact tags and that command, and only on their explicit yes in this conversation run exactly it yourself (named tags, never `--tags` or other refs). Agents cut release tags only with the script, which never moves or deletes one; exit 2 means stop and report it to the maintainer, never hand-fix, move or delete a tag (ADR-0033). - **This repo and Gitea are the only source of truth.** All project state, decisions, and working conventions live here. Do not use an external memory system for this project — cached state diverges from the repo and you get a split brain. Before answering any design or architecture question, check `docs/adr/` for an existing decision. diff --git a/LESSONS.md b/LESSONS.md index d164a3a..ebb4fcb 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -154,4 +154,4 @@ Under the `run-tests` pre-push hook, git exported `GIT_DIR` to the hook, so a ba ## 2026-11-26 — A hook's GIT_DIR leaks through any tool that runs git -#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others. *2026-12-02 (#272):* apm 0.39.3 strips `GIT_DIR` and the other repo-locating vars from its own git calls (`git_subprocess_env` in `apm_cli/utils/git_env.py`). The leak was not reproduced again on 0.39.3, and the scrub stays, because the rule is about the hook, not about one tool version. +#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others. *2026-12-02 (#272):* apm 0.39.3's `apm_cli/utils/git_env.py` provides `git_subprocess_env`, which strips `GIT_DIR` and the other repo-locating vars. The leak was not re-tested on 0.39.3, and the scrub stays, because the rule is about the hook, not about one tool version. diff --git a/README.md b/README.md index cab902c..adb9fe1 100644 --- a/README.md +++ b/README.md @@ -61,15 +61,15 @@ uv run --frozen apm install pre-commit install -t pre-commit -t commit-msg -t pre-push ``` -**`uv sync --frozen`** installs the apm that `uv.lock` pins into `.venv/`. Every apm command in this repo runs as `uv run --frozen apm ...`. +**`uv sync --frozen`** installs the apm that `uv.lock` pins into `.venv/`. **`uv run --frozen apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins//.apm/` remains the only place to edit. Steps 1 and 2 each need the network once per checkout; the first apm 0.39 install also records commit-reachability verdicts. The install materializes `apm_modules/` (which stays gitignored). -**Run apm only through `uv run --frozen apm`.** A bare `apm` reaches whatever is on `PATH`; on a machine with the global pipx apm 0.28.0, that one is not used in this repo and refuses the v4 `apm.lock.yaml`. +**Run apm only through `uv run --frozen apm`.** A bare `apm` reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`. The global pipx apm 0.28.0 some machines carry is not used in this repo. **An existing checkout deployed by apm 0.28 needs one more step before step 2.** Move `.claude/skills`, `.claude/agents` and `.claude/commands` aside (or delete them if they hold no edits), then run `uv run --frozen apm install`. Without that, apm 0.39 refuses to replace the 0.28-deployed files with "no trustworthy local deployment baseline", because 0.28 recorded no deployment evidence for them. apm's own message suggests a bare `apm install`; use the `uv run --frozen` form instead. -**Writing the lock from a checkout whose `apm_modules/` apm 0.28 populated needs a clean cache first.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an install that changes the lock), move `apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era third-party copies and writes a lock without their `carried_licenses` entries, which a fresh install then contradicts. Consuming the committed lock is unaffected and needs only the two setup steps above. +**Writing the lock from a checkout whose `apm_modules/` apm 0.28 populated needs a clean cache first.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an install that changes the lock), move `apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era third-party copies and writes a lock without their `carried_licenses` entries, which a fresh install then contradicts. kyberforge's `SessionStart` hook is such a writer: it runs `uv run --frozen apm update --yes` at session start, so it can write the bad lock before you read this. To recover, discard it with `git checkout -- apm.lock.yaml`, move `apm_modules/` aside, then run `uv run --frozen apm install`. Consuming the committed lock is unaffected and needs only the two setup steps above. **Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags. @@ -103,7 +103,7 @@ pre-commit run --hook-stage pre-push --all-files See [`docs/spec/gates.md`](docs/spec/gates.md) for what each hook enforces and why. -**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `uv run --frozen apm install` have each run once, online** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on. +**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `uv run --frozen apm install` have each run once, online** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on. ## Editing plugin content @@ -146,7 +146,8 @@ releases, run `git ls-remote --tags https://git.rkdr.net/Mortis/Holocron.git '

#-v` does not work on this host. apm reads `plugins/` as part of the repository path, so a real install tries to clone -`.../Holocron/plugins/.git` and fails with "Not found". `apm install --dry-run` does not catch +`.../Holocron/plugins/.git` and fails because no such repository exists (on apm 0.39.3: +"Repository Mortis/Holocron/plugins/ not found on git.rkdr.net"). `apm install --dry-run` does not catch this. Use the object form. ### Automated updates diff --git a/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md b/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md index 52a7b30..a13a7ad 100644 --- a/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md +++ b/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md @@ -6,14 +6,14 @@ check in Context and the apm behaviour in consequence 3) are pending re-verification on 0.39.3 under #265, once apm is pinned per repo (ADR-0034). The Decision is unchanged.* -*Amended 2026-12-02 (holocron#272): re-checked on apm 0.39.3.* -- *The tag pattern holds in source: `apm_cli/marketplace/tag_pattern.py` still lists - `{name}-v{version}`. The synthetic-repo `apm outdated` run was not repeated.* -- *Consequence 3's shorthand failure holds. A scratch install of - `git.rkdr.net/Mortis/Holocron/plugins/lint#` fails with `Repository - Mortis/Holocron/plugins/lint not found on git.rkdr.net`. The tag in that run did not exist, but - the failure comes at repository resolution, before any ref is read.* -- *The `rstrip(".git")` bug is fixed in 0.39.3, which uses `removesuffix(".git")`.* +> **Amendment (2026-12-02, holocron#272) — the 0.28.0 claims re-checked on apm 0.39.3.** +> - The tag pattern holds in source: `apm_cli/marketplace/tag_pattern.py` still lists +> `{name}-v{version}`. The synthetic-repo `apm outdated` run was not repeated. +> - Consequence 3's shorthand failure holds. A scratch install of +> `git.rkdr.net/Mortis/Holocron/plugins/lint#` fails with `Repository +> Mortis/Holocron/plugins/lint not found on git.rkdr.net`. The tag in that run did not exist, but +> the failure comes at repository resolution, before any ref is read. +> - The `rstrip(".git")` bug is fixed in 0.39.3, which uses `removesuffix(".git")`. ## Context diff --git a/docs/spec/gates.md b/docs/spec/gates.md index 8e42e94..462087c 100644 --- a/docs/spec/gates.md +++ b/docs/spec/gates.md @@ -1162,9 +1162,8 @@ plugin packages under `plugins/` — because the root-only invocation audits the **nothing else**, and `apm-pack-check-clean` does not parse plugin `dependencies:` blocks either. Verified: a malformed dependency entry passes `apm pack --check-versions --check-clean --dry-run` and fails `apm audit --ci` in that package's -directory. The whole hook, the root plus every plugin package, takes about 70 s through `uv run` on -apm 0.39.3 (measured 70-90 s, about 20 s of it the root audit). On apm 0.28.0 it cost about 0.5 s -per package. +directory. The whole hook, the root plus every plugin package, takes 70-90 s through `uv run` on +apm 0.39.3, about 20 s of it the root audit. On apm 0.28.0 it cost about 0.5 s per package. **Both apm hooks run the repo-pinned apm.** They source `scripts/lib/apm.sh`, the one place the invocation is spelled: `uv run --project --frozen apm` (ADR-0034). `--project` comes @@ -1180,16 +1179,16 @@ pins the command, the `--project` root, the scrub and the version floor with a f `scripts/lib/clean-git-env.sh` before anything calls `apm`, which unsets `GIT_DIR`, `GIT_WORK_TREE`, `GIT_INDEX_FILE`, `GIT_OBJECT_DIRECTORY`, `GIT_COMMON_DIR`, `GIT_PREFIX` and `GIT_IMPLICIT_WORK_TREE`. It deliberately keeps the config-passing vars (`GIT_CONFIG_PARAMETERS`, -`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason: `git push` from a **linked worktree** exports an -absolute `GIT_DIR=

/.git/worktrees/` to its hooks, and from the main checkout it exports -none. `drift`'s install replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an -env copied from `os.environ`, so the inherited `GIT_DIR` wins. The `init` wrote `core.bare=true` into -the shared `.git/config`, and the `checkout` moved the worktree's HEAD to the lock-pinned commit -(issue #204). Pre-commit runs hooks from the worktree root, so once the vars are gone plain -discovery finds the right repo. *2026-12-02 (holocron#272):* apm 0.39.3 builds the env for its own -git calls through `git_subprocess_env` in `apm_cli/utils/git_env.py`, which strips `GIT_DIR` and the -other repo-locating vars. The leak was not reproduced again on 0.39.3, and the scrub stays as -defence in depth. `tests/test-apm-hooks-git-env.sh` pins this for both hooks. +`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason: +`git push` from a **linked worktree** exports an absolute `GIT_DIR=
/.git/worktrees/` to +its hooks, and from the main checkout it exports none. `drift`'s install replay (apm 0.28.0) runs +`git init` and `git checkout` in a temp dir with an env copied from `os.environ`, so the inherited +`GIT_DIR` wins. The `init` wrote `core.bare=true` into the shared `.git/config`, and the `checkout` +moved the worktree's HEAD to the lock-pinned commit (issue #204). Pre-commit runs hooks from the +worktree root, so once the vars are gone plain discovery finds the right repo. *2026-12-02 +(holocron#272):* apm 0.39.3's `apm_cli/utils/git_env.py` provides `git_subprocess_env`, which strips +`GIT_DIR` and the other repo-locating vars. The leak was not re-tested on 0.39.3, and the scrub +stays as defence in depth. `tests/test-apm-hooks-git-env.sh` pins this for both hooks. **What it actually runs is asymmetric**, and the two manifest classes are not comparable. Verified by running `apm audit --ci` (apm 0.39.3, holocron#272; first done on 0.28.0) at the repo root and in @@ -1204,19 +1203,21 @@ are `lockfile-targets-current`, `native-mcp-ownership`, `local-bundle-hooks`, `h and `exec-status-current`. On each **plugin** manifest, **2 checks**: `lockfile-exists` and `content-integrity` (0.28.0 ran -only `lockfile-exists`). The plugin-level `content-integrity` row scans no package source: on -0.39.3 it still passed with a bidi override planted in a scratch copy of `plugins/lint`. When -`lockfile-exists` fails, the table holds that one row alone. `lockfile-exists` is conditional, and vacuous while every -plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No dependencies declared --- lockfile not required`. An earlier revision of this section said it would arm the moment one did -not. **It has armed.** `plugins/onedev` was the first plugin package to declare a real dependency — it -pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on 2026-11-11; `plugins/mattpocock` -carries the same shape (pinned third-party skills, no primitives of its own) and the check fires on -it for real. Everything else in the root list is root-only, because it is the -root install that has a lockfile, a deployment ledger and deployed files to check. +only `lockfile-exists`). The plugin-level `content-integrity` row scans no package source: on 0.39.3 +it still passed with a bidi override planted in a scratch copy of `plugins/lint`. When +`lockfile-exists` fails, the table holds that one row alone. `lockfile-exists` is conditional, and +vacuous while every plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No +dependencies declared -- lockfile not required`. An earlier revision of this section said it would +arm the moment one did not. **It has armed.** `plugins/onedev` was the first plugin package to +declare a real dependency — it pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on +2026-11-11; `plugins/mattpocock` carries the same shape (pinned third-party skills, no primitives of +its own) and the check fires on it for real. Everything else in the root list is root-only, because +it is the root install that has a lockfile, a deployment ledger and deployed files to check. **A plugin package that declares dependencies has no green state, so the hook waives exactly one -failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the same for any package that declares dependencies), and again on apm 0.39.3 in a scratch copy of `plugins/mattpocock` (holocron#272): +failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the +same for any package that declares dependencies), and again on apm 0.39.3 in a scratch copy of +`plugins/mattpocock` (holocron#272): - **Without a package `apm.lock.yaml`**, `lockfile-exists` fails — `apm.yml declares dependencies but apm.lock.yaml is absent` — reported as `1 of 1 check(s) failed`. Unchanged on 0.39.3. @@ -1233,14 +1234,14 @@ and nothing else, and only for a non-root manifest: it asserts the string `1 of so any second failing check changes the count and the run fails normally, and output it does not recognise fails closed. The root manifest is never waived. Recorded as ADR-0026. -**Dropping `--ci` for package directories was considered and rejected.** It is the smaller change and -it is wrong. Verified on apm 0.28.0, and again on 0.39.3 (holocron#272), against a scratch package -whose dependency entry carried no `git`/`path`/`registry` field: `apm audit --ci` exits 1 naming the -field, while plain `apm audit` exits 0. Plain `apm audit` printed `No apm.lock.yaml found -- nothing -to scan` on 0.28.0 and prints `No recognized deployed primitives found -- nothing to scan` on 0.39.3. Malformed-dependency detection is the -reason this section gives for auditing packages at all, and a package *with* dependencies is the only -kind that can carry a malformed dependency entry — so dropping `--ci` would discard the check -precisely where it earns its keep. +**Dropping `--ci` for package directories was considered and rejected.** It is the smaller change +and it is wrong. Verified on apm 0.28.0, and again on 0.39.3 (holocron#272), against a scratch +package whose dependency entry carried no `git`/`path`/`registry` field: `apm audit --ci` exits 1 +naming the field, while plain `apm audit` exits 0. Plain `apm audit` printed `No apm.lock.yaml found +-- nothing to scan` on 0.28.0 and prints `No recognized deployed primitives found -- nothing to +scan` on 0.39.3. Malformed-dependency detection is the reason this section gives for auditing +packages at all, and a package *with* dependencies is the only kind that can carry a malformed +dependency entry — so dropping `--ci` would discard the check precisely where it earns its keep. **Known weak point: the waiver matches on apm's stdout.** An apm upgrade that rewords either line turns the waiver off. That fails the push rather than hiding a defect; re-verify against the new @@ -1259,11 +1260,12 @@ disk, so on a fresh clone it fails with ` deployed file(s) missing` (303 on 0 follows the lock) and takes the push with it. That is not a defect in the gate; it is the gate correctly reporting that nothing has been installed yet. Before the first push from a new checkout, run `uv sync --frozen` and then `uv run --frozen apm install`, each once and online. Without the -first, the hooks' plain `uv run --frozen` performs that sync itself, which needs the network. An older checkout -whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by apm 0.28 moves those -three directories aside before that first 0.39 install. Otherwise apm refuses to replace the files -with `no trustworthy local deployment baseline`, because 0.28 recorded no deployment evidence for -them. apm's message suggests a bare `apm install`; run the `uv run --frozen` form instead. +first, the hooks' plain `uv run --frozen` performs that sync itself, which needs the network. An +older checkout whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by apm +0.28 moves those three directories aside before that first 0.39 install. Otherwise apm refuses to +replace the files with `no trustworthy local deployment baseline`, because 0.28 recorded no +deployment evidence for them. apm's message suggests a bare `apm install`; run the `uv run --frozen` +form instead. **A lock written over a 0.28-populated `apm_modules/` is wrong, and this gate family catches it late.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an @@ -1273,7 +1275,11 @@ third-party copies and writes a lock without their `carried_licenses` entries. A adds the LICENSE files, the cached content hash no longer matches the lock, and `apm-pack-check-clean` fails with `does not match the content hash recorded in apm.lock.yaml` (found under #272, fixed on #271 by regenerating the lock from a fresh install). Only writing the -lock is affected: consuming the committed lock needs only the two setup steps. +lock is affected: consuming the committed lock needs only the two setup steps. kyberforge's +`SessionStart` hook is such a writer: it runs `uv run --frozen apm update --yes` at session start, +so in a checkout apm 0.28 populated it can write the bad lock before anyone reads this. To recover, +discard it with `git checkout -- apm.lock.yaml`, move `apm_modules/` aside, then run +`uv run --frozen apm install`. It does **not** enforce an org policy. apm discovers one from the git remote and only understands github.com and Azure DevOps, so against this repo's self-hosted Gitea remote it prints: @@ -1418,10 +1424,10 @@ replay the install to diff scratch against the working tree, and that replay is `[>] Replaying install (cache-only)` — which is exactly why it costs no network here. On a **fresh clone** there is no cache to replay from, so the replay clones from the holocron remote and those two checks fail offline, with `deployed-files-present` already failing for the same reason (see -`apm-audit-ci` above). The offline guarantee is a property of a populated `apm_modules/`, not of the -hook set: run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it -holds from then on. Run apm only in that pinned form here: a bare `apm` reaches the machine-global -0.28.0, which this repo does not use and which refuses the v4 `apm.lock.yaml`. +`apm-audit-ci` above). The offline guarantee is a property of a synced `.venv/` and a populated +`apm_modules/`, not of the hook set: run `uv sync --frozen` and `uv run --frozen apm install` once +on a new checkout and it holds from then on. Run apm only in that pinned form here: a bare `apm` +reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`. ## Plugin release tags are not a gate diff --git a/tests/test-apm-hooks-git-env.sh b/tests/test-apm-hooks-git-env.sh index 78074dc..87513cd 100644 --- a/tests/test-apm-hooks-git-env.sh +++ b/tests/test-apm-hooks-git-env.sh @@ -7,10 +7,10 @@ # drift replay runs `git init` / `git checkout` in a temp dir with an env copied # from os.environ, so the inherited GIT_DIR wins: `git init` wrote # core.bare=true into the shared .git/config, and a later checkout moved the -# worktree's HEAD to the lock-pinned commit. apm 0.39.3 strips GIT_DIR from -# its own git calls (git_subprocess_env, apm_cli/utils/git_env.py); the leak -# was not reproduced again there, and this suite keeps the hooks' own scrub -# pinned as defence in depth (#272). +# worktree's HEAD to the lock-pinned commit. apm 0.39.3's +# apm_cli/utils/git_env.py provides git_subprocess_env, which strips GIT_DIR +# and the other repo-locating vars; the leak was not re-tested on 0.39.3, and +# this suite keeps the hooks' own scrub pinned as defence in depth (#272). # # The stub `apm` below reproduces that pattern -- record GIT_DIR, then `git init` # and `git checkout` inside a fresh `mktemp -d` -- and each hook script is run -- 2.43.0