feat(supabase): db:trial foundation (plan, create, start, stop, status)

scripts/db-trial.sh builds the persistent manual trial stack on
literal faunosteo_trial_* names, loopback 58xxx ports, named volumes
and a 700 state folder outside any git work tree; it refuses
SANDBOX_* variables, a remote Docker daemon, a missing or failing
ss, and checks each container's exact loopback publication and the
gateway identity. The stub harness (scripts/db-trial-check.sh,
87 cases, no daemon reachable) proves it; db-sandbox.sh refuses a
trial state folder (additions only). Nothing is created here.
This commit is contained in:
bchanot committed 2026-11-10 14:05:56 +01:00
1 parent 9f60d841eb
commit 1a7b952f2f
6 files changed
+1712 -2

No files matched your search

@@ -2242,7 +2242,8 @@ expect_run() { # name port inner memory pids [volume]
if [ -n "${6:-}" ]; then grep -qF -- " -v $6 " <<<"$line"; else ! grep -qE -- ' -v ' <<<"$line"; fi
}
# Resource names plus the Supabase roles and the migrations schema that SQL text in argv may name.
ALLOWED_NAMES='faunosteo_trial_(db|mail|auth|storage|rest|gateway|helper|net)|supabase_(admin|auth_admin|storage_admin|migrations)'
# faunosteo_stack and faunosteo_trial: the gateway identity path and body (/__faunosteo_stack answers faunosteo_trial), not resource names.
ALLOWED_NAMES='faunosteo_trial_(db|mail|auth|storage|rest|gateway|helper|net)|supabase_(admin|auth_admin|storage_admin|migrations)|faunosteo_stack|faunosteo_trial'
only_trial_names() { ! docker_calls | grep -oE '(faunosteo|supabase)_[A-Za-z0-9_]+' | grep -vxE "$ALLOWED_NAMES" | grep -q .; }
no_volume_removal() { ! log_has 'docker volume rm'; }
line_of() { grep -nF -- "$1" "$CASE/log" | head -n 1 | cut -d: -f1; }
@@ -2448,6 +2449,24 @@ echo "-- $PASS passed, $FAIL failed"
if [ "$FAIL" -eq 0 ] && [ "$PASS" -gt 0 ]; then echo "db-trial-check: ALL PASS"; else exit 1; fi
```
#### Lot B1 review fixes (2026-11-10)
The files `scripts/db-trial.sh` and `scripts/db-trial-check.sh` intentionally differ from the B1 code blocks above:
- Harness: the equine-seed check is two checks (`stdin_has`, `stdin_lacks`); no unquoted `$stdin`, no read of the harness stdin.
- Harness: `verify_stub_shadow` runs in every `run_script` with the case's own PATH (ss: the stub, or absent for the ss-absent case); a mismatch prints the reason and exits 1 for the whole run. PATH is applied after EXTRA; a PATH in EXTRA is refused.
- `new_secrets_file`: written to `<file>.new` under umask 077, then `mv -f`; `.new` removed on failure.
- Git guard: `refuse_inside_git` refuses a `.git` entry (file or folder) in any ancestor, then asks git with GIT_DIR, GIT_WORK_TREE and GIT_CEILING_DIRECTORIES unset (a subshell `unset`, not `env -u`: the harness `env` wrapper logs argv); only "not a git repository" (exit 128) is outside, any other answer dies.
- `container_exists`, `volume_exists`, `network_exists` go through `resource_exists`: only an error matching, case-insensitively, "no such" or "not found" is absent (real wordings: `No such container: x`, `get x: no such volume`, `network x not found`), any other inspect error dies naming the resource. Docker stub: absent answers those three real wordings, `volume create` is idempotent, `fail/inspect-error`, `fail/helper` and `fail/networks-create-after` modes.
- `create_state_folder`: lock taken right after mkdir and chmod, `secrets.env` check repeated under it, marker written after.
- `FIRST_RESOURCE=yes` is set before `docker network create`; `create_stopped` then removes the state files only when no faunosteo_trial_ resource exists (existing case kept), else names what is present.
- `take_lock` opens `.lock` under umask 077 (harness asserts 600).
- `require_local_daemon` prints the endpoint without anything up to the last `@`.
- `check_helper_image` message names its two causes and the `docker rm` way out.
- `cmd_plan`, `cmd_create`, `cmd_status`, `status_database` split into helpers (`plan_*`, `create_*`, `status_*`), same output; plan sections append refusals through a nameref array.
- Harness header: `hold_port` opens real loopback listeners on 58801, 5194 and 58300 for up to 30 s, closed at cleanup.
- Kept for B2/B3: `client_key`, `gateway_identity`, `key_identity`, `restart_gateway` and the other helpers; no B2/B3 block relies on a changed behaviour (`new_secrets_file "$next" || true` stays correct).
---
### Lot B2: backup, restore, destroy, migrate, rotate-keys, rotate-secrets