feat(gates): waive ref-consistency for a plugin not yet on origin/main
A first-landing hook- or bin-shipping plugin could not be pushed. check-executables-allow-sync requires its git+path entry in root apm.yml, but root dependencies resolve from the remote's main (ADR-0019), so the lock cannot record the plugin until it lands and root `apm audit --ci` fails ref-consistency with `<identity>/plugins/<name>: not found in lockfile`. No state of the branch satisfied both gates. scripts/apm-audit-ci.sh now waives the root audit only when the sole failure is ref-consistency (`1 of 3 check(s) failed`, as apm 0.39.3 prints it), every detail line is that form for the identity root apm.yml's own git+path entry yields, plugins/<name>/apm.yml exists in the working tree, and the plugin is absent from the local origin/main. No fetch; a missing origin/main or unrecognised output fails closed. The waiver lapses for a plugin once it is on origin/main, when the follow-up lock PR must record 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
cc1d396d47
commit
aaa73dddd3
4 files changed
+328
-4
No files matched your search
Executable
+181
@@ -0,0 +1,181 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tests scripts/apm-audit-ci.sh's root ref-consistency waiver: a plugin whose
|
||||
# git+path entry is in root apm.yml but which is not yet on origin/main (#179,
|
||||
# ADR-0019). See docs/spec/gates.md, "apm-audit-ci".
|
||||
#
|
||||
# Same seam as tests/test-apm-gate-invocation.sh: a stub `apm`, reached through
|
||||
# the APM override so no uv or real apm runs. The stub prints canned `audit
|
||||
# --ci` output for the root manifest ($STUB_ROOT_OUTPUT, exit 1) and passes in
|
||||
# every plugin directory. The fixture is a throwaway git repo whose
|
||||
# refs/remotes/origin/main is set with update-ref -- nothing is fetched.
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
AUDIT="$REPO_ROOT/scripts/apm-audit-ci.sh"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
|
||||
|
||||
unset APM GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
|
||||
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
BIN="$TMP/bin"
|
||||
mkdir -p "$BIN"
|
||||
cat > "$BIN/apm" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
if [[ "${1:-}" == --version ]]; then
|
||||
echo "Agent Package Manager (APM) CLI version 0.39.3"
|
||||
exit 0
|
||||
fi
|
||||
if [[ -f apm.lock.yaml.root-marker ]]; then
|
||||
printf '%s\n' "$STUB_ROOT_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x "$BIN/apm"
|
||||
|
||||
IDENTITY="git.rkdr.net/Mortis/Holocron"
|
||||
|
||||
# The output apm 0.39.3 printed for this branch's root manifest (#179).
|
||||
root_output() { # <failing count line> <extra failing row> <detail lines...>
|
||||
local count="$1" extra="$2"
|
||||
shift 2
|
||||
printf '%s\n' \
|
||||
'[+] No drift detected' \
|
||||
'+------------------------------------------------------------------------------+' \
|
||||
'| Status | Check | Message |' \
|
||||
'|----------+-----------------+-------------------------------------------------|' \
|
||||
'| [+] | lockfile-exists | Lockfile present |' \
|
||||
"| [x] | ref-consistency | $# ref mismatch -- run 'apm install' to update |" \
|
||||
'| | | lockfile |'
|
||||
if [[ -n "$extra" ]]; then printf '%s\n' "$extra"; else
|
||||
printf '%s\n' '| [+] | drift | no drift detected against lockfile |'
|
||||
fi
|
||||
printf '%s\n' \
|
||||
'+------------------------------------------------------------------------------+' \
|
||||
'' \
|
||||
' ref-consistency details:'
|
||||
local d
|
||||
for d in "$@"; do printf ' - %s\n' "$d"; done
|
||||
printf '%s\n' '' "$count"
|
||||
}
|
||||
|
||||
# make_fixture <dir> — a repo with root apm.yml naming plugins/core and
|
||||
# plugins/rtk, both plugin dirs present, origin/main at a commit holding
|
||||
# plugins/core only.
|
||||
make_fixture() {
|
||||
local dir="$1"
|
||||
mkdir -p "$dir/plugins/core" "$dir/plugins/rtk"
|
||||
cat > "$dir/apm.yml" << EOF
|
||||
name: fixture
|
||||
dependencies:
|
||||
apm:
|
||||
- git: https://$IDENTITY.git
|
||||
path: plugins/core
|
||||
# Routes Bash tool calls through rtk.
|
||||
- git: https://$IDENTITY.git
|
||||
path: plugins/rtk
|
||||
mcp: []
|
||||
EOF
|
||||
printf 'name: core\nversion: 1.0.0\n' > "$dir/plugins/core/apm.yml"
|
||||
touch "$dir/apm.lock.yaml.root-marker"
|
||||
git -C "$dir" init -q
|
||||
git -C "$dir" add apm.yml plugins/core/apm.yml
|
||||
git -C "$dir" -c user.name=t -c user.email=t@t commit -qm base
|
||||
git -C "$dir" update-ref refs/remotes/origin/main HEAD
|
||||
printf 'name: rtk\nversion: 0.1.0\n' > "$dir/plugins/rtk/apm.yml"
|
||||
}
|
||||
|
||||
RC=0
|
||||
OUT=""
|
||||
run_audit() { # <dir> <root output>
|
||||
RC=0
|
||||
OUT="$(cd "$1" && env APM="$BIN/apm" STUB_ROOT_OUTPUT="$2" bash "$AUDIT" 2>&1)" || RC=$?
|
||||
}
|
||||
|
||||
WAIVER_LINE='apm audit --ci: waived ref-consistency for plugins/rtk (not yet on origin/main; ADR-0019)'
|
||||
SOLE='[x] 1 of 3 check(s) failed'
|
||||
RTK_DETAIL="$IDENTITY/plugins/rtk: not found in lockfile"
|
||||
|
||||
echo "--- waived: one plugin not yet on origin/main ---"
|
||||
F="$TMP/waived"
|
||||
make_fixture "$F"
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")"
|
||||
[[ $RC -eq 0 ]] && pass "exits 0" || fail "exited $RC: $OUT"
|
||||
grep -qxF "$WAIVER_LINE" <<< "$OUT" && pass "prints the waiver line" || fail "no waiver line: $OUT"
|
||||
|
||||
echo ""
|
||||
echo "--- not waived: the plugin is already on origin/main ---"
|
||||
F="$TMP/landed"
|
||||
make_fixture "$F"
|
||||
git -C "$F" add plugins/rtk/apm.yml
|
||||
git -C "$F" -c user.name=t -c user.email=t@t commit -qm landed
|
||||
git -C "$F" update-ref refs/remotes/origin/main HEAD
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")"
|
||||
[[ $RC -ne 0 ]] && grep -qF "plugins/rtk is already on origin/main" <<< "$OUT" \
|
||||
&& pass "fails, naming the landed plugin" || fail "must fail (rc=$RC): $OUT"
|
||||
|
||||
echo ""
|
||||
echo "--- not waived: a second check also fails ---"
|
||||
F="$TMP/second"
|
||||
make_fixture "$F"
|
||||
run_audit "$F" "$(root_output '[x] 2 of 3 check(s) failed' \
|
||||
'| [x] | drift | 1 file(s) differ |' "$RTK_DETAIL")"
|
||||
[[ $RC -ne 0 ]] && ! grep -qF "waived ref-consistency" <<< "$OUT" \
|
||||
&& pass "fails when drift fails too" || fail "must fail (rc=$RC): $OUT"
|
||||
|
||||
echo ""
|
||||
echo "--- not waived: a mismatch outside plugins/ ---"
|
||||
F="$TMP/nonplugin"
|
||||
make_fixture "$F"
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "github.com/acme/skills: not found in lockfile")"
|
||||
[[ $RC -ne 0 ]] && grep -qF "unrecognised detail line" <<< "$OUT" \
|
||||
&& pass "fails on a non-plugins detail" || fail "must fail (rc=$RC): $OUT"
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL" "github.com/acme/skills: not found in lockfile")"
|
||||
[[ $RC -ne 0 ]] && ! grep -qF "waived ref-consistency" <<< "$OUT" \
|
||||
&& pass "fails when an unlanded plugin is mixed with a non-plugins detail" \
|
||||
|| fail "must fail on a mixed block (rc=$RC): $OUT"
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "$IDENTITY/plugins/rtk: ref main != abc123")"
|
||||
[[ $RC -ne 0 ]] && pass "fails on a plugins/ detail of another kind" || fail "must fail (rc=$RC): $OUT"
|
||||
|
||||
echo ""
|
||||
echo "--- not waived: the identity is not root apm.yml's entry ---"
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "git.example.com/Other/Repo/plugins/rtk: not found in lockfile")"
|
||||
[[ $RC -ne 0 ]] && grep -qF "is not root apm.yml's git+path entry" <<< "$OUT" \
|
||||
&& pass "fails on a foreign identity" || fail "must fail (rc=$RC): $OUT"
|
||||
|
||||
echo ""
|
||||
echo "--- not waived: plugins/<name>/apm.yml is absent ---"
|
||||
F="$TMP/absent"
|
||||
make_fixture "$F"
|
||||
rm "$F/plugins/rtk/apm.yml"
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")"
|
||||
[[ $RC -ne 0 ]] && grep -qF "plugins/rtk/apm.yml is not in the working tree" <<< "$OUT" \
|
||||
&& pass "fails when the plugin manifest is missing" || fail "must fail (rc=$RC): $OUT"
|
||||
|
||||
echo ""
|
||||
echo "--- fails closed: origin/main does not resolve ---"
|
||||
F="$TMP/noorigin"
|
||||
make_fixture "$F"
|
||||
git -C "$F" update-ref -d refs/remotes/origin/main
|
||||
run_audit "$F" "$(root_output "$SOLE" "" "$RTK_DETAIL")"
|
||||
[[ $RC -ne 0 ]] && grep -qF "origin/main does not resolve locally" <<< "$OUT" \
|
||||
&& pass "fails without origin/main" || fail "must fail (rc=$RC): $OUT"
|
||||
|
||||
echo ""
|
||||
echo "--- fails closed: unrecognised output ---"
|
||||
F="$TMP/garbled"
|
||||
make_fixture "$F"
|
||||
run_audit "$F" "something apm never printed"
|
||||
[[ $RC -ne 0 ]] && pass "fails on output of an unknown shape" || fail "must fail (rc=$RC): $OUT"
|
||||
run_audit "$F" "$(root_output "$SOLE" "")"
|
||||
[[ $RC -ne 0 ]] && pass "fails on an empty details block" || fail "must fail (rc=$RC): $OUT"
|
||||
|
||||
echo ""
|
||||
echo "Results: $PASS passed, $FAIL failed"
|
||||
[[ "$FAIL" -eq 0 ]]
|
||||
Reference in new issue
Block a user