Owner checkpoint 2026-11-02: creation page checks loading, server refusal, failed read, then the editor rule; Administration home shows the same notice. reloadAccess re-reads roles and grants without wiping held state; refreshAccount (no caller) removed. Zone panel live region always mounted. Unit and e2e for reviewer-only and editor.
19 KiB
Plan: V1-2.5 owner checkpoint corrections (revised after challenge)
Contract .claude/tasks/contracts/2026-11-02-v1-2-5-owner-checkpoint-2041.md (criteria 1-12). Branch
feature/v1-2-anatomical-sheets, worktree
/tmp/claude-1000/-home-bchanot-Documents-faunosteo/e641af9a-743e-46d0-9804-99667836040e/scratchpad/v1-2
(every command runs from there; never the main checkout /home/bchanot/Documents/faunosteo, never DEV, no
pnpm e2e:sheet-assets, no worker against DEV). Sandbox only (pnpm db:sandbox …). Three lots, one fresh
executor each, in order; the orchestrator commits each lot after pnpm typecheck && pnpm lint && pnpm test:run
are green (project rule), plus the lot's own checks.
In-force decisions honoured: BDR-094 (« Accès non autorisé » acts on the server's refusal: kept, and on the
creation page the server's rights.* answer is checked before the failed client read), BDR-096 (boards never
regenerated), BDR-097 (M7 = V1-2.5's migration, sandbox only), BDR-098 (M7 redefinitions restate privileges),
LRN-112 (GoTrue MFA, aal2 for factor changes: untouched), LRN-110 (sandbox-only runners). Server/RLS checks
unchanged.
Lot 1 — three permission states (criteria 1-5)
apps/app/src/state/authStore.ts- delete
refreshAccount(interface line ~75 and implementation ~263; no caller in src, tests or e2e). - new action
reloadAccess: () => Promise<void>, doc « Reads the platform roles and own grants again after a failed permission read (owner 2026-11-02): pages wait, then show what the answer gives; a technical error never wipes what the account already holds. Never rejects. » Body:const user = get().user; const client = getSupabaseClient(); if either is missing →set({ catalogGrants: [], catalogGrantsStatus: 'failed' })and return. Elseconst setOwn = setForUser(user, set, get);setOwn({ catalogGrantsStatus: 'loading' });try { const [roles, catalogGrants] = await Promise.all([fetchOwnPlatformRoles(client, user.id), listOwnCatalogGrants(client, user.id)]); setOwn({ roles, catalogGrants, catalogGrantsStatus: 'ready' }) } catch { setOwn({ catalogGrants: [], catalogGrantsStatus: 'failed' }) }. Profile and workspace untouched.applyAuthEvent's catch unchanged. catalogGrantsStatusdoc:failed= the read failed; pages show the unavailable state, never deduce an absence of right from it.
- delete
apps/app/src/components/shell/PermissionsUnavailable.tsx(new, modelled onAccessDenied.tsx): props{ asPage: boolean; onRetry?: () => void }. Retry buttononClick={onRetry ?? (() => void useAuthStore.getState().reloadAccess())}.asPage→<Card as="section" className="space-y-3 p-5 sm:p-6">with<h1 ref={usePageHeading()} tabIndex={-1}>(AccessDenied classes); else<Card as="section" aria-labelledby="permissions-unavailable-title">with<h2 id=…>(font-serif text-lg text-[var(--color-ink)]). Bodyt('permissions_unavailable.body'), button<Button type="button" variant="secondary">{t('common.retry')}</Button>. Doc comment: owner 2026-11-02, a technical error never reads as an absence of right; the server still decides.apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx: checks in this order:grantsStatus === 'loading'→ existing waiting status;species.state.status === 'error' && isRightsRefusal(species.state.failure)→<AccessDenied />;grantsStatus === 'failed'→<PermissionsUnavailable asPage onRetry={retry} />whereretry = () => { void reloadAccess(); if (species.state.status === 'error') species.refresh() }(reloadAccessread with a selector);!editor→<AccessDenied />. Replace the comment block with the new rule, and state the invariant: every hook stays above the early returns (form values survive a state switch; do not move form state into a child).
apps/app/src/app/routes/app/admin/AdminHomeRoute.tsx: a wrapper<div ref={access} tabIndex={-1} className="outline-none">under the h1 stays mounted in every state; inside it:loading→<p role="status" className="text-sm text-[var(--color-ink-muted)]">{t('shell.loading_session')}</p>;failed→<PermissionsUnavailable asPage={false} onRetry={retry} />;ready→ today'spermissionsLineparagraph.retry = async () => { await reloadAccess(); access.current?.focus() }(focus not lost when the button unmounts). Cards unchanged.apps/app/src/components/shell/AccessDenied.tsx: doc comment only (shown on the creation page once the own grants are read and hold no editor capability, or when the server refuses; never for a failed read).apps/app/src/i18n/fr.ts,en.tsnext toaccess_denied.*:permissions_unavailable.titleFR « Impossible de vérifier vos autorisations » / EN « Unable to verify your permissions »;permissions_unavailable.bodyFR « La vérification n'a pas abouti, probablement à cause d'un problème de connexion. Cette erreur ne modifie pas vos droits. » / EN « The check did not complete, probably because of a connection problem. This error does not change your permissions. ». Retry reusescommon.retry.apps/app/tests/unit/routes.admin.test.tsx: inbeforeEach/afterEach, save and restore the store's realreloadAccess(no leak). Replace the test at ~658-665 (« leaves a failed read to the server ») by: for a reviewer-only grant set and an editor grant set, each inready/failed/loading: form / « Accès non autorisé » / unavailable (noinput, noselect, no « Accès non autorisé ») / waiting. Retry: setStatereloadAccess: vi.fn(async () => useAuthStore.setState({ catalogGrants, catalogGrantsStatus: 'ready' }))→ form for the editor, « Accès non autorisé » for the reviewer-only. Species list failing with a network kind + grants failed → Retry → species options present (the species accessor mock answers on the second call). Server rights refusal + grants failed → « Accès non autorisé ». Admin home:loadingstatus,failednotice + Retry and no « aucune »,readyunchanged, focus on the wrapper after Retry.apps/app/tests/unit/state.authStore.test.ts:reloadAccess→loadingthenready(roles + grants replaced); grants read rejects →failed, grants[], roles/profile/workspace unchanged; roles read rejects → same; no user →failed, resolves; account change during the reload → late answer dropped.apps/app/e2e/shell/admin.spec.ts: in « access per right » (~603) addpage.goto('/app/admin/sheets/new')and theaccess_denied.titleheading check for the reviewer. New test « creation page: unreadable permissions show a retry, never the form » (desktop only,test.skip(isPhone(info))with the same comment as A0/A1/S1): the A1 editor setup ataal2→ form visible; thenpage.route('**/rest/v1/anatomical_catalog_grants*', r => r.fulfill({ status: 500, contentType: 'application/json', body: '{}' })), reload the page → unavailable heading, no#sheet-species-id, axe clean (the suite's helper);page.unroute(…), click « Réessayer » → form visible. Respect the suite's allowlist (a fulfilled route answers locally).apps/app/src/components/catalogue/ZonePanel.tsx: keep one<div aria-live="polite" className="space-y-2">mounted in both branches (selection content, or the existing prompt<p id="catalogue-zone-title">); markup and classes otherwise unchanged, nothing visible changes.apps/app/e2e/shell/catalogue.spec.ts(P1): for 320 and 375 px, set the viewport explicitly; before any pick the panel holds[aria-live="polite"]; after the pick it contains the zone name; the « Références » card's top ≥ the drawing's bottom − 1 px, once the drawing is visible (reuse the file's box helper).
Lot checks: typecheck, lint, pnpm test:run, then on the sandbox (pnpm db:sandbox up fresh if not up; pnpm db:sandbox test-db before e2e on one stack) pnpm e2e:shell.
Lot 2 — expiry, species order, labels, TOTP key (criteria 6-9)
apps/app/src/lib/dates.ts:export const PARIS_TIME_ZONE = 'Europe/Paris'; privateparisParts(instant: number)vianew Intl.DateTimeFormat('en-US', { timeZone: PARIS_TIME_ZONE, year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hourCycle: 'h23' }).formatToParts(instant)→ numbers;parisDateIso(date = new Date())from those parts (YYYY-MM-DD, padded);parisTomorrowIso(date = new Date())= the next calendar day ofparisDateIso(date)(UTC date arithmetic on the Y-M-D, never + 86 400 000 ms);endOfParisDayIso(day: string): string: validate^\d{4}-\d{2}-\d{2}$and a real date (else throw);guess = Date.UTC(y, m - 1, d, 23, 59, 59, 999); offset =Date.UTC(parts at guess, ms 999) - guess(Paris changes offset at 01:00 UTC, so one pass is exact for 23:59 local); returnnew Date(guess - offset).toISOString(). NolongOffset, noformat()string parsing.apps/app/src/admin/validation.ts:parseGrant(values, today = parisDateIso()); transform usesendOfParisDayIso. Comments « the end of the chosen day, Europe/Paris (owner 2026-11-02) ». Theexpires_onrefine also checks the day is a real calendar date (round-trip throughDate.UTC), so the transform never sees2026-02-30(refused withadmin.access.error.expiry; test it).apps/app/src/components/admin/GrantPanel.tsx~280:min={parisTomorrowIso()}; drop thelocalDateIsoimport if unused.apps/app/src/admin/labels.ts:formatDay(iso, locale, timeZone?: string)passestimeZonetotoLocaleDateStringwhen given.GrantList.tsx: expiryformatDay(grant.expires_at, locale, PARIS_TIME_ZONE); granted date unchanged.apps/app/tests/unit/lib.dates.test.ts: adescribethat setsprocess.env.TZ = 'America/Los_Angeles'inbeforeAll(and another with'Pacific/Kiritimati'), assertsIntl.DateTimeFormat().resolvedOptions().timeZoneis that zone, restores inafterAll. Cases:endOfParisDayIso('2026-01-15')→2026-01-15T22:59:59.999Z;'2026-07-15'→2026-07-15T21:59:59.999Z;'2026-03-28'→2026-03-28T22:59:59.999Z;'2026-03-29'→2026-03-29T21:59:59.999Z;'2026-10-25'→2026-10-25T22:59:59.999Z;'2026-02-30'and'2026-1-5'throw;parisDateIso(new Date('2026-11-02T23:30:00Z'))→'2026-11-03';parisTomorrowIso(new Date('2026-03-28T22:30:00Z'))→'2026-03-29'(Paris still 03-28, 23:30 CET) andparisTomorrowIso(new Date('2026-03-28T23:30:00Z'))→'2026-03-30'(Paris 03-29 00:30). Newapps/app/tests/unit/admin.validation.test.ts(same TZ setup):parseGrant→ Paris instant; today refused, tomorrow accepted; move the parseGrant case fromroutes.admin.test.tsx(~552-583) here and delete it there. A GrantList render withprocess.env.TZ = 'Pacific/Kiritimati'(asserted; a zone east of Paris, where the device-zone display would say « 1 janvier 2027 ») shows « 31 décembre 2026 » for2026-12-31T22:59:59.999Zin FR — in the new file.routes.admin.test.tsx~458: the label lookup « Relecteur, relectrice » → « Relecteur ou relectrice ».supabase/migrations/20261102100000_sheet_admin_reads.sql(M7): append « Species order range (owner 2026-11-02) »: the full M5create or replace functionstatements ofpublic.create_species(id text, name_fr text, name_en text, sort_order integer default 100)andpublic.update_inactive_species(id text, name_fr text, name_en text, sort_order integer)copied with signature, defaults and qualified names unchanged, adding onlyor (create_species.sort_order is not null and create_species.sort_order not between 0 and 9999)(resp.update_inactive_species.sort_order) to theinvalid_inputcondition; then for bothrevoke all on function … from public, anon, service_role; grant execute on function … to authenticated;(M5's loop). Header: replace « No write, no grant, no policy and no rule changes here » with what M7 now changes (two species RPCs range check, privileges restated).supabase/tests/022_sheet_admin_reads.sql: as an editor at aal2 (the file's helpers):create_specieswith -1 and 10000 →invalid_input; 0 and 9999 accepted;update_inactive_species-1/10000 refused, 0/9999 accepted, null keeps the stored order;prosecdeftrue andproconfig = array['search_path=""']for both; bumpplan.supabase/tests/015_catalog_access.sql: as the owner at aal2 (file helpers), underset local timezone 'UTC'then'America/New_York':grant_catalog_right(..., expires_at => '2027-03-28T23:59:59.999+02:00')(and'2027-10-31T23:59:59.999+01:00') stores'2027-03-28T21:59:59.999Z'::timestamptz(resp.'2027-10-31T22:59:59.999Z') — revoke between grants or use distinct accounts/kinds to avoidgrant.active; and via direct inserts with an explicit earliergranted_at(pattern at ~179), one fresh confirmed account per state, kindcatalog_reader(effectiveis per account and kind): now()-1 min →expired, effective false; now()+1 min →expiring, effective true; now()+30 days+1 min →active, effective true. Bumpplan. No UPDATE of existing rows.- Labels:
fr.tsadmin.grant_kind.sheet_reviewer→ « Relecteur ou relectrice » (grep both dicts for other « relectrice » forms);en.tscatalogue.failure.drawing_hash_mismatch→ « The illustration file's contents do not match its recorded SHA-256 hash. ». apps/app/tests/unit/components.SecurityPanel.test.tsx(reuse its fakemfa.enrollandstartEnrolment): the setup key is the full text of one element with noselect-noneclass and no inlineuser-select; no button named /cop(y|ier)/i; a 65-character name refused without calling GoTrue, 64 accepted.
Lot checks: typecheck, lint, pnpm test:run (includes PGlite pgTAP), pnpm db:sandbox up fresh + test-db,
pnpm db:sandbox up upgrade 20261102100000 + test-db, pnpm db:sandbox types --check.
Lot 3 — MFA reuse measure, recovery review, decisions in docs (criteria 8, 10, 11)
packages/supabase/tests/sandbox/mfa-behaviour.sandbox.tscase « 11. TOTP code reuse »: account with a verified factor (withFactorverifies with the enrolment step's code); wait into a fresh 30 s step N (so C is not the enrolment code) with ≥ 8 s left; session A (password) takes code C of step N, verifies → aal2. Then sign in session B (password, after A's verify), assert B isaal1and alive (agetUseror itsauth.sessionsrow, as the file does elsewhere) before sending C; B challenge + verify with C; assert the answer is notsession_not_foundand record whether C is accepted. Then A challenges and verifies again with C. Then wait into step N+1, sign in session D, verify with C once more (skew); then into step N+2, session E, verify with C (upper bound of the span). Assertions pin the observed outcome (first run measures; then the assertions are written to it and the suite re-run). No secret or code printed on failure.docs/development/IDENTITY.md§4.1: replace « observed, not asserted » with the asserted outcome, the measured span (one step or two with skew) and its consequence, citing the configuration that ran the measurement (the sandbox GoTrue environment inscripts/db-sandbox.sh, image defaults plus its overrides) and, separately,supabase/config.toml[auth.mfa]for the CLI/DEV stacks, before any claim about mitigations. New §4.2 « Lost authenticator: paths and gaps »: second factor (enrol fromaal2, recommended for every capability holder, two on independent devices for the owner, V1-2 §5.6); self-service recovery (none: no recovery codes; password reset and factor removal needaal2; an ordinary account keepsaal1use, a capability holder loses administration); authorised administrative intervention (operator procedure of V1-2 §5.6 and §5.7.7, server access, never an app path, no RPC or screen); identity checks (out of band, owner present, reason recorded) and audit (auth.mfa_factor_resetrow written by the operator in the same session, GoTrue audit log); gaps: not rehearsed (V1-2.9), audit row depends on the operator, single-owner platform has no second person, no recovery codes → « Production prerequisite: a recovery runbook rehearsed on the sandbox and written here before any production use of MFA-protected rights. » No new path, no weakening ofaal2.docs/development/V1-2_ANATOMICAL_SHEETS.md: §3 nomenclature « Relecteur ou relectrice »; §12.3 M7 row and §17.10 row: M7 also redefinescreate_species/update_inactive_species(order 0..9 999) with privileges restated; §13: new bullets « TOTP code reuse within its window (measured, IDENTITY §4.1): residual » and « Production prerequisite: the lost-factor recovery rehearsed and written (§5.7.7, IDENTITY §4.2) »; new §17.11 « V1-2.5 checkpoint decisions (owner, 2026-11-02) »: three permission states (creation page order: loading, server refusal, failed read, editor or not; Administration home notice; lists keep actions hidden), accepted UX deviations (selection in the zone panel with an always-mounted live region; « Références » card not collapsible on mobile, below the drawing, measured at 320/375 px), MFA factor name 64, TOTP key without Copy (readable, selectable), expiry end of day Europe/Paris (23:59:59.999, picker and display in Paris, backend compares instants, historical rows untouched), species order 0..9 999 server-side (M7), « relecteur ou relectrice », L14, L15 title alone,object_conflictEN, ~350 new labels not approved (separate owner review).docs/design/README.md: « Accepted deviations (owner 2026-11-02, V1-2.5) » with the two items and conditions; boards unchanged.docs/design/v1-2-4/REVUE.md: L15 second-sentence row → decided (removed, title alone);object_conflictEN row → ratified wording. No image touched..claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md: the C4 clarification sentence (« when their read failed … shows the form and the server decides … Submitted for the owner's acknowledgement ») → the owner's decision (unavailable state with Retry; server refusal first; owner 2026-11-02)..claude/audits/2026-11-02-v1-2-5-label-proposals.md: header: L14, L15,object_conflictEN, « relecteur ou relectrice » ratified 2026-11-02; every other new label stays a proposal for a separate owner review; ~31 expiry line → end of the chosen day Europe/Paris, species order → 0..9 999 checked in SQL; ~74 « Relecteur, relectrice » → « Relecteur ou relectrice »; addpermissions_unavailable.*as proposals (FR title = owner wording).
Lot checks: pnpm db:sandbox test (MFA suite and the others) twice green after the assertions are pinned.
After the lots (orchestrator)
GATE 0 gates.sh, fresh verifier, fresh security audit on the whole diff; pnpm check:all; pnpm e2e:shell on
the final code; commit + push per lot; memory (BDR for the checkpoint decisions, journal), TODO; V1-2.6 scope from
V1-2 contract §16.7 and §8.2 for the checkpoint report.