After e2e:shell seeds the same content-addressed drawing, Storage answers HTTP 400 with statusCode 409 (KeyAlreadyExists); any other 400 still fails. Docs: M7 adds no new write path; a TOTP code replays more than once within its span.
224 lines
15 KiB
Markdown
224 lines
15 KiB
Markdown
# CONTRACT — v1-2-5-owner-checkpoint
|
|
- date: 2026-11-02 | flow: feat | branch: feature/v1-2-anatomical-sheets
|
|
- status: active
|
|
- worktree: /tmp/claude-1000/-home-bchanot-Documents-faunosteo/e641af9a-743e-46d0-9804-99667836040e/scratchpad/v1-2
|
|
(every command runs from this worktree; never from /home/bchanot/Documents/faunosteo, never against DEV)
|
|
|
|
## REQUEST (verbatim — IMMUTABLE)
|
|
|
|
# FAUNOSTEO — V1-2.5 : décisions propriétaire au checkpoint
|
|
|
|
J'ai examiné ton rapport au HEAD `14ff890`.
|
|
|
|
Les résultats techniques de V1-2.5 sont acceptés : pgTAP, tests unitaires, E2E, MFA GoTrue, check:all et revues indépendantes.
|
|
|
|
Je valide les choix suivants et demande de traiter les dernières corrections ciblées avant de déclarer l'étape définitivement VERIFIED.
|
|
|
|
## 1. Autorisations indisponibles
|
|
|
|
Je ne souhaite pas afficher un formulaire de création pleinement utilisable lorsque la lecture des permissions échoue.
|
|
|
|
Afficher plutôt :
|
|
- « Impossible de vérifier vos autorisations ».
|
|
- Une explication courte.
|
|
- Un bouton « Réessayer ».
|
|
|
|
Ne pas déduire une absence de droit d'une erreur technique.
|
|
|
|
Distinguer explicitement trois situations :
|
|
1. Utilisateur autorisé : formulaire disponible.
|
|
2. Utilisateur non autorisé : accès refusé.
|
|
3. Vérification indisponible : état temporaire avec nouvelle tentative.
|
|
|
|
Les contrôles serveur/RLS demeurent obligatoires.
|
|
|
|
Ajouter des tests pour ces trois cas, notamment pour un compte reviewer-only et un compte editor.
|
|
|
|
## 2. Différences graphiques acceptées
|
|
|
|
J'accepte :
|
|
- La sélection affichée dans le panneau plutôt que dans une étiquette au-dessus du dessin, à condition qu'elle reste identifiable et accessible.
|
|
- Une carte « Références » non repliable sur mobile, sous réserve qu'elle ne masque pas la zone anatomique.
|
|
|
|
Consigner ces deux écarts comme décisions UX acceptées, sans modifier les maquettes historiques.
|
|
|
|
Ne pas entreprendre de refonte graphique.
|
|
|
|
## 3. Choix complémentaires ratifiés
|
|
|
|
- Nom de facteur MFA : 64 caractères maximum.
|
|
- Clé TOTP : absence de bouton Copier acceptée, mais affichage lisible et sélectionnable pendant la configuration.
|
|
- Habilitations : validité jusqu'à la fin du jour sélectionné, selon Europe/Paris pour le périmètre français initial. Vérifier l'interprétation backend, notamment aux changements d'heure, sans modifier les données historiques.
|
|
- Ordre des espèces : entier entre 0 et 9 999, validé côté serveur.
|
|
- Terminologie : « relecteur ou relectrice ».
|
|
|
|
## 4. Libellés
|
|
|
|
Ratifier :
|
|
- L14 : « Access and permissions » dans l'interface ; `capability` reste technique.
|
|
- L15 : supprimer la seconde phrase redondante si la restriction de largeur est déjà explicite.
|
|
- `object_conflict` (EN) : « The illustration file's contents do not match its recorded SHA-256 hash. »
|
|
|
|
Ne pas déclarer les quelque 350 nouveaux libellés approuvés. Ils feront l'objet d'une revue distincte du propriétaire.
|
|
|
|
Conserver les formulations ratifiées de V1-2.4.
|
|
|
|
## 5. MFA et récupération de compte
|
|
|
|
Consigner le comportement observé de GoTrue concernant la réutilisation des codes TOTP dans une fenêtre de validité.
|
|
|
|
Examiner et documenter le parcours lorsqu'un utilisateur perd son authentificateur :
|
|
- Facteur secondaire éventuel.
|
|
- Récupération de compte.
|
|
- Intervention administrative autorisée.
|
|
- Contrôles d'identité et traces d'audit.
|
|
|
|
Ne pas créer de contournement de MFA ni affaiblir les protections AAL2.
|
|
|
|
Si un parcours de récupération sûr manque, le signaler explicitement comme prérequis à la mise en production.
|
|
|
|
## 6. Validation
|
|
|
|
Effectuer les corrections ciblées et les tests de non-régression.
|
|
|
|
Vérifier :
|
|
- Les trois états d'autorisation.
|
|
- Les droits reviewer/editor.
|
|
- Les invariants MFA.
|
|
- Les accès serveur/RLS.
|
|
- Les comportements mobiles concernés.
|
|
- Les dates de validité si le code les traite.
|
|
|
|
Relancer les contrôles pertinents et une revue indépendante du HEAD final.
|
|
|
|
Commiter et pousser sur `feature/v1-2-anatomical-sheets` uniquement après validation.
|
|
|
|
Aucune opération sur DEV, aucun worker DEV, aucune migration DEV, aucune fusion et aucun déploiement.
|
|
|
|
## 7. Checkpoint
|
|
|
|
Présenter les corrections, résultats des tests, éventuels risques résiduels et HEAD final.
|
|
|
|
Si tout est conforme, déclarer V1-2.5 VERIFIED.
|
|
|
|
Ne pas commencer V1-2.6 dans cette intervention. Présenter son périmètre contractuel et ses prérequis au checkpoint suivant, sans inventer de fonctionnalités.
|
|
|
|
## CLARIFICATIONS
|
|
|
|
Q: Where does the « verification unavailable » state apply? / A: [gated 2026-11-02] Creation page
|
|
(`/app/admin/sheets/new`: full unavailable screen) + Administration home (`/app/admin`: the « Vos habilitations »
|
|
line replaced by the same notice with Retry). Sheets and species lists keep their grant-dependent actions hidden
|
|
on a failed read (no false statement); no notice there.
|
|
Q: Expiry instant / A: delegated — internal: the instant stored is 23:59:59.999 Europe/Paris of the chosen day
|
|
(UTC offset of that instant, DST-aware); the backend compares instants (`expires_at > now()`), unchanged;
|
|
historical rows untouched; the expiry day is displayed in Europe/Paris.
|
|
Q: TOTP key display / A: delegated — no visible change: the key is already rendered as plain selectable text
|
|
(`<code>`, monospace, wrapped); a test pins that it stays selectable and complete.
|
|
Q: Species order server check / A: delegated — M7 (V1-2.5 migration, sandbox only) redefines `create_species`
|
|
and `update_inactive_species` with the 0..9 999 range (null keeps today's meaning), privileges restated; M5 and
|
|
earlier migrations untouched (forward-only).
|
|
Q: Creation page with failed own grants but a server `rights.*` refusal / A: delegated (plan challenge,
|
|
2026-11-02) — the server's refusal wins: « Accès non autorisé » (BDR-094 kept); the unavailable state covers a
|
|
failed client read only.
|
|
Q: What does Retry re-read? / A: delegated (plan challenge) — roles and own grants (and the creation page's species
|
|
list when it failed); a failed Retry never wipes the profile, roles or workspace already held.
|
|
Q: The new unavailable-permissions e2e test is skipped on `chromium-375` / A: [gated 2026-11-02, mid-run, internal]
|
|
criterion 5 asks for a desktop proof; the skip follows the file's A0/A1/S1 idiom; the 375 px admin pages stay
|
|
covered by the unskipped « admin screens » and « access per right » tests.
|
|
Q: Sandbox suites share one stack's state / A: [gated 2026-11-02, mid-run, internal] two pre-existing test defects
|
|
surfaced by the gates are fixed inside this run (FILE SCOPE extended): `sheets-admin.sandbox.ts` working-copy case
|
|
(green only from the second run) and `sheets-concurrency.sandbox.ts` storage seeding (HTTP 400 duplicate after
|
|
e2e:shell seeded the same content-addressed object). Product code untouched.
|
|
|
|
## ACCEPTANCE CRITERIA
|
|
|
|
1. Three permission states on `/app/admin/sheets/new`, checked in this order: own grants `loading` → the
|
|
waiting status; the server refused (species read answered a `rights.*` kind) → « Accès non autorisé »
|
|
(BDR-094, the server's answer wins); own grants `failed` → the unavailable screen (title « Impossible de
|
|
vérifier vos autorisations » / EN proposal, one short explanation, a « Réessayer » button), never the form;
|
|
`ready` with an active `sheet_editor` grant → the form; `ready` without it (reviewer-only, publisher-only,
|
|
owner without capability) → « Accès non autorisé ». A failed client read never yields « Accès non autorisé »
|
|
by itself. Retry re-reads the roles and own grants through the store and the species list when it failed,
|
|
shows the waiting status, then lands on the state the new answers give.
|
|
2. `/app/admin`: own grants `loading` → the line shows the waiting status, not « aucune »; `failed` → the
|
|
line is replaced by the unavailable notice with Retry (section heading, not a second h1); `ready` → today's
|
|
line unchanged.
|
|
3. Store: a retry action (`reloadAccess`) sets `catalogGrantsStatus` to `loading`, re-reads the platform roles
|
|
and own grants, ends `ready` (roles and grants replaced) or `failed` (grants `[]`; profile, roles and
|
|
workspace already held are kept, never wiped by a technical error); it never rejects (no user or client →
|
|
`failed`); the account-change guard (`setForUser`) drops late answers. The unused `refreshAccount` is
|
|
removed (no caller).
|
|
4. Unit tests cover criteria 1-3, including a reviewer-only account and an editor account in each of the
|
|
three states, Retry recovering to the form (editor) and to « Accès non autorisé » (reviewer-only), Retry
|
|
recovering a failed species list, a failed Retry keeping roles/profile/workspace; the old « leaves a failed
|
|
read to the server » test is replaced; `pnpm test:run` is green on each lot.
|
|
CHECK: cd /tmp/claude-1000/-home-bchanot-Documents-faunosteo/e641af9a-743e-46d0-9804-99667836040e/scratchpad/v1-2 && pnpm --filter @faunosteo/app exec vitest run tests/unit/routes.admin.test.tsx tests/unit/state.authStore.test.ts tests/unit/lib.dates.test.ts tests/unit/admin.validation.test.ts tests/unit/components.SecurityPanel.test.tsx && echo UNIT-OK
|
|
EXPECT: UNIT-OK
|
|
EVIDENCE: MET exit=0 marker-found :: RUN v3.2.7 /tmp/claude-1000/-home-bchanot-Documents-faunosteo/e641af9a-743e-46d0-9804-99667836040e/scratchpad/v1-2/apps/app ✓ tests/unit/lib…
|
|
5. `e2e:shell` (sandbox) proves on desktop: an editor at `aal2` gets the form; a reviewer-only account gets
|
|
« Accès non autorisé » on `/app/admin/sheets/new`; with the own-grants request answered 500, the unavailable
|
|
screen shows (no form field present), axe clean, and Retry after the request is restored shows the form. At
|
|
320 and 375 px (viewport set explicitly) the catalogue sheet page's zone panel holds an `aria-live` region
|
|
before any pick, which then names the picked zone, and the « Références » card starts at or below the
|
|
drawing's bottom (1 px tolerance).
|
|
6. Grant expiry: the form converts the chosen day to 23:59:59.999 Europe/Paris with the offset in force at that
|
|
instant; « today » for the past-day check and the date picker's `min` (tomorrow) are Europe/Paris dates;
|
|
tests run with `process.env.TZ` set to non-Paris zones (asserted) and cover a winter day, a summer day,
|
|
2026-03-29 and 2026-10-25 (DST days); the grant list shows the expiry day in Europe/Paris (tested under a
|
|
non-Paris zone). pgTAP proves, through `grant_catalog_right` under two session `TimeZone` values, that the
|
|
stored instant for future DST days (2027-03-28, 2027-10-31) is the same, and that `list_catalog_grants`
|
|
gives `expired` (now - 1 min), `expiring` (now + 1 min) and `active` (now + 30 days + 1 min) with
|
|
`effective` as expected. No historical row is rewritten (no UPDATE, no migration touching existing
|
|
`expires_at`).
|
|
7. Species order: `create_species` and `update_inactive_species` refuse an order outside 0..9 999 with
|
|
`invalid_input`; 0 and 9 999 accepted; null keeps the current default/value; pgTAP covers -1, 10 000, 0,
|
|
9 999, null; the redefined RPCs keep `security definer` and `search_path=""` (pgTAP `proconfig`); types
|
|
unchanged (`db:types --check`); fresh install and upgrade from M6 (`pnpm db:sandbox up upgrade
|
|
20261102100000`) on the sandbox.
|
|
8. Labels: FR `admin.grant_kind.sheet_reviewer` = « Relecteur ou relectrice »; contract §3 nomenclature row
|
|
aligned; EN `catalogue.failure.drawing_hash_mismatch` = « The illustration file's contents do not match its
|
|
recorded SHA-256 hash. »; L14 EN card title stays « Access and permissions »; L15 recorded as the title alone
|
|
(no second sentence) for V1-2.6; MFA factor name max 64 (client and its test unchanged or tightened); no
|
|
other ratified V1-2.4 wording changed; the label-proposals file says the ~350 new labels are not approved.
|
|
9. TOTP enrolment: a test proves the setup key is rendered in full as text in a selectable element (no
|
|
`select-none`, no `user-select: none`) while enrolment is open; no Copy button added; the key is still never
|
|
stored, logged or sent by the app.
|
|
10. MFA docs: `IDENTITY.md` §4.1 records TOTP code reuse within its window as measured by a new asserted case of
|
|
`mfa-behaviour.sandbox.ts` (same code verified by a second aal1 session signed in after the first verify and
|
|
proven alive before the code is sent, again by the same session, and once more in the following 30 s step;
|
|
the measured span quoted);
|
|
a new `IDENTITY.md` subsection reviews the lost-authenticator paths (second factor, account recovery,
|
|
authorised administrative intervention, identity checks, audit trail), states each gap, and the V1-2 contract
|
|
lists the missing safe recovery as an explicit production prerequisite. No MFA bypass, no AAL2 weakening, no
|
|
new RPC, screen or service path that resets a factor.
|
|
11. Decisions recorded without touching any board image: V1-2 contract §12.3 M7 row and §17.10 row (M7 now
|
|
redefines two species RPCs), §13 new bullets (TOTP reuse residual; production prerequisite: rehearsed
|
|
lost-factor recovery), §17.11 (this checkpoint: three states and the creation-page order,
|
|
two accepted UX deviations with their conditions, ratified choices, labels), `docs/design/README.md`
|
|
(accepted deviations), `docs/design/v1-2-4/REVUE.md` label rows (L15, `object_conflict` EN), the V1-2.5
|
|
contract clarification on the failed read replaced.
|
|
12. Gates on the final code: `pnpm check:all` green; sandbox `test-db` (fresh install and upgrade from M6),
|
|
`pnpm db:sandbox test` (MFA suite included), `pnpm e2e:shell` green; nothing reported that did not run;
|
|
no DEV operation, no merge, no deploy.
|
|
|
|
## FILE SCOPE
|
|
|
|
- apps/app/src/state/authStore.ts
|
|
- apps/app/src/components/shell/PermissionsUnavailable.tsx (new)
|
|
- apps/app/src/components/shell/AccessDenied.tsx (doc comment only)
|
|
- apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx
|
|
- apps/app/src/app/routes/app/admin/AdminHomeRoute.tsx
|
|
- apps/app/src/lib/dates.ts
|
|
- apps/app/src/admin/validation.ts, apps/app/src/admin/labels.ts, apps/app/src/components/admin/{GrantList,GrantPanel}.tsx
|
|
- apps/app/src/components/catalogue/ZonePanel.tsx (live region always mounted, nothing visible changes)
|
|
- apps/app/src/i18n/fr.ts, apps/app/src/i18n/en.ts
|
|
- apps/app/tests/unit/{routes.admin.test.tsx,state.authStore.test.ts,lib.dates.test.ts,components.SecurityPanel.test.tsx},
|
|
new apps/app/tests/unit/admin.validation.test.ts
|
|
- apps/app/e2e/shell/{admin.spec.ts,catalogue spec}
|
|
- supabase/migrations/20261102100000_sheet_admin_reads.sql (M7), supabase/tests/{015_catalog_access,022_sheet_admin_reads}.sql
|
|
- packages/supabase/tests/sandbox/mfa-behaviour.sandbox.ts
|
|
- packages/supabase/tests/sandbox/{sheets-admin,sheets-concurrency}.sandbox.ts (state-independence fixes, mid-run)
|
|
- docs/development/IDENTITY.md, docs/development/V1-2_ANATOMICAL_SHEETS.md, docs/design/README.md,
|
|
docs/design/v1-2-4/REVUE.md, .claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md,
|
|
.claude/audits/2026-11-02-v1-2-5-label-proposals.md
|