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.
This commit is contained in:
1 parent
637ea6334c
commit
2c445063a4
20 files changed
+1595
-21
No files matched your search
@@ -0,0 +1,57 @@
|
||||
#!/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
|
||||
@@ -29,6 +29,10 @@ cargo test -p faunosteo-core --features cli --locked
|
||||
# module or the worker; its suites hold it to the TypeScript oracles of `oracles/r5`.
|
||||
cargo clippy -p faunosteo-core --all-targets --features curation --locked -- -D warnings
|
||||
cargo test -p faunosteo-core --features curation --locked
|
||||
# The sheet-asset upload tool (R5.5) adds `ureq` on top of `curation`: its rules, and the binary
|
||||
# against a loopback stub of the local stack (`upload_tool`); never built into the module.
|
||||
cargo clippy -p faunosteo-core --all-targets --features upload --locked -- -D warnings
|
||||
cargo test -p faunosteo-core --features upload --locked
|
||||
# Exports the TypeScript types of the contracts (ts-rs) into packages/core-wasm/types.
|
||||
# `git status --porcelain --untracked-files=all -- packages/core-wasm/types` must stay
|
||||
# empty afterwards (scripts/check-all.sh, .gitea/workflows/ci.yml): the committed types
|
||||
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# `pnpm e2e:sheet-assets`: the sheet-asset upload tool against the LOCAL Supabase stack (R5.5,
|
||||
# docs/development/SUPABASE.md §3.1). Needs `pnpm db:start`. Run by hand: it uploads the equine
|
||||
# draft drawing to the local bucket and confirms its row (idempotent; a rerun changes nothing).
|
||||
# The keys are read from `pnpm supabase status`, held in variables, never printed.
|
||||
#
|
||||
# Checks: --check writes nothing; a first run uploads and confirms; a rerun has nothing to do;
|
||||
# the anon key and a wrong key are refused; a destination that is not a local stack is refused
|
||||
# before any request; an unreachable local port is a network error (exit 3).
|
||||
set -uo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
. scripts/rust-env.sh
|
||||
SEED=supabase/seed/anatomical-sheets/equine/draft
|
||||
BIN=target/release/upload-sheet-assets
|
||||
FAIL=0
|
||||
|
||||
cargo build --release --locked -q -p faunosteo-core --features upload --bin upload-sheet-assets || exit 2
|
||||
STATUS=$(bash scripts/supabase.sh status -o json 2>/dev/null) || { echo "stack not running (pnpm db:start)"; exit 2; }
|
||||
field() { printf '%s' "$STATUS" | python3 -c "import json,sys;print(json.load(sys.stdin)['$1'])"; }
|
||||
SERVICE=$(field SERVICE_ROLE_KEY)
|
||||
ANON=$(field ANON_KEY)
|
||||
LOCAL=http://127.0.0.1:54321
|
||||
|
||||
# expect <name> <expected exit> <url> <key> <args...>; output kept to grep, keys never echoed.
|
||||
expect() {
|
||||
local name=$1 want=$2 url=$3 key=$4; shift 4
|
||||
local out rc
|
||||
out=$(env -i PATH="$PATH" SUPABASE_URL="$url" SUPABASE_SERVICE_ROLE_KEY="$key" "$BIN" "$@" 2>&1); rc=$?
|
||||
LAST=$out
|
||||
if [ "$rc" -eq "$want" ] && ! grep -qF -e "$key" -e "$SERVICE" -e "$ANON" <<<"$out"; then
|
||||
echo "PASS $name (exit $rc)"
|
||||
else
|
||||
echo "FAIL $name (exit $rc, wanted $want)"; FAIL=1
|
||||
fi
|
||||
}
|
||||
|
||||
expect "check writes nothing" 0 "$LOCAL" "$SERVICE" --check "$SEED"
|
||||
expect "first run" 0 "$LOCAL" "$SERVICE" "$SEED"
|
||||
expect "rerun" 0 "$LOCAL" "$SERVICE" "$SEED"
|
||||
grep -q "nothing to do" <<<"$LAST" && echo "PASS rerun has nothing to do" || { echo "FAIL rerun did work"; FAIL=1; }
|
||||
expect "anon key refused" 1 "$LOCAL" "$ANON" "$SEED"
|
||||
expect "wrong key refused" 1 "$LOCAL" "not-a-valid-key" "$SEED"
|
||||
expect "https refused" 1 "https://127.0.0.1:54321" "$SERVICE" "$SEED"
|
||||
expect "non-local host refused" 1 "http://example.test:54321" "$SERVICE" "$SEED"
|
||||
expect "no port refused" 1 "http://127.0.0.1" "$SERVICE" "$SEED"
|
||||
expect "unreachable port" 3 "http://127.0.0.1:9" "$SERVICE" "$SEED"
|
||||
expect "folder outside the seed" 1 "$LOCAL" "$SERVICE" --check crates/core/src
|
||||
|
||||
[ "$FAIL" -eq 0 ] && echo "e2e:sheet-assets OK" || echo "e2e:sheet-assets FAILED"
|
||||
exit "$FAIL"
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# `pnpm assets:upload [--check] <seed folder>`: uploads the SVG drawings of a generated sheet
|
||||
# seed folder to the private bucket `anatomical-sheet-assets` of the LOCAL Supabase stack
|
||||
# (R5.5, docs/development/SUPABASE.md §3.1). The `upload-sheet-assets` binary of crates/core
|
||||
# behind its `upload` feature, on the native toolchain (scripts/rust-env.sh); the first run
|
||||
# compiles it (release profile). Reads SUPABASE_URL (a local address, no default) and
|
||||
# SUPABASE_SERVICE_ROLE_KEY from the environment; a relative folder is typed from the folder
|
||||
# pnpm was run in (INIT_CWD). Run it by hand: the service key is typed, never stored.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
. scripts/rust-env.sh
|
||||
|
||||
exec cargo run --release --locked -q -p faunosteo-core --features upload --bin upload-sheet-assets -- "$@"
|
||||
Reference in new issue
Block a user