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 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
c2ba7f01bf
commit
7e63f22bf8
5 files changed
+45
-28
No files matched your search
+30
-20
@@ -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
|
||||
|
||||
+1
-1
@@ -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.
|
||||
@@ -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/<pkg>/.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.
|
||||
|
||||
+2
-1
@@ -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 `<skill>/tests/*.bats` file under plugins/ would then
|
||||
# land at .claude/skills/<name>/tests/ and be discovered and run a second time,
|
||||
# which is ADR-0024 consequence 2 arriving here. Keeping the exclusion now is
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user