fix(gates): carry info/exclude into the waiver's scratch re-run
The unlanded-plugin waiver re-runs `apm audit --ci` in a fresh `git init` copy, which lacked the repo's info/exclude that deployed-files-present consults through `git check-ignore`. Copy it from `git rev-parse --git-path info/exclude` (the shared one in a linked worktree) when it exists, and correct the claim that origin is the only git state apm reads. Leave .claude/worktrees out of the tar copy: those checkouts can carry full .venvs, are ignored via info/exclude, and hold no lock-recorded deployed path, so no root check could see them. Add tests that turn red without the deletions-only diff guard (a manifest with no trailing newline) or without the post-reduce dep_identity guard (an rtk item split by a blank line surviving a deletions-only reduction), plus coverage for the exclude copy and the worktrees exclusion. Note in gates.md that a stale local origin/main keeps the waiver alive after landing, which fails safe behind the 15-check re-run, and that `git fetch` ends it. Refs: #179 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
7ee2066407
commit
b66f1b838f
3 files changed
+101
-12
No files matched your search
+15
-6
@@ -1247,22 +1247,31 @@ that `not found in lockfile` form for an identity equal to root `apm.yml`'s own
|
||||
must also exist in the working tree and be absent from the **local** `origin/main`, which must
|
||||
resolve; nothing is fetched. A plugin name must start with a letter or digit and may not contain
|
||||
`..`. Any other output fails closed. The waiver lapses for a plugin by itself: once it is on
|
||||
`origin/main`, the follow-up PR that records it in the lock is required.
|
||||
`origin/main`, the follow-up PR that records it in the lock is required. Because the hook reads
|
||||
only the local `origin/main` ref, a stale or unfetched one keeps the waiver alive after the plugin
|
||||
has landed. That fails safe: the waiver still requires the full 15-check re-run below to pass, so
|
||||
it waives only the `not found in lockfile` rows. `git fetch` refreshes the ref and ends the waiver.
|
||||
|
||||
**The waiver re-runs the full root check set before it passes.** The cut-short run never reaches the
|
||||
other twelve root checks (`content-integrity`, `hook-approval-pins`, `local-bundle-hooks`,
|
||||
`exec-status-current`, `deployed-files-present` and the rest), so the three-check result alone
|
||||
would let a defect in any of them through. Once the conditions above hold, the hook copies the working
|
||||
tree (minus `.git` and `.venv`) into a `mktemp -d` directory with `tar`. In the copy it drops only the
|
||||
`dependencies:` > `apm:` items whose `path:` names a waived plugin, checks that the reduced
|
||||
`apm.yml` differs from the original by those deletions alone, and runs `git init` with the same
|
||||
`origin` URL, the only git state apm reads. It then runs `apm audit --ci` there. The push passes only
|
||||
tree (minus `.git`, `.venv` and `.claude/worktrees`) into a `mktemp -d` directory with `tar`. In the
|
||||
copy it drops only the `dependencies:` > `apm:` items whose `path:` names a waived plugin, checks
|
||||
that the reduced `apm.yml` differs from the original by those deletions alone and that no entry for
|
||||
a waived plugin survived, and runs `git init`. It gives that repo the git state apm reads: the
|
||||
same `origin` URL, for org-policy discovery, and a copy of the real repo's `info/exclude` (from
|
||||
`git rev-parse --git-path info/exclude`, so a linked worktree's shared one), which
|
||||
`deployed-files-present` consults through `git check-ignore`. It then runs `apm audit --ci` there. The push passes only
|
||||
if that run exits 0 and prints `All 15 check(s) passed`. On this branch (holocron#179, apm 0.39.3) it
|
||||
does, and the hook prints `root re-run without the unlanded plugins: All 15 check(s) passed`. A copy
|
||||
was chosen over swapping `apm.yml` in place under a `trap`: the copy never writes the working tree, so
|
||||
the tree stays byte-identical even after `SIGKILL`, and a concurrent apm never sees a reduced
|
||||
manifest. `.git` is not copied because in a linked worktree it points into the shared gitdir. `.venv`
|
||||
is not copied because apm runs from the real one via `uv run --project`. The scratch directory is
|
||||
is not copied because apm runs from the real one via `uv run --project`. `.claude/worktrees` is not
|
||||
copied because each worktree there is a full checkout that can carry its own `.venv`. Leaving it out
|
||||
hides nothing: it is ignored through `info/exclude`, and the root checks look only at lock-recorded
|
||||
deployed paths, none of which is under it. The scratch directory is
|
||||
removed on exit, including on `INT`, `TERM` and `HUP`. The script header records the full reasoning.
|
||||
`tests/test-apm-audit-ci-waiver.sh` covers the waiver, the re-run, and each of its guards.
|
||||
|
||||
|
||||
Reference in new issue
Block a user