fix(supabase): db:trial closure review fixes

Strict absent detection (stderr sentence per kind, measured on Docker 29.9.3), tri-state container_running, empty-volume check before restore, quieter DB init and rotation logging, backup/migrate refuse while the app runs, lock first in start/stop, truthful rotate-secrets and post-create checks. Stub reproduces Docker's stdout/stderr split. Harness 364/0.
This commit is contained in:
bchanot committed 2026-11-11 14:16:32 +01:00
1 parent a78da9f4e2
commit d3bdbbe0ba
5 files changed
+357 -54

No files matched your search

@@ -3571,6 +3571,38 @@ bash scripts/db-trial-check.sh # environment-free checks of db:trial and the db
image, default logging, the async Vite config and its port guard at the first real `app` and the next
`db:sandbox trial`). STOP; no `create`.
#### Closure code-review fixes (2026-11-11)
1. `resource_exists`: absent only on the daemon's whole sentence for that name (`absent_answer`); the stub's `fail/daemon` fails every docker call with the real dial error; `plan` skips the resource listing with the daemon down.
2. `container_running` tri-state (an inspect error dies); `backup_now` refuses when a container still runs after the stop; `status_containers` reads through `container_exists`.
3. `restore`: each fresh volume is checked empty by the helper before the extraction (`volume_is_empty`).
4. `rotate-secrets` final message: old access tokens refused, refresh tokens and sessions stay valid.
5. `DB_INIT` and the rotation SQL: `\set VERBOSITY terse`, `log_statement`, `log_min_duration_statement` and `pgaudit.log` off before the first value-carrying statement.
6. `backup` and `migrate` call `refuse_while_app_runs`.
7. `restore` and `rotate-secrets` check `trial_host` before the confirmation and the backup.
8. `start` and `stop` lock before reading conf and secrets.
9. `grant owner|admin` for an address with no account refuses with the account hint (`no_account` marker from the factor-count SQL).
10. `SUPABASE.md` §5.2: rotate-secrets wording, no avatar worker, two post-create checks, backup and migrate rows.
Harness cases added: daemon lost mid-command (create on container, network and volume inspects, destroy, restore), plan with the daemon down lists nothing, inspect failing during the stop, container still running after the stop, non-empty volume at extraction, helper emptiness check order, backup and migrate refused while the app runs, unusable app host for restore and rotate-secrets, start and stop lock first, grant with no account (owner, admin), final rotate message, DB_INIT and rotation SQL lines and order.
#### Closure re-review fixes (2026-11-11)
Measured on Docker 29.9.3: a failing `inspect -f` (absent resource or lost daemon) exits 1, writes one newline to stdout and the sentence to stderr (container `No such container: <name>`, volume `get <name>: no such volume`, network `network <name> not found`, image `No such image: <name>`; a lost daemon: `failed to connect to the docker API at <DOCKER_HOST>; ...`).
- C1: `resource_exists` and `container_running` judge stderr alone against `absent_answer` (the merged `2>&1` compare refused every absent resource); `container_running` checks existence first, then reads the state apart. Other docker calls merging `2>&1` audited, none compared with a docker sentence.
- C2: `first_absent_image` goes through `image_exists` (strict); a lost daemon refuses ("cannot tell whether its images are present") instead of "docker pull it"; `check_backup` refuses when that helper dies.
- C3: stub: every failing inspect, four kinds, writes `"\n"` to stdout and the sentence to stderr; image honours the daemon-lost hooks; new hook `daemon-lost-after-create`; header comment updated.
- I1: SUPABASE.md: signing out right after `rotate-secrets` does not end a session (auth-js 2.117.3 ignores the 401/403 of `/logout`); the app's scope is `global`; sign in again, then sign out; revocation by the script is an owner decision not taken.
- M1: refusing-while-app-runs lists now include `backup` and `migrate` (SUPABASE.md, TRIAL_STACK.md); the `cmd_app` shortcut comment rewritten.
- M2: post-create checks: `pg_authid` as `supabase_admin`, secrets scanned through `grep -cFf <(sed ...)`, the server log location read with `show logging_collector; show log_directory; show log_destination;`, what to do above 0, unproven items added.
- M3: `set pg_stat_statements.track_utility = off;` in `DB_INIT` and `set local ...` in the rotation SQL.
- M4: `backup_failed` takes the stack's fate as an optional third argument; "still runs after the stop" no longer says it stays stopped.
- M5: `inspect_refused` shows Docker's answer (quoted, 200 characters), "unexpected value" wording, hint `docker info`.
- M6: create's EXIT trap prints a hint when its listing fails; destroy's way-out line says when a listing failed.
- M7: `cmd_start` checks `trial_host` before starting or recreating a container.
- H: `lines_before_first` checks order; the rotation check asserts every silencing line; the tautological `! grep "already exists"` replaced by one that can fail; cases: stream split of the stub, plan, create, backup and status on stub-absent resources, create with the daemon lost after the first resource, restore with the daemon lost, start with no usable host.
## Review record (orchestrator)
Each reviewer was a fresh subagent; each fix round went to a fresh executor; the orchestrator re-ran the checks