From 545a161f69dc05f00a88471be0eeb7b8c2541a3b Mon Sep 17 00:00:00 2001 From: bchanot Date: Mon, 26 Oct 2026 22:00:52 +0100 Subject: [PATCH] chore(memory): restore check rehearsal 2, LRN-091 --- .claude/memory/journal.md | 4 ++++ .claude/memory/learnings.md | 5 +++++ .claude/tasks/TODO.md | 1 + 3 files changed, 10 insertions(+) diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 5e8a01fe..ee47ca0e 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -438,3 +438,7 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp ## 2026-10-26 (V1-1.7 owner brief: preflight accepted) - Owner accepted preflight, keeps backup/restore/migration/acceptance. Classified 26 restore errors: pg_restore errors, not negative tests (18 ALTER DEFAULT PRIVILEGES, 7 GRANT ... WITH GRANT OPTION, 1 COPY vault.secrets). DEV vault 0 (read-only check). - §3.3 hardened: pg_restore exit + full message/command set, vault count, exit codes, pgtap after db:test, object query. Exit status of earlier rehearsal not recorded. STOP: owner runs steps 0-4. + +## 2026-10-26 (V1-1.7 restore check closed before owner run) +- 26 vs 28: my report double-counted (pg_reload_conf/pg_stat_statements_reset inside "7 GRANT"); log = 26. Rehearsal 2 sandbox, 4 variants, real exit codes; retained filtered TOC + single transaction, exit 0, rows + privileges identical. DEV D=21 → 29 exclusions expected. +- §3.3 step 2/3b rewritten, replayed verbatim on sandbox. LRN-091. STOP: owner runs steps 0-4. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index 98b58ec4..ff3f8b43 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -629,3 +629,8 @@ Apply: suites that proxy requests in route handlers → unrouteAll ignoreErrors Context: V1-1 DEV preflight, CLI read from bundled binary strings, not docs. (1) `supabase test db` runs `create extension if not exists pgtap with schema extensions`, then `drop extension if exists pgtap` only when absent before: transient DDL; interrupted run leaves pgtap. (2) `supabase status` default output prints SERVICE_ROLE_KEY, SECRET_KEY, JWT_SECRET; `-o env | grep '^API_URL='` safe. (3) `pnpm db:types:check` without `-s` adds 2 `>` header lines from pnpm → count drift with `pnpm -s`. (4) pg_dump -Fc of `postgres` restored `--no-owner` into scratch db of same image: 26 privilege refusals only (vault, pg_stat_statements_reset, pg_reload_conf, default privileges, grant options); md5 of `t::text` per table (timezone UTC) identical after restore → good restore proof. (5) Storage file backend keeps bytes in container volume `/mnt`; DEV had 11 files for 2 rows (reset leftovers). Apply: any procedure on DEV → read CLI behaviour from installed binary; read-only SQL via PGOPTIONS default_transaction_read_only; compare fingerprints, not only counts. + +## LRN-091 | 2026-10-26 | Restore with "expected errors" never validated by message count; filter TOC, exit 0 + +Context: V1-1 restore check. LRN-090 (4) called 26 pg_restore errors "privilege refusals" and report double-counted them (28): wrong frame. Real: 26 TOC entries `postgres` cannot replay under `--no-owner` on same Supabase image: 18 DEFAULT ACL of supabase_admin/supabase_auth_admin, 5 vault ACL (grant option to self), ACL pg_reload_conf + pg_stat_statements_reset, COPY vault.secrets = data load fail, lossless only with vault empty. Each failing entry also carries other grants (service_role, anon). `--no-acl` loses app grants; `--exit-on-error` alone stops at COPY. Fix: `pg_restore --list` → exclude exact entries by anchored regex → count per kind must equal catalog prediction (D default ACL rows + 8) → `--use-list --single-transaction --exit-on-error` → exit 0, empty log, rows md5 + effective ACL (`acldefault`) identical. pg_dump drops ACL equal to default → compare effective, not stored. Expected count is per-instance: DEV D=21 vs sandbox 18 (supabase_functions schema). +Apply: any restore check → real exit status from shell, every failing command classified (object, cause, data impact), conditions explicit (empty table), prefer filtered TOC with exit 0; derive expected exclusions from target catalog, never from rehearsal host; never widen pattern to go green. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 608bbfd6..f8861d2a 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -508,6 +508,7 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [x] scripts read: supabase.sh / dev-env.sh (local CLI, no remote), CLI 2.120.0 `test db` creates + drops pgtap, `supabase status` prints keys, e2e:avatar writes beyond its fixture (temp account, bob sign-in, purge-queue drain) - [x] SUPABASE.md §3.3 corrected: read-only helpers, counts + md5 fingerprints, Storage bytes tar, restore check on the sandbox (not the DEV server), post-migration SQL, test effects, failure handling, restore effects; browser acceptance aligned on the brief §11 (19 lines); restore comparison rehearsed on the sandbox (identical, 26 privilege refusals) - [x] owner brief 2026-10-26 « V1-1.7 validation du préflight »: preflight accepted, owner runs backup + M1-M3. 26 restore errors classified = pg_restore errors, NOT negative tests (25 ACL on Supabase-managed objects + COPY vault.secrets, lossless only with vault empty); §3.3 now checks pg_restore exit (1) + full message/command set, vault count (step 2), migration up + db:test exit, pgtap after db:test, object query for failure; acceptance lines 9 (no duplicate current relation) and 17 (session change, same browser) + - [x] owner brief « dernière correction de la validation des sauvegardes »: 26 vs 28 = report double count (log has 26); rehearsal 2 on sandbox (156 MB, 4 variants, real exit codes): `--no-owner` exit 1 / 26 errors, `--no-acl` exit 1 + app grants lost, `--exit-on-error` exit 1 at COPY, filtered TOC + `--single-transaction --exit-on-error` exit 0, 28 rows + 15 privilege lines identical; §3.3 step 2 adds privs.sql + managed.sql (vault 0, D default ACL), step 3b = filtered list (D + 8 entries, DEV D=21 → 29), doc block replayed verbatim exit 0; DEV + sandbox unchanged; LRN-091 - [ ] owner: steps 0-3b of SUPABASE.md §3.3 (backup + restore check) - [ ] owner: step 4 `pnpm supabase migration up --local`, then the post-migration checks and `pnpm db:test` - [ ] owner: browser acceptance on DEV (19 lines × FR/EN × computer/375 px)