diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index c22a6418..9479f877 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -547,3 +547,4 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp ## 2026-11-11 - db:trial closure: code review + 2 fresh re-reviews fixed (d3bdbbe f2cbf68 953ae41). Strict absent match broke on real docker: inspect -f prints '\n' on stdout before stderr error; fresh re-review caught it, stub now splits streams. GATE 0 MET, harness 372/0, plan read-only: create would proceed. Stopped before create, owner go pending. +- db:trial first create 2026-11-11 at 255dd67 (owner go): 6 containers, net, 2 volumes as planned, loopback ports only, DEV and sandbox unchanged, 17 migrations, equine draft equal. Interrupted at check 3: TR_PW in db container log, image migrate.sh ALTER USER logged during init. LRN-123..126 written. Owner decision pending. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index 097e3485..fd2f9fc7 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -832,3 +832,49 @@ Observation, not a routine: worktree held uncommitted format-only Prettier chang - **Context**: V1-2.6 U1 Lot I. Implementer wait loop `while pgrep -f 'playwright.shell.config'; do sleep …; done` never ended: `pgrep -f` matched the loop's own shell command line, which contains the pattern. - **Rule**: `pgrep -f` pattern must not match the caller: bracket trick `pgrep -f '[p]laywright.shell.config'`, or wait on a known PID (`wait $pid`, `kill -0`), or the harness Monitor / background notification. - **Apply**: any wait-for-process loop in briefs and scripts. + +## LRN-123 — docker inspect -f failure: bare newline on stdout, error sentence on stderr (2026-11-11) +Context: db:trial absent detection, `resource_exists` in scripts/db-trial.sh. Measured 2026-11-11 on this machine: docker client 29.9.3, rootless daemon 29.9.2, read-only inspect of absent name `faunosteo_probe_absent`. + +Fact (demonstrated): `docker inspect -f '{{...}}' ` -> rc 1, stdout exactly "\n" (template inspector flush), stderr one sentence: +- container: `Error response from daemon: No such container: ` +- volume: `Error response from daemon: get : no such volume` +- network: `Error response from daemon: network not found` +- image: `Error response from daemon: No such image: ` +Daemon unreachable: stdout also "\n", stderr = dial error. + +Trap: `out="$(docker ... inspect -f ... 2>&1)"` then exact compare never matches (leading "\n"): every absent resource refused. Shipped in a fix round, stub printed stderr line only, 353 green tests missed it; fresh re-review caught it (d3bdbbe history). + +Apply: absent = rc != 0 AND stderr alone (`2>&1 >/dev/null`) equals the per-kind sentence; anything else refuses. Stubs reproduce both streams (control: merged compare restored -> 288 harness fails). Measure real tool output stream by stream before freezing it in a stub. + +Limit: sentences proven on this version pair only; a Docker upgrade may reword them (absent_answer then refuses everything, fail-closed). + +## LRN-124 — bash 5.3 EXIT trap sees exit status 0 after SIGTERM (2026-11-11) +Context: db:trial backup_now EXIT trap (scripts/db-trial.sh ~1170 comment), lot B2. + +Fact (demonstrated 2026-11-11, GNU bash 5.3.9): script with `trap '...' EXIT` and no TERM trap, killed by SIGTERM -> EXIT trap runs, `$?` inside it is 0, process still exits 143. With `trap 'exit 143' TERM` the EXIT trap sees 143. +Repro: `bash -c 'trap "echo \$?" EXIT; kill -TERM $$; sleep 2'` prints 0. + +Apply: never decide success/failure from `$?` in an EXIT trap. Clear the trap on success (`trap - EXIT`) so any run of it means failure, or set a status variable, or add `trap 'exit 143' TERM` / `trap 'exit 130' INT`. + +Limit: only bash 5.3.9 tested; other versions unproven. + +## LRN-125 — psql single-transaction commits a truncated piped script (documented, unproven here) (2026-11-11) +Context: db:trial rotation and grant SQL (scripts/db-trial.sh ~1525 comment; plan .claude/tasks/plans/2026-11-09-db-trial-stack.md B2/B3 records). + +Rule (NOT demonstrated here, derived from psql's documented behaviour): `psql --single-transaction` / `-1` wraps the whole input in BEGIN ... COMMIT. If the producer of stdin dies mid-script (pipe closed early), psql sees EOF and sends COMMIT: the truncated prefix commits. ON_ERROR_STOP stops on SQL errors only, never on a short input. + +Apply: for multi-statement writes fed through a pipe, write explicit `begin;` ... `commit;` in the script itself (a truncated script then never reaches its commit and rolls back on disconnect), plus a commit marker checked afterwards when the outcome matters (db-trial rotation digest marker). + +Limit: no run in this project reproduced the truncation; treat as design rule pending a real psql test. Note: seed_equine still uses `sb_psql --single-transaction < file` (file input, not a pipe: lower risk). + +## LRN-126 — Docker daemon-down error contains no such file or directory (2026-11-11) +Context: db:trial daemon-down handling. Measured 2026-11-11, docker client 29.9.3, DOCKER_HOST=unix:///nonexistent/docker.sock. + +Fact (demonstrated): every docker call with no daemon -> rc 1, stderr `failed to connect to the docker API at unix:///nonexistent/docker.sock; check if the path is correct and if the daemon is running: dial unix /nonexistent/docker.sock: connect: no such file or directory`. + +Trap: substring tests like `*"no such"*` (meant for "No such container" / "no such volume") also match the dial error: daemon-down reads as "absent". On destructive paths (destroy, restore) that meant deleting live state or extracting into a non-empty volume. + +Apply: never classify Docker errors by substring; exact whole-sentence match per kind on stderr, everything else refuses (see the inspect -f learning). + +Limit: wording of this client version only. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 9ed3cd32..50153d87 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -694,8 +694,13 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [ ] Test anomaly A (owner 2026-11-09, separate from U1/U2): fictitious fingerprints `'a'.repeat(64)` from worker stand-ins (`packages/supabase/tests/sandbox/sheet-fixtures.ts:115` openRound, `sheets-concurrency.sandbox.ts:168`, `sheets-perf.sandbox.ts:169`); 7 published/deprecated sandbox versions fail `check_published`. Fix: real fingerprint through the core (as e2e `fingerprintOf`, `apps/app/e2e/support/catalogue.ts:88`); never weaken the publish gate or the reader check. Needs its own go. - [ ] Test anomaly B (owner 2026-11-09, separate from U1/U2): `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts:181-195` creates the historical working copy and never archives it; slot taken → `admin.spec.ts:717` fails x4. Fix test independence and cleanup; the existing copy `8c315a12-20d4-4432-9db3-7cb88b27a5b4` stays untouched until the owner authorises. Linked: RR-13, the admin.spec confirmation line above. - [ ] Test anomaly C (owner 2026-11-09, separate from U1/U2): integrity failure invisible in catalogue cards; implemented as lot R4; failure shown, never hidden or bypassed. - - [ ] Dedicated persistent manual trial stack (owner 2026-11-09, D8; brief « Après R0 — Implémentation technique », contract .claude/tasks/contracts/2026-11-09-db-trial-stack-1809.md): [x] lot A suites' guard · [x] lot A2 trial dev server target (R13) · [x] lot B1 foundation · [x] lot B2 backups, restore, migrate, rotation · [x] lot B3 accounts, grants, drawings, app · [x] lot C docs · [x] reviews (verifier ECARTS owner-gated only, security PASS, code review + 2 re-reviews fixed: d3bdbbe, f2cbf68) · [ ] creation checkpoint (owner go before any create) + - [ ] Dedicated persistent manual trial stack (owner 2026-11-09, D8; brief « Après R0 — Implémentation technique », contract .claude/tasks/contracts/2026-11-09-db-trial-stack-1809.md): [x] lot A suites' guard · [x] lot A2 trial dev server target (R13) · [x] lot B1 foundation · [x] lot B2 backups, restore, migrate, rotation · [x] lot B3 accounts, grants, drawings, app · [x] lot C docs · [x] reviews (verifier ECARTS owner-gated only, security PASS, code review + 2 re-reviews fixed: d3bdbbe, f2cbf68) · [x] first create 2026-11-11 at 255dd67 (owner go) · [ ] post-create checks: INTERRUPTED at check 3, TR_PW in the db container log (image migrate.sh), owner decision pending - shortcut: `pnpm db:trial app` takes no lock (scripts/db-trial.sh, comment above cmd_app): stop, backup, migrate, destroy, restore or rotate-* started in another terminal in the second before Vite listens on 5194 goes ahead. Upgrade: a dedicated app lock, shared by app and exclusive for those commands. + - [ ] init log leak: the image's /docker-entrypoint-initdb.d/migrate.sh runs `ALTER USER supabase_admin WITH PASSWORD '…'` while the init server logs statements, before /etc/postgresql.schema.sql (db container log line 379); fix for any future create, and decide the cleanup of the current container log + - [ ] arbitration 1: narrow the file-wide `# shellcheck disable=SC2016` of db-trial-check.sh to its lines; a readable reason on every directive + - [ ] arbitration 2: LAN Playwright environment check proves target, container or service, key issuer and no DEV fallback before connecting (5193 vs 5194 explained and checked) + - [ ] arbitration 3: rotate-secrets revokes refresh tokens and handles old access JWTs, tested on the real stack before it is enabled, else it refuses with the limit documented + - [ ] arbitration 4: destroy refused by default without a backup proved by an isolated restore (PostgreSQL and Storage); explicit controlled procedure for an instance proved empty - [ ] Rights screen lists every catalogue grant unbounded (list_catalog_grants, GrantList): 2 306 rows crash axe at 8 workers on a long-lived sandbox. Owner 2026-11-09 (BDR-106): own priority track RR-13, separate from U1 and U2, not implemented now. - [ ] V1-2.6 UX complement « annotations ↔ constats » (owner brief 2026-11-06 « Nouvelle exigence UX : navigation bidirectionnelle »; contract `.claude/tasks/contracts/2026-11-06-v1-2-6-findings-nav-design.md`; design only, U1 plan untouched, no code, no DEV): [x] relations audit (one link `finding_zone_id`, no new association, equine draft 1:1) · [x] boards 17-22 `docs/design/v1-2-6-constats/` · [x] study `docs/development/V1-2-6_UX_FINDINGS_NAV.md` (no U1 integration point needed, sub-step U2b proposed, risks, tests, decisions F1-F21) · [x] fresh design review APPROVE WITH FIXES (3 MUST-FIX, 16 SHOULD), fixes applied · [x] fresh verifier ECARTS(4) → ECARTS(2) → CONFORME 9/9 (round 3; 567da67 came after it, not covered) · [x] owner principle validation 2026-11-06 (brief « Validation de principe U2b et préparation des checkpoints », BDR-103): U2b retained after U2 and before U3, F1/F2/F6/F8/F22 approved, F7 for the term « Famille », F3/F4 in part · [x] decisions F1-F22 table (alternatives, consequences, state), F2 groups vs leaves, F3 field list, F4 view semantics, boards with their decisions in study §7.4, U2b entry in `V1-2-6_UX_PLAN.md` §3, LRN-119 (``), contract `.claude/tasks/contracts/2026-11-06-v1-2-6-findings-nav-decisions.md` · [x] fresh verifier on that contract: ECARTS(9) → fixed → CONFORME 11/11 (6 observations outside criteria kept for the owner) · [x] owner 2026-11-06 (brief « U1 / U2b — Derniers arbitrages avant implémentation », BDR-104): F2 leaves, F3, F4 model A, F8, F22 decided; study §6-§7 updated · [x] owner: F5, F9-F21 approved as recommended, precisions F3, F8, F11-F14, F22 (brief « Ratification finale U1 … », 2026-11-06, BDR-105); study header, §6 tests, §7 table, 7.2, 7.3, UX PLAN U2b entry, REVUE, DECISIONS pointer updated; no implementation · [ ] U2b authorisation (after U2, before U3) - [ ] follow-up candidates (owner T14): multi-tab notice; RR item for the rollback limit of the category model (new id, reconcile with develop) diff --git a/.claude/tasks/contracts/2026-11-09-db-trial-stack-1809.md b/.claude/tasks/contracts/2026-11-09-db-trial-stack-1809.md index 153c3dd5..69a62b0c 100644 --- a/.claude/tasks/contracts/2026-11-09-db-trial-stack-1809.md +++ b/.claude/tasks/contracts/2026-11-09-db-trial-stack-1809.md @@ -146,6 +146,23 @@ protected prior backup, app address recomputed at each launch, ss checked explic static or simulated checks only: no real create/start/stop/migration/restore/destroy/rotation, no DEV or sandbox, no merge or deploy; a script's interactive confirmation is never the owner's prior authorisation. [gated 2026-11-10] +Q: owner arbitrations at the creation checkpoint (HEAD 255dd67) / A: (1) shellcheck: the 15 directives are allowed +for demonstrated false positives only, with minimal scope and a readable reason, global shellcheck clean, no other +diagnostic masked (the file-wide SC2016 at the top of db-trial-check.sh does not qualify: to narrow). (2) LAN +Playwright: before any LAN test the environment check proves the expected target, the container or service really +used, the key issuer and that DEV cannot be reached; a port is no identity; 5193 vs 5194 explained and checked; any +ambiguity refuses before connecting. (3) rotate-secrets: existing sessions invalidated, users sign in again: +refresh tokens actually revoked and old access JWTs handled (revoking a session is not invalidating a JWT); real +behaviour tested before the command is enabled, else it refuses and the limit is documented; DEV accounts and +secrets untouched. (4) destroy: refused by default for keepable data without a backup verified by an isolated +restore, PostgreSQL and Storage both; a backup file is never proof of restore; an explicit controlled procedure for +an instance proved empty; no destroy in this step. (5) GO for the first create of faunosteo_trial only, after +worktree/HEAD, Docker context/daemon, no overwrite, no concurrent run, static checks on the final code and proof +that create depends on neither rotate-secrets, destroy nor the LAN test; then immediate checks 1-10; an exposed +secret, a DEV target or a failed critical check interrupts, no optional step, real state reported, no secret shown. +No merge, deploy, DEV change or DEV secret, no rotate-secrets before its validation, no destroy, no new network +exposure, no DEV worker. [gated 2026-11-11] + ## ACCEPTANCE CRITERIA 1. `pnpm db:trial` (root `package.json`) runs `scripts/db-trial.sh` with the commands of TRIAL_STACK.md §4 (`create`, `start`, `stop`, `status`, `migrate`, `backup`, `rotate-keys`, `rotate-secrets`, `app`, `account `,