Files
faunosteo/scripts/floor-clarification-check.sh
T
bchanot 2c445063a4 feat(supabase): R5.5 upload-sheet-assets in Rust, R5.4 caps and FLOOR clarification
Core rules curation::upload (manifest, local destination, bytes through the SVG reader,
plan from observed state); binary upload-sheet-assets over ureq (handshake, no overwrite,
confirm after verify, bounded retries, key never printed); pnpm assets:upload repointed,
e2e:sheet-assets for the local stack. 4 MiB cap on changes.json and references.json.
FLOOR clarification for audit prose with its negative proof.
2026-10-23 21:15:22 +02:00

58 lines
2.4 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]+ '
# rc 0: every finding is requalified; rc 1: at least one real finding remains.
classify() {
local report="$1" total requalified remaining
total=$(grep -c '^FLOOR [A-Z_]* ' "$report")
requalified=$(grep -cE "$ALLOWED_RE" "$report")
remaining=$(grep '^FLOOR [A-Z_]* ' "$report" | grep -vE "$ALLOWED_RE")
echo "findings $total, requalified $requalified"
[ -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