63 lines
2.8 KiB
Bash
63 lines
2.8 KiB
Bash
#!/usr/bin/env bash
|
|
# Applies the R5.4 FLOOR clarification (owner 2026-10-23, contract
|
|
# 2026-10-23-rust-r5-review.md): a SUPPRESS finding on a Markdown line under
|
|
# .claude/audits/ only quotes a keyword in prose and is requalified. Any other
|
|
# finding keeps failing. A negative proof in a throwaway repo shows that a real
|
|
# suppression in executable code and one in an active contract still trip it.
|
|
#
|
|
# bash scripts/floor-clarification-check.sh [base-ref] (default: develop)
|
|
set -uo pipefail
|
|
|
|
GUARD="$HOME/.claude/lib/floor-guard.sh"
|
|
BASE="${1:-develop}"
|
|
ALLOWED_RE='^FLOOR SUPPRESS \.claude/audits/[^:]+\.md:[0-9]+ '
|
|
# Declared in the clarification and left to the owner: reported, never requalified, not
|
|
# counted as a new finding. Anything else outside ALLOWED_RE fails.
|
|
DECLARED_RE='^FLOOR STUB \.claude/memory/evals\.md:205 '
|
|
|
|
# rc 0: every finding is requalified or the declared one; rc 1: a real finding remains.
|
|
classify() {
|
|
local report="$1" total requalified remaining declared
|
|
total=$(grep -c '^FLOOR [A-Z_]* ' "$report")
|
|
requalified=$(grep -cE "$ALLOWED_RE" "$report")
|
|
declared=$(grep -E "$DECLARED_RE" "$report")
|
|
remaining=$(grep '^FLOOR [A-Z_]* ' "$report" | grep -vE "$ALLOWED_RE" | grep -vE "$DECLARED_RE")
|
|
echo "findings $total, requalified $requalified"
|
|
[ -z "$declared" ] || { echo "DECLARED (owner decision pending):"; echo "$declared" | cut -c1-200; }
|
|
[ -z "$remaining" ] || { echo "REMAINING:"; echo "$remaining" | cut -c1-200; return 1; }
|
|
}
|
|
|
|
branch_report=$(mktemp)
|
|
bash "$GUARD" "$BASE" >"$branch_report" 2>&1
|
|
echo "== branch vs $BASE"
|
|
classify "$branch_report"
|
|
branch_rc=$?
|
|
rm -f "$branch_report"
|
|
|
|
# Negative proof: a literal throwaway repo, never the project tree.
|
|
proof=$(mktemp -d)
|
|
(
|
|
cd "$proof" || exit 9
|
|
git init -q . && git config user.email t@t && git config user.name t
|
|
mkdir -p src .claude/audits .claude/tasks/contracts
|
|
echo 'export const a = 1' >src/a.ts
|
|
echo 'prose' >.claude/audits/A.md
|
|
echo 'contract' >.claude/tasks/contracts/C.md
|
|
git add -A && git commit -qm base
|
|
printf '// @ts-ignore\nexport const b: number = "x"\n' >>src/a.ts # floor-guard: allow negative-proof fixture
|
|
echo 'no `nosemgrep` was added' >>.claude/audits/A.md # floor-guard: allow negative-proof fixture
|
|
echo '// @ts-ignore active' >>.claude/tasks/contracts/C.md # floor-guard: allow negative-proof fixture
|
|
echo 'fn f() { // nosec' >src/lib.rs # floor-guard: allow negative-proof fixture
|
|
git add -A
|
|
bash "$GUARD" HEAD >"$proof/report.txt" 2>&1
|
|
echo "== negative proof"
|
|
classify "$proof/report.txt"
|
|
)
|
|
proof_rc=$?
|
|
echo "proof repo left in $proof (temp dir, no recursive delete by variable)"
|
|
|
|
# The proof must FAIL (real findings kept); the branch must PASS.
|
|
[ "$proof_rc" -eq 1 ] && [ "$branch_rc" -eq 0 ] && echo "OK" && exit 0
|
|
echo "NOT OK (branch rc=$branch_rc, proof rc=$proof_rc, expected 0 and 1)"
|
|
exit 1
|