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:
Defame1297andClaude Opus 5.5 committed 2026-12-06 16:15:44 +00:00
1 parent 7ee2066407
commit b66f1b838f
3 files changed
+101 -12

No files matched your search

+29 -5
View File
@@ -116,11 +116,25 @@
# reading another path cannot silently see an empty one.
# * NOT .git: from a linked worktree it is a pointer file into the shared
# gitdir, and a git command run in the copy could then refresh that
# worktree's real index. A fresh `git init` with the same origin URL
# stands in for it -- apm reads only the origin remote, for org-policy
# discovery, and the copy prints the same policy line the real root does.
# worktree's real index. A fresh `git init` stands in for it, carrying the
# two pieces of git state apm reads: the origin remote's URL (org-policy
# discovery; the copy prints the same policy line the real root does) and
# the repo's info/exclude, copied from `git rev-parse --git-path
# info/exclude` (which resolves to the shared gitdir in a linked worktree)
# when it exists. deployed-files-present runs `git check-ignore` on each
# lock-recorded path that is absent, and an absent path ignored only
# through info/exclude must not count as missing in the copy either.
# .gitignore files travel with the tree, and core.excludesFile is the same
# user-level config for both runs.
# * NOT .venv: apm runs through `uv run --project <repo root>`, so the
# environment is the real one; .venv is no apm input and most of the size.
# * NOT .claude/worktrees: Claude Code's linked worktrees, each a full
# checkout that can carry its own .venv. They are ignored through
# info/exclude, and no root check reads them: deployed-files-present and
# content-integrity look up lock-recorded paths, none of which is under
# .claude/worktrees, and drift compares the replay's deployed files
# against the same paths in the tree. Leaving them out hides nothing the
# real audit would see.
# Only list items under `dependencies:` > `apm:` whose `path:` names a waived
# plugin are removed (comments and every other line kept), and the result is
# checked to differ from the original by deletions only, each waived entry gone.
@@ -276,9 +290,10 @@ trap 'exit 143' TERM HUP
# 0 and reports the full root check set passing; otherwise prints why, and
# apm's output, on stderr and fails.
reduced_root_audit() {
local names="$1" origin name rerun rc delta
local names="$1" origin exclude name rerun rc delta
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/apm-audit-ci.XXXXXX")" || return 1
if ! tar -C . --exclude=./.git --exclude=./.venv -cf - . | tar -C "$SCRATCH" -xf -; then
if ! tar -C . --exclude=./.git --exclude=./.venv --exclude=./.claude/worktrees -cf - . |
tar -C "$SCRATCH" -xf -; then
echo 'apm audit --ci: ref-consistency not waived: could not copy the tree for the re-run' >&2
return 1
fi
@@ -309,6 +324,15 @@ reduced_root_audit() {
if origin="$(git remote get-url origin 2>/dev/null)"; then
git -C "$SCRATCH" remote add origin "$origin" || return 1
fi
# The real repo's ignore rules for deployed-files-present (header, "NOT
# .git"). --git-path resolves to the shared gitdir from a linked worktree.
exclude="$(git rev-parse --path-format=absolute --git-path info/exclude 2>/dev/null)" || exclude=""
if [ -n "$exclude" ] && [ -f "$exclude" ]; then
if ! mkdir -p "$SCRATCH/.git/info" || ! cp "$exclude" "$SCRATCH/.git/info/exclude"; then
echo 'apm audit --ci: ref-consistency not waived: could not copy info/exclude into the re-run copy' >&2
return 1
fi
fi
rc=0
rerun="$(cd "$SCRATCH" && run_apm audit --ci 2>&1)" || rc=$?
if [ "$rc" -ne 0 ] || ! grep -qF "$ROOT_FULL_PASS" <<<"$rerun"; then