chore(docs): R3 plan rev 2b validated by the owner, TODO subtasks

Plan .claude/tasks/plans/2026-11-16-r3-sheet-list-0017.md: audit F1-F14,
three fresh challenges folded, owner answers D1-D7 and precisions P1-P4.
RR-13 scope widened to admin list paging (D4); D5 kept as a follow-up.
This commit is contained in:
bchanot committed 2026-11-16 01:13:26 +01:00
1 parent 98178dea26
commit 2277e41b09
2 files changed
+772 -1

No files matched your search

+11 -1
View File
@@ -707,6 +707,16 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet
- R2 BUILT 2026-11-13, awaiting owner validation: fc3fec7 R2.0, 4499bc7 R2.1, c21995b R2.2, 3baac4d R2.3, 8db6f42 R2.4, 4b7d254 R2.5, 2182307 R2.6 docs, 1bf2701 final-review fixes (all pushed). Verifier 18/20 (NOT-MET 9 admin.spec renderer crash from accumulated grants, 15 read-only flip keeps panel open), security PASS, final review ready-with-fixes → fixed, re-review ready. Owner decisions pending: read-only flip ratification, admin.spec closure before merge (fresh-run authorisation or separate fix: paginated grants / run-scoped cleanup), add-draft cancel control, V1-2_ANATOMICAL_SHEETS.md D1-D4 supersede note wording. editor-equine updated, never run. Parked: N1 silent draft loss on read-only flip of an unmatched tile, N2 pinned non-matching tile beside no-result, first-click loss below a refused field, landscape 667×375 panel 13 px, M10 locals over 5 in R2 hooks (/refactor)
- [x] R2 corrections (owner brief 2026-11-13, plan rev 5/5b): C0 admin.spec diagnosis (A/B 65a8fd3 vs 52aac41 identical, dose-response proves grant accumulation, BLK-015 open, pagination = RR-13), C1 read-only flip never drops a refused draft silently (3303530, 1e19479), C2 « Annuler l'ajout » + Escape (d177992, c8109af), C3 « Ne correspond pas à la recherche » (b1fd896), C4 667×375 touch proof, test only (969a5f3..78fb2d0), C5 docs (b919cf8, c0da36d, 58228ab), final review I1 (94f8a8b, 346a8fd), verifier gap undo drop announced (cb1ad47, 538ce27). Sweep 221p/119s/5f (admin.spec only), guard OK, verifier CONFORME, security PASS. BDR-115, LRN-133..135. Awaiting owner db:trial trial; residuals: two drops one flip speak last, undo/redo overwriting a pending draft in a mounted view, rotation cramped exception (auto-scroll offered), prettier drift editor-shell-layout.spec.ts:297-302
- [x] R2 CLOSED 2026-11-15 (owner brief « Clôture R2 »): owner db:trial checks §4.13 + §4.14 pass, R2 validated functionally and graphically; Rev 4-6 adjustments (b41c24b..54e09a7, BDR-118, BDR-119); choices ratified: saved-reference edit keeps own Défaire, unsaved new reference lost on abrupt close. Final sweep 52d5613: 273p/163s/6f (admin.spec BLK-015, stays open, RR-13), not green. No merge, no deploy. Next: R3, R4; U2 not started (orientation 2026-11-14 kept)
- [ ] R3 sheet list + Administration home (owner brief 2026-11-16): plan VALIDATED rev 2b `.claude/tasks/plans/2026-11-16-r3-sheet-list-0017.md` (D1-D4, D6, D7 yes; D5 no; recorded choices accepted; precisions P1-P4). Sandbox work authorised in plan scope; `pnpm db:trial migrate` waits for the operational checkpoint (Task 2 Step 6) and the owner's go; DEV unchanged. BLK-015 + RR-13 separate, open.
- [ ] Task 1 M9 migration + pgTAP 022 (72) + security review, frozen before first application
- [ ] Task 2 `db:sandbox migrate`, sandbox migrated, whole-stack recomputation; STOP trial checkpoint
- [ ] Task 3 client requires last_modified_at (after the trial step)
- [ ] Task 4 search, sort, date format (pure)
- [ ] Task 5 list page (board 28, 29 A)
- [ ] Task 6 home card (board 29 B)
- [ ] Task 7 shell spec admin-sheets-list + three locators
- [ ] Task 8 docs, closing gates, owner trial on db:trial
- [ ] Follow-up, NOT R3 (owner D5 2026-11-16): keep the admin sheet list's search, sort and filters when coming back from a sheet; joins the app-wide « search not kept on back » follow-up (BDR-079); BDR-116 rejected address parameters for view state; later navigation improvement, own go
- [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
- [ ] editor-equine risk (owner 2026-11-12 « Validation du correctif E2E et GO R2 » §3; separate fix, NOT part of R2): `editor-equine.spec.ts` beforeAll archives every active historical working copy (`update public.anatomical_sheets … private.is_historical_working_copy(id)`), afterAll restores them, and `confirmHistoricalDrawing` may upload / confirm the historical sheet's drawing; it already changed 8c315a12's `updated_at` (2026-11-12 13:40 UTC). NOT to be run on a persistent database holding data to preserve until fixed. Before any rerun: list its writes exactly, propose a reproducible non-destructive isolation of pre-existing resources, check interactions with admin.spec and parallel suites; keep 8c315a12 and its current metadata (no artificial date restore); no sandbox reset or deletion
- [ ] e2e fixture accumulation (owner 2026-11-12 §3): sheets created by the suites persist on the sandbox (admin.spec A1 `fiche-e2e-<tag>` never archived, seedDraft / seedOfficialSheet sheets, editor copies); track them (count per run, owner per fixture) and propose run-scoped cleanup limited to ids each run created
@@ -748,7 +758,7 @@ Inventory: `.claude/audits/2026-10-25-functional-inventory.md`. Each item: treat
- [ ] RR-9 release 0.2.0 fate (Steps 3–6 on TS engines, 341 commits behind develop): ship, supersede, or rebase; sheet bundle default `none`
- [ ] RR-10 census tools maintenance (LOW `#[ignore]` positions) and controlled oracle evolution on a new anatomical changeset
- [ ] RR-12 (RR-11 is taken on develop: « sandbox-only e2e follow-ups ») AAL2 token after factor removal, production security prerequisite (owner 2026-11-03, recorded at V1-2.6, NOT fixed): catalogue and sheet RPCs and Storage policies check the JWT `aal2` claim (`private.has_mfa()`), not the live session (`has_aal2_session()` serves role and rights RPCs only), so a token issued at `aal2` keeps passing them after a factor removal until it expires. Study a live-session check or a revocation strategy compatible with Supabase / GoTrue before production; no authentication change in V1-2.6. Recorded in V1-2 contract §13
- [ ] RR-13 (free on develop, max RR-11, and on V1-2, max RR-12) « Pagination côté serveur de la liste des droits et prévention de l'épuisement mémoire » (owner 2026-11-09, BDR-106; priority technical track, separate from U1 and U2; NOT implemented, needs its own plan and owner go). Cause: `list_catalog_grants()` (`supabase/migrations/20261028100000_sheet_access_hardening.sql:542`) and `GrantList.tsx` return and render every grant; on a long-lived sandbox (2 306 rows) the axe scan takes the Chromium renderer to ~2.2 GB and earlyoom kills it (« Target crashed », admin.spec 9/9 on 89da8d3, 580ff28, 606f7ba; absent at seed volume); the same memory pressure SIGTERMs DEV `pg_meta` (39 restarts in 2 days, stateless). The plan must cover: [ ] bounded server paging · [ ] deterministic result order · [ ] authorization checks unchanged · [ ] paging and large-volume tests · [ ] admin scenario independence tests (admin.spec:717 working-copy slot) · [ ] memory consumption check · [ ] Supabase DEV protected from indirect effects of the test suites
- [ ] RR-13 (free on develop, max RR-11, and on V1-2, max RR-12) « Pagination côté serveur de la liste des droits et prévention de l'épuisement mémoire », scope widened 2026-11-16 by the owner (R3 D4) to the server paging of the admin lists, rights and official sheets (R3's browser-side search and sort move with it), not implemented in R3 (owner 2026-11-09, BDR-106; priority technical track, separate from U1 and U2; NOT implemented, needs its own plan and owner go). Cause: `list_catalog_grants()` (`supabase/migrations/20261028100000_sheet_access_hardening.sql:542`) and `GrantList.tsx` return and render every grant; on a long-lived sandbox (2 306 rows) the axe scan takes the Chromium renderer to ~2.2 GB and earlyoom kills it (« Target crashed », admin.spec 9/9 on 89da8d3, 580ff28, 606f7ba; absent at seed volume); the same memory pressure SIGTERMs DEV `pg_meta` (39 restarts in 2 days, stateless). The plan must cover: [ ] bounded server paging · [ ] deterministic result order · [ ] authorization checks unchanged · [ ] paging and large-volume tests · [ ] admin scenario independence tests (admin.spec:717 working-copy slot) · [ ] memory consumption check · [ ] Supabase DEV protected from indirect effects of the test suites
- [ ] RR-14 (on V1-2; develop max RR-11) secrets outside logs, process arguments and test artifacts, production security prerequisite (owner 2026-11-12; not blocking R2; recorded in V1-2 contract §13): no real password or secret in any log; no real secret in process arguments (argv); no real secret in test or CI/CD artifacts; these three checked before any deployment. Trigger: guardrails FAIL `API-PASSWORD-PLAINTEXT` / `API-PASSWORD-LOGGED` at `scripts/db-trial-check.sh:1340` (security gate 2026-11-12); the passwords there are fictitious, test-only. Owner: harness NOT modified, no secret rotation now
## Phase A — DONE (kept for reference)
@@ -0,0 +1,761 @@
# R3 Sheet List and Administration Home Implementation Plan (V1-2.6), rev 2
> **For agentic workers:** REQUIRED SUB-SKILL: Use subagent-driven-development to implement this plan task-by-task.
> Steps use checkbox (`- [ ]`) syntax for tracking.
**Status:** VALIDATED by the owner, 2026-11-16 (brief « Validation du plan R3 révision 2 »): D1 to D4, D6 and D7
yes as recommended, D5 no (out of R3, kept as a later navigation improvement), every « Recorded unless the owner
objects » item accepted. Development and checks on the sandbox authorised within this plan. `pnpm db:trial migrate`
is NOT authorised: Task 2 Step 6 stops on an operational checkpoint (exact operations, backup, downtime, checks
after restart) and waits for the owner's go. DEV unchanged. Owner precisions, binding: (P1) the tests cover the
real computation of `last_modified_at` on PostgreSQL, drafts and working copies included; (P2) the migration is
reviewed and frozen before its first application; (P3) the application never shows an old or wrong date as a
reliable last modification; (P4) exact test results kept, the known BLK-015 failures included.
Rev 2 = rev 1 + three fresh challenges of 2026-11-16 (correctness CONCERNS(3), robustness CONCERNS(5), simplicity
CONCERNS(2)); their findings and what became of them are in « Challenge round » at the end. Rev 2b = the owner's
answers: Task 1 gains a dated working copy (P1), Task 2 a whole-stack recomputation check on the sandbox (P1).
**Goal:** the official sheet list gets a name search, a sort by true last modification (default) or by name, a
visible date and a result count; the Administration home card lists the five most recently modified sheets.
**Architecture:** one SQL read change adds `last_modified_at` to `private.official_sheet_admin_summary` (design
accepted, `V1-2-6_R3_SQL_CHECKPOINT.md`). The typed client requires the key. Search, sort and date formatting are pure
TypeScript display functions over the loaded list (same class as the R2 Références tab), read by the list page and
the home card. No table, policy, privilege, Rust core or worker change.
**Tech Stack:** PostgreSQL 17 (pgTAP, PGlite), `@faunosteo/supabase` (Zod 3.25), React 19, Tailwind 4, vitest,
Playwright + axe.
**Spec:** `docs/development/V1-2-6_U1_CORRECTIONS.md` §R3 (D7, A7 to A9), `docs/development/V1-2-6_R3_SQL_CHECKPOINT.md`,
boards `docs/design/v1-2-6-r0/28-liste-fiches-desktop.png` and `29-liste-fiches-telephone-accueil.png`, labels
`docs/design/v1-2-6-r0/REVUE.md:82-84`, rules REVUE.md points 4, 6, 7, 8. Board 30 belongs to R4, not to this plan.
Plan form (deviation from writing-plans « full code », stated, as the R2 plan did): the SQL, the pgTAP assertions and
the pure functions are given in full; the React tasks give files, behaviour, test cases and verification, and the
executor writes the JSX under TDD against boards 28 and 29.
## Audit findings (2026-11-16, read-only, checked again by the correctness challenge at 98178de)
Worktree `/home/bchanot/Documents/faunosteo-v1-2`, branch `feature/v1-2-anatomical-sheets` at 98178de (R2 closed).
| # | Finding | Evidence | Consequence |
|---|---|---|---|
| F1 | The typed client rejects an answer whose shape differs: `parseSheetAnswer` throws `unavailable` on a schema miss, and `OfficialSheetAdminSchema` (sheet page, editor draft route, save and conflict reads) extends the summary schema. The reverse is harmless: the schema is a non-strict `z.object`, so today's code drops an extra key. | `packages/supabase/src/sheets.ts:150-154`, `:381-420`, `:454` | Once the client requires `last_modified_at`, the admin screens and the editor answer « indisponible » on a stack without the migration. Stacks are migrated before the app code, never after. |
| F2 | The shell suite runs on the sandbox, which has no forward migration command; the checkpoint recommends applying to the trial stack only. | `scripts/db-sandbox.sh:237-262` (`up fresh`, `up upgrade` only), checkpoint §4 | With path a alone `admin.spec` and every `editor-*` spec fail at load (F1) and nothing proves the date on a real PostgreSQL. Path b (a `migrate` command) is needed too; `migrate_up` already exists (`:188-190`). |
| F3 | Checkpoint §4 says « PGlite and `pnpm db:test` need no existing stack ». `pnpm db:test` runs `supabase test db` on the DEV stack, and V1-2 is « sandbox only, not on DEV ». | `package.json:34`, `CLAUDE.md:60` | The real-PostgreSQL pgTAP run is `pnpm db:sandbox test-db` after the sandbox migrate, never `pnpm db:test`. DEV stays untouched. |
| F4 | pgTAP files run in one transaction, where `now()` is frozen; `set_updated_at` stamps `now()`. | `supabase/tests/022_sheet_admin_reads.sql:6`, `:229`, `20261008100000_foundation.sql:30-38` | « A draft save moves `last_modified_at` and not `updated_at` » cannot be seen with rows dated `now()`. The new fixture rows are dated in the past at insert (the trigger stamps updates only). |
| F5 | RR-13 as recorded covers the rights list only (`list_catalog_grants`, `GrantList`). Two R3 documents lean on it to page the sheet list. | `.claude/tasks/TODO.md` RR-13 line, BDR-106; `V1-2-6_U1_CORRECTIONS.md:616`, checkpoint :32 | The `shortcut:` of the browser-side search and sort points to a track whose written scope does not include the sheet list (decision D4). |
| F6 | `admin.spec.ts` « admin screens » visits `/app/admin/access` before `/app/admin/sheets` and is red on the accumulated sandbox (BLK-015). It also holds the only axe scan of `/app/admin`. | `apps/app/e2e/shell/admin.spec.ts:733-750`, `.claude/memory/blockers.md` BLK-015 | R3's browser proof gets its own spec, which never opens the rights screen, scans a searched (short) list and the home page. |
| F7 | The date moves, or fails to, in ways the checkpoint does not list: (i) `delete_sheet_version` removes the draft row, so the date can go back (no screen calls it today); (ii) deleting an account that created a draft sets `created_by` to null, an update that stamps the version; (iii) review rounds never move it (by design); (iv) a future data migration that rewrites drafts re-dates every such sheet to the deploy time; (v) at the autumn clock change two saves an hour apart read the same « 02:30 » and sort differently. | `20261028110000_sheet_review_workflow.sql:1304-1332`, `20261008110000_anatomical_sheets.sql:111`, `:143-145`, `20261008100000_foundation.sql:30-38` | Known limits, recorded in the checkpoint document. Only (iii) is reachable from the application today. |
| F8 | The home card link is located in three shell tests by the fixed text of `admin.home.all_sheets`, inside the sheets card. | `admin.spec.ts:460-461`, `:671-672`, `editor-journey.spec.ts:58-61` | « Voir les {n} fiches » changes the accessible name: three locators rewritten one for one (R-24), through one helper that keeps the card scope. |
| F9 | The sort « Dernière modification » puts the historical sheet last most of the time, so it leaves the home card's five, and with it the card's « Créer une copie de travail » shortcut. | board 29 note « Une fiche historique qui entre dans les cinq garde son action », `AdminHomeRoute.tsx:65-72`, `AdminSheetRoute.tsx:295` | Validated behaviour (A9). The action stays on the historical sheet's own page. Named in the owner trial text. |
| F10 | Board 28's note « Sans résultat » settles the empty result with a filter active: the existing filters sentence stays. | board 28 | Followed as drawn. No decision. |
| F11 | Search, sort and filters live in component state: opening a sheet and coming back resets them. The owner filed « search not kept on back » as an app-wide product follow-up (BDR-079), and R2 rejected address parameters for view state (BDR-116). | `AdminSheetsRoute.tsx:143`, `.claude/memory/decisions.md` BDR-079, BDR-116 | Out of R3 unless the owner decides otherwise (D5). |
| F12 | The trial app is running now (a listener on port 5194) and follows the worktree live (Vite HMR); `pnpm db:trial migrate` refuses while the app runs. | `ss -ltn` 2026-11-16, `scripts/db-trial.sh:641`, `:1455`, `:1884-1887` | From the client change (Task 3) the owner's trial shows « indisponible » on the admin screens and the editor until the trial stack is migrated. The trial is migrated before Task 3, the app stopped during it. |
| F13 | A7 is ratified as a delivery in two steps (search and name sort without a date first; the date after the SQL change). | `V1-2-6_U1_CORRECTIONS.md:613-615`, `:635-636`, checkpoint §5, BDR-108, BDR-109 | Building the final state in one lot supersedes that split: an explicit owner decision (D2). |
| F14 | Boards 28 and 29 draw a magnifier in the search field. `Icon` has no such glyph, and the two search fields already shipped and validated (catalogue, Références tab) render none. | `components/ui/Icon.tsx:3-23`, `CatalogRoute.tsx:32-40`, `ReferenceToolbar.tsx:93-124` | No magnifier, as the two shipped searches; recorded as a deviation in `docs/design/README.md` unless the owner asks for the glyph. |
Checked and found sound: the proposed expression (`greatest` ignores a null; both columns are trigger-kept; the unique
index `(sheet_id, version_number)` serves the lookup), no PostgREST reload needed (same signature, private function,
`jsonb` return, generated types unchanged), the fixture inserts of Task 1 against every insert-time trigger and
constraint, `cmd_migrate` against the script's real names, the trial `migrate` command (cold backup first, A15), the
ratified date format against Node 24 ICU (`fr-FR` « 9 nov. 2026, 12:06 », `en-GB` « 9 Nov 2026, 12:06 »; `en-US` does
not), Zod `datetime({ offset: true })` against the jsonb timestamp format, soft deletion of a draft-only official
sheet by an editor.
## Owner decisions pending
| # | Question | Recommendation | If answered otherwise |
|---|---|---|---|
| D1 | Go to write the migration M9 and its pgTAP (PGlite only, no stack touched) | Yes | The ratified « before » state only: search, sort by name, no date, the card's first five by name (Tasks 4 to 7 without the date). |
| D2 | One delivery in the final state, superseding A7's two steps | Yes: with D1 and D3 the « before » state is never shown | Step one ships first as A7 says, the date in a second lot. |
| D3 | Stacks and order | After M9 passes PGlite and a fresh security review of its two-line diff: the sandbox through a new `pnpm db:sandbox migrate` (forward only, no reset, no row changed), then the trial stack through `pnpm db:trial migrate` on the owner's go at that moment (the trial app stopped, cold backup first, the stack stops a few seconds). Both before any app code that requires the key. M9 is frozen once applied to a stack: a later change ships as a new migration. | Trial only: the key becomes optional in the client and the UI hides the date when absent (a second code path, no real-stack proof). A new sandbox: the current one is removed (inventory and go first). |
| D4 | RR-13's written scope | The TODO text says « admin lists: rights and official sheets »; still separate, still not implemented | A new item for the sheet list; the `shortcut:` cites it. |
| D5 | Search, sort and filters kept when coming back from a sheet | Not in R3: it is the app-wide follow-up of BDR-079, and the address was rejected for view state in BDR-116 | Its own small lot after R3, on the editor's browser-history mechanism, typed text kept local. |
| D6 | The card's link below two sheets (« Voir les {n} fiches » has no singular) | The existing validated label « Toutes les fiches officielles » for zero or one sheet, « Voir les {n} fiches » from two | Another wording: a label change to validate. |
| D7 | The R3 browser test removes its own fixtures (soft deletion of the three sheets each run created, ids captured one by one) | Yes: it is the run-scoped cleanup the owner asked to be proposed (TODO, « e2e fixture accumulation ») | The three sheets stay listed on the sandbox, six more per sweep. |
Recorded unless the owner objects (each follows a validated document or an existing rule):
- Boards as drawn: no new badge (published and draft told apart by the detail line), the four filters unchanged,
the empty-result note of board 28 literally.
- No magnifier in the search field (F14).
- The name sort follows the shown name: French names with the French collation in the French interface, English
names in the English interface (the board says « ordre alphabétique français » for the French screen).
- The date is shown in Paris time, as the editor's « enregistré le … ».
- Search and sort stay TypeScript, with their rows in the Rust exception table (class C, display only), as
BDR-114 (A) did for the Références tab and as the ratified R3 text prescribes (`folded`, `Intl.Collator`).
- The limits of F7 are written into the checkpoint document; (i) is fixed in the write the day a « supprimer le
brouillon » screen exists.
## Global Constraints
- Work in `/home/bchanot/Documents/faunosteo-v1-2` on `feature/v1-2-anatomical-sheets`. No merge, no deploy, no DEV.
- The trial app serves this worktree live: between tasks it shows work in progress. The owner's verdict is asked
only at the final stop.
- Never touch: `crates/`, `supabase/migrations/*` other than the one new file, `scripts/db-trial*`,
`components/editor/**`, `components/catalogue/**`, `GrantList`, `list_catalog_grants`, `admin.spec.ts` beyond the
two locator rewrites of Task 7 (BLK-015 and RR-13 stay separate tracks).
- M9 is frozen from its first application to any stack: never edited in place afterwards (the sandbox cannot detect
an edited migration).
- `scripts/db-sandbox.sh`: additions only, no line removed or changed (`scripts/db-trial-check.sh:627`).
- Stack operations: `pnpm db:sandbox migrate` only after D3; `pnpm db:trial migrate` only on the owner's go at that
moment; never `db:sandbox down` or `up`, a reset, `pnpm db:trial stop` or `start`, or `editor-equine.spec.ts`.
`scripts/db-trial-check.sh` exits 2 while the trial is up and suggests stopping it: report the refusal, stop nothing.
- Limits: 25 logic lines per function, 100 chars per line, 5 params, 5 locals, no global state; i18n through
`useT()` with fr / en parity; no raw string in JSX.
- Labels exactly as `REVUE.md:82-84`: « Rechercher une fiche par son nom », « Trier par », « Dernière modification »,
« Nom », « {n} fiches », « {n} fiches sur {total} », « Modifiée le {date} », « Aucune fiche ne contient « {q} » dans
son nom. », « Effacer la recherche », « Dernières modifications », « Voir les {n} fiches »; EN « Search a sheet by
name », « Sort by », « Last modified », « Name », « {n} sheets », « {n} sheets of {total} », « Modified on {date} »,
« No sheet name contains “{q}”. », « Clear the search », « Latest changes », « See the {n} sheets ».
- Date (A8): « 9 nov. 2026, 12:06 » / « 9 Nov 2026, 12:06 », Paris time.
- No section, filter or rule built on a UUID, a name, a slug or a test convention; generic for every species (D7).
- R-24: every removed or rewritten assertion mapped to its replacement in the commit body.
- Data guard around every sandbox session (R2 rule G3): per-id snapshot of the pre-existing rows of
`anatomical_sheets` and `anatomical_sheet_versions` (full rows, `md5(content::text)`) before and after, through
`pnpm db:sandbox sql`, select only; a changed or missing row stops the run. New rows are counted per run.
- Commits: Conventional Commits; one coherent change each.
- Gates per task in this order: `pnpm typecheck`, `pnpm lint`, `pnpm test:run`, then what the task names.
## Review Focus
1. A stack without the migration: the client answers the closed `unavailable` failure, never a list with a missing
or invented date. Test in Task 3.
2. Two sheets with the same date, or the same name: the order does not depend on the server's order and does not
flip between renders. Test in Task 4 (ties by name, then id).
3. Search text with replacement patterns (`$&`), brackets, or 100 characters without a space: shown as plain text,
no exception, no sideways scroll at 375 px. Tests in Task 5 (unit) and Task 7 (browser).
4. A sheet named differently in each language (« Cheval » / « Horse »): found by either name in either interface
language; the name sort follows the shown language. Test in Task 4.
5. The species read fails while the sheet list answers: the home card still shows, with the species id in place of
its name. Test in Task 6.
---
## File Structure
| File | Responsibility |
|---|---|
| Create `supabase/migrations/20261116100000_sheet_admin_last_modified.sql` | M9: the summary with `last_modified_at` |
| Modify `supabase/tests/022_sheet_admin_reads.sql` | 8 new assertions, plan 60 → 68 |
| Modify `scripts/db-sandbox.sh` | `migrate` command (additions only) |
| Modify `packages/supabase/src/sheets.ts`, `tests/sheets-admin.test.ts` | the summary schema requires the key |
| Modify `apps/app/src/catalogue/useCatalogue.ts` | `matchesSheetName` exported, `filterCatalog` calls it (one search rule for both screens) |
| Create `apps/app/src/admin/sheetList.ts` | `searchSheets`, `sortSheets`, `SHEET_SORTS` (pure) |
| Modify `apps/app/src/admin/labels.ts` | `formatShortParisDateTime`, `sheetDetails` (moved from the route) |
| Create `apps/app/src/components/admin/ModifiedDate.tsx` | « Modifiée le … » as a `<time>`, shared by the row and the card |
| Modify `apps/app/src/app/routes/app/admin/AdminSheetsRoute.tsx` | search, sort, count line, row date, empty states |
| Modify `apps/app/src/app/routes/app/admin/AdminHomeRoute.tsx` | the « Fiches officielles » card of board 29 B |
| Modify `apps/app/src/i18n/{fr,en}.ts` | the keys of Tasks 5 and 6 |
| Create `apps/app/tests/unit/admin.sheetList.test.ts`; modify `admin.labels.test.ts`, `routes.admin.test.tsx` | unit tests |
| Create `apps/app/e2e/shell/admin-sheets-list.spec.ts` | the list and the card on the sandbox, fr / en, desktop and 375 px |
| Modify `apps/app/e2e/support/admin.ts`, `e2e/shell/{admin,editor-journey}.spec.ts` | `allSheetsLink` helper, three locators |
| Modify docs (Task 8) | as built, owner trial, exception table, migration list |
If the 25-line limit forces it, the route's row and toolbar are extracted to `components/admin/SheetRow.tsx` and
`components/admin/SheetListToolbar.tsx`; no other new file.
---
### Task 1: SQL read change M9, its pgTAP, its security review (after D1)
**Files:**
- Create: `supabase/migrations/20261116100000_sheet_admin_last_modified.sql`
- Modify: `supabase/tests/022_sheet_admin_reads.sql:7` (plan), before `-- ============ Privileges and nature` (:184)
**Interfaces:**
- Produces: `list_official_sheets_admin()` and `get_official_sheet_admin(uuid)` answers carry
`last_modified_at` (timestamptz as an ISO 8601 string with offset), never null.
- [ ] **Step 1: Write the failing assertions.** `select plan(60);` becomes `select plan(72);`, and this section is
inserted before « Privileges and nature » (after every existing list assertion, so none changes):
```sql
-- ============ Last modification date (R3, M9) ============
-- now() is the transaction's start for the whole file, so these rows are dated
-- in the past at insert (the trigger stamps updates only): a later write then
-- shows as a newer date.
reset role;
select set_config('request.jwt.claims', '{"sub":"22000000-0000-0000-0000-00000000000e"}', true);
insert into pg_temp.k values
('SL', '22200000-0000-0000-0000-000000000007'), ('SL.v1', '22300000-0000-0000-0000-000000000071'),
('SN', '22200000-0000-0000-0000-000000000008'),
('WK', '22200000-0000-0000-0000-000000000009'), ('WK.v1', '22300000-0000-0000-0000-000000000091');
insert into public.anatomical_sheets (id, species_id, name, slug, is_official, visibility, status,
created_at, updated_at, working_copy_source_version_id) values
(pg_temp.id('SL'), 'equine', 'SL', 'm22-sl', true, 'private', 'active', '2026-01-01T10:00:00Z', '2026-01-01T10:00:00Z', null),
(pg_temp.id('SN'), 'equine', 'SN', 'm22-sn', true, 'private', 'active', '2026-01-03T10:00:00Z', '2026-01-03T10:00:00Z', null),
-- A second, dated working copy of the historical sheet: the single slot is a
-- rule of create_sheet_working_copy, not a constraint, and WC holds it already.
(pg_temp.id('WK'), 'equine', 'WK', 'm22-wk', true, 'private', 'active', '2026-01-01T10:00:00Z', '2026-01-01T10:00:00Z',
pg_temp.id('h.v'));
insert into public.anatomical_sheet_versions (id, sheet_id, version_number, status, document_schema_version, content,
created_at, updated_at) values
(pg_temp.id('SL.v1'), pg_temp.id('SL'), 1, 'draft', 2, pg_temp.doc('Datée'), '2026-01-02T10:00:00Z', '2026-01-02T10:00:00Z'),
(pg_temp.id('WK.v1'), pg_temp.id('WK'), 1, 'draft', 2, pg_temp.doc('Copie datée'), '2026-01-04T10:00:00Z', '2026-01-04T10:00:00Z');
update public.anatomical_sheets set last_version_number = 1 where id in (pg_temp.id('SL'), pg_temp.id('WK'));
-- The update above stamps both sheet rows with now(): put their dates back in the past.
-- (The executor checks whether last_version_number must be set for save_sheet_draft; if not, this update and
-- the comment go, and the rows keep their insert dates. If it must, the dates are restored through
-- `alter table … disable trigger anatomical_sheets_set_updated_at` around one dated update, re-enabled at once,
-- inside this rolled-back transaction only, and the executor reports it.)
-- One date of a sheet's admin answer.
create function pg_temp.at(p_key text, p_field text) returns timestamptz language sql as $$
select (public.get_official_sheet_admin(pg_temp.id(p_key)) ->> p_field)::timestamptz
$$;
grant execute on function pg_temp.at(text, text) to authenticated;
select pg_temp.as_user('E', 'aal2');
select is(pg_temp.at('SL', 'last_modified_at'), '2026-01-02T10:00:00Z'::timestamptz,
'a version newer than the sheet row gives the last modification');
select is(pg_temp.at('SN', 'last_modified_at'), '2026-01-03T10:00:00Z'::timestamptz,
'a sheet without a version answers its own date');
select is(pg_temp.val($$ select public.save_sheet_draft(pg_temp.id('SL.v1'), 0, pg_temp.doc('Datée 2'), 'r3') ->> 'revision' $$),
'1', 'E saves the dated draft');
select is(pg_temp.at('SL', 'last_modified_at'), now(), 'a draft save moves last_modified_at');
select is(pg_temp.at('SL', 'updated_at'), '2026-01-01T10:00:00Z'::timestamptz, 'a draft save leaves the sheet row''s date');
reset role;
update public.anatomical_sheets set name = 'SN 2' where id = pg_temp.id('SN');
select pg_temp.as_user('E', 'aal2');
select is(pg_temp.at('SN', 'last_modified_at'), now(), 'a sheet change moves last_modified_at');
select is(pg_temp.at('SN', 'updated_at'), now(), 'a sheet change moves updated_at too');
select is((public.get_official_sheet_admin(pg_temp.id('WK')) ->> 'working_copy')::boolean, true,
'the dated fixture is a working copy');
select is(pg_temp.at('WK', 'last_modified_at'), '2026-01-04T10:00:00Z'::timestamptz,
'a working copy is dated by its own draft');
select is(pg_temp.val($$ select public.save_sheet_draft(pg_temp.id('WK.v1'), 0, pg_temp.doc('Copie datée 2'), 'r3') ->> 'revision' $$),
'1', 'E saves the working copy''s draft');
select is(pg_temp.at('WK', 'last_modified_at'), now(), 'a working copy''s draft save moves its last_modified_at');
select is(pg_temp.val($$ select count(*)::text from jsonb_array_elements(public.list_official_sheets_admin()) e
where e ->> 'last_modified_at' is null $$), '0', 'every listed sheet carries last_modified_at');
```
The call rights of the checkpoint's list are the existing assertions that follow, re-run unchanged.
- [ ] **Step 2: Run and watch it fail.** `pnpm --filter @faunosteo/supabase test:run -- pgtap`. Expected in 022:
seven of the new assertions fail (the six on `last_modified_at`, the null count) and five pass (the two saves, the
two on `updated_at`, the working copy flag); the 60 earlier ones pass.
- [ ] **Step 3: Write the migration.** The file replaces `private.official_sheet_admin_summary` with the body of
`20261102100000_sheet_admin_reads.sql:40-93` copied character for character, plus the two lines of one key after
`'updated_at'`:
```sql
-- V1-2.6 R3 M9 `sheet_admin_last_modified`: a true last-modification date in
-- the administration reads. docs/development/V1-2-6_R3_SQL_CHECKPOINT.md
-- (design accepted by the owner 2026-11-09, BDR-109, arbitration A7).
--
-- The admin list dated a sheet by `anatomical_sheets.updated_at`, which a
-- draft save does not move: `save_sheet_draft` writes
-- `anatomical_sheet_versions` only. The summary now also answers
-- `last_modified_at`, the newest of the sheet row's `updated_at` and its
-- versions' `updated_at`, both kept by the existing `set_updated_at`
-- triggers. Review rounds and audit rows do not count. Read change only: body
-- otherwise identical to M7, no table, policy, index or privilege change;
-- `updated_at` keeps its meaning.
create or replace function private.official_sheet_admin_summary(p_sheet_id uuid)
returns jsonb
language sql
stable
security definer
set search_path = ''
as $$
select jsonb_build_object(
'sheet_id', s.id,
'species_id', s.species_id,
'slug', s.slug,
'status', s.status,
'archived_at', s.archived_at,
'created_at', s.created_at,
'updated_at', s.updated_at,
'last_modified_at', greatest(s.updated_at, (
select max(v.updated_at) from public.anatomical_sheet_versions v where v.sheet_id = s.id)),
-- (here: M7 lines 55 to 92 as they are, from `'name', coalesce(…` through the closing parenthesis of
-- jsonb_build_object, the from clause and `where s.id = p_sheet_id;`; this comment is not kept)
$$;
-- Kept by `create or replace`, stated again so this file stands alone.
revoke all on function private.official_sheet_admin_summary(uuid) from public, anon, authenticated, service_role;
```
The comment stands for M7 lines 55 to 92, copied, not retyped (40 lines retyped by hand are a transcription risk
in a `security definer` function; dropping the `where` would answer an arbitrary sheet). Check:
`diff <(sed -n 40,93p supabase/migrations/20261102100000_sheet_admin_reads.sql) <(sed -n '/^create or replace/,/^\$\$;/p' supabase/migrations/20261116100000_sheet_admin_last_modified.sql)`
shows the two added lines and nothing else.
- [ ] **Step 4: Run and watch it pass.** `pnpm --filter @faunosteo/supabase test:run`. Expected: 022 at 72 of 72,
the other pgTAP files and `schema-types.test.ts` unchanged.
- [ ] **Step 5: Fresh security review of the SQL**, before any stack sees it: `security-auditor` on the migration
and the test diff. A requested change is made now, never after Task 2.
- [ ] **Step 6: Commit.** `feat(supabase): last_modified_at in the admin sheet summary (M9)`.
### Task 2: `pnpm db:sandbox migrate`, the sandbox then the trial stack migrated (after D3)
**Files:**
- Modify: `scripts/db-sandbox.sh` (a `cmd_migrate` function with its comment, one `case` line before `sql)`)
- Modify: `docs/development/SUPABASE.md` §5.1 (the command)
**Interfaces:**
- Consumes: `migrate_up` (:188), `load_secrets`, `sb_psql`, `$DB`, `die`.
- Produces: `pnpm db:sandbox migrate`: the branch's pending migrations on the running sandbox; no reset, no seed,
no container recreated. Both persistent stacks at `20261116100000`.
- [ ] **Step 1: Add the command** (additions only). The script's own help prints header lines 2 to 36 and that
line may not change, so the command is documented by its comment and in `SUPABASE.md`, not in the header:
```bash
# pnpm db:sandbox migrate: forward only, on the running sandbox; the branch's
# pending migrations and nothing else (no reset, no seed, no container recreated).
cmd_migrate() {
[ $# -eq 0 ] || die "migrate takes no argument"
docker ps --format '{{.Names}}' | grep -qx "$DB" || die "sandbox not up (pnpm db:sandbox up fresh)"
load_secrets
local last='select max(version) from supabase_migrations.schema_migrations'
echo "== before: $(sb_psql -t -A -c "$last")"
migrate_up .
echo "== after: $(sb_psql -t -A -c "$last")"
}
```
and in the dispatch: `migrate) shift; cmd_migrate "$@" ;;`.
- [ ] **Step 2: Static checks.** `shellcheck -e SC1090,SC1091,SC2016 scripts/db-sandbox.sh` clean;
`git diff --numstat -- scripts/db-sandbox.sh` shows 0 removed lines. Commit
`feat(supabase): db:sandbox migrate, forward only on the running sandbox`.
- [ ] **Step 3: Data guard, before.** The per-id snapshot of the Global Constraints, saved to the scratchpad.
- [ ] **Step 4: Migrate the sandbox** in a quiet window (no suite running). `pnpm db:sandbox migrate`. Expected:
before `20261103100000`, after `20261116100000`; a second run prints the same version twice and applies nothing.
Record `select md5(pg_get_functiondef('private.official_sheet_admin_summary(uuid)'::regprocedure))`.
- [ ] **Step 5: Data guard, after, and real-PostgreSQL pgTAP.** The snapshot is identical (a function replace
changes no row). `pnpm db:sandbox test-db`: file 022 at 72 of 72 is the gate; the other files' result is reported
exactly as it stands on the accumulated sandbox. `pnpm db:sandbox types --check`: no drift.
- [ ] **Step 5b: The real computation on every sheet of the sandbox (P1), select only** through
`pnpm db:sandbox sql`: for every official sheet not deleted, `private.official_sheet_admin_summary(id)
->> 'last_modified_at'` equals `greatest(s.updated_at, max(v.updated_at))` computed directly (count of
differences = 0); report the number of sheets checked, of working copies among them, and of sheets whose date now
differs from `updated_at` (the checkpoint read 28 of 219 on 2026-11-09).
- [ ] **Step 6: STOP, operational checkpoint for the trial stack (owner go required, not yet given).** Present to
the owner, in French: the exact commands (`pnpm db:trial status`; the app stopped; `pnpm db:trial migrate`;
`pnpm db:trial status`; the app restarted), the backup `migrate` takes (cold, both volumes and the secrets, kept,
never pruned, A15) and how to restore it, the downtime estimated from the script and from the last `backup` run,
and the checks after restart (applied version `20261116100000`, function md5 equal to the sandbox's, the R3
recomputation of Step 5b on the trial stack, accounts and the equine sheet unchanged, the app answering on the LAN
address). Only on the owner's go: run it. Today's app code keeps working on the migrated stacks (it drops the
extra key). Task 3 starts only after this step, whatever its outcome is (no go: Task 3 waits).
### Task 3: The typed client requires the key
**Files:**
- Modify: `packages/supabase/src/sheets.ts:388` (one entry after `updated_at`)
- Modify: `packages/supabase/tests/sheets-admin.test.ts` (the `summary` fixture, one test beside :194)
**Interfaces:**
- Produces: `OfficialSheetAdminSummary['last_modified_at']: string` (ISO 8601 with offset, checked at the boundary).
- [ ] **Step 1: Write the failing test.** The `summary` fixture gains
`last_modified_at: '2026-11-09T11:06:00.123456+00:00'`, and:
```ts
it('refuses a summary without last_modified_at, or with one that is no timestamp, as unavailable', async () => {
const answer = (data: unknown) => stubClient({ rpc: { data } }).client
const before = Object.fromEntries(Object.entries(summary).filter(([key]) => key !== 'last_modified_at'))
expect(await kindOf(listOfficialSheetsAdmin(answer([before])))).toBe('unavailable')
expect(await kindOf(listOfficialSheetsAdmin(answer([{ ...summary, last_modified_at: 'nope' }])))).toBe('unavailable')
})
```
- [ ] **Step 2: Run, watch it fail** (`pnpm --filter @faunosteo/supabase test:run -- sheets-admin`): both read
« no failure ».
- [ ] **Step 3: Implement.** After `updated_at: z.string(),`:
```ts
/** The newest of the sheet's and its versions' `updated_at` (M9): what « dernière modification » sorts and shows. */
last_modified_at: z.string().datetime({ offset: true }),
```
The siblings are plain strings because they are only printed; this one is sorted on and formatted by `Intl`, which
throws on an invalid date, so it is checked where it enters.
- [ ] **Step 4: Run, watch it pass;** then `pnpm test:run`: the app fixtures that feed the fake RPC
(`routes.admin.test.tsx` `summary()` and `historical()`, found by the run, not by the compiler) gain the key, and
`tests/helpers/editorRoute.tsx` `adminAnswer()` too, for a truthful fixture.
- [ ] **Step 5: Real answer.** `pnpm db:sandbox test sheets-admin` (parses the migrated sandbox's answers): result
reported exactly.
- [ ] **Step 6: Commit.** `feat(supabase): admin sheet summary carries last_modified_at`.
### Task 4: Search, sort and date format (pure)
**Files:**
- Modify: `apps/app/src/catalogue/useCatalogue.ts:57-71`, `apps/app/src/admin/labels.ts`,
`apps/app/tests/unit/admin.labels.test.ts`
- Create: `apps/app/src/admin/sheetList.ts`, `apps/app/tests/unit/admin.sheetList.test.ts`
**Interfaces:**
- Produces:
- `matchesSheetName(name: { fr: string; en: string }, query: string): boolean` (`@/catalogue/useCatalogue`)
- `SHEET_SORTS = ['modified', 'name'] as const`, `type SheetSort`
- `searchSheets(sheets: readonly OfficialSheetAdminSummary[], query: string): OfficialSheetAdminSummary[]`
- `sortSheets(sheets: readonly OfficialSheetAdminSummary[], sort: SheetSort, locale: Locale): OfficialSheetAdminSummary[]`
- `formatShortParisDateTime(iso: string, locale: Locale): string`
- [ ] **Step 1: Write the failing tests.**
```ts
import { describe, expect, it } from 'vitest'
import type { OfficialSheetAdminSummary } from '@faunosteo/supabase'
import { searchSheets, sortSheets } from '@/admin/sheetList'
const sheet = (id: string, fr: string, en: string, at: string) =>
({ sheet_id: id, name: { fr, en }, last_modified_at: at }) as OfficialSheetAdminSummary
const A = sheet('a', 'Âne, squelette', 'Donkey, skeleton', '2026-11-03T10:02:00+00:00')
const C = sheet('c', 'Cheval (tête)', 'Horse (head)', '2026-11-09T11:06:00.123456+00:00')
const E = sheet('e', 'Émeu', 'Emu', '2026-11-05T15:20:00+00:00')
const Z = sheet('z', 'Zèbre', 'Zebra', '2026-11-05T15:20:00+00:00')
const ids = (list: OfficialSheetAdminSummary[]) => list.map((s) => s.sheet_id).join('')
describe('searchSheets', () => {
it('matches the French or the English name, accents and case ignored', () => {
expect(ids(searchSheets([A, C, E, Z], 'ane'))).toBe('a')
expect(ids(searchSheets([A, C, E, Z], 'HORSE'))).toBe('c')
expect(ids(searchSheets([A, C, E, Z], 'émeu'))).toBe('e')
})
it('ignores surrounding spaces; an empty search keeps every sheet; brackets are plain text', () => {
expect(ids(searchSheets([A, C], ' cheval '))).toBe('c')
expect(ids(searchSheets([A, C], ' '))).toBe('ac')
expect(ids(searchSheets([A, C], '(tête)'))).toBe('c')
})
})
describe('sortSheets', () => {
it('modified: newest first, equal dates by name', () => {
expect(ids(sortSheets([A, Z, E, C], 'modified', 'fr'))).toBe('ceza')
})
it('name: the collation of the interface language, not code points', () => {
expect(ids(sortSheets([Z, E, C, A], 'name', 'fr'))).toBe('acez')
expect(ids(sortSheets([Z, E, C, A], 'name', 'en'))).toBe('aecz')
})
it('equal names fall back to the id, whatever the input order', () => {
const twin = { ...A, sheet_id: 'b' }
expect(ids(sortSheets([twin, A], 'name', 'fr'))).toBe('ab')
expect(ids(sortSheets([A, twin], 'modified', 'fr'))).toBe('ab')
})
it('returns a new array and leaves its input alone', () => {
const input = [Z, A]
expect(sortSheets(input, 'name', 'fr')).not.toBe(input)
expect(ids(input)).toBe('za')
})
})
```
In `admin.labels.test.ts`:
```ts
describe('formatShortParisDateTime (A8)', () => {
it('reads « 9 nov. 2026, 12:06 » in French and « 9 Nov 2026, 12:06 » in English, in Paris time', () => {
expect(formatShortParisDateTime('2026-11-09T11:06:00.123456+00:00', 'fr')).toBe('9 nov. 2026, 12:06')
expect(formatShortParisDateTime('2026-11-09T11:06:00.123456+00:00', 'en')).toBe('9 Nov 2026, 12:06')
})
it('follows the Paris summer offset', () => {
expect(formatShortParisDateTime('2026-07-01T22:30:00+00:00', 'fr')).toBe('2 juil. 2026, 00:30')
})
})
```
- [ ] **Step 2: Run, watch them fail** (`pnpm --filter @faunosteo/app test:run -- admin.sheetList admin.labels`).
- [ ] **Step 3: Implement.** In `catalogue/useCatalogue.ts`, the name rule leaves `filterCatalog` for a shared
function (behaviour identical, the catalogue suites unchanged and green):
```ts
/** A sheet name contains the search, in French or in English, accents and case ignored. */
export function matchesSheetName(name: { fr: string; en: string }, query: string): boolean {
const term = folded(query.trim())
return term === '' || folded(name.fr).includes(term) || folded(name.en).includes(term)
}
```
with `filterCatalog` returning `entries.filter((entry) => (speciesId === null || entry.species_id === speciesId)
&& matchesSheetName(entry.name, query))`. Then `apps/app/src/admin/sheetList.ts`:
```ts
import type { OfficialSheetAdminSummary } from '@faunosteo/supabase'
import { matchesSheetName } from '@/catalogue/useCatalogue'
import type { Locale } from '@/i18n/types'
// shortcut: search and sort run in the browser on the whole list; they move to
// the server with the list's paging (RR-13, TODO.md).
/** The display orders of the admin list; `modified` is the default (D7). */
export const SHEET_SORTS = ['modified', 'name'] as const
export type SheetSort = (typeof SHEET_SORTS)[number]
type Sheet = OfficialSheetAdminSummary
/** Search on the sheet name only, as the catalogue does (D7). */
export function searchSheets(sheets: readonly Sheet[], query: string): Sheet[] {
return sheets.filter((sheet) => matchesSheetName(sheet.name, query))
}
/**
* Display order only: a new array, the input untouched. `modified` puts the
* newest `last_modified_at` first; equal dates, and `name`, follow the name in
* the interface language, then the id, so the order never depends on the
* server's.
*/
export function sortSheets(
sheets: readonly Sheet[],
sort: SheetSort,
locale: Locale,
): Sheet[] {
const collator = new Intl.Collator(locale, { sensitivity: 'base', numeric: true })
const time = (sheet: Sheet) => Date.parse(sheet.last_modified_at)
const byName = (a: Sheet, b: Sheet) =>
collator.compare(a.name[locale], b.name[locale]) ||
a.sheet_id.localeCompare(b.sheet_id)
return [...sheets].sort(
(a, b) => (sort === 'modified' ? time(b) - time(a) : 0) || byName(a, b),
)
}
```
and in `apps/app/src/admin/labels.ts`, beside `formatDay` (one formatter per language, built once: the list
formats hundreds of rows at each keystroke):
```ts
import { PARIS_TIME_ZONE } from '@/lib/dates'
function shortDateTime(tag: string): Intl.DateTimeFormat {
return new Intl.DateTimeFormat(tag, {
day: 'numeric',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
timeZone: PARIS_TIME_ZONE,
})
}
const SHORT_DATE_TIME: Record<Locale, Intl.DateTimeFormat> = {
fr: shortDateTime('fr-FR'),
en: shortDateTime('en-GB'),
}
/** « 9 nov. 2026, 12:06 » / « 9 Nov 2026, 12:06 », in Paris time (A8). */
export function formatShortParisDateTime(iso: string, locale: Locale): string {
return SHORT_DATE_TIME[locale].format(new Date(iso))
}
```
- [ ] **Step 4: Run, watch them pass** (the catalogue suites included). If the runner's ICU prints another
separator than the ratified string, stop and report: the ratified text wins, never the expectation.
- [ ] **Step 5: Commit.** `feat(app): search, sort and date format of the admin sheet list`.
### Task 5: The list page (board 28, board 29 A)
**Files:**
- Modify: `apps/app/src/app/routes/app/admin/AdminSheetsRoute.tsx`, `apps/app/src/admin/labels.ts`
(`sheetDetails`, the route's `details` moved with the species first), `apps/app/src/i18n/{fr,en}.ts`,
`apps/app/tests/unit/routes.admin.test.tsx`
- Create: `apps/app/src/components/admin/ModifiedDate.tsx`
**Interfaces:**
- Consumes: Task 4's functions, `filterSheets`, `usePlural` (`@/editor/plural`), `Input`, `Select`, `Icon`.
- Produces:
- `sheetDetails(t, sheet, species, locale): string` (the « Cheval · Active · version publiée 3 · … » line)
- `<ModifiedDate iso={string} />`: `<time dateTime={new Date(iso).toISOString()}>` around the whole phrase
« Modifiée le {date} » (a valid HTML time value has at most three fraction digits)
- i18n keys `admin.sheets.search`, `admin.sheets.clear_search`, `admin.sheets.sort_by`,
`admin.sheets.sort.modified`, `admin.sheets.sort.name`, `admin.sheets.count_one`, `admin.sheets.count_other`,
`admin.sheets.count_of_one`, `admin.sheets.count_of_other`, `admin.sheets.modified`, `admin.sheets.no_result`
(texts: Global Constraints; singular « {count} fiche », « {count} fiche sur {total} », « {count} sheet »,
« {count} sheet of {total} »).
**Behaviour:**
- The search text and the sort are two `useState` beside the existing filters state; the rows shown are
`sortSheets(searchSheets(filterSheets(sheets, filters), query), sort, locale)`.
- Order on the page (board 28): heading and « Nouvelle fiche »; the search field and « Trier par » on one line
from 640 px, stacked below (board 29 A: search, sort, then the four filters, each full width, 44 px targets);
the four filters unchanged; the count line; the list.
- Search field: `type="search"`, the label as `aria-label` and placeholder, `maxLength={100}`,
`autoComplete="off"` (as the catalogue), no magnifier (F14); a « × » button only while the field is not empty
(accessible name « Effacer la recherche »); Escape on a non-empty field empties it and stops there (REVUE
point 4), on an empty field does nothing. Clearing, by either way, returns the focus to the field.
`// shortcut:` same markup as `ReferenceToolbar`'s search (R2, closed and validated, not reopened here); fold
both onto one component when the editor is next opened.
- Search is instant, on the name only; it combines with the four filters.
- « Trier par »: a native select, « Dernière modification » (default) and « Nom ».
- Count line, `aria-live="polite"`: « {n} fiches » when everything is shown, « {n} fiches sur {total} » otherwise
(`total` = the loaded list; « 0 fiche sur 12 », « 0 sheets of 12 », through `usePlural`). Shown once the list is
ready and not empty.
- Row (board 28): the whole row is one link; name and badges; the detail line; the date top right from 640 px, on
its own line under the detail below (board 29 A). The name wraps anywhere (`[overflow-wrap:anywhere]`). No new
badge, no highlight of the found text.
- Empty states (board 28 note, literally): no official sheet at all: « Aucune fiche officielle pour le moment. »;
nothing shown while a filter is active: « Aucune fiche ne correspond à ces filtres. »; nothing shown with a
search and no filter: a block « Aucune fiche ne contient « {q} » dans son nom. » with the button « Effacer la
recherche ». The block is a plain element, not `Notice` (a live region; the count line announces the result);
the search text is the trimmed text, inserted with a function replacement (`.replace('{q}', () => query)`) and
wrapping anywhere.
**Test cases** (`routes.admin.test.tsx`, « Official sheets list »; three sheets with distinct names and dates; the
existing test keeps its assertions):
1. Default order is by last modification, newest first; a row reads « Modifiée le 9 nov. 2026, 12:06 » and its
`time` carries `2026-11-09T11:06:00.123Z`.
2. Typing « chev » narrows the list and the count reads « 1 fiche sur 3 ».
3. The clear button appears with text, empties the field, restores « 3 fiches », and the field has the focus;
Escape does the same on a non-empty field and nothing on an empty one.
4. « Nom » reorders the rows.
5. The three empty states; a search of `$&` shows `$&` in the sentence.
6. The English interface reads « 1 sheet of 3 », « Modified on 9 Nov 2026, 12:06 », « Sort by ».
**Verification:** `pnpm typecheck && pnpm lint && pnpm test:run && pnpm build`; `impeccable detect` on the changed
`.tsx`.
- [ ] Steps: failing tests → run (fail) → implement → run (pass) → verification → commit
`feat(app): search, sort, count and date on the official sheet list`.
### Task 6: The Administration home card (board 29 B)
**Files:**
- Modify: `apps/app/src/app/routes/app/admin/AdminHomeRoute.tsx`, `apps/app/src/i18n/{fr,en}.ts`,
`apps/app/tests/unit/routes.admin.test.tsx`
**Interfaces:**
- Consumes: `sortSheets`, `sheetDetails`, `ModifiedDate`, `SheetBadges`, `WorkingCopyAction`.
- Produces: i18n `admin.home.latest` (« Dernières modifications » / « Latest changes »), `admin.home.see_all`
(« Voir les {count} fiches » / « See the {count} sheets »); `admin.home.all_sheets` kept for fewer than two (D6).
**Behaviour:**
- The card reads the sheet list and the species names together; a failed species read falls back to an empty list
(`listCatalogSpecies(client).catch(() => [])`, so `speciesLabel` shows the id), the card never fails for it. A
rights refusal of the sheet list still hides the card.
- Under « Brouillons, revues, versions. »: the sub-heading « Dernières modifications » (shown with at least one
sheet), then at most five sheets, `sortSheets(sheets, 'modified', locale)`: the name as a link with the badges,
the detail line, the date; the historical sheet, when among the five and for an editor, keeps its working copy
action under its line (unchanged component). No new badge.
- Footer link to `/app/admin/sheets`: « Voir les {n} fiches » with the total from two sheets; « Toutes les fiches
officielles » for zero or one (D6).
**Unit test cases:** seven sheets give five items in date order and « Voir les 7 fiches »; one sheet and no sheet
give « Toutes les fiches officielles » (and the empty sentence for none); the historical sheet outside the five
shows no working copy action on the card, inside the five it does (editor only); the detail line and the date are
those of the list for the same sheet; the species read refused: the card shows with « equine » in the detail line;
English texts.
- [ ] Steps: failing tests → run (fail) → implement → run (pass) → gates, `impeccable detect` → commit
`feat(app): Administration home lists the latest modified sheets`.
### Task 7: The browser proof on the sandbox
**Files:**
- Create: `apps/app/e2e/shell/admin-sheets-list.spec.ts`
- Modify: `apps/app/e2e/support/admin.ts` (`allSheetsLink`), `apps/app/e2e/shell/admin.spec.ts:460-461`,
`:671-672`, `apps/app/e2e/shell/editor-journey.spec.ts:58-61` (locator only)
**Interfaces:**
- Consumes: `editorActor(locale)` (`e2e/support/editor.ts:64`, returns `{ account, secret, aal2 }`),
`seedOfficialSheet(names, 'draft')` (`e2e/support/catalogue.ts:141`, returns `{ id, names }`), `sql()` and
`rpc(fn, args, token)` of the sandbox helpers, `stepUpAdmin`, `expectAccessible`, `expectNoHorizontalOverflow`.
- Produces: `allSheetsLink(scope: Page | Locator, dict: Dict): Locator`: the link of `scope` named by
`admin.home.all_sheets` or by `admin.home.see_all` with any number; the three call sites pass the same card
locator they use today.
**Spec** (needs the sandbox migrated; never opens `/app/admin/access`; serial; one actor per project):
- Fixtures, once per project: three official draft sheets named with a run token, « R3 {token} Alpha »,
« R3 {token} Émeu », « R3 {token} Zèbre » (English names with the same token), seeded in that order, each id
pushed to the cleanup list as soon as it exists; then Alpha's draft id and content read with `sql()` and one more
save through `save_sheet_draft` with the actor's aal2 token.
- Teardown (D7): each listed id soft-deleted through `delete_anatomical_sheet` with the same token, the returned id
checked, each step independent of the others' failure.
- fr and en, desktop and 375 px:
1. Search the token: three rows; the count line's total equals the length of the `list_official_sheets_admin`
answer captured in that same load (`page.waitForResponse`); order Alpha, Zèbre, Émeu (Alpha's sheet row is
the oldest of the three: only the true date puts it first); each row's date matches the ratified format.
2. « Nom »: Alpha, Émeu, Zèbre.
3. A search of the token followed by 100 characters without a space cut to the field's limit: the search
sentence, no sideways scroll; « Effacer la recherche » empties, focuses the field and restores the count.
4. axe and no sideways scroll on the searched list, on the empty state and on `/app/admin` (never on the
unsearched list of the accumulated sandbox).
5. Home: the sub-heading; at most five items; their `time[datetime]` values non-increasing by `Date.parse`; the
footer link carries a number and opens the list.
- Each sweep adds two accounts and two catalogue grants to the sandbox (BLK-015 counts grants: stated, not
hidden); no sheet is left listed.
**Verification:** `pnpm db:sandbox e2e-shell admin-sheets-list.spec.ts` under the data guard, then the explicit
spec list of the full sweep without `editor-equine.spec.ts`, with its exact counts. Expected failures are named,
not grouped: `admin.spec.ts` A0 « the rights screen with grants » and « admin screens … », with « Target crashed »
at `/app/admin/access` (BLK-015). A1 and « access per right » (the two rewritten locators) must be green in both
languages. Any other red is R3's until proven otherwise.
- [ ] Steps: helper and the three locator rewrites (R-24 map in the commit body) → the spec → verification →
commit `test(app): shell proof of the sheet list search, sort and dates`.
### Task 8: Documents and closing gates
**Files:** `docs/development/V1-2-6_U1_CORRECTIONS.md` (§R3 as built, the A7 split superseded per D2),
`V1-2-6_R3_SQL_CHECKPOINT.md` (status, the corrections F2, F3, F4, the limits F7, the owner's answers),
`V1-2-6_OWNER_TRIAL.md` (a French §4.15), `V1-2_ANATOMICAL_SHEETS.md` §12.3 (M9), `SUPABASE.md` §5.1,
`BROWSER_TESTS.md` (the new spec, the named expected failures), `RUST_ARCHITECTURE_REVIEW.md` Part II (class C rows
for `admin/sheetList.ts` and the date format), `docs/design/README.md` (the magnifier deviation), `CLAUDE.md`
(migration list, new files), `CHANGELOG.md`, `.claude/tasks/TODO.md` (R3 block, RR-13 wording per D4, the
`shortcut:` lines harvested).
- [ ] Owner trial text §4.15 (French, on `db:trial`): the search and its clear button; the two sorts; a draft saved
moves its sheet to the top and changes its date; a search without result; a search with a filter; the home
card's five and its link; the same at 375 px; the note that the historical sheet's working copy button is on its
own page when it is not among the five (F9).
- [ ] Closing gates, each by a fresh agent: `verifier` on the contract written after the owner's answers;
`security-auditor` on the whole diff (the script change, search text rendered, the client boundary); a fresh
design review of the two screens against boards 28 and 29 at 1 280 and 375 px; a fresh code review of the range.
- [ ] `pnpm check:all` result reported exactly; nothing is called green that is not.
- [ ] STOP: the owner's trial on `db:trial` (already migrated at Task 2). No merge.
## Out of scope, tracked
- BLK-015 (rights screen under axe on accumulated grants) and RR-13 (server paging): untouched, still open, their
lines kept; R3 adds no dependency on them beyond the `shortcut:` of Task 4.
- R4 (integrity warning in catalogue cards, board 30): next lot, its own go.
- Anomaly A (fictitious fingerprints) and the `editor-equine` set-aside risk: unchanged.
- List state kept on return (D5): BDR-079's follow-up.
## Challenge round (2026-11-16, three fresh `plan-challenger` agents, read-only)
| Lens | Finding | Outcome in rev 2 |
|---|---|---|
| correctness 1, simplicity 12 | A7's two-step delivery dropped without saying so; « no go: nothing starts » contradicts the ratified fallback | F13, D2; D1's fallback is the « before » state |
| correctness 2, simplicity 2 | Board 28 already settles the empty result with a filter; the plan recommended a deviation | F10 corrected, the note followed literally, the question removed |
| correctness 2, simplicity 10 | « Voir la fiche » and a hidden link are labels no board validates | D6 on already validated labels; a link stays at zero |
| correctness 3, robustness 9 | The spec's helpers give no aal2 token; ids not captured one by one; run-scoped cleanup is an open owner item | `editorActor`, `seedOfficialSheet`, `sql()`; D7 |
| correctness 4 to 9 | Test snippet not fitting the file and failing lint; fixtures found by the run; red count; M7 line range and diff; missing grant; help header | Tasks 1 to 3 corrected |
| correctness 11, robustness 10 d | `<time dateTime>` with six fraction digits is invalid HTML | `toISOString()`; the spec compares `Date.parse` |
| correctness 12, robustness 4 | The total compared across two loads of a changing sandbox | Compared within one load; format only on the card |
| correctness 13 | The name sort in the English interface is a choice | Listed under « Recorded unless the owner objects » |
| correctness 14 | F2 overstated, F11 line | Corrected |
| robustness 1, 6; simplicity 1 | The address as source of truth of a typed field drops characters (react-router transitions); stale parameters; against BDR-079 and BDR-116 | Task removed; D5 recommends no |
| robustness 2 | The owner's trial app breaks from the client change until the trial is migrated | F12; the trial is migrated in Task 2, before Task 3 |
| robustness 3 | M9 reached the sandbox before its security review; an edited migration is never re-applied there | Review in Task 1; M9 frozen once applied; function md5 recorded |
| robustness 5 | « Expected red: admin.spec » could hide R3's own regressions; no passing axe scan of the home page | Failures named by test; A1 and « access per right » must be green; axe on `/app/admin` in the R3 spec |
| robustness 7 | `Notice` is a live region; long text without a space; `$` patterns in `.replace` | Plain block, wrapping, function replacement, tests |
| robustness 8 | The card failed whole on a failed species read | Fallback to ids, Review Focus 5 |
| robustness 10 a to c | Three more limits of the date | F7 (iv), (v); the lock-wait case judged negligible and not recorded |
| robustness 11 | A formatter built per row per keystroke | One per language, built once |
| robustness 12 | The locator helper lost the card scope | `allSheetsLink(scope, dict)` |
| robustness 13 | `db-trial-check.sh` suggests stopping the trial | Not run; Global Constraints |
| simplicity 3 | Four of eight decisions already answered by validated documents | Moved to « Recorded unless the owner objects »; D4 kept (the owner's own track) |
| simplicity 4, 5 | Seven new app files, a single-use `SearchField` | Two new app files; the field inline with its `shortcut:` |
| simplicity 6 | The search rule copied from the catalogue | `matchesSheetName` shared |
| simplicity 7 | `.datetime()` on one field only | Kept, with its reason (sorted and formatted by `Intl`, which throws) |
| simplicity 8 | A third Paris literal, a near-twin name | `PARIS_TIME_ZONE`, `formatShortParisDateTime` |
| simplicity 9 | The same behaviour proven at three levels | Pure rules in unit tests; route tests for wiring; the spec for the real date, layout and axe |
| simplicity 11 | Magnifier, `<time>` wrapping, field limits left open | F14, Task 5 |