From 714e8a0c78cd7bdf09433f25f1abd915ea2ae632 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 9 Aug 2026 13:06:36 +0000 Subject: [PATCH] fix(lint): fail the style-sync check when one copy is missing The guard used `||`, so exactly one of the two audit skill directories missing also exited 0, where the intended silent no-op is both absent. A renamed skill-audit reported green instead of flagging that a canonical style copy had lost its counterpart. One-present now exits 1 naming the missing side and the remedy. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01MCQ648fLSFXPHGZdQ8gn58 --- scripts/check-vale-style-sync.sh | 14 +++++++++++++- tests/test-check-vale-style-sync.sh | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/scripts/check-vale-style-sync.sh b/scripts/check-vale-style-sync.sh index 029bb92..4f9dd1c 100755 --- a/scripts/check-vale-style-sync.sh +++ b/scripts/check-vale-style-sync.sh @@ -17,10 +17,22 @@ err() { echo " FAIL: $1" >&2; FAIL=$((FAIL + 1)); } SKILL_AUDIT="$REPO_ROOT/plugins/kyberforge/skills/skill-audit" AGENT_AUDIT="$REPO_ROOT/plugins/kyberforge/skills/agent-audit" -if [[ ! -d "$SKILL_AUDIT" || ! -d "$AGENT_AUDIT" ]]; then +if [[ ! -d "$SKILL_AUDIT" && ! -d "$AGENT_AUDIT" ]]; then exit 0 fi +# Exactly one present is drift, not absence: the missing copy can't be in sync +# with the surviving one, and treating it as a no-op is how a deleted or +# renamed copy would slip through silently. +if [[ ! -d "$SKILL_AUDIT" ]]; then + echo "Vale style sync check failed: $AGENT_AUDIT exists but $SKILL_AUDIT does not — run scripts/sync-vale-styles.sh to regenerate skill-audit's copy." >&2 + exit 1 +fi +if [[ ! -d "$AGENT_AUDIT" ]]; then + echo "Vale style sync check failed: $SKILL_AUDIT exists but $AGENT_AUDIT does not — agent-audit holds the canonical copy, so restore it before syncing." >&2 + exit 1 +fi + if ! diff -q "$SKILL_AUDIT/scripts/vale-wrap.sh" "$AGENT_AUDIT/scripts/vale-wrap.sh" >/dev/null 2>&1; then err "scripts/vale-wrap.sh differs between skill-audit and agent-audit" fi diff --git a/tests/test-check-vale-style-sync.sh b/tests/test-check-vale-style-sync.sh index d822e4b..a0d82b1 100755 --- a/tests/test-check-vale-style-sync.sh +++ b/tests/test-check-vale-style-sync.sh @@ -86,6 +86,27 @@ else fail "exited non-zero when skill-audit/agent-audit are simply absent" fi +# --- 6. Exits 1 when only one of the two copies is present --- +# The no-op guard used `||`, so a single missing copy also exited 0 — a deleted +# or renamed copy passed the sync check silently. +echo "" +echo "--- exits 1 when only one of the two copies is present ---" +FIXTURE6="$(make_fixture)" +FIXTURE7="$(make_fixture)" +trap 'rm -rf "$FIXTURE" "$FIXTURE2" "$FIXTURE3" "$FIXTURE4" "$FIXTURE5" "$FIXTURE6" "$FIXTURE7"' EXIT +rm -rf "$FIXTURE6/plugins/kyberforge/skills/skill-audit" +rm -rf "$FIXTURE7/plugins/kyberforge/skills/agent-audit" +if bash "$SCRIPT" "$FIXTURE6" > /dev/null 2>&1; then + fail "exited 0 when only agent-audit is present — expected exit 1" +else + pass "exits non-zero when skill-audit's copy is missing but agent-audit's is present" +fi +if bash "$SCRIPT" "$FIXTURE7" > /dev/null 2>&1; then + fail "exited 0 when only skill-audit is present — expected exit 1" +else + pass "exits non-zero when agent-audit's canonical copy is missing but skill-audit's is present" +fi + echo "" echo "Results: $PASS passed, $FAIL failed" [[ $FAIL -eq 0 ]]