fix(apm): key executables.allow on the full 0.39 package identity
apm 0.39.3 matches executable grants on the package identity <host>/<owner>/<repo>/<path>. The bare kyberforge#<version> and delivery#<version> keys that 0.28.0 matched no longer match, so the first 0.39 install parks both hooks and rewrites .claude/settings.json without them, while root apm audit --ci stays green (spike #269, on #268). Rename both keys to git.rkdr.net/Mortis/Holocron/plugins/<name>#<version> with type-level grants, as `apm approve --list` names them on 0.39.3. Keep the version suffix convention; apm strips it before matching. Do not use `apm approve`, which would content-pin, strip the block's comments and park the hook on every script edit. check-executables-allow-sync now derives each expected key from root apm.yml's git + path dependency entry for the plugin, fails a bare key with a message saying why, and fails a shipping plugin with no such entry. Both readers carry the change, and the test covers URL and path spellings. Refs: #271 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
feef6d8307
commit
e1a99a7291
4 files changed
+249
-50
No files matched your search
@@ -71,7 +71,7 @@ repos:
|
||||
|
||||
- id: check-executables-allow-sync
|
||||
name: Check executables allow keys sync
|
||||
description: Verify root apm.yml's executables.allow carries a "<name>#<version>" key matching the apm.yml version of every plugin that ships executables (plugins/<name>/.apm/hooks/ or bin/), reporting every out-of-sync package in one run. apm's grant is version-blind, so a stale key still deploys; this is a record-keeping gate that fails a version bump made without the matching key edit, keeping each key an accurate record of what was approved (see ADR-0019's 2026-09-19 correction and docs/spec/gates.md)
|
||||
description: Verify root apm.yml's executables.allow carries a "<host>/<owner>/<repo>/plugins/<name>#<version>" key -- the full package identity apm 0.39 matches on, derived from root apm.yml's git+path dependency entry for the plugin, plus the plugin's apm.yml version -- for every plugin that ships executables (plugins/<name>/.apm/hooks/ or bin/), reporting every out-of-sync package in one run. A bare "<name>#<version>" key fails, because apm 0.39 parks the hooks under it while root `apm audit --ci` stays green (spike #269). The version half is version-blind to apm, so a stale version still deploys; that half is a record-keeping gate that fails a version bump made without the matching key edit (see ADR-0019's 2026-09-19 correction and docs/spec/gates.md)
|
||||
entry: bash scripts/check-executables-allow-sync.sh
|
||||
language: system
|
||||
stages: [pre-push]
|
||||
|
||||
@@ -58,26 +58,32 @@ dependencies:
|
||||
# verified: `apm approve --list` reports "Executable-trust gate disabled -- all
|
||||
# executables deploy" until an `executables:` block exists.
|
||||
#
|
||||
# Keys are the FULL package identity apm 0.39 matches on,
|
||||
# <host>/<owner>/<repo>/<path>#<version>, as `apm approve --list` prints it.
|
||||
# The bare `kyberforge#<version>` form 0.28 accepted no longer matches: under
|
||||
# 0.39.3 it parks both hooks, writes `.claude/settings.json` back to `{}`, and
|
||||
# root `apm audit --ci` still passes (spike #269, on #268). The `#<version>`
|
||||
# suffix is stripped before matching, so the grant is version-blind and a
|
||||
# plugin bump alone does not park the hook; the suffix is a repo convention
|
||||
# that `scripts/check-executables-allow-sync.sh`, a pre-push hook, holds level
|
||||
# with each plugin's apm.yml `version:`.
|
||||
#
|
||||
# The grants are type-level (`hooks: true`), not content-pinned. Every install
|
||||
# warns that they are not pinned to content; that is accepted, because a
|
||||
# content pin parks the hook on every edit to its scripts until someone re-runs
|
||||
# `apm approve`. Do not run `apm approve` here: it rewrites this block, adds
|
||||
# content pins and strips these comments.
|
||||
#
|
||||
# kyberforge ships the SessionStart hook that keeps this install level with the
|
||||
# remote (ADR-0019). The `#2.0.0` suffix below is cosmetic as far as apm is
|
||||
# concerned: grants are version-BLIND in apm 0.28.0. `_map_grants`
|
||||
# (apm_cli/security/executables.py) matches the exact key, the version-blind
|
||||
# name, or any stored key sharing that name, and `materialize_exec_map` also
|
||||
# stores the version-blind name — so approving `kyberforge` covers
|
||||
# `kyberforge#2.0.0` and vice-versa, and a kyberforge version bump does NOT
|
||||
# make this entry stop matching or stop the hook deploying. Do not delete the
|
||||
# suffix anyway: `scripts/check-executables-allow-sync.sh` is a repo-authored
|
||||
# pre-push hook that asserts this key carries the version in
|
||||
# plugins/kyberforge/apm.yml, so a bump here is a repo convention to keep, not
|
||||
# an apm mechanic.
|
||||
# remote (ADR-0019).
|
||||
executables:
|
||||
allow:
|
||||
kyberforge#2.3.0:
|
||||
git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.3.0:
|
||||
hooks: true
|
||||
bin: true
|
||||
# delivery ships the guard hook (ADR-0032 enforcement layer 2). Same
|
||||
# version-in-key convention as above, kept by the same sync check.
|
||||
delivery#0.8.0:
|
||||
# full-identity, version-in-key convention as above, kept by the same check.
|
||||
git.rkdr.net/Mortis/Holocron/plugins/delivery#0.8.0:
|
||||
hooks: true
|
||||
|
||||
marketplace:
|
||||
|
||||
@@ -1,22 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Fails the push when root apm.yml's executables.allow stops naming the 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 '<name>#<version>' key, where <name> and <version> come from its own
|
||||
# apm.yml (and <name> must equal the directory name, since keys use the
|
||||
# package name). Every failing package is reported in one run.
|
||||
# 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:
|
||||
#
|
||||
# The grant itself is version-blind — apm matches the version-less name
|
||||
# alongside '<package>#<version>' (exec_gate.py builds the candidate list,
|
||||
# _map_grants matches it) — so a stale key keeps granting the package's hooks/
|
||||
# and bin/ and deployment does not break. What this gate 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.
|
||||
# * <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.
|
||||
|
||||
@@ -110,6 +125,8 @@ fi
|
||||
# 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
|
||||
@@ -167,6 +184,14 @@ if isinstance(allow, dict):
|
||||
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
|
||||
}
|
||||
|
||||
@@ -193,6 +218,16 @@ top_level_scalar() {
|
||||
|
||||
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"
|
||||
@@ -208,12 +243,38 @@ read_facts_bash() {
|
||||
# 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
|
||||
if [[ "$line" == executables:* ]]; then
|
||||
in_executables=1
|
||||
else
|
||||
in_executables=0
|
||||
fi
|
||||
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
|
||||
@@ -236,6 +297,7 @@ read_facts_bash() {
|
||||
printf 'k\t%s\n' "$key"
|
||||
fi
|
||||
done < "$ROOT_MANIFEST"
|
||||
flush_dep
|
||||
|
||||
printf 'a\t%s\n' "$allow_state"
|
||||
}
|
||||
@@ -263,6 +325,36 @@ fact() {
|
||||
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%/}"
|
||||
}
|
||||
|
||||
# identity <plugin dir> — <host>/<owner>/<repo>/<path> from root apm.yml's
|
||||
# git+path dependency entry for plugins/<plugin dir>; empty when it has none.
|
||||
identity() {
|
||||
local want="plugins/$1" tag path url
|
||||
while IFS=$'\t' read -r tag path url; do
|
||||
[[ "$tag" == d && "$(norm_path "$path")" == "$want" ]] || continue
|
||||
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"
|
||||
return
|
||||
done <<< "$FACTS"
|
||||
}
|
||||
|
||||
# expected_key <plugin dir> — '<identity>#<version>'.
|
||||
expected_key() {
|
||||
printf '%s#%s' "$(identity "$1")" "$(fact v "$1")"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Per-package checks
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -294,20 +386,31 @@ for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
|
||||
|
||||
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 '<package>#<version>'; with no version there is" >&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
|
||||
|
||||
EXPECTED+=("$plugin")
|
||||
done
|
||||
|
||||
if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
|
||||
summary=""
|
||||
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
||||
summary+="${summary:+, }$plugin#$(fact v "$plugin")"
|
||||
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
|
||||
@@ -317,7 +420,7 @@ if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
|
||||
echo " executables:" >&2
|
||||
echo " allow:" >&2
|
||||
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
||||
echo " $plugin#$(fact v "$plugin"):" >&2
|
||||
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
|
||||
@@ -325,18 +428,30 @@ if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
|
||||
fi
|
||||
|
||||
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
||||
expected_key="$plugin#$(fact v "$plugin")"
|
||||
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
|
||||
if [[ -n "$key" && "$key" == "$plugin#"* ]]; then stale_keys+=("$key"); fi
|
||||
[[ -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 version." >&2
|
||||
if [[ ${#stale_keys[@]} -gt 0 ]]; then
|
||||
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
|
||||
|
||||
@@ -46,12 +46,18 @@ make_fixture() {
|
||||
echo "description: fixture"
|
||||
} > "$dir/plugins/kyberforge/apm.yml"
|
||||
|
||||
# Both plugins are declared the way the real root apm.yml declares them, as
|
||||
# git + path entries: the gate derives each key's identity from these.
|
||||
{
|
||||
echo "name: ai-development"
|
||||
echo "version: 0.0.1"
|
||||
echo "dependencies:"
|
||||
echo " apm:"
|
||||
echo " - name: kyberforge"
|
||||
echo " - git: https://git.example.invalid/Owner/Repo.git"
|
||||
echo " path: plugins/kyberforge"
|
||||
echo " - git: https://git.example.invalid/Owner/Repo.git"
|
||||
echo " path: plugins/delivery"
|
||||
echo " mcp: []"
|
||||
[[ -n "$executables_block" ]] && printf '%s\n' "$executables_block"
|
||||
# A top-level key after the block: the fallback reader must stop collecting
|
||||
# allow keys here rather than reading on into the next section.
|
||||
@@ -74,40 +80,50 @@ add_plugin() {
|
||||
} > "$dir/apm.yml"
|
||||
}
|
||||
|
||||
# The identity apm 0.39 matches on: <host>/<owner>/<repo>/<path>.
|
||||
ID=git.example.invalid/Owner/Repo/plugins
|
||||
|
||||
MATCHING_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.5.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.5.0:
|
||||
hooks: true
|
||||
bin: true'
|
||||
|
||||
STALE_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.4.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.4.0:
|
||||
hooks: true
|
||||
bin: true'
|
||||
|
||||
TWO_MATCHING_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.5.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.5.0:
|
||||
hooks: true
|
||||
bin: true
|
||||
# delivery ships a guard hook; an indented comment must not read as a key.
|
||||
delivery#0.1.0:
|
||||
git.example.invalid/Owner/Repo/plugins/delivery#0.1.0:
|
||||
hooks: true'
|
||||
|
||||
TWO_STALE_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.4.0:
|
||||
git.example.invalid/Owner/Repo/plugins/kyberforge#1.4.0:
|
||||
hooks: true
|
||||
bin: true
|
||||
delivery#0.0.9:
|
||||
git.example.invalid/Owner/Repo/plugins/delivery#0.0.9:
|
||||
hooks: true'
|
||||
|
||||
OTHER_PACKAGE_BLOCK='executables:
|
||||
allow:
|
||||
git#1.0.0:
|
||||
git.example.invalid/Owner/Repo/plugins/git#1.0.0:
|
||||
hooks: true'
|
||||
|
||||
# The bare '<name>#<version>' form apm 0.28 matched and 0.39 does not.
|
||||
BARE_BLOCK='executables:
|
||||
allow:
|
||||
kyberforge#1.5.0:
|
||||
hooks: true
|
||||
bin: true'
|
||||
|
||||
# run_gate <fixture> — echoes combined output, sets GATE_RC.
|
||||
GATE_RC=0
|
||||
run_gate() {
|
||||
@@ -281,6 +297,33 @@ run_gate "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "refuses an unquoted 2-component version" \
|
||||
|| fail "a float version must fail rather than be compared in reader-invented form"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- the key is the full package identity apm 0.39 matches on ---"
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# The 0.28-era bare key: apm 0.39.3 parks the hooks under it while root
|
||||
# `apm audit --ci` stays green (spike #269), so this gate is what catches it.
|
||||
F="$(make_fixture "version: 1.5.0" "$BARE_BLOCK")"
|
||||
run_gate "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "fails on a bare '<name>#<version>' key" \
|
||||
|| fail "a bare key no longer matches under apm 0.39 and must fail"
|
||||
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
|
||||
grep -qF "$ID/kyberforge#1.5.0" <<< "$OUT" && pass "names the full-identity key to use" \
|
||||
|| fail "the failure must state the full-identity key, got: $OUT"
|
||||
grep -qF "full package identity" <<< "$OUT" && pass "says why a bare key no longer matches" \
|
||||
|| fail "the failure must explain the bare key, got: $OUT"
|
||||
|
||||
# No git+path dependency entry for the plugin means no identity to derive.
|
||||
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||
sed -i '/path: plugins\/kyberforge/d' "$F/apm.yml"
|
||||
run_gate "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "fails when root apm.yml has no git+path entry for the plugin" \
|
||||
|| fail "with no dependency entry the identity cannot be derived; must fail"
|
||||
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
|
||||
grep -qF "cannot be derived" <<< "$OUT" && pass "says the identity cannot be derived" \
|
||||
|| fail "the failure must say why, got: $OUT"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- the fallback reader agrees with the PyYAML reader ---"
|
||||
@@ -338,6 +381,41 @@ run_fallback "$F"
|
||||
run_fallback "$REPO_ROOT"
|
||||
[[ $GATE_RC -eq 0 ]] && pass "fallback passes the real repo" || fail "fallback disagrees with PyYAML on the real repo"
|
||||
|
||||
# Dependency entry shapes that name the same identity: no .git suffix, path
|
||||
# first, quoted values, ./ prefix and trailing slash, and an scp-like URL. Each
|
||||
# must pass under both readers.
|
||||
identity_variant() {
|
||||
local label="$1" entry="$2" f
|
||||
f="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||
python3 - "$f/apm.yml" "$entry" << 'PY2'
|
||||
import sys
|
||||
path, entry = sys.argv[1], sys.argv[2]
|
||||
text = open(path).read()
|
||||
old = " - git: https://git.example.invalid/Owner/Repo.git\n path: plugins/kyberforge\n"
|
||||
assert old in text
|
||||
open(path, "w").write(text.replace(old, entry + "\n"))
|
||||
PY2
|
||||
run_gate "$f"
|
||||
[[ $GATE_RC -eq 0 ]] && pass "PyYAML reader derives the identity: $label" \
|
||||
|| fail "PyYAML reader: $label should pass, got: $(bash "$SCRIPT" "$f" 2>&1 | head -2 || true)"
|
||||
run_fallback "$f"
|
||||
[[ $GATE_RC -eq 0 ]] && pass "fallback reader derives the identity: $label" \
|
||||
|| fail "fallback reader: $label should pass"
|
||||
}
|
||||
|
||||
identity_variant "no .git suffix" " - git: https://git.example.invalid/Owner/Repo
|
||||
path: plugins/kyberforge"
|
||||
identity_variant "path before git" " - path: plugins/kyberforge
|
||||
git: https://git.example.invalid/Owner/Repo.git"
|
||||
identity_variant "quoted values, ./ and trailing /" " - git: \"https://git.example.invalid/Owner/Repo.git\"
|
||||
path: './plugins/kyberforge/'"
|
||||
identity_variant "scp-like URL" " - git: [email protected]:Owner/Repo.git
|
||||
path: plugins/kyberforge"
|
||||
|
||||
F="$(make_fixture "version: 1.5.0" "$BARE_BLOCK")"
|
||||
run_fallback "$F"
|
||||
[[ $GATE_RC -ne 0 ]] && pass "fallback fails a bare key" || fail "fallback missed a bare key"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- wired into the pre-push gate ---"
|
||||
|
||||
Reference in new issue
Block a user