test(supabase): sheet-assets e2e on the sandbox only

pnpm e2e:sheet-assets is now an alias of pnpm db:sandbox sheet-assets-e2e:
gateway on 127.0.0.1:57800 (occupied port refused), the runner refuses any
URL but the sandbox gateway and any key not issued by the sandbox, before
building or any request; no DEV URL, port or key remains.
This commit is contained in:
bchanot committed 2026-11-02 00:09:02 +01:00
1 parent 57b93afae6
commit f924ad056d
6 files changed
+64 -26

No files matched your search

+1 -1
View File
@@ -137,7 +137,7 @@ pnpm preview:draft # same, then serves it
pnpm import:equine --check | --out <dir> # since R5.6 the official seed writer: the Rust pipeline (same as `pnpm r5:import-equine`), fingerprint `sha256-rfc8785-validated-v1`; the TypeScript generator left at R5.7 (replayed from a historical revision only, RUST.md §11.23) pnpm import:equine --check | --out <dir> # since R5.6 the official seed writer: the Rust pipeline (same as `pnpm r5:import-equine`), fingerprint `sha256-rfc8785-validated-v1`; the TypeScript generator left at R5.7 (replayed from a historical revision only, RUST.md §11.23)
pnpm r5:import-equine --check | --out <dir> # the Rust pipeline (R5.2 importer, R5.3 draft, R5.4 review files): compare the 18 generated files with the committed folders (bytes; app drawings under the declared R3 rule), or write <dir>/{legacy-import,draft} into an empty folder; never deletes (scripts/import-equine.sh, first run compiles) pnpm r5:import-equine --check | --out <dir> # the Rust pipeline (R5.2 importer, R5.3 draft, R5.4 review files): compare the 18 generated files with the committed folders (bytes; app drawings under the declared R3 rule), or write <dir>/{legacy-import,draft} into an empty folder; never deletes (scripts/import-equine.sh, first run compiles)
pnpm assets:upload [--check] <seed folder> # R5.5: uploads the sheet drawings of a generated seed folder to the LOCAL stack's private bucket (Rust `upload-sheet-assets`, feature `upload`; SUPABASE_URL local with a port, SUPABASE_SERVICE_ROLE_KEY typed, never printed; no overwrite, confirm after verify; run by hand, scripts/upload-sheet-assets.sh) pnpm assets:upload [--check] <seed folder> # R5.5: uploads the sheet drawings of a generated seed folder to the LOCAL stack's private bucket (Rust `upload-sheet-assets`, feature `upload`; SUPABASE_URL local with a port, SUPABASE_SERVICE_ROLE_KEY typed, never printed; no overwrite, confirm after verify; run by hand, scripts/upload-sheet-assets.sh)
pnpm e2e:sheet-assets # scripts/sheet-assets-e2e.sh: that tool against the local stack (upload, rerun, anon and wrong key, refused destinations); run by hand pnpm e2e:sheet-assets # scripts/sheet-assets-e2e.sh: that tool against the throwaway sandbox (= `pnpm db:sandbox sheet-assets-e2e`, gateway on 127.0.0.1:57800; upload, rerun, anon and wrong key, refused destinations); needs `pnpm db:sandbox up fresh`, refuses any other target
pnpm report:compare <pdf|dir>... # archive check: attachment vs its v3 reading, unresolved items flagged (docs/PDF-FORMAT.md); the core's `report-compare` binary since R4.7 (scripts/report-compare.sh, first run compiles) pnpm report:compare <pdf|dir>... # archive check: attachment vs its v3 reading, unresolved items flagged (docs/PDF-FORMAT.md); the core's `report-compare` binary since R4.7 (scripts/report-compare.sh, first run compiles)
# Rust (docs/development/RUST.md) — native toolchain (user-level rustup, channel of rust-toolchain.toml) first # Rust (docs/development/RUST.md) — native toolchain (user-level rustup, channel of rust-toolchain.toml) first
+5 -3
View File
@@ -155,9 +155,11 @@ oversized answer) is final. Exit codes: 0 done, 1 refused (usage, manifest,
destination, content, handshake, state, access), 2 an argument that is not destination, content, handshake, state, access), 2 an argument that is not
UTF-8, 3 network. The DEV address counts only if it is an address of this UTF-8, 3 network. The DEV address counts only if it is an address of this
machine. The key is machine. The key is
never printed and goes through no proxy. `pnpm e2e:sheet-assets` runs the never printed and goes through no proxy. `pnpm e2e:sheet-assets` (= `pnpm db:sandbox
whole behaviour against the local stack (upload, rerun, anon and wrong key, sheet-assets-e2e`) runs the whole behaviour against the sandbox stack, never
refused destinations, unreachable port). The TypeScript tool DEV (upload, rerun, anon and wrong key, refused destinations, unreachable
port); the script refuses any URL but `http://127.0.0.1:57800` and any key
whose issuer is not `db-sandbox`. The TypeScript tool
(`packages/supabase/scripts/upload-sheet-assets.ts`) was deleted at R5.7 (RUST.md §11.23). (`packages/supabase/scripts/upload-sheet-assets.ts`) was deleted at R5.7 (RUST.md §11.23).
### 3.2 Files worker (Storage, Step 8) ### 3.2 Files worker (Storage, Step 8)
+11 -9
View File
@@ -1486,10 +1486,10 @@ A drawing never blocks authoring: only the round waits for its verdict.
object's integrity undemonstrated (§12.3, §17.3). object's integrity undemonstrated (§12.3, §17.3).
- `pnpm assets:upload` stays the seed tool of local and sandbox stacks. With - `pnpm assets:upload` stays the seed tool of local and sandbox stacks. With
the service role's table privileges revoked (F12), the same step gives the the service role's table privileges revoked (F12), the same step gives the
tool a narrow read RPC for its planning. `pnpm e2e:sheet-assets` targets the tool a narrow read RPC for its planning. `pnpm e2e:sheet-assets` runs on the
local DEV stack only, so V1-2.1 did not run it (sandbox-only rule); the sandbox stack (`pnpm db:sandbox sheet-assets-e2e`, owner brief 2026-11-02);
tool's switch to that RPC is covered by its stub-server tests and pgTAP 006, V1-2.1 did not run it, the tool's switch to that RPC is covered by its
and the rerun is an owner step of §16.11. stub-server tests and pgTAP 006, and the sandbox run closes V1-2.3.
- Objects are never deleted by the worker: its purge guard refuses any purge - Objects are never deleted by the worker: its purge guard refuses any purge
whose bucket is `anatomical-sheet-assets`, and no trigger enqueues a sheet whose bucket is `anatomical-sheet-assets`, and no trigger enqueues a sheet
object. object.
@@ -2043,8 +2043,8 @@ The final approval needs all 30 groups acknowledged, no `to_confirm` and no
the purge guard by bucket, sandbox tests and seccomp derivation, an e2e on the purge guard by bucket, sandbox tests and seccomp derivation, an e2e on
the sandbox stack with the verification worker running; the avatar suite the sandbox stack with the verification worker running; the avatar suite
unchanged in outcome on the sandbox (`pnpm db:sandbox avatar-e2e`, owner unchanged in outcome on the sandbox (`pnpm db:sandbox avatar-e2e`, owner
decision 2026-11-01: `pnpm e2e:avatar` is now its alias, the DEV script removed); `pnpm e2e:sheet-assets` targets DEV only, its rerun decision 2026-11-01: `pnpm e2e:avatar` is now its alias, the DEV script removed); `pnpm e2e:sheet-assets` now runs on the sandbox
is an owner step (§16.11). (`pnpm db:sandbox sheet-assets-e2e`, gateway on 127.0.0.1:57800, refuses DEV).
- Release replay: a script loads every published version and drawing of a - Release replay: a script loads every published version and drawing of a
stack through the new core and fails on any regression. stack through the new core and fails on any regression.
- Application: failure codes to FR and EN messages, editor state (undo, - Application: failure codes to FR and EN messages, editor state (undo,
@@ -2177,7 +2177,8 @@ V1-2.7 on.
- SQL changes: M6 (§12.3). - SQL changes: M6 (§12.3).
- Tests: `pnpm worker:test`, hostile corpus, e2e on the sandbox, each failure - Tests: `pnpm worker:test`, hostile corpus, e2e on the sandbox, each failure
of §6.5, upgrade rehearsal with a copy of the DEV object; `pnpm e2e:avatar` of §6.5, upgrade rehearsal with a copy of the DEV object; `pnpm e2e:avatar`
unchanged; `pnpm e2e:sheet-assets` rerun by the owner on DEV (§16.11). unchanged; `pnpm e2e:sheet-assets` on the sandbox (`pnpm db:sandbox
sheet-assets-e2e`).
- Acceptance: verdict accepted on a clean sheet; each failure produced and its - Acceptance: verdict accepted on a clean sheet; each failure produced and its
exit working; a stale or malformed completion writes nothing; avatars and exit working; a stale or malformed completion writes nothing; avatars and
purges unaffected; publication refused without a current passed verdict; purges unaffected; publication refused without a current passed verdict;
@@ -2329,8 +2330,9 @@ Each is an owner action, never run by Claude, after its own checkpoint:
6. any submission, approval, publication, deprecation or archive; 6. any submission, approval, publication, deprecation or archive;
7. any factor reset (§5.6, §5.7.7) and any `object_conflict` deletion (§9.3); 7. any factor reset (§5.6, §5.7.7) and any `object_conflict` deletion (§9.3);
8. rerunning the equine seed; 8. rerunning the equine seed;
9. rerunning `pnpm e2e:sheet-assets` against DEV once M4 to M6 are applied 9. uploading the equine drawing to DEV with the operator tool
(§9.5). `pnpm assets:upload` once M4 to M6 are applied (§9.5); `pnpm e2e:sheet-assets`
is sandbox-only and not part of this list.
### 16.12 Deferred (not V1-2) ### 16.12 Deferred (not V1-2)
+1 -1
View File
@@ -36,7 +36,7 @@
"db:types:check": "bash scripts/supabase.sh gen types typescript --local --schema public | prettier --parser typescript | diff - packages/supabase/src/database.types.ts", "db:types:check": "bash scripts/supabase.sh gen types typescript --local --schema public | prettier --parser typescript | diff - packages/supabase/src/database.types.ts",
"db:sandbox": "bash scripts/db-sandbox.sh", "db:sandbox": "bash scripts/db-sandbox.sh",
"assets:upload": "bash scripts/upload-sheet-assets.sh", "assets:upload": "bash scripts/upload-sheet-assets.sh",
"e2e:sheet-assets": "bash scripts/sheet-assets-e2e.sh", "e2e:sheet-assets": "bash scripts/db-sandbox.sh sheet-assets-e2e",
"build:preview": "SHEET_BUNDLE=draft pnpm --filter @faunosteo/app build", "build:preview": "SHEET_BUNDLE=draft pnpm --filter @faunosteo/app build",
"preview:draft": "SHEET_BUNDLE=draft pnpm --filter @faunosteo/app build && pnpm --filter @faunosteo/app preview", "preview:draft": "SHEET_BUNDLE=draft pnpm --filter @faunosteo/app build && pnpm --filter @faunosteo/app preview",
"rust:builder": "docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker", "rust:builder": "docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker",
+21 -1
View File
@@ -20,6 +20,8 @@
# pnpm db:sandbox avatar-e2e [args] (= pnpm e2e:avatar) the avatar worker (default mode: avatars + sweep) against the # pnpm db:sandbox avatar-e2e [args] (= pnpm e2e:avatar) the avatar worker (default mode: avatars + sweep) against the
# sandbox: a gateway on 127.0.0.1:$PORT_GATEWAY, the worker # sandbox: a gateway on 127.0.0.1:$PORT_GATEWAY, the worker
# container, then tests/e2e/avatar-flow.e2e.ts (args go to vitest) # container, then tests/e2e/avatar-flow.e2e.ts (args go to vitest)
# pnpm db:sandbox sheet-assets-e2e (= pnpm e2e:sheet-assets) the sheet-asset upload tool against the sandbox:
# a gateway on 127.0.0.1:$PORT_GATEWAY, then scripts/sheet-assets-e2e.sh
# pnpm db:sandbox sql psql as postgres on stdin # pnpm db:sandbox sql psql as postgres on stdin
# pnpm db:sandbox down # pnpm db:sandbox down
# #
@@ -356,6 +358,23 @@ cmd_avatar_e2e() {
node_modules/.bin/pnpm --filter @faunosteo/supabase test:e2e "$@" node_modules/.bin/pnpm --filter @faunosteo/supabase test:e2e "$@"
} }
# The upload tool talks to the gateway's loopback port with the typed keys in
# its environment (never argv); the runner refuses any other target. Nothing is
# started when the port is taken; the gateway is removed at exit.
cmd_sheet_assets_e2e() {
load_secrets
docker rm -f "$GATEWAY" >/dev/null 2>&1 || true
if (exec 3<>"/dev/tcp/127.0.0.1/$PORT_GATEWAY") 2>/dev/null; then
die "port 127.0.0.1:$PORT_GATEWAY is already in use: free it, nothing was started"
fi
trap 'docker rm -f "$GATEWAY" >/dev/null 2>&1 || true' EXIT
start_gateway -p 127.0.0.1:$PORT_GATEWAY:8000
[ "$(docker port "$GATEWAY" 8000/tcp)" = "127.0.0.1:$PORT_GATEWAY" ] \
|| die "the gateway is not published on 127.0.0.1:$PORT_GATEWAY only"
SUPABASE_URL="http://127.0.0.1:$PORT_GATEWAY" SUPABASE_ANON_KEY="$SB_ANON_KEY" \
SUPABASE_SERVICE_ROLE_KEY="$SB_SERVICE_KEY" bash scripts/sheet-assets-e2e.sh
}
case "${1:-}" in case "${1:-}" in
up) shift; cmd_up "$@" ;; up) shift; cmd_up "$@" ;;
down) cmd_down ;; down) cmd_down ;;
@@ -372,6 +391,7 @@ case "${1:-}" in
e2e-shell) shift; load_secrets; with_sandbox_env node_modules/.bin/pnpm --filter @faunosteo/app e2e:shell "$@" ;; e2e-shell) shift; load_secrets; with_sandbox_env node_modules/.bin/pnpm --filter @faunosteo/app e2e:shell "$@" ;;
verify-e2e) shift; cmd_verify_e2e "$@" ;; verify-e2e) shift; cmd_verify_e2e "$@" ;;
avatar-e2e) shift; cmd_avatar_e2e "$@" ;; avatar-e2e) shift; cmd_avatar_e2e "$@" ;;
sheet-assets-e2e) cmd_sheet_assets_e2e ;;
sql) load_secrets; sb_psql ;; sql) load_secrets; sb_psql ;;
*) sed -n '2,29p' "$0"; exit 1 ;; *) sed -n '2,31p' "$0"; exit 1 ;;
esac esac
+25 -11
View File
@@ -1,8 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# `pnpm e2e:sheet-assets`: the sheet-asset upload tool against the LOCAL Supabase stack (R5.5, # `pnpm e2e:sheet-assets` (= `pnpm db:sandbox sheet-assets-e2e`): the sheet-asset upload tool against the
# docs/development/SUPABASE.md §3.1). Needs `pnpm db:start`. Run by hand: it uploads the equine # throwaway SANDBOX stack (docs/development/SUPABASE.md §3.1, §5.1), never DEV. It uploads the equine draft
# draft drawing to the local bucket and confirms its row (idempotent; a rerun changes nothing). # drawing to the sandbox bucket and confirms its row (idempotent; a rerun changes nothing).
# The keys are read from `pnpm supabase status`, held in variables, never printed. # The runner (scripts/db-sandbox.sh) starts the gateway and passes SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY
# and SUPABASE_ANON_KEY in the environment; this script refuses anything else before building or any
# request, and never prints a key.
# #
# Checks: --check writes nothing; a first run uploads and confirms; a rerun has nothing to do; # 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 # the anon key and a wrong key are refused; a destination that is not a local stack is refused
@@ -10,17 +12,29 @@
set -uo pipefail set -uo pipefail
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
SANDBOX_URL=http://127.0.0.1:57800
SERVICE=${SUPABASE_SERVICE_ROLE_KEY:-}
ANON=${SUPABASE_ANON_KEY:-}
# A key is accepted only when its JWT payload names the sandbox issuer; nothing is printed.
sandbox_key() { printf '%s' "$1" | python3 -I -c '
import base64, json, sys
try:
p = sys.stdin.read().split(".")[1]
sys.exit(0 if json.loads(base64.urlsafe_b64decode(p + "=" * (-len(p) % 4))).get("iss") == "db-sandbox" else 1)
except Exception:
sys.exit(1)'; }
if [ "${SUPABASE_URL:-}" != "$SANDBOX_URL" ] || ! sandbox_key "$SERVICE" || ! sandbox_key "$ANON"; then
echo "sheet-assets-e2e: sandbox only, run it through pnpm e2e:sheet-assets" >&2
exit 2
fi
. scripts/rust-env.sh . scripts/rust-env.sh
SEED=supabase/seed/anatomical-sheets/equine/draft SEED=supabase/seed/anatomical-sheets/equine/draft
BIN=target/release/upload-sheet-assets BIN=target/release/upload-sheet-assets
FAIL=0 FAIL=0
env -u SUPABASE_SERVICE_ROLE_KEY cargo build --release --locked -q -p faunosteo-core --features upload --bin upload-sheet-assets || exit 2 env -u SUPABASE_SERVICE_ROLE_KEY 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; } LOCAL=http://127.0.0.1:57800
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 <name> <expected exit> <url> <key> <args...>; output kept to grep, keys never echoed.
expect() { expect() {
@@ -42,8 +56,8 @@ 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; } 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 "anon key refused" 1 "$LOCAL" "$ANON" "$SEED"
expect "wrong key refused" 1 "$LOCAL" "not-a-valid-key" "$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 "https refused" 1 "https://127.0.0.1:57800" "$SERVICE" "$SEED"
expect "non-local host refused" 1 "http://example.test:54321" "$SERVICE" "$SEED" expect "non-local host refused" 1 "http://example.test:57800" "$SERVICE" "$SEED"
expect "no port refused" 1 "http://127.0.0.1" "$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 "unreachable port" 3 "http://127.0.0.1:9" "$SERVICE" "$SEED"
expect "folder outside the seed" 1 "$LOCAL" "$SERVICE" --check crates/core/src expect "folder outside the seed" 1 "$LOCAL" "$SERVICE" --check crates/core/src