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 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
66443e7458
commit
db34dfa728
7 files changed
+71
-64
No files matched your search
+48
-42
@@ -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 <repo root> --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=<main>/.git/worktrees/<name>` 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=<main>/.git/worktrees/<name>` 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 `<N> 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
|
||||
|
||||
|
||||
Reference in new issue
Block a user