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

+57 -1
View File
@@ -9,7 +9,9 @@
# every plugin directory. The waiver's re-run is told apart by where it runs:
# under $TMPDIR, the script's mktemp scratch copy, where the stub saves the manifest it was given ($STUB_RERUN_LOG) and prints
# $STUB_RERUN_OUTPUT (default: the full root pass) with exit $STUB_RERUN_RC
# (default 0). The fixture is a throwaway git repo whose
# (default 0). With $STUB_GIT_LOG set it also saves the copy's
# .git/info/exclude and notes whether .claude/worktrees was copied. The fixture
# is a throwaway git repo whose
# refs/remotes/origin/main is set with update-ref -- nothing is fetched.
set -euo pipefail
@@ -40,6 +42,10 @@ if [[ -f apm.lock.yaml.root-marker ]]; then
exit 1
fi
[[ -z "${STUB_RERUN_LOG:-}" ]] || cp apm.yml "$STUB_RERUN_LOG"
if [[ -n "${STUB_GIT_LOG:-}" ]]; then
cp .git/info/exclude "$STUB_GIT_LOG.exclude" 2> /dev/null || true
[[ ! -e .claude/worktrees ]] || touch "$STUB_GIT_LOG.worktrees"
fi
printf '%s\n' "${STUB_RERUN_OUTPUT-[*] All 15 check(s) passed}"
exit "${STUB_RERUN_RC:-0}"
fi
@@ -141,8 +147,58 @@ cmp -s "$TMP/apm.yml.orig" "$F/apm.yml" && [[ -z "$(git -C "$F" status --porcela
&& pass "leaves the working tree's apm.yml byte-identical" || fail "apm.yml changed"
tmp_clean && pass "removes the scratch copy" || fail "scratch left behind: $(ls -A "$TMPD")"
echo ""
echo "--- the re-run copy: carries info/exclude, leaves out .claude/worktrees ---"
F="$TMP/excl"
make_fixture "$F"
printf '%s\n' '# fixture marker' '**/.claude/worktrees/' >> "$F/.git/info/exclude"
mkdir -p "$F/.claude/worktrees/wt/.venv"
touch "$F/.claude/worktrees/wt/.venv/big"
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")" STUB_GIT_LOG="$TMP/gitlog"
[[ $RC -eq 0 ]] && pass "still waived" || fail "exited $RC: $OUT"
cmp -s "$F/.git/info/exclude" "$TMP/gitlog.exclude" \
&& pass "the copy's .git/info/exclude is the repo's" || fail "info/exclude not carried into the copy"
[[ ! -e "$TMP/gitlog.worktrees" ]] && pass ".claude/worktrees is not copied" || fail ".claude/worktrees was copied"
echo ""
echo "--- not waived: the reduction changes a line, not only deletes (deletions-only guard) ---"
F="$TMP/nonl"
make_fixture "$F"
# No trailing newline: awk prints one back, so the reduced manifest's last
# line differs from the original's, a change rather than a deletion.
printf '%s' "$(cat "$F/apm.yml")" > "$F/apm.yml.new" && mv "$F/apm.yml.new" "$F/apm.yml"
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")"
[[ $RC -ne 0 ]] && ! grep -qF "waived ref-consistency" <<< "$OUT" \
&& grep -qF "changed more than the waived entries" <<< "$OUT" \
&& pass "fails when the reduced apm.yml differs by more than deletions" || fail "must fail (rc=$RC): $OUT"
echo ""
echo "--- not waived: the reduction leaves an rtk entry in place ---"
F="$TMP/blank"
make_fixture "$F"
# A blank line inside the rtk item: dep_identity skips it and still finds the
# entry, but reduce_manifest ends the item there and keeps it whole.
sed -i '/# Routes Bash/{n;s|$|\n|}' "$F/apm.yml"
grep -qx '' "$F/apm.yml" || fail "fixture: no blank line in the rtk item"
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")"
[[ $RC -ne 0 ]] && ! grep -qF "waived ref-consistency" <<< "$OUT" \
&& pass "fails when nothing was removed" || fail "must fail (rc=$RC): $OUT"
# A second, blank-split rtk item after a normal one: the normal one is
# removed, a pure deletion, so only the post-reduce dep_identity guard sees the
# entry that survived.
F="$TMP/dup"
make_fixture "$F"
awk -v e=" - git: https://$IDENTITY.git"$'\n\n'" path: plugins/rtk" \
'/^ mcp:/ { print e } { print }' "$F/apm.yml" > "$F/apm.yml.new"
mv "$F/apm.yml.new" "$F/apm.yml"
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")"
[[ $RC -ne 0 ]] && ! grep -qF "waived ref-consistency" <<< "$OUT" \
&& grep -qF "could not remove plugins/rtk's entry" <<< "$OUT" \
&& pass "fails when an rtk entry survives a deletions-only reduction" || fail "must fail (rc=$RC): $OUT"
echo ""
echo "--- not waived: the full-set re-run fails ---"
F="$TMP/waived"
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")" STUB_RERUN_RC=1 \
STUB_RERUN_OUTPUT="$(printf '%s\n' '| [x] | content-integrity | hidden Unicode |' '[x] 1 of 15 check(s) failed')"
[[ $RC -ne 0 ]] && ! grep -qF "waived ref-consistency" <<< "$OUT" \