fix(gates): close six PR #135 review findings in gates and their tests
B1: check-skill-version-bump.sh resolves every merge-base with `git merge-base
--all` instead of the single base git happens to pick. A criss-cross history has
two, so the verdict turned on that choice: a skill byte-identical to main's tip
could still be reported "not above merge-base" / "not above main tip" and fail a
push that should pass. A skill now counts as changed only when it differs from
EVERY base, and its version must exceed the version at every base it exists at
as well as at the main tip; with more than one base the failure names which one.
Case 40 in tests/test-skill-version-bump.sh builds the criss-cross fixture and
pins both directions.
B2: check-apm-current.sh no longer assumes the remote default branch is `main`
when origin/HEAD is unset. A checkout whose default is `master` was standing on
its default branch and being told "this is a feature branch, so discard it" --
to throw away a real lock update. With origin/HEAD unset nothing is asserted and
the neutral advice stands. tests/test-apm-current-hook.sh covers the unset case
on both `main` and `master`.
#4: the required-frontmatter checks folded into skill-size-check.sh by c8a7c9e
were untested apart from the leading-zero shape -- mutating the missing-version
ERROR into a no-op left every suite green. tests/test-adr0020-frontmatter.sh now
pins name presence and non-emptiness, metadata.version presence and semver
shape, and the four grep defects the deleted test-skill-frontmatter.sh named.
#5: nothing asked whether a Vale rule still MATCHES anything -- rewriting
CompositionNote.yml's tokens to match nothing left test-vale-wrap.sh at 63/63.
Case 35 enumerates the rule files under the Kyberforge* style directories at run
time, requires an alert from each on its own fixture, and fails when a
discovered rule has no fixture row. The stale comment at case 31 is corrected.
#6: tests/run-tests.sh --strict exited 0 when discovery found no test-*.sh at
all; strictness only ever acted on skips, and with no suites there were none. It
now cross-checks the git index the way run-bats.sh does and fails
unconditionally on an empty set, naming the search root.
N9: the skill-size-check hook description in .pre-commit-config.yaml covered
only the size, context-budget and boundary-target gates. It now also names the
required frontmatter fields, matching docs/spec/gates.md.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NwD8Egs5r4ndqeFLmhusX2
This commit is contained in:
@@ -588,6 +588,51 @@ expect_fail "unbumped skill with leading blank lines is held to its baseline ver
|
||||
write_skill "$F" demo alpha 'version: "1.0.1"' "lead body 2"; blank_lead "$F" alpha; commit "$F"
|
||||
expect_pass "bumped skill with leading blank lines passes" "$F"
|
||||
|
||||
echo ""
|
||||
echo "--- 40. a criss-cross history is judged against EVERY merge-base ---"
|
||||
# Two merge bases, and which one plain `git merge-base` prints is git's choice,
|
||||
# not a property of the history. The gate used to take that single answer, so
|
||||
# the verdict turned on it: here `git diff main feature -- plugins` is EMPTY
|
||||
# (main already carries the bump, via its merge of the feature branch) and the
|
||||
# push still failed with "not above main tip", because the base git picked was
|
||||
# the one that predates the bump. `--all` plus the intersection rule makes the
|
||||
# answer the same whichever base git would have named.
|
||||
#
|
||||
# C0 alpha 1.0.0
|
||||
# +-- feature: F1 bumps alpha to 1.0.1
|
||||
# +-- main: M1 unrelated, then M2 merges F1
|
||||
# feature: F2 merges M1 -> merge bases {M1, F1}
|
||||
F="$(mktemp -d)"; CLEANUP_DIRS+=("$F")
|
||||
(cd "$F" && git init -q -b main && git config user.email t@t.t && git config user.name t)
|
||||
write_skill "$F" demo alpha 'version: "1.0.0"'; commit "$F" C0
|
||||
(cd "$F" && git checkout -q -b feature)
|
||||
write_skill "$F" demo alpha 'version: "1.0.1"' "new body"; commit "$F" F1
|
||||
F1_SHA="$(cd "$F" && git rev-parse HEAD)"
|
||||
(cd "$F" && git checkout -q main)
|
||||
echo unrelated > "$F/m1.txt"; commit "$F" M1
|
||||
M1_SHA="$(cd "$F" && git rev-parse HEAD)"
|
||||
(cd "$F" && git merge -q --no-edit "$F1_SHA" -m M2 > /dev/null)
|
||||
(cd "$F" && git checkout -q feature && git merge -q --no-edit "$M1_SHA" -m F2 > /dev/null)
|
||||
|
||||
BASES40="$(cd "$F" && git merge-base --all main feature | sort)"
|
||||
if [[ "$(printf '%s\n' "$BASES40" | wc -l)" -eq 2 ]]; then
|
||||
pass "fixture check: the history really does have two merge bases"
|
||||
else
|
||||
fail "fixture check: expected two merge bases, got: $BASES40"
|
||||
fi
|
||||
if [[ -z "$(cd "$F" && git diff main feature -- plugins)" ]]; then
|
||||
pass "fixture check: nothing under plugins/ differs between main and the branch"
|
||||
else
|
||||
fail "fixture check: plugins/ differs between main and the branch, so this is not the case under test"
|
||||
fi
|
||||
expect_pass "a skill identical to main's tip passes whichever merge-base git would pick" "$F"
|
||||
|
||||
# And the ratchet still holds on the same shape: a further edit with no bump
|
||||
# differs from BOTH bases, so it is not excused by the criss-cross.
|
||||
write_skill "$F" demo alpha 'version: "1.0.1"' "later body"; commit "$F" F3
|
||||
expect_fail "an unbumped edit on a criss-cross branch still fails, naming the baseline sha" \
|
||||
"alpha: 1\.0\.1 -> 1\.0\.1 \(not above merge-base [0-9a-f]{40}\)" "$F"
|
||||
|
||||
echo ""
|
||||
echo "Results: $PASS passed, $FAIL failed"
|
||||
[[ $FAIL -eq 0 ]]
|
||||
|
||||
Reference in New Issue
Block a user