69 lines
8.0 KiB
Markdown
69 lines
8.0 KiB
Markdown
# CONTRACT — core-stopped-audit-fix
|
|
- date: 2026-10-15 | flow: bugfix | branch: feature/rust-r3-anatomy-core
|
|
- status: active
|
|
- plan: .claude/tasks/plans/2026-10-15-core-stopped-audit-fix-1830.md (rev 3, owner-approved 2026-10-15)
|
|
- base: 0279953 (run every CHECK from the repository root)
|
|
|
|
## REQUEST (verbatim — IMMUTABLE)
|
|
Je valide le comportement d'arrêt définitif du moteur WASM après trois reprises, ainsi que les messages FR/EN proposés.
|
|
|
|
La disparition du bouton « Réessayer » et la correction des huit alertes sont approuvées.
|
|
|
|
Effectue un dernier audit indépendant, ciblé uniquement sur cette correction : compteur de reprises, distinction erreur temporaire/arrêt définitif, réinitialisation après rechargement, cohérence des messages et conservation des données.
|
|
|
|
Vérifie particulièrement que le message annonçant la conservation du bilan ne soit pas trompeur si l'enregistrement du brouillon a échoué (quota ou autre erreur). Réutilise autant que possible les mécanismes de persistance et d'alerte déjà existants.
|
|
|
|
Si cet audit est satisfaisant, conserve les résultats dans le suivi. Ne recommence pas les audits complets de R3.
|
|
|
|
Les corrections UX et les formulations sont désormais acceptées.
|
|
|
|
R3 reste non fusionnée jusqu'à ma confirmation de la validation manuelle LAN. Ne commence pas R4.
|
|
|
|
## CLARIFICATIONS
|
|
Q: stopped + last save refused: what replaces « votre bilan est conservé » ? / A: variant `core.stopped_unsaved` + « Télécharger une copie » (in-memory report as JSON, no core). FR « Le moteur de calcul de Faunosteo s'est arrêté après plusieurs erreurs, et l'espace de stockage de cet onglet est plein : vos dernières modifications ne sont pas enregistrées et seraient perdues en rechargeant la page. Téléchargez une copie avant de recharger. » EN "Faunosteo's computation engine stopped after several errors, and this tab's storage is full: your latest changes are not saved and would be lost if you reload the page. Download a copy before reloading." [gated 2026-10-15]
|
|
Q: « plusieurs erreurs successives » inaccurate? / A: reword to « plusieurs erreurs » / "several errors", rest of `core.stopped` unchanged. [gated 2026-10-15]
|
|
Q: reload button on the stopped notice? / A: yes, `core.reload` « Recharger la page » / "Reload the page", only when the save is fine, never in the unsaved variant. [gated 2026-10-15]
|
|
Q: copy button on the existing storage-full banner (engine not stopped)? / A: yes, always; banner text (`editor.save_failed`) unchanged. [gated 2026-10-15]
|
|
Q: confirm reload / close while the report is not saved in the tab? / A: yes, native `beforeunload` while unsaved. [gated 2026-10-15]
|
|
Q: stopped notice placement on Home and New report? / A: top of the page content, below the header; in the editor, in place of the storage-full banner. [gated 2026-10-15]
|
|
Q: (internal, orchestrator) test helper extension in tests/helpers/core.ts outside the listed scope? / A: accepted: shared test seam, no product effect. [gated 2026-10-15]
|
|
Q: plan rev 3 approved, run on the branch, no merge, no R4? / A: yes. [gated 2026-10-15]
|
|
|
|
## ACCEPTANCE CRITERIA
|
|
1. A failed recovery below the cap is restarted by the next call or `ready()` (not counted as a recovery, compiled module reused); a failed first load is not; the default cap is 3; the third failed recovery or the fourth trap stops; listeners are notified after a microtask and a throwing listener changes nothing (core-wasm tests).
|
|
CHECK: cd packages/core-wasm && npx vitest run tests/runtime.test.ts > /tmp/cs-rt.log 2>&1 && grep -qi "restart" tests/runtime.test.ts && grep -qi "subscribe" tests/runtime.test.ts && echo RUNTIME_OK
|
|
EXPECT: RUNTIME_OK
|
|
EVIDENCE: MET exit=0 marker-found :: RUNTIME_OK
|
|
2. FR and EN dictionaries hold `core.stopped_unsaved` and `core.reload`, and `core.stopped` no longer says « successives » / "successive".
|
|
CHECK: f=apps/app/src/i18n/fr.ts; e=apps/app/src/i18n/en.ts; for k in core.stopped_unsaved core.reload core.stopped; do grep -q "'$k'" $f && grep -q "'$k'" $e || exit 1; done; grep -A2 "'core.stopped'" $f | grep -q successives && exit 1; grep -A2 "'core.stopped'" $e | grep -qi successive && exit 1; grep -A2 "'core.stopped'" $f | grep -q "plusieurs erreurs" && echo I18N_OK
|
|
EXPECT: I18N_OK
|
|
EVIDENCE: MET exit=0 marker-found :: I18N_OK
|
|
3. The ESLint census refuses a direct `t('core.action_failed')` outside src/core/failure.ts (positive control), and the tree lints clean.
|
|
CHECK: cd apps/app && echo "export const x = (t: (k: string) => string) => t('core.action_failed')" | npx eslint --stdin --stdin-filename src/app/routes/Probe.tsx > /dev/null 2>&1 && exit 1; echo "export const x = (t: (k: string) => string) => t('editor.export_failed')" | npx eslint --stdin --stdin-filename src/app/routes/Probe.tsx > /dev/null 2>&1 && exit 1; npx eslint . --max-warnings 0 > /dev/null 2>&1 && echo CENSUS_OK
|
|
EXPECT: CENSUS_OK
|
|
EVIDENCE: MET exit=0 marker-found :: CENSUS_OK
|
|
4. The whole app suite, typecheck and lint pass.
|
|
CHECK: ./node_modules/.bin/pnpm typecheck > /tmp/cs-tc.log 2>&1 && ./node_modules/.bin/pnpm test:run > /tmp/cs-test.log 2>&1 && ./node_modules/.bin/pnpm lint > /tmp/cs-lint.log 2>&1 && echo SUITES_OK
|
|
EXPECT: SUITES_OK
|
|
EVIDENCE: MET exit=0 marker-found :: SUITES_OK
|
|
5. No golden, oracle, seed, Rust crate or frozen package changed since the base.
|
|
CHECK: n=$(git status --porcelain -- apps/app/tests/fixtures crates supabase packages/domain packages/pdf packages/anatomy | wc -l); m=$(git diff --stat 0279953 -- apps/app/tests/fixtures crates supabase packages/domain packages/pdf packages/anatomy | wc -l); [ "$n" = 0 ] && [ "$m" = 0 ] && echo FROZEN_OK
|
|
EXPECT: FROZEN_OK
|
|
EVIDENCE: MET exit=0 marker-found :: FROZEN_OK
|
|
6. Stopped engine, save fine: every core page (Editor banner slot, Home, New report, the full-page CoreUnavailable) shows `core.stopped` with a « Recharger la page » button and no « Réessayer »; action / export / import / new-report failures say `core.stopped`. Tested.
|
|
7. Stopped engine, last save refused (`saveFailed` with a report in memory): the same surfaces show `core.stopped_unsaved` with « Télécharger une copie », never the reload button; the downloaded Blob content equals `JSON.stringify(report)` of the in-memory report; no message on any page names a button absent from that page. Tested.
|
|
8. Engine not stopped, save refused: the editor banner keeps the `editor.save_failed` text and gains the core-free « Télécharger une copie » button; a `beforeunload` handler is registered exactly while the report is unsaved. Tested.
|
|
9. Canvas: « Réessayer » (engine failure, not stopped) calls `coreRuntime().retry()` before rebuilding; a canvas engine failure shown while the engine becomes stopped switches to the stopped text with no button (derived at render, reactive to `saveFailed`). Tested.
|
|
10. A core failure while reading an unread draft makes `initReport` / `hydrateImport` return `{ ok: false }` without `reason: 'held'`, the draft untouched; New report and Home no longer say `session.held_blocked` for it (state.heldSession.test.ts inverted accordingly).
|
|
11. `HeldSessionPanel` download behaviour unchanged (shared helper); `core/sheetOps.ts` comment no longer names `core.action_failed` as the shown message; RUST.md §9.4 and the CHANGELOG R3 owner-decisions line describe the restart, the stopped notice placement and both variants.
|
|
12. No merge, no R4 work, no change outside the FILE SCOPE.
|
|
|
|
## FILE SCOPE
|
|
packages/core-wasm/src/runtime.ts, packages/core-wasm/tests/runtime.test.ts,
|
|
apps/app/src/core/{runtime,failure,sheetOps}.ts, apps/app/src/lib/download.ts (new),
|
|
apps/app/src/components/report/{CoreStoppedNotice.tsx (new),CoreUnavailable.tsx,HeldSessionPanel.tsx},
|
|
apps/app/src/components/canvas/AnatomyCanvas.tsx,
|
|
apps/app/src/app/routes/{EditorRoute,NewReportRoute,HomeRoute}.tsx, apps/app/src/state/reportStore.ts,
|
|
apps/app/src/i18n/{fr,en}.ts, apps/app/eslint.config.js, apps/app/tests/unit/** (new or updated tests), apps/app/tests/helpers/core.ts (test seam `controlStopped`; internal, added after verifier pass 1),
|
|
docs/development/RUST.md, CHANGELOG.md
|