docs: document the uv-pinned apm setup and full-identity allow keys

README: uv replaces the global apm as a prerequisite, setup starts with
`uv sync --frozen`, and the offline note names both one-time steps.
gates.md: the apm hooks run through scripts/lib/apm.sh with plain
--frozen (and why the gates, unlike the SessionStart hook, keep the
sync), and check-executables-allow-sync expects the full package
identity apm 0.39 matches on.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-12-02 08:47:53 +00:00
1 parent e87bd67c1f
commit a48f0fdf5b
2 files changed
+42 -12

No files matched your search

+31 -6
View File
@@ -1164,8 +1164,18 @@ 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.
**apm runs with git's repo-locating env scrubbed.** Both apm hooks source
`scripts/lib/clean-git-env.sh` before calling `apm`, which unsets `GIT_DIR`, `GIT_WORK_TREE`,
**Both apm hooks run the repo-pinned apm.** They source `scripts/lib/apm.sh`, the one place the
invocation is spelled: `uv run --project <repo root> --frozen apm` (ADR-0034). `--project` comes
from the helper's own location, so it names the repo root even when apm runs inside
`plugins/<name>/`. Each hook first checks the resolved apm's version and fails, naming
`uv sync --frozen` as the fix, below 0.39.2. The gates keep plain `--frozen`, without the
SessionStart hook's `--no-sync --offline`: once `uv sync --frozen` has run, the sync it implies is a
no-op that needs no network, and after a pull that moves the pin it brings `.venv/` to the new pin
instead of letting a gate certify the tree with a stale apm. `tests/test-apm-gate-invocation.sh`
pins the command, the `--project` root, the scrub and the version floor with a fake `uv`.
**apm runs with git's repo-locating env scrubbed.** Sourcing `scripts/lib/apm.sh` also sources
`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
@@ -1256,6 +1266,21 @@ among them, which is the state ADR-0026 rules out rather than a second scan wort
### `check-executables-allow-sync`
**Keys are full package identities (apm 0.39, #271).** apm 0.39.3 matches a grant on the package
identity `<host>/<owner>/<repo>/<path>`, as `apm approve --list` prints it, e.g.
`git.rkdr.net/Mortis/Holocron/plugins/kyberforge`. The bare `kyberforge#<version>` key that 0.28.0
matched no longer matches: the first 0.39 install parks the hooks, rewrites `.claude/settings.json`
without them, and root `apm audit --ci` still passes (spike #269, on #268). So the gate now derives
each expected key from root `apm.yml`'s own `git:` + `path:` dependency entry for the plugin (URL
without scheme, user or `.git`, then the path), appends `#<version>`, and fails a bare key with a
message saying why. A shipping plugin with no such entry fails, since no key can be derived. The
`#<version>` suffix is still stripped before apm matches, so the grant stays version-blind and the
version half stays a repo-level record. The grants are type-level (`hooks: true`), not
content-pinned: `apm approve` would pin content, strip the block's comments, and park the hook on
every script edit until someone approves again.
The rest of this section describes the 0.28.0 matching that the version-blind behaviour comes from.
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
it is never called with a single key: `install/exec_gate.py` builds a candidate list that includes
@@ -1276,10 +1301,10 @@ It covers every plugin that ships executables, not one named package. The script
`plugins/*/` and treats a plugin as shipping executables when `plugins/<name>/.apm/hooks/` or
`plugins/<name>/bin/` exists — kyberforge ships both, delivery ships a guard hook. For each one it
reads `name:` and `version:` from `plugins/<name>/apm.yml` and asserts root `apm.yml` carries the
`<name>#<version>` key under `executables.allow`. Keys use the package name, so a `name:` that
differs from the directory name fails rather than being guessed at. Every failing package is
reported in one run, each with its own Why/Fix block; a stale `<name>#<other-version>` key is quoted
back as "found instead". It also fails on a shipping plugin with no `apm.yml`, a missing `version:`,
`<identity>#<version>` key under `executables.allow`. The `name:` must equal the directory name, so
one that differs fails rather than being guessed at. Every failing package is
reported in one run, each with its own Why/Fix block; a stale `<identity>#<other-version>` key, or a
bare `<name>#...` key, is quoted back as "found instead". It also fails on a shipping plugin with no `apm.yml`, a missing `version:`,
a missing root `apm.yml`, or no `executables.allow` mapping. A repo with no executable-shipping
plugin at all is the one no-op, and a plugin with neither directory needs no key.