chore(memory): anomaly B fixed, contract and plan

This commit is contained in:
bchanot committed 2026-11-12 17:06:53 +01:00
1 parent 2cdee42fe1
commit f873e06413
3 files changed
+188 -1

No files matched your search

+2 -1
View File
@@ -703,7 +703,8 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet
- [ ] R2.4 finding panel (filtered, Modifier, Retirer de ce constat, Aller à, Tout afficher, 34 rem, slide, reduced motion, inert through exit, focus return)
- [ ] R2.5 tests and non-regressions (unit, e2e:ui, e2e:shell on db:sandbox, axe, keyboard walk, layout widths)
- [ ] R2.6 docs, FR/EN label table, Rust exception (Part II), db:trial manual protocol, closure
- [ ] Anomaly B (owner 2026-11-12, decision C): `admin.spec.ts` « admin screens: axe and no sideways scroll » (4 failures: 2 locales × 2 viewports) depends on the historical sheet's free working-copy slot, taken on the sandbox by `sheets-admin.sandbox.ts:181-195` (copy `8c315a12-…`, never archived). Fix in its own commit with proof the 4 failures are gone; isolated reproducible fixture, no existing data deleted; stop and present options if impossible without a destructive op or a scope change
- [x] Anomaly B FIXED `2cdee42` (owner 2026-11-12 « Décision sur l'anomalie E2E », option 1): dialog checks moved to e2e:ui on the real WorkingCopyAction (`e2e/harness/working-copy.*`, `e2e/ui/working-copy.spec.ts`), shell keeps the historical page + state-consistent button check, sandbox suite archives only its own copies (`returning id` checked). Before 4 failed; after 4 passed ×2; full admin.spec 16 passed / 8 skipped; e2e:ui 251 ×2; sandbox sheets-admin 5/5; pre-existing anatomical_sheets rows identical per id (637 → 643, 6 added by A1). Verifier CONFORME, security PASS (1 LOW: optional uuid check before interpolation). Open: cleanup creation branch not run on a fresh stack; free branch of the shell check not run on this sandbox; `editor-equine.spec.ts` set-aside still archives and restores pre-existing copies (8c315a12 included, updated_at 2026-11-12 13:40 from the R1 follow-up run): owner decision. R2.0 waits for the owner's green light on this result
- [x] (was) Anomaly B (owner 2026-11-12, decision C): `admin.spec.ts` « admin screens: axe and no sideways scroll » (4 failures: 2 locales × 2 viewports) depends on the historical sheet's free working-copy slot, taken on the sandbox by `sheets-admin.sandbox.ts:181-195` (copy `8c315a12-…`, never archived). Fix in its own commit with proof the 4 failures are gone; isolated reproducible fixture, no existing data deleted; stop and present options if impossible without a destructive op or a scope change
- [ ] R3 sheet list: search + name sort first; date, date sort and « most recent » home card only after the dedicated SQL checkpoint `docs/development/V1-2-6_R3_SQL_CHECKPOINT.md` (A7 ratified 2026-11-09; never a creation date shown as modification date)
- [ ] R4 catalogue card integrity warning (independent fix, = anomaly C): `useCardDetails.ts` drops a failed `loadVersion` silently; UI only, check never bypassed
- [ ] owner arbitrations A1-A15 (`V1-2-6_U1_CORRECTIONS.md` §6, `TRIAL_STACK.md` §6)
@@ -0,0 +1,113 @@
# CONTRACT — anomaly-b-working-copy-dialog
- date: 2026-11-12 | flow: bugfix | branch: feature/v1-2-anatomical-sheets
- status: active
- plan: .claude/tasks/plans/2026-11-12-anomaly-b-working-copy-dialog-1530.md (rev 2)
## REQUEST (verbatim — IMMUTABLE)
# FAUNOSTEO V1-2.6 — Décision sur l'anomalie E2E
Je valide l'OPTION 1 : déplacer les contrôles d'accessibilité et de mise en page du dialogue « Créer une copie de travail » dans e2e:ui.
Le diagnostic est accepté : seule la fiche historique peut servir de source à une copie de travail, et une seule copie active est autorisée. Nous ne devons pas modifier cette règle métier pour les tests.
## 1. Correctif autorisé
- Utiliser le véritable composant WorkingCopyAction dans e2e:ui, avec une situation simulant une place disponible.
- Vérifier le dialogue dans les deux langues et les deux largeurs prévues.
- Conserver les assertions axe, focus, navigation clavier et absence de défilement horizontal.
- Vérifier que le comportement testé correspond au composant réellement utilisé dans l'application.
- Conserver dans e2e:shell les contrôles de la page historique et son accessibilité, sans dépendre de la disponibilité de sa copie de travail.
- Ne pas affaiblir les assertions existantes : les déplacer vers la couche appropriée et documenter le changement de couverture.
## 2. Nettoyage des fixtures
La suite sandbox peut archiver exclusivement les copies qu'elle crée elle-même.
Le nettoyage doit être limité aux ressources identifiées comme appartenant à l'exécution courante, avec gestion des échecs lorsque c'est possible.
Ne jamais archiver ou modifier la copie préexistante 8c315a12-… ni une autre ressource préexistante.
Ne pas réinitialiser la sandbox.
## 3. Vérifications
- Les quatre variantes précédemment défaillantes doivent réussir.
- Exécuter au moins deux passages pour démontrer la reproductibilité.
- Vérifier les contrôles du vrai composant dans e2e:ui.
- Vérifier que la page historique reste couverte dans e2e:shell.
- Vérifier que les refus et contraintes serveur restent couverts par les tests sandbox.
- Documenter explicitement la limite : le dialogue n'est plus testé dans son contexte serveur réel par ce test d'accessibilité.
- Effectuer une revue fonctionnelle et une revue indépendante du code.
Si une assertion essentielle ne peut pas être préservée, s'arrêter et présenter le problème.
## 4. Restrictions
Aucune migration SQL.
Aucune modification des règles de copie de travail.
Aucune modification de données existantes, y compris 8c315a12-….
Aucun test automatisé sur db:trial ou DEV.
Aucune fusion ni aucun déploiement.
Préserver le fichier de revue ChatGPT non suivi.
Isoler le correctif dans un commit indépendant, puis pousser.
## 5. Checkpoint
Fournir :
- Le détail des assertions déplacées.
- Les résultats avant/après.
- Les résultats des deux passages.
- Les contrôles d'accessibilité conservés.
- La preuve que les ressources préexistantes sont intactes.
- Les éventuelles limites de couverture.
- Les commits et l'état Git.
S'arrêter après ce correctif.
R1 est définitivement validé par le propriétaire.
Le plan R2 est approuvé, mais ne commencer R2.0 qu'après mon nouveau feu vert sur le résultat du correctif.
## CLARIFICATIONS
Q: tests environment? / A: e2e:ui local (no backend); e2e:shell and sandbox suite only through `pnpm db:sandbox` (faunosteo_dbsandbox_*, already up); never db:trial, DEV, `up`/`down`/`reset`/`trial*`.
Q: run editor-equine? / A: no (its set-aside archives and restores pre-existing copies); reported to the owner.
Q: data proof? / A: per-id snapshot (id, status, archived_at, updated_at) of every pre-existing anatomical_sheets row before and after; new rows allowed.
Q: Tab walk vs Dialog contract? / A: explicit order with one 'browser' step (LRN-082), like dialog.spec.ts; not "stays inside".
## ACCEPTANCE CRITERIA
1. Harness renders the real WorkingCopyAction (free + taken, StrictMode, MemoryRouter, ?lang) and a new e2e:ui spec covers fr/en on both projects: axe, overflow, panel in viewport, keyboard open, prefilled slug, explicit Tab/Shift+Tab walk, Escape + focus return, taken button disabled with its reason.
CHECK: cd /home/bchanot/Documents/faunosteo-v1-2/apps/app && test -f e2e/harness/working-copy.html && grep -q "WorkingCopyAction" e2e/harness/working-copy.tsx && grep -q "StrictMode" e2e/harness/working-copy.tsx && grep -q "MemoryRouter" e2e/harness/working-copy.tsx && grep -q "faunosteo-cheval-copie-de-travail" e2e/ui/working-copy.spec.ts && grep -q "expectAccessible" e2e/ui/working-copy.spec.ts && grep -q "expectNoHorizontalOverflow" e2e/ui/working-copy.spec.ts && grep -q "Shift+Tab" e2e/ui/working-copy.spec.ts && grep -q "Escape" e2e/ui/working-copy.spec.ts && grep -q "toBeDisabled" e2e/ui/working-copy.spec.ts && echo UI_SPEC_OK
EXPECT: UI_SPEC_OK
EVIDENCE: MET exit=0 marker-found :: UI_SPEC_OK
2. admin.spec.ts no longer opens the working-copy dialog (other dialogs of the file untouched; oracle corrected 2026-11-12, the first form matched them); it keeps the historical page in the axe/overflow loop and asserts the button state is consistent with its linked reason.
CHECK: cd /home/bchanot/Documents/faunosteo-v1-2/apps/app && ! grep -A1 "getByRole('dialog', {$" e2e/shell/admin.spec.ts | grep -q "admin.working_copy.create" && grep -q "historical}" e2e/shell/admin.spec.ts && grep -q "admin.working_copy.active" e2e/shell/admin.spec.ts && grep -q "working-copy.spec" e2e/shell/admin.spec.ts && echo SHELL_OK
EXPECT: SHELL_OK
EVIDENCE: MET exit=0 marker-found :: SHELL_OK
3. Sandbox suite captures every created copy, archives only those with `returning id` checked, cleanup steps independent, first error rethrown.
CHECK: cd /home/bchanot/Documents/faunosteo-v1-2 && grep -q "returning id" packages/supabase/tests/sandbox/sheets-admin.sandbox.ts && grep -q "status = 'archived'" packages/supabase/tests/sandbox/sheets-admin.sandbox.ts && echo CLEANUP_OK
EXPECT: CLEANUP_OK
EVIDENCE: MET exit=0 marker-found :: CLEANUP_OK
4. Static gates green; no SQL, Rust, worker, app src change.
CHECK: cd /home/bchanot/Documents/faunosteo-v1-2 && [ -z "$(git diff --name-only HEAD -- supabase crates apps/app/src packages/supabase/src scripts docker)" ] && pnpm -s typecheck >/dev/null 2>&1 && pnpm -s lint >/dev/null 2>&1 && pnpm -s test:run >/dev/null 2>&1 && echo STATIC_OK
EXPECT: STATIC_OK
EVIDENCE: MET exit=0 marker-found :: STATIC_OK
5. Runs (manual, logs in scratchpad): BEFORE grep « admin screens » 4 failed; AFTER passes 1 and 2: 4 passed each; full admin.spec once; e2e:ui full ×2 green; sandbox suite sheets-admin green; pre-existing anatomical_sheets rows identical per id before/after.
6. Docs updated in the same commit: BROWSER_TESTS.md (e2e:ui row, harness paragraph, coverage change + limit), V1-2-6_U1_CORRECTIONS.md §5 row B and four-failure lines, playwright.ui.config.ts header, CLAUDE.md e2e:ui line and harness list.
CHECK: cd /home/bchanot/Documents/faunosteo-v1-2 && grep -q "working-copy" docs/development/BROWSER_TESTS.md && grep -q "working-copy" apps/app/e2e/playwright.ui.config.ts && grep -q "working-copy" CLAUDE.md && echo DOCS_OK
EXPECT: DOCS_OK
EVIDENCE: MET exit=0 marker-found :: DOCS_OK
## FILE SCOPE
- apps/app/e2e/harness/working-copy.html (new), apps/app/e2e/harness/working-copy.tsx (new)
- apps/app/e2e/ui/working-copy.spec.ts (new)
- apps/app/e2e/shell/admin.spec.ts
- packages/supabase/tests/sandbox/sheets-admin.sandbox.ts
- apps/app/e2e/playwright.ui.config.ts (header comment only)
- docs/development/BROWSER_TESTS.md, docs/development/V1-2-6_U1_CORRECTIONS.md, CLAUDE.md
- this contract, the plan, .claude/tasks/TODO.md and memory (memory commit)
@@ -0,0 +1,73 @@
# PLAN — anomaly B: working-copy dialog checks out of the shared slot (bugfix) — rev 2
Owner brief 2026-11-12 « Décision sur l'anomalie E2E »: OPTION 1 approved. Rev 2 after challenge (correctness SOLID,
robustness CONCERNS(1), simplicity CONCERNS(1)); changes marked [C], [R], [S].
## Diagnosis
- Symptom: `apps/app/e2e/shell/admin.spec.ts` « admin screens: axe and no sideways scroll on every page, desktop and
375 px » fails 4 times (fr/en × chromium-desktop/chromium-375): the click on « Créer une copie de travail » times out.
- Root cause: the test opens the dialog on the historical sheet `503dc301-…` (slug `faunosteo-cheval`). The working
copy exists ONLY for that sheet (`private.historical_sheet_id()` fixed id; `create_sheet_working_copy` refuses
any other source `working_copy.source_invalid`; `AdminSheetRoute.tsx:294` renders `WorkingCopyAction` only when
`sheet.historical`) and ONE active copy is allowed for the whole database. The test depends on shared, mutable state:
(a) on this sandbox the slot is taken by `8c315a12-…`, leaked by `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts`
« the working copy and the catalogue reads answer their closed kinds » (`kindOf` discards the created id; `afterAll`
deletes the run's accounts, not their sheets); (b) [C] even on a fresh stack, `editor-equine.spec.ts` (beforeAll
set-aside + own copy, afterAll restore) flips the slot while `admin.spec` runs in parallel (`fullyParallel`, 8
workers). Fixing (a) alone would not fix the test.
- `seedOfficialSheet` cannot help (random id, never historical). Owner: business rule unchanged, no SQL.
- Note for the owner (not fixed here, out of scope): `editor-equine.spec.ts` set-aside archives and restores
pre-existing active copies of the historical sheet (8c315a12 included) on every run; it ran during the R1 follow-up
e2e runs today. Not run in this fix.
- RELATED MEMORY: LRN-089, LRN-076 (stub vs real service: coverage change documented), LRN-082 (native modal: Tab past
last control reaches the browser UI), BDR-114 (decision C). No BLK bears.
## Fix plan
1. NEW `apps/app/e2e/harness/working-copy.html` + `working-copy.tsx` (dev server only, never built, like `dialog.tsx`):
`?lang=en` picks the language (localeStore + `documentElement.lang`); under `<StrictMode>` [R] and `MemoryRouter`,
renders the REAL `@/components/admin/WorkingCopyAction` twice, each in its own `<section>` with its own heading
[R]: slot free (`slug="faunosteo-cheval"`, `sourceVersionId` a fixed fake uuid, `copyActive={false}`) and slot taken
(same, `copyActive={true}`); page `<h1>`, `@/styles/index.css`. No network (`getSupabaseClient` only on submit,
never triggered; e2e:ui server has empty Supabase env).
2. NEW `apps/app/e2e/ui/working-copy.spec.ts` (chromium-desktop 1 280 and chromium-375; fr and en via `?lang`):
- page: axe + no horizontal overflow with both states shown; taken button `toBeDisabled()` with accessible
description = `admin.working_copy.active` (aria-describedby) [S: no « does not open » click];
- free button opened by keyboard (focus + Enter): dialog named `admin.working_copy.create`, description
`admin.working_copy.body`, slug input prefilled `faunosteo-cheval-copie-de-travail` (proof it is the real
component's proposal);
- focus: initial focus inside the dialog; keyboard walk written explicitly like `dialog.spec.ts`
[C][R]: Tab order close ✕ → slug input (identified by id `working-copy-slug`, `focusedName` is empty for inputs) →
Cancel → Submit → one `'browser'` step → back to ✕, and Shift+Tab the reverse; never `outside:*`;
- axe + no horizontal overflow on the open dialog, plus the dialog panel inside the viewport and panel
`scrollWidth <= clientWidth` at both widths [R];
- Escape closes, focus returns to the opener.
3. `apps/app/e2e/shell/admin.spec.ts`: historical page stays in the axe / overflow loop unchanged; the click + dialog
block is removed; replaced by a state-consistent check on the historical page [C]: the « Créer une copie de travail »
button is visible, and it is disabled exactly when the `admin.working_copy.active` reason is shown and linked
through aria-describedby (enabled with no reason otherwise). Comment points to `e2e/ui/working-copy.spec.ts`.
4. `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts` [R][C]: every successful `createSheetWorkingCopy` result
(both calls) is pushed to a run-owned `copies` list before `kindOf` classification; `afterAll`: when `copies` is
non-empty, `update public.anatomical_sheets set status = 'archived', archived_at = now() where id in (<copies>)
returning id` as postgres and assert the returned ids equal `copies`; each cleanup step (copies, species, grants +
accounts) runs even if an earlier one throws, the first error rethrown at the end. Never touches other rows.
5. Docs (same commit) [C]: `docs/development/BROWSER_TESTS.md` (e2e:ui row and harness paragraph: new page and spec;
coverage change: the dialog's axe / layout / keyboard checks run in e2e:ui on the real component, no longer in its
real server context; the shell keeps the historical page and the button state); `V1-2-6_U1_CORRECTIONS.md` §5 row
B (cause (b), fix, limit, « creation branch of the cleanup not yet run on a fresh stack » open check) and the lines
saying four admin failures; `playwright.ui.config.ts` header; root `CLAUDE.md` e2e:ui line + folder map harness
list. TODO lines in the memory commit.
## Verification (sandbox only; db:trial and DEV never)
- Snapshot BEFORE (read-only `select` through `pnpm db:sandbox sql`): every pre-existing `anatomical_sheets` row
(id, status, archived_at, updated_at) [R][C] incl. 8c315a12 and the historical sheet, saved to scratchpad.
- BEFORE fix: `pnpm db:sandbox e2e-shell e2e/shell/admin.spec.ts --grep "admin screens"` → 4 failed (expected).
- AFTER, pass 1 and pass 2: same grep → 4 passed; `pnpm e2e:ui` full (new spec included).
- AFTER once: full `admin.spec.ts`; `pnpm db:sandbox test tests/sandbox/sheets-admin.sandbox.ts` (server refusals
still covered; `working_copy.exists` path); typecheck, lint, test:run.
- Snapshot AFTER: every pre-existing row identical per id (new rows allowed: A1 creates sheets).
- Not run: `editor-equine.spec.ts` (its set-aside touches pre-existing copies).
## Risks
- The creation branch of the cleanup (copies non-empty) is not exercised on this sandbox (slot taken): recorded open.
- The dialog is no longer axe-checked inside the admin page chrome; it is a top-layer modal; page chrome stays covered
by the shell loop.