From a48f0fdf5b8ed9f3b5ddc14091a72486aea92119 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 08:47:53 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- README.md | 17 +++++++++++------ docs/spec/gates.md | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6b15234..1d38d35 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Install all of these before setting up. Each one is a hard dependency of a git h | Tool | Why | Install | | --- | --- | --- | -| `apm` CLI | Two pre-push hooks shell out to it (`apm-audit-ci` and `apm-pack-check-clean`) | The `apm-install` skill, or `curl -sSL https://aka.ms/apm-unix \| sh`. Verify with `apm --version` | +| `uv` | Runs this repo's pinned apm. The root `pyproject.toml` pins `apm-cli==0.39.3` and `uv.lock` locks it (ADR-0034); the `apm-audit-ci` and `apm-pack-check-clean` pre-push hooks run it as `uv run --frozen apm` through `scripts/lib/apm.sh`, and fail below apm 0.39.2 | https://docs.astral.sh/uv/getting-started/installation/. A global `apm` is not needed and not used: a bare `apm` here may be an older one that refuses the v4 `apm.lock.yaml` | | `python3` + PyYAML | Required by `scripts/skill-size-check.sh` (the `skill-size-check` pre-commit hook) and `scripts/check-skill-version-bump.sh` (the `check-skill-version-bump` pre-push hook), which both parse YAML frontmatter | `python3` is usually present — pre-commit is itself a Python application. `pip install pyyaml` if the hook reports PyYAML missing | | `vale` | Required by the `vale-audit-prefilter-skill` / `-agent` pre-commit hooks, and by the `test-vale-wrap.sh` suite that `run-tests --strict` runs at pre-push | `brew install vale` (macOS), `snap install vale` (Linux), `choco install vale` (Windows), or https://vale.sh/docs/vale-cli/installation/ | | `claude` CLI | Required by the `validate-marketplace` pre-push hook | Claude Code | @@ -51,14 +51,19 @@ Two notes worth reading before you skip one: Run these in order, from the repo root. ```bash -# 1. Deploy this repo's own skills and agents -apm install +# 1. Install the pinned apm into .venv/ (gitignored) +uv sync --frozen -# 2. Install the git hooks — all three stages +# 2. Deploy this repo's own skills and agents +uv run --frozen apm install + +# 3. Install the git hooks — all three stages pre-commit install -t pre-commit -t commit-msg -t pre-push ``` -**`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. It needs the network and materializes `apm_modules/` (which stays gitignored). +**`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). **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. @@ -92,7 +97,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 `apm install` has populated `apm_modules/`**. 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 `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 `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. ## Editing plugin content diff --git a/docs/spec/gates.md b/docs/spec/gates.md index fad7272..d9e1ab8 100644 --- a/docs/spec/gates.md +++ b/docs/spec/gates.md @@ -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 --frozen apm` (ADR-0034). `--project` comes +from the helper's own location, so it names the repo root even when apm runs inside +`plugins//`. 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 `///`, as `apm approve --list` prints it, e.g. +`git.rkdr.net/Mortis/Holocron/plugins/kyberforge`. The bare `kyberforge#` 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 `#`, 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 +`#` 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//.apm/hooks/` or `plugins//bin/` exists — kyberforge ships both, delivery ships a guard hook. For each one it reads `name:` and `version:` from `plugins//apm.yml` and asserts root `apm.yml` carries the -`#` 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 `#` key is quoted -back as "found instead". It also fails on a shipping plugin with no `apm.yml`, a missing `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 `#` key, or a +bare `#...` 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.