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

+56 -5
View File
@@ -64,13 +64,64 @@ for plugin_dir in "$REPO_ROOT"/plugins/*/; do
done
shopt -u nullglob
# Only a repo with no executable-shipping plugin at all is a legitimate no-op —
# there is no version to pin and no hook to deploy.
if [[ ${#PLUGINS[@]} -eq 0 ]]; then
exit 0
FAILED=0
# ---------------------------------------------------------------------------
# Parked executables in the lock (spike #269, on #268, section 7.3)
# ---------------------------------------------------------------------------
# apm records each dependency's executables decision as `exec_status:` in
# apm.lock.yaml: `deployed`, or a `gated_*` value (for example
# `gated_pending_approval`) when the trust gate parked its hooks, bin or MCP
# servers. Root `apm audit --ci` passes in that state, because its
# exec-status-current check only asserts the lock agrees with the gate. So a
# wrong key, or a content-pinned hook whose script changed, would leave the
# SessionStart hook or the delivery guard silently uninstalled with every
# other gate green. This fails the push instead. Runs whether or not any
# plugin here ships executables: a third-party dependency can be parked too.
# A missing lock is not this check's concern (apm-audit-ci's lockfile-exists).
#
# A line scan, not a YAML parse: apm writes the lock with libyaml in one fixed
# shape, with `- repo_url:` opening each dependency and its fields at 2 spaces.
LOCKFILE="$REPO_ROOT/apm.lock.yaml"
if [[ -f "$LOCKFILE" ]]; then
GATED="$(awk '
/^[^ -]/ { in_deps = ($0 ~ /^dependencies:/); next }
!in_deps { next }
/^- / { host = ""; repo = ""; vpath = "" }
{
line = $0
sub(/^- /, " ", line)
if (line !~ /^ [a-z_]+: /) next
key = line; sub(/^ /, "", key); sub(/: .*/, "", key)
val = line; sub(/^ [a-z_]+: /, "", val); gsub(/["\047]/, "", val)
if (key == "host") host = val
else if (key == "repo_url") repo = val
else if (key == "virtual_path") vpath = val
else if (key == "exec_status" && val ~ /^gated_/) {
id = (host != "" ? host "/" : "") repo (vpath != "" ? "/" vpath : "")
printf "%s: %s\n", id, val
}
}
' "$LOCKFILE")"
if [[ -n "$GATED" ]]; then
echo "FAIL: apm.lock.yaml records executables apm did not deploy:" >&2
while IFS= read -r line; do echo " $line" >&2; done <<< "$GATED"
echo " Why: a gated_* exec_status means the trust gate parked that package's hooks, bin or" >&2
echo " MCP servers: no executables.allow key matches it, or a content pin no longer" >&2
echo " does. Root 'apm audit --ci' still passes in that state (spike #269), so without" >&2
echo " this check a parked SessionStart hook or guard goes unnoticed." >&2
echo " Fix: run 'uv run --frozen apm approve --list' to see why each is parked, correct its" >&2
echo " executables.allow key in root apm.yml, then 'uv run --frozen apm install' and" >&2
echo " commit the rewritten apm.lock.yaml." >&2
FAILED=1
fi
fi
FAILED=0
# Only a repo with no executable-shipping plugin at all is a legitimate no-op
# for the key checks below — there is no version to pin and no hook to deploy.
if [[ ${#PLUGINS[@]} -eq 0 ]]; then
exit "$FAILED"
fi
# "hooks/ and bin/", "hooks/" or "bin/" — what the plugin actually ships, so a
# message never claims a package has a bin/ it does not.