Files
Holocron/scripts/check-executables-allow-sync.sh
T
Defame1297andClaude Opus 5.5 b0977d4073 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
2026-12-02 10:12:06 +00:00

565 lines
23 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Fails the push when root apm.yml's executables.allow stops naming the full
# identity and actual version of every plugin that ships executables. A plugin
# ships executables when plugins/<name>/.apm/hooks/ or plugins/<name>/bin/
# exists; each one needs a '<identity>#<version>' key:
#
# * <identity> is the package identity apm 0.39 matches grants on,
# <host>/<owner>/<repo>/<path>, e.g. git.rkdr.net/Mortis/Holocron/plugins/kyberforge.
# It is derived from root apm.yml's own `git:` + `path:` dependency entry
# for plugins/<name>, the same fields apm builds it from: the URL loses its
# scheme, any user@ and a trailing .git, and the path is appended. Verified
# against `apm approve --list` on apm 0.39.3 for a git+path entry on a
# self-hosted host. A plugin with no such entry fails, because no key can be
# derived for it.
# * <version> comes from plugins/<name>/apm.yml (whose name: must equal the
# directory name).
#
# Every failing package is reported in one run.
#
# Under apm 0.28 a bare '<name>#<version>' key matched. Under 0.39.3 it does
# not: the hooks are parked, .claude/settings.json is rewritten without them,
# and root `apm audit --ci` still passes (spike #269, on #268). So a bare key is
# now a real deployment failure that nothing else catches, and this gate names
# it as one.
#
# The '#<version>' suffix is stripped before apm matches, so the grant is
# version-blind and a stale version keeps granting the package's hooks/ and
# bin/. What the version half buys is repo-level, not apm-level: a version bump
# without the matching key edit fails this repo's own pre-push, so each key
# stays an accurate record of what was approved. See ADR-0019's 2026-09-19
# correction and docs/spec/gates.md, "check-executables-allow-sync"; nothing
# else in the pre-push gate compares these files.
#
# Run from repo root or pass REPO_ROOT as arg.
REPO_ROOT="${1:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
# A nonexistent REPO_ROOT fails loudly rather than falling through to the
# "no executable-shipping plugin here" no-op below: that no-op is for a repo
# that legitimately ships no executables, not for a typo'd or stale path, and
# exit 0 would read as "checked, in sync" when nothing was compared at all.
if [[ ! -d "$REPO_ROOT" ]]; then
echo "FAIL: executables-allow sync check: REPO_ROOT '$REPO_ROOT' is not a directory." >&2
echo " Fix: run this from the repo root, or pass a real repo path as the first argument." >&2
exit 1
fi
REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
ROOT_MANIFEST="$REPO_ROOT/apm.yml"
# ---------------------------------------------------------------------------
# Discovery
# ---------------------------------------------------------------------------
# PLUGINS: directory names of every plugin that ships executables. READABLE
# (below) is the subset whose apm.yml exists; only those reach the readers.
PLUGINS=()
shopt -s nullglob
for plugin_dir in "$REPO_ROOT"/plugins/*/; do
plugin_dir="${plugin_dir%/}"
if [[ -d "$plugin_dir/.apm/hooks" || -d "$plugin_dir/bin" ]]; then
PLUGINS+=("${plugin_dir##*/}")
fi
done
shopt -u nullglob
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
# 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.
ships() {
local dir="$REPO_ROOT/plugins/$1"
if [[ -d "$dir/.apm/hooks" && -d "$dir/bin" ]]; then
printf 'hooks/ and bin/'
elif [[ -d "$dir/.apm/hooks" ]]; then
printf 'hooks/'
else
printf 'bin/'
fi
}
# "hooks: true, bin: true" etc. — the allow entry body the plugin needs.
grants() {
local dir="$REPO_ROOT/plugins/$1" out=""
if [[ -d "$dir/.apm/hooks" ]]; then out="hooks: true"; fi
if [[ -d "$dir/bin" ]]; then out+="${out:+, }bin: true"; fi
printf '%s' "$out"
}
READABLE=()
for plugin in ${PLUGINS[@]+"${PLUGINS[@]}"}; do
if [[ -f "$REPO_ROOT/plugins/$plugin/apm.yml" ]]; then
READABLE+=("$plugin")
continue
fi
echo "FAIL: plugins/$plugin/ ships $(ships "$plugin") but has no apm.yml, so its version cannot be read." >&2
echo " Why: this gate compares that version against root apm.yml's executables.allow key;" >&2
echo " without the manifest it would exit 0 having compared nothing." >&2
echo " Fix: restore plugins/$plugin/apm.yml, or remove plugins/$plugin/ entirely." >&2
FAILED=1
done
if [[ ! -f "$ROOT_MANIFEST" ]]; then
echo "FAIL: root apm.yml is missing, so no executables allow key can be verified (${PLUGINS[*]})." >&2
echo " Why: apm reads executables.allow from the consuming package's manifest; with no root" >&2
echo " manifest nothing grants these packages' hooks/ and bin/ permission to deploy." >&2
echo " Fix: restore apm.yml at the repo root." >&2
exit 1
fi
# ---------------------------------------------------------------------------
# Manifest facts
# ---------------------------------------------------------------------------
# Both readers emit the same line protocol, so the rest of the script does not
# care which ran:
#
# v<TAB><plugin dir><TAB><version> once per readable plugin (version may be empty)
# n<TAB><plugin dir><TAB><name> once per readable plugin (name may be empty)
# e<TAB><plugin dir><TAB><message> zero or more — the plugin's facts are unusable
# a<TAB>present|absent exactly once — is executables.allow a mapping?
# k<TAB><allow key> zero or more
# d<TAB><path><TAB><git url> zero or more — a root dependencies.apm entry
# carrying both git: and path:
#
# python3 + PyYAML is preferred where importable; the fallback below is not a
# YAML parser, it recognises only the shapes these manifests use. PyYAML stays
# optional so a missing pip package can't block every push (ADR-0019).
reader_args() {
local plugin
printf '%s\0' "$ROOT_MANIFEST"
for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
printf '%s\0%s\0' "$plugin" "$REPO_ROOT/plugins/$plugin/apm.yml"
done
}
read_facts_python() {
local args=() arg
while IFS= read -r -d '' arg; do
args+=("$arg")
done < <(reader_args)
python3 - ${args[@]+"${args[@]}"} << 'PY'
import sys
import yaml
def load(path):
with open(path) as fh:
data = yaml.safe_load(fh)
return data if isinstance(data, dict) else {}
root = load(sys.argv[1])
pairs = sys.argv[2:]
for plugin_dir, path in zip(pairs[::2], pairs[1::2]):
plugin = load(path)
version = plugin.get("version")
# A 2-component version parses as a YAML float and would render back as
# e.g. "1.5" from 1.50 — a mismatch invented by the reader rather than
# found in the files. Refuse instead of guessing; semver keys here are
# always strings.
if version is not None and not isinstance(version, str):
print(
"e\t%s\tversion: is not a string (%r) — quote it so the "
"executables.allow key can be compared verbatim." % (plugin_dir, version)
)
continue
name = plugin.get("name")
print("v\t%s\t%s" % (plugin_dir, "" if version is None else version))
print("n\t%s\t%s" % (plugin_dir, "" if name is None else name))
executables = root.get("executables")
allow = executables.get("allow") if isinstance(executables, dict) else None
if isinstance(allow, dict):
print("a\tpresent")
for key in allow:
print("k\t%s" % key)
else:
print("a\tabsent")
dependencies = root.get("dependencies")
apm_deps = dependencies.get("apm") if isinstance(dependencies, dict) else None
for entry in apm_deps if isinstance(apm_deps, list) else []:
if isinstance(entry, dict):
git, path = entry.get("git"), entry.get("path")
if isinstance(git, str) and isinstance(path, str):
print("d\t%s\t%s" % (path, git))
PY
}
# Strips one layer of matching quotes plus surrounding whitespace from a scalar.
unquote() {
local value="$1"
read -r value <<< "$value"
case "$value" in
\"*\") value="${value#\"}"; value="${value%\"}" ;;
\'*\') value="${value#\'}"; value="${value%\'}" ;;
esac
printf '%s\n' "$value"
}
# top_level_scalar <file> <key> — the first column-0 '<key>:' value, unquoted.
top_level_scalar() {
local line
while IFS= read -r line || [[ -n "$line" ]]; do
[[ "$line" == "$2:"* ]] || continue
unquote "${line#"$2":}"
return
done < "$1"
}
read_facts_bash() {
local line allow_state="absent" in_executables=0 in_allow=0 key plugin manifest
local in_deps=0 in_apm_deps=0 dep_git="" dep_path=""
# Emits the dependency entry collected so far, if it carried both fields.
flush_dep() {
if [[ -n "$dep_git" && -n "$dep_path" ]]; then
printf 'd\t%s\t%s\n' "$dep_path" "$dep_git"
fi
dep_git=""
dep_path=""
}
for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
manifest="$REPO_ROOT/plugins/$plugin/apm.yml"
printf 'v\t%s\t%s\n' "$plugin" "$(top_level_scalar "$manifest" version)"
printf 'n\t%s\t%s\n' "$plugin" "$(top_level_scalar "$manifest" name)"
done
while IFS= read -r line || [[ -n "$line" ]]; do
# Blank and full-line comments carry no structure at any depth.
case "$line" in
'' | '#'*) continue ;;
esac
# A top-level key (column 0) closes whatever block was open. Checked before
# anything else so `marketplace:` after `executables:` cannot leak keys in.
if [[ "$line" != [[:space:]]* ]]; then
flush_dep
in_executables=0
in_deps=0
case "$line" in
executables:*) in_executables=1 ;;
dependencies:*) in_deps=1 ;;
esac
in_allow=0
in_apm_deps=0
continue
fi
# dependencies: -> apm: -> a list of `- git: ...` / ` path: ...` items at
# 4-space indent, fields at 6 (or on the dash line itself).
if [[ $in_deps -eq 1 ]]; then
if [[ "$line" =~ ^\ \ [^[:space:]#] ]]; then
flush_dep
in_apm_deps=0
[[ "$line" =~ ^\ \ apm: ]] && in_apm_deps=1
continue
fi
[[ $in_apm_deps -eq 1 ]] || continue
if [[ "$line" =~ ^\ \ \ \ -\ * ]]; then
flush_dep
line=" ${line#*- }"
fi
if [[ "$line" =~ ^\ \ \ \ \ \ (git|path):(.*)$ ]]; then
if [[ "${BASH_REMATCH[1]}" == git ]]; then
dep_git="$(unquote "${BASH_REMATCH[2]}")"
else
dep_path="$(unquote "${BASH_REMATCH[2]}")"
fi
fi
continue
fi
[[ $in_executables -eq 1 ]] || continue
# 2-space indent: a key directly under executables:. `allow:` opens the
# mapping this gate reads; any sibling key closes it.
if [[ "$line" =~ ^\ \ [^[:space:]#] ]]; then
if [[ "$line" =~ ^\ \ allow: ]]; then
in_allow=1
allow_state="present"
else
in_allow=0
fi
continue
fi
# 4-space indent while inside allow: — an allow key. Keys contain '#' by
# construction ("kyberforge#1.5.0"), so a trailing-comment strip would eat
# them; there is none, and inline comments are not used on these lines.
if [[ $in_allow -eq 1 && "$line" =~ ^\ \ \ \ ([^[:space:]#][^:]*): ]]; then
key="$(unquote "${BASH_REMATCH[1]}")"
printf 'k\t%s\n' "$key"
fi
done < "$ROOT_MANIFEST"
flush_dep
printf 'a\t%s\n' "$allow_state"
}
if command -v python3 > /dev/null 2>&1 && python3 -c 'import yaml' > /dev/null 2>&1; then
READER="python3 + PyYAML"
if ! FACTS="$(read_facts_python)"; then
echo "FAIL: could not read apm.yml or a plugin's apm.yml (see the parser error above)." >&2
echo " Why: this gate compares each executable-shipping plugin's version against root" >&2
echo " apm.yml's executables.allow keys; an unreadable manifest means the comparison" >&2
echo " did not happen." >&2
echo " Fix: make the manifests valid YAML, then re-run." >&2
exit 1
fi
else
READER="shape-scan fallback (PyYAML unavailable)"
FACTS="$(read_facts_bash)"
fi
# fact <tag> <plugin dir> — the third field of that plugin's <tag> line.
fact() {
awk -F'\t' -v t="$1" -v d="$2" '$1 == t && $2 == d { sub(/^[^\t]*\t[^\t]*\t/, ""); print; exit }' <<< "$FACTS"
}
ALLOW_STATE="$(printf '%s\n' "$FACTS" | sed -n 's/^a\t//p')"
ALLOW_KEYS="$(printf '%s\n' "$FACTS" | sed -n 's/^k\t//p')"
# Strips one leading ./ and any trailing / from a dependency path.
norm_path() {
local path="${1#./}"
printf '%s' "${path%/}"
}
# dep_url <plugin dir> — the git: URL of root apm.yml's git+path dependency
# entry for plugins/<plugin dir>; empty when it has none.
dep_url() {
local want="plugins/$1" tag path url
while IFS=$'\t' read -r tag path url; do
[[ "$tag" == d && "$(norm_path "$path")" == "$want" ]] || continue
printf '%s' "$url"
return
done <<< "$FACTS"
}
# url_has_port <url> — true when a scheme URL names a port (host:port).
url_has_port() {
local rest
[[ "$1" == *://* ]] || return 1
rest="${1#*://}"
rest="${rest%%/*}"
rest="${rest#*@}"
[[ "$rest" == *:* ]]
}
# identity <plugin dir> — <host>/<owner>/<repo>/<path> from that entry; empty
# when there is none.
#
# Verified against apm 0.39.3 (`apm approve --list`) for an https URL on a
# lowercase host only. The scp-like (user@host:owner/repo) and ssh:// forms are
# derived by the same rule but were not checked against apm, and the host's
# case is kept as written, also unchecked. A URL with a port is refused before
# this runs (see the per-package checks): where apm puts a port in the
# identity is unknown, so a derived key could be wrong while looking right.
identity() {
local want="plugins/$1" url
url="$(dep_url "$1")"
[[ -n "$url" ]] || return 0
if [[ "$url" == *://* ]]; then
url="${url#*://}"
elif [[ "$url" == *:* ]]; then
url="${url/://}" # scp-like user@host:owner/repo
fi
url="${url#*@}"
url="${url%/}"
url="${url%.git}"
printf '%s/%s' "$url" "$want"
}
# expected_key <plugin dir> — '<identity>#<version>'.
expected_key() {
printf '%s#%s' "$(identity "$1")" "$(fact v "$1")"
}
# ---------------------------------------------------------------------------
# Per-package checks
# ---------------------------------------------------------------------------
# EXPECTED: plugin dir names whose manifest is usable; the key each needs is
# '<identity>#<version>'. The dir name is what finds the identity: it is
# matched against the `path: plugins/<dir>` of a root dependency entry, which
# is why a usable manifest's name: must equal it.
EXPECTED=()
for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
error="$(fact e "$plugin")"
if [[ -n "$error" ]]; then
echo "FAIL: plugins/$plugin/apm.yml: $error" >&2
echo " Why: a non-string version would be compared in a form the reader invented rather" >&2
echo " than the one written in the file." >&2
echo " Fix: quote the version, e.g. version: \"1.5\" (read by $READER)." >&2
FAILED=1
continue
fi
version="$(fact v "$plugin")"
name="$(fact n "$plugin")"
if [[ "$name" != "$plugin" ]]; then
echo "FAIL: plugins/$plugin/apm.yml declares name: '${name}', which does not match its directory '$plugin'." >&2
echo " Why: the '<identity>#<version>' key is found through the directory name, which this gate" >&2
echo " matches against root apm.yml's 'path: plugins/<dir>' entry; with name: disagreeing" >&2
echo " it cannot tell which package the key should be for." >&2
echo " Fix: make plugins/$plugin/apm.yml's name: equal '$plugin', or rename the directory (read by $READER)." >&2
FAILED=1
continue
fi
if [[ -z "$version" ]]; then
echo "FAIL: plugins/$plugin/apm.yml declares no version:, so no allow key can be checked against it." >&2
echo " Why: the executables.allow key is '<identity>#<version>'; with no version there is" >&2
echo " nothing for root apm.yml's key to stay in sync with." >&2
echo " Fix: give plugins/$plugin/apm.yml a top-level version: (read by $READER)." >&2
FAILED=1
continue
fi
if [[ -z "$(identity "$plugin")" ]]; then
echo "FAIL: root apm.yml has no dependencies.apm entry with git: and path: plugins/$plugin, so the" >&2
echo " identity apm approves $plugin's $(ships "$plugin") under cannot be derived." >&2
echo " Why: apm 0.39 matches executables.allow on the full identity <host>/<owner>/<repo>/<path>," >&2
echo " built from that entry; this gate builds the expected key from the same fields." >&2
echo " Fix: declare plugins/$plugin in root apm.yml as a '- git: <url>' / 'path: plugins/$plugin'" >&2
echo " dependency (read by $READER)." >&2
FAILED=1
continue
fi
if url_has_port "$(dep_url "$plugin")"; then
echo "FAIL: root apm.yml's dependency entry for plugins/$plugin uses a git: URL with a port," >&2
echo " '$(dep_url "$plugin")', so its executables.allow key cannot be derived reliably." >&2
echo " Why: this gate derives the full package identity apm 0.39 approves under from that URL," >&2
echo " and how apm writes a port into the identity was never verified." >&2
echo " Fix: use the URL without a port if the host allows it; otherwise read the identity from" >&2
echo " 'uv run --frozen apm approve --list' and extend this check to match it." >&2
FAILED=1
continue
fi
EXPECTED+=("$plugin")
done
if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
summary=""
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
summary+="${summary:+, }$(expected_key "$plugin")"
done
echo "FAIL: root apm.yml has no executables.allow mapping, but these packages ship executables: $summary." >&2
echo " Why: without an allow entry apm refuses to deploy a package's hooks/ and bin/ — for" >&2
echo " kyberforge that means the SessionStart hook that keeps this install level with the" >&2
echo " remote never runs and the deployed skills go stale silently (ADR-0019)." >&2
echo " Fix: add to root apm.yml:" >&2
echo " executables:" >&2
echo " allow:" >&2
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
echo " $(expected_key "$plugin"):" >&2
if [[ -d "$REPO_ROOT/plugins/$plugin/.apm/hooks" ]]; then echo " hooks: true" >&2; fi
if [[ -d "$REPO_ROOT/plugins/$plugin/bin" ]]; then echo " bin: true" >&2; fi
done
exit 1
fi
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
expected_key="$(expected_key "$plugin")"
if grep -qxF -- "$expected_key" <<< "$ALLOW_KEYS"; then
continue
fi
# Keys for the right identity at another version, and bare '<name>#...' keys,
# which apm 0.28 matched and 0.39 does not.
stale_keys=()
bare_keys=()
while IFS= read -r key; do
[[ -n "$key" ]] || continue
if [[ "$key" == "$(identity "$plugin")#"* ]]; then stale_keys+=("$key"); fi
if [[ "$key" == "$plugin" || "$key" == "$plugin#"* ]]; then bare_keys+=("$key"); fi
done <<< "$ALLOW_KEYS"
echo "FAIL: root apm.yml's executables.allow has no '$expected_key' key, but that is $plugin's identity and version." >&2
if [[ ${#bare_keys[@]} -gt 0 ]]; then
echo " Found instead:" >&2
printf ' %s\n' ${bare_keys[@]+"${bare_keys[@]}"} ${stale_keys[@]+"${stale_keys[@]}"} >&2
echo " Why: apm 0.39 matches grants on the full package identity. A bare '$plugin#...' key" >&2
echo " matches nothing, so $plugin's $(ships "$plugin") are parked, .claude/settings.json" >&2
echo " loses its entries, and root 'apm audit --ci' still passes (spike #269, on #268)." >&2
echo " Fix: rename the key in root apm.yml to '$expected_key:'." >&2
elif [[ ${#stale_keys[@]} -gt 0 ]]; then
echo " Found instead:" >&2
printf ' %s\n' ${stale_keys[@]+"${stale_keys[@]}"} >&2
echo " Why: nothing is broken right now — apm's grant is version-blind, so a key naming another" >&2
echo " version still grants $plugin's $(ships "$plugin"). This gate is a repo-level record" >&2
echo " check: a version bump without the matching key edit fails here, which is what keeps" >&2
echo " the key an accurate record of what was approved (ADR-0019, 2026-09-19 correction)." >&2
echo " Fix: bump the key in root apm.yml to '$expected_key:' — the version bump in" >&2
echo " plugins/$plugin/apm.yml is not complete without it." >&2
else
echo " Why: $plugin ships $(ships "$plugin") and no key grants them, so apm refuses to deploy" >&2
echo " them; this gate also keeps each key an accurate record of what was approved" >&2
echo " (ADR-0019, 2026-09-19 correction)." >&2
echo " Fix: add '$expected_key:' under executables.allow in root apm.yml, granting" >&2
echo " $(grants "$plugin")." >&2
fi
FAILED=1
done
exit "$FAILED"