feat(scripts): fail the push on a parked executable in apm.lock.yaml

apm records each dependency's executables decision as `exec_status:` in
the lock. A gated_* value means the trust gate parked that package's
hooks, bin or MCP servers. Root `apm audit --ci` still passes in that
state, so a wrong key would leave the SessionStart hook or the delivery
guard uninstalled with every gate green (spike #269, section 7.3).

check-executables-allow-sync now scans the lock's dependencies and fails
on any gated_* entry, naming its identity and status, with a Why/Fix
block that starts from `apm approve --list`. It runs even when no plugin
here ships executables. The test covers deployed, two gated_* values
under both readers, the no-plugin case, and that neither the next
dependency nor the deployments: section is misreported. gates.md and the
hook description note it.

Refs: #271

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-02 10:12:06 +00:00
1 parent 045e43f0f8
commit b0977d4073
4 files changed
+130 -6

No files matched your search

@@ -443,6 +443,70 @@ PY2
|| fail "fallback must refuse a URL with a port ($port_url)"
done
# ---------------------------------------------------------------------------
echo ""
echo "--- a parked executable recorded in apm.lock.yaml fails ---"
# ---------------------------------------------------------------------------
# write_lock <fixture> <kyberforge exec_status> — a lock in the shape apm 0.39.3
# writes: `- repo_url:` opens each dependency, fields at 2 spaces, host after
# repo_url, exec_status last, then a top-level deployments: section.
write_lock() {
{
echo "lockfile_version: '4'"
echo "apm_version: 0.39.3"
echo "dependencies:"
echo "- repo_url: Owner/Repo"
echo " name: kyberforge"
echo " host: git.example.invalid"
echo " virtual_path: plugins/kyberforge"
echo " deployed_files:"
echo " - .claude/hooks/kyberforge/x.sh"
echo " exec_status: $2"
echo "- repo_url: Owner/Repo"
echo " name: docs"
echo " host: git.example.invalid"
echo " virtual_path: plugins/docs"
echo "deployments:"
echo "- exec_status: gated_pending_approval"
} > "$1/apm.lock.yaml"
}
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
write_lock "$F" deployed
run_gate "$F"
[[ $GATE_RC -eq 0 ]] && pass "passes a lock whose executables are deployed" \
|| fail "exec_status: deployed must pass, got: $(bash "$SCRIPT" "$F" 2>&1 | head -3 || true)"
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
write_lock "$F" gated_pending_approval
run_gate "$F"
[[ $GATE_RC -ne 0 ]] && pass "fails a lock that records gated_pending_approval" \
|| fail "a parked executable in the lock must fail the push"
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
grep -qF "git.example.invalid/Owner/Repo/plugins/kyberforge: gated_pending_approval" <<< "$OUT" \
&& pass "names the parked package by identity and its status" \
|| fail "the failure must name the package and status, got: $OUT"
grep -q "Why:" <<< "$OUT" && grep -qF "apm approve --list" <<< "$OUT" \
&& pass "carries Why: and a Fix: naming apm approve --list" || fail "message must carry Why/Fix: $OUT"
grep -qF "plugins/docs" <<< "$OUT" && fail "a dependency with no exec_status must not be reported" \
|| pass "reports only the gated dependency, not the next one or the deployments: section"
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
write_lock "$F" gated_definition_changed
run_fallback "$F"
[[ $GATE_RC -ne 0 ]] && pass "fails any gated_* status, without PyYAML too" \
|| fail "gated_definition_changed must fail under the fallback reader"
# A third-party dependency can be parked in a repo whose own plugins ship no
# executables, so the check runs before the no-plugin no-op.
F="$(mktemp -d "$RUN_TMP/fx.XXXXXX")"
echo "name: someone-else" > "$F/apm.yml"
write_lock "$F" gated_pending_approval
run_gate "$F"
[[ $GATE_RC -ne 0 ]] && pass "fails a parked executable even with no executable-shipping plugin" \
|| fail "the lock check must run before the no-plugin no-op"
# ---------------------------------------------------------------------------
echo ""
echo "--- wired into the pre-push gate ---"