From 78aacc09e1e5810bb7d37fd41b5efbf3a2066fae Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 27 Oct 2026 14:44:03 +0100 Subject: [PATCH] chore(memory): DEV migration, db:test run 1, pgTAP fix, LRN-093 --- .claude/memory/journal.md | 4 ++++ .claude/memory/learnings.md | 6 ++++++ .claude/tasks/TODO.md | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 93ee4cd7..f1576213 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -446,3 +446,7 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp ## 2026-10-27 (V1-1.7 DEV preflight + backup + restore check, owner-authorized steps 0-3b) - Preflight ok (vault 0, D=21, 28+15 lines = 2026-10-26, M1-M3 pending). pg_dump + storage tar ok outside Git, mode 600, dump sha256 kept. - 3b run 1 exit 1: role supabase_functions_admin missing in sandbox. Owner authorized option A: NOLOGIN role sandbox only. Run 2 exit 0, empty log, 28+15 identical, scratch DB dropped, DEV unchanged. LRN-092. STOP: awaiting owner go for step 4. + +## 2026-10-27 (V1-1.7 M1-M3 on DEV, db:test, pgTAP 007/010 fix) +- Owner-authorized: migration up exit 0 (M1-M3 only), post checks ok. db:test DEV exit 1: 007 storage collision, 010 13 due purges; DEV unchanged. +- Fix 007/010 (owner option 2): sandbox B1 reproduced DEV failures, B2 latent (jobs, leftovers, stale uploads: 15 fails old). New: A + B PASS 921; 11 mutations detected A + B, same as old. Verifier + security gates. LRN-093. DEV rerun awaits owner go. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index 06227084..463c36d8 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -639,3 +639,9 @@ Apply: any restore check → real exit status from shell, every failing command Context: V1-1 step 3b, first run on real DEV dump. Filtered TOC (29 = D+8) right, but exit 1: `GRANT USAGE ON SCHEMA supabase_functions` names cluster role `supabase_functions_admin`, absent in sandbox (roles are cluster-level, not in dump). Rehearsal on sandbox dump (LRN-091) could not see it. Fix: NOLOGIN no-privilege role in sandbox only → exit 0, empty log, 28+15 identical. Apply: restore check on real dump before trusting rehearsal; roles named by ACL/owner entries must exist in target cluster (`--no-owner` needs name, not powers); never widen exclusions, fix the target; create minimal role, never copy login/CREATEROLE/password. + +## LRN-093 | 2026-10-27 | pgTAP on a used stack: global queue counts and fixed seed keys break; lease base work in-tx, scope to fixture + +Context: `db:test` on DEV after M1-M3. 007 inserted seed drawing key already uploaded (unique collision, 4 assertions never run); 010 counted 13 DEV due purge rows. Audit found more: claim_avatar_jobs takes oldest uploaded row, leftovers sweep whole bucket, expire_pending_uploads counts all stale rows. Clean sandbox / PGlite never show it. +Fix: 007 seed key in pg_temp table, confirmation cleared in-tx, insert only if absent + assertion "object once"; 010 section 0 leases base's due purges + jobs and expires stale uploads in-tx (capped loop) + setup assertion, leftovers by fixture key prefix. Proof: reproduce on sandbox with fictitious conditions first, mutation run (mutation + suite body in one rolled-back tx) on clean and loaded base, old vs new detection sets compared. +Apply: SQL test touching a worker queue or shared bucket → neutralise or scope pre-existing work inside the test tx, never count globally; validate on a sandbox seeded like the target before running on it. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index f8861d2a..2be89438 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -509,8 +509,11 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [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` + - [x] steps 0-3b run by Claude on the owner's authorization (2026-10-27): preflight = 2026-10-26, vault 0, D 21; dump + Storage tar in `~/faunosteo-backups` (600, dump sha256); restore check run 1 exit 1 (role `supabase_functions_admin` missing in the sandbox), owner option A (NOLOGIN role, sandbox only), run 2 exit 0, 28 + 15 lines identical; LRN-092 + - [x] step 4 run by Claude on the owner's authorization: `migration up` exit 0, exactly M1-M3; post.sql, counts deltas, types check all as expected; DEV data unchanged + - [ ] `pnpm db:test` on DEV: run 1 exit 1 (919 planned, 915 run, 914 passed: 007 storage collision, 010 13 due purge entries; 012-014 passed; DEV unchanged, pgtap absent after) + - [x] 007 + 010 made independent of the base's data (007: seed key only, confirmation cleared in-tx, 20 assertions; 010: section 0 leases the base's queued work in-tx, leftovers by fixture prefix, 141); sandbox A clean + B DEV-like and latent conditions: old FAIL reproduced, new PASS 921; 11 mutations detected on A and B (same set as the old suites); LRN-093 + - [ ] rerun on DEV on the owner's go - [ ] owner: browser acceptance on DEV (19 lines × FR/EN × computer/375 px) - [ ] after the owner's results: fixes if any (branch, gates, fresh verifier + security), CHANGELOG Unreleased, TODO closure, final report; merge only on the owner's explicit go - Owner cleanup (optional): rehearsal leftovers `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/8d6890e5-060c-431d-b99f-545f2e315333/scratchpad/rehearsal/` (3 small files, fictitious data); the backup folder `~/faunosteo-backups` is kept until the acceptance is validated