chore(memory): R3 stopped-state audit and fix recorded (BDR-055, BLK-011)
This commit is contained in:
1 parent
6371523f8c
commit
9464651140
8 files changed
+228
No files matched your search
@@ -88,3 +88,10 @@ Friction: the three `isolation: worktree` forks of R2 started at 605ee7c (an old
|
||||
Root cause: harness side (base commit of the agent worktree), not reproducible from the repo; the removal refusal is the destructive-command policy.
|
||||
Solution: forks briefed with the exact base commit and told to verify `git log -1`; diffs collected uncommitted and copied by literal paths. Leftover: `.claude/worktrees/agent-{a0cefd439bff650a2,a3f684449d0776ad1,af6ebe79b8f742039}` (3.2 GB) + 3 local temp branches at 22fea87 (merged), owner removes them (`git worktree remove --force <path>`, `git branch -d <branch>`).
|
||||
Status: resolved 2026-10-14 — after R2 merged into develop (c3f28d8): 66 files checked blob by blob (60 identical to branch history, 6 = fork stub / merged mod lists / lifted `#[ignore]`), no process or agent on them, tip 22fea87 in develop → `git worktree remove --force` ×3 + `gitflow.sh delete` ×3 accepted this time. Harness base-commit cause stays upstream.
|
||||
|
||||
## BLK-011 | 2026-10-16 | Stopped-engine message promised "bilan conservé" with draft unsaved; dead "Réessayer" paths
|
||||
|
||||
Friction: 0279953 picked `core.stopped` from `CoreRuntime.stopped` alone: with sessionStorage full, reload restored older draft, edits lost silently; save banner advised PDF export (needs core). CoreUnavailable, export, import, new report still offered retry after stop; failed recovery below cap = dead end (nothing called `retry()` in editor; canvas button only rebuilt).
|
||||
Root cause: terminal-state message not bound to persistence status (`saveFailed` existed, unread); retry labels audited only on the 8 alerts + canvas the patch touched, not every failure surface; runtime exit from `unavailable` only via explicit `retry()` called by useSheet alone.
|
||||
Solution: 6371523 (BDR-055): `isUnsaved` selector drives variant + copy; CoreStoppedNotice on all core pages; runtime self-restart below cap; FAILED not held; ESLint census. Verifier CONFORME 12/12 (pass 2), security PASS 2 LOW.
|
||||
Status: resolved 2026-10-16. Residuals: saveFailed also on refused archive (over-warns); offline restart never stops (copy on banner); beforeunload only in editor; trap-every-load draft → reload loop; GC finalizer of trapped-instance SheetHandle throws "memory access out of bounds" later (harmless, tests retain handles).
|
||||
@@ -424,3 +424,9 @@ Status: active; R3 awaiting owner validation, not merged.
|
||||
Owner validated after R3 review: (1) unnamed trigger → `data-anno-name-fr`/`-en` + title take opened view name per language, empty language falls back to other; display only (not identifier, not persisted); frozen oracles untouched, tests apply declared change (`with_trigger_names_per_language` / `withTriggerNamesPerLanguage`, MAKE refused). (2) canvas failures distinct: engine (core_unavailable, internal) → `sheet.core_unavailable` + Réessayer (fresh instance may succeed); view (svg_rejected, no_asset, unknown_view, invalid_character, parse) → `canvas.view_unavailable`, no retry; detail in core outcome + DEV console only. (3) recovery cap 3 kept; after it `CoreRuntime.stopped` → `core.stopped` ("reload the page, report kept in tab") in canvas and in the 8 action alerts (`coreFailureMessage`), no retry. Wording of the three messages accepted.
|
||||
Alt rejected: correcting the TS renderer too (engine/pipeline frozen until R4/R5; invisible in PDF: data-* dropped, title not rasterised); retry for deterministic view failures; editing goldens.
|
||||
Status: closed (decisions); R3 still awaiting owner LAN confirmation, not merged.
|
||||
|
||||
## BDR-055 | 2026-10-16 | Engine stopped vs unsaved draft: honest variant, core-free copy, restart not counted
|
||||
|
||||
Owner audit of 0279953 (stopped state) not satisfactory → owner choices (AskUserQuestion 2026-10-15): stopped + `isUnsaved` (saveFailed && report) → `core.stopped_unsaved` + "Télécharger une copie" (in-memory report JSON, `lib/download.ts`, no core); save fine → `core.stopped` + `core.reload` button; copy button also on `editor.save_failed` banner (any engine state); `beforeunload` guard in editor while unsaved; "plusieurs erreurs" (counter = page lifetime, not successive). One `CoreStoppedNotice`: editor banner slot, top of Home / New report, CoreUnavailable full page; canvas stopped text without button. Runtime: failed recovery below cap restarted by next call / `ready()` (`restartable` = unavailable && !stopped && generation > 0), compiled module kept, restart not counted (cap = traps); deferred status listeners. Core failure reading unread draft → FAILED, never held. ESLint census on failure keys. Commit 6371523.
|
||||
Alt rejected: counting failed restarts toward cap (offline → stopped, reload offline fails too); retry button on every page (new UI, owner already removed dead retries); copy only once stopped (offline restart loop never reaches stopped, no rescue).
|
||||
Status: closed; R3 still awaiting owner LAN confirmation, not merged, R4 not started.
|
||||
@@ -171,3 +171,10 @@ Method: maintenance: AskUserQuestion for B UI, store rewrite + 27 tests, verifie
|
||||
Result: all oracles green (O2 exact incl. order, O1/O3 tree-equal, 42 hostile + 10 generated declared or equal, 4 product SVGs untouched); Chromium live trees = O1, 30/30 pixel-identical; module 395.5 KB gz (+56); editor 503 vs 476 ms, detail 143 vs 125 ms (CPU ×4); check:all green.
|
||||
Anomalies: my first prescan had the closer-overlap bug (security caught it, tests did not: corpus lacked overlapped closers); first wasm memory threshold measured leaked sessions (harness artefact) → per-case fresh instance; probe in perf script retained detached nodes (fake leak); `env` and `export` refused by harness → inline env vars; cargo fmt reformat broke python patch anchors ×3 (write whole file or re-read).
|
||||
Action: owner LAN validation (TEST FONCTIONNEL / TEST GRAPHIQUE), owner decisions (EN trigger name, degraded wording), then merge; R4 not started.
|
||||
|
||||
## EVAL-023 | 2026-10-16 | Owner-requested audit of 0279953 + bugfix — independent auditor, 3 challengers + confirm, verifier ×2, security
|
||||
|
||||
Method: fresh general-purpose auditor on commit only (5 owner axes); claims re-read in code; /bugfix: plan → 3 blind challengers → rev 2 → confirm pass → rev 3; owner AskUserQuestion ×3 batches; bugfixer; gates.sh 5/5; verifier; security; doc-syncer.
|
||||
Result: audit NOT satisfactory (3 defects: unsaved promise, 4 dead retries, recovery dead end) — all fixed 6371523; app 374 tests, core-wasm 37; verifier pass 1 ECARTS(3) (2 untested surfaces, helper out of scope) → pass 2 CONFORME 12/12; security PASS 2 LOW; docs NONE.
|
||||
Anomalies: previous session's commit + CHANGELOG claimed "never a retry that cannot work" without surface census; challengers converged on dead end the plan fixed only on canvas; confirm pass found offline restart never reaching stopped → copy moved to save banner (owner choice). Executor found latent GC finalizer throw (not fixed).
|
||||
Action: R3 stays unmerged until owner LAN confirmation; R4 not started.
|
||||
@@ -267,3 +267,4 @@ feature/rust-r3-anatomy-core: plan rev 2 after 3 challengers (32 findings; block
|
||||
- Same day: gates. Verifier CONFORME 11/11. Security PASS + MEDIUM (prescan closer searched inside its opener, `<!-->` hid 5,000 levels → stack overflow) fixed; pass 2 PASS (4M differential docs) + LOW url( whitespace fixed; verifier re-run CONFORME. Final check:all green, Chromium 30/30 identical. BDR-052/053, LRN-056, EVAL-022. Stop: owner LAN validation.
|
||||
- 2026-10-15 owner UX decisions on R3: unnamed trigger names per language (contract doc first, Rust layer, declared change applied to frozen oracles, goldens untouched); canvas engine failure (retry) vs view failure (own message, no retry). check:all green, Chromium 30/30 identical + DOM = O1 (declared), verifier CONFORME 8/8, security PASS 0 findings. Owner LAN tests in progress; no merge, no R4.
|
||||
- 2026-10-15 owner validated both UX fixes + retry on internal; asked 3-attempt cap then clear failure state: found canvas + 8 alerts would still offer retry after cap → `CoreRuntime.stopped` + `core.stopped` message, no retry. BDR-054. R3 not merged (LAN tests pending).
|
||||
- 2026-10-16 owner asked final independent audit of 0279953 (stopped state): not satisfactory (unsaved draft promise false, 4 dead retries, recovery dead end). Owner choices: unsaved variant + core-free copy, reload button, copy on save banner, beforeunload, "plusieurs erreurs". Fixed 6371523 (runtime self-restart below cap, CoreStoppedNotice on core pages, FAILED not held, ESLint census); verifier CONFORME 12/12, security PASS. BDR-055, BLK-011, LRN-057, EVAL-023. R3 not merged (LAN pending), no R4.
|
||||
@@ -436,3 +436,12 @@ Apply: any reader of user data (R3 SVG, R4 PDF reader, R5 pipeline) → refuse w
|
||||
- vitest/React: effect with per-render deps (useT closure) + setState(new array) → infinite render loop (OOM); guard side-effectful restore per attempt with a ref.
|
||||
- Visual parity: freeze happy-dom trees + Chromium screenshots BEFORE switch; same-build double capture gives the noise floor (30/30 identical); synthetic controls validate the comparator; baseline = `git archive develop` built in scratchpad (no worktree).
|
||||
Apply: R4 PDF reader/writer (byte scanners, inflate), Step 13 uploads (reader in worker child), any parser fed untrusted input.
|
||||
|
||||
## LRN-057 | 2026-10-16 | Terminal-failure UX: bind data-safety promises to save status, census every retry surface
|
||||
|
||||
- Message promising data kept ("report kept in this tab") must read real persistence status (quota flag); else variant + core-free rescue (download of in-memory state).
|
||||
- Capped recovery → enumerate EVERY failure surface (grep failure keys, retry handlers, full-page degraded states), not only those the patch touched; enforce with ESLint `no-restricted-syntax` on `t('<key>')` literals (dictionaries untouched, file-scoped exceptions; later block overrides earlier for same rule).
|
||||
- Each "retry" label needs reachable path to the runtime's recovery; runtime-level restart on next call beats per-surface buttons.
|
||||
- Rescue must exist in every non-ready state, not only terminal one: a restart loop offline never reaches "stopped".
|
||||
- Status listeners from a state machine: notify via microtask, try/catch per listener, never inside load/recover try blocks; stable module-scope subscribe for useSyncExternalStore.
|
||||
Apply: R4 PDF worker failure states, Step 8 avatar upload errors, any capped retry or offline mode.
|
||||
@@ -200,6 +200,7 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
|
||||
- [ ] R3 owner validation (LAN: TEST FONCTIONNEL + TEST GRAPHIQUE), then merge on the owner's go; R4 not started
|
||||
- [x] R3 owner decisions 2026-10-15: unnamed trigger names per language (6882c6d, contract d8e9bd3); canvas engine failure (retry) vs view failure (no retry) (c0a5c8c)
|
||||
- [x] R3 owner follow-up 2026-10-15: retry kept for `internal`; after the 3 recoveries a clear final state (`core.stopped`) in the canvas and the action alerts, no retry (BDR-054)
|
||||
- [x] R3 owner-requested audit of 0279953 (2026-10-15/16): not satisfactory (unsaved draft promise, 4 dead retries, recovery dead end) → fixed 6371523 (BDR-055, BLK-011); verifier CONFORME 12/12, security PASS; residuals in BLK-011
|
||||
- [ ] R3 follow-ups kept by the owner (2026-10-15): worker TLS exercised against a real HTTPS endpoint before the deployment that needs it; roxmltree limits + SVG prescan (pin the iterative release when published); Firefox/WebKit check; SVG references across drawings scoped per view before community uploads (Step 13); WASM size margin (396 of 600 KB) before R4; TypeScript PDF sanitiser still present until R4
|
||||
- [ ] R4 pdf core: reader (Web Worker, BLK-009 browser measurements) + writer (`pdf-writer`, Std14 AFM, draw log; lines/rects/colours golden frozen with the TS engine first, D-R2) + `report-compare` tool; `packages/pdf` deleted; N-1 scanner reads R4 PDFs
|
||||
- [ ] R5 curation pipeline + importer + upload tool: seed golden regenerated once (new `documentSha256`, D-R5), `packages/anatomy` + `packages/domain` deleted, docs map; all before Step 13
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# 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
|
||||
@@ -0,0 +1,129 @@
|
||||
# Plan — engine stopped: audit fixes on 0279953 (bugfix, branch feature/rust-r3-anatomy-core)
|
||||
|
||||
## Context
|
||||
Commit 0279953 added `CoreRuntime.stopped` (recovery cap 3 spent), `coreStopped()`, `coreFailureMessage(t)`
|
||||
(apps/app/src/core/failure.ts), canvas failure `engine_stopped`, key `core.stopped` ("reload the page, your
|
||||
report is kept in this tab"). Independent audit found:
|
||||
|
||||
- A. `core.stopped` ignores `reportStore.saveFailed` (set by the draft mirror when sessionStorage refuses a write,
|
||||
reportStore.ts:392-396, shown as banner `editor.save_failed` "Exportez le PDF pour les conserver",
|
||||
EditorRoute.tsx:303). Once stopped, export needs the core (pdf/export.ts:37 `index.ops.snapshot`) → impossible.
|
||||
Reload restores the last successful write → edits since the refused write lost, unannounced.
|
||||
- B. Surfaces still offering a retry that cannot work once stopped: CoreUnavailable (EditorRoute.tsx:257,
|
||||
`sheet.retry` → runtime.retry() returns false at cap), export catch (`editor.export_failed` "Réessayez"),
|
||||
import (`home.import.error_core_unavailable` "Réessayez l'import"), NewReportRoute.tsx:55
|
||||
(`sheet.core_unavailable`). Also `releaseUnreadSession` (reportStore.ts:248-262) returns false on a core
|
||||
failure, so initReport / hydrateImport return HELD and the pages say `session.held_blocked` (wrong cause).
|
||||
- C. Canvas "Réessayer" (AnatomyCanvas.tsx ~145) only bumps `attempt` (rebuild), never calls
|
||||
`coreRuntime().retry()`: after a failed recovery below the cap (state unavailable, stopped false) it is a dead end.
|
||||
- D. Stale comment core/sheetOps.ts:17; test gaps (default cap 3 unpinned, failed recovery below/at cap, no census
|
||||
of call sites, no stopped+saveFailed test).
|
||||
|
||||
Owner choices (AskUserQuestion 2026-10-15):
|
||||
1. stopped + save failed → variant message `core.stopped_unsaved` + "Télécharger une copie" button writing the
|
||||
IN-MEMORY report as JSON, no core (rescue copy; not importable today, import reads PDFs only).
|
||||
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."
|
||||
2. `core.stopped` wording: "plusieurs erreurs successives" → "plusieurs erreurs" (EN "several successive errors"
|
||||
→ "several errors"); rest unchanged.
|
||||
3. "Recharger la page" button (new key `core.reload`, FR « Recharger la page », EN "Reload the page") on the
|
||||
stopped notice ONLY when the save is fine; never in the unsaved variant.
|
||||
|
||||
## Fix plan (rev 2, after 3 challengers)
|
||||
|
||||
1. packages/core-wasm/src/runtime.ts —
|
||||
a. Self-restart after a failed recovery (closes C everywhere, not only on the canvas): `restartable` =
|
||||
`state === 'unavailable' && !stopped && generation > 0` (an instance ran before: a failed recovery or a
|
||||
failed restart; a failed FIRST load stays on useSheet's explicit retry). `ready()` on a restartable runtime
|
||||
returns `this.retry()` (awaits the restart); every CORE_UNAVAILABLE answer of `invoke()` and of
|
||||
`SheetSession.current()` on a restartable runtime kicks `void this.retry()` and still answers
|
||||
CORE_UNAVAILABLE (the next user action works: "Réessayez" becomes true). No counter change: a restart is
|
||||
not a recovery; the cap still counts traps. A restart keeps `compiled` when `generation > 0` (the module
|
||||
already ran; only a failed FIRST load clears it), so a restart fetches a glue record, never recompiles.
|
||||
b. Status listeners: `subscribe(listener): () => void`. Notification is deferred (`queueMicrotask`) after the
|
||||
transition, never inside the try blocks of load/recover, each listener wrapped in try/catch; a throwing or
|
||||
re-entrant listener cannot change the state machine.
|
||||
2. apps/app/src/core/runtime.ts — module-scope `subscribeCore(cb) = coreRuntime().subscribe(cb)` (stable
|
||||
identity) and `useCoreStopped()` = `useSyncExternalStore(subscribeCore, coreStopped)`. Used on the three core
|
||||
pages only (Editor, Home, New report); creating the runtime object loads nothing (lazy load stays on ready()).
|
||||
3. apps/app/src/state/reportStore.ts —
|
||||
a. exported selector `isUnsaved(s) = s.saveFailed && s.report !== null` (one rule, used by the notice and the
|
||||
alerts).
|
||||
b. `releaseUnreadSession` / `mayStartSession` return `ActionResult`: set-aside failure → HELD; core cannot read
|
||||
the unread draft (any kind outside UNREADABLE_DRAFT_KINDS) → FAILED (never HELD); initReport / hydrateImport:
|
||||
`const may = mayStartSession(index); if (!may.ok) return may`. Nothing written in either case (unchanged).
|
||||
4. apps/app/src/core/failure.ts — `stoppedMessageKey()` = `isUnsaved(useReportStore.getState()) ?
|
||||
'core.stopped_unsaved' : 'core.stopped'`; `coreFailureMessage(t, fallbackKey = 'core.action_failed')`:
|
||||
stopped → `t(stoppedMessageKey())`, else `t(fallbackKey)`.
|
||||
5. apps/app/src/lib/download.ts (new) — `downloadJson(raw, stem)`: body of HeldSessionPanel's `downloadCopy`
|
||||
(Blob application/json, anchor attached while clicked, URL revoked after 30 s, `<stem>-<todayIso()>.json`).
|
||||
HeldSessionPanel calls it (behaviour unchanged).
|
||||
6. apps/app/src/components/report/CoreStoppedNotice.tsx (new) — the one host of the stopped buttons. Reads
|
||||
`useReportStore(isUnsaved)` and `report`. unsaved → Notice error `core.stopped_unsaved` + Button
|
||||
`session.held.download` (reused key) → `downloadJson(JSON.stringify(report), 'faunosteo-brouillon')`;
|
||||
otherwise Notice error `core.stopped` + Button `core.reload` → `window.location.reload()`. Never a retry.
|
||||
`CoreStoppedBanner` (same file or inline) = `useCoreStopped() ? <CoreStoppedNotice/> : null`.
|
||||
7. Placement (persistent, whenever stopped, so alerts never name a button that is not on the page):
|
||||
- EditorRoute banner slot: stopped → `<CoreStoppedNotice/>` (same margins as the save banner) INSTEAD of
|
||||
`editor.save_failed`; not stopped + saveFailed → `editor.save_failed` text + the same core-free
|
||||
"Télécharger une copie" button [rev 3, owner gate Q1]: the rescue exists in every engine state (a restart that
|
||||
keeps failing offline never reaches `stopped`).
|
||||
- [rev 3, owner gate Q2] `beforeunload` guard while `isUnsaved` (native browser confirm), registered in
|
||||
EditorRoute; removed when the save recovers.
|
||||
- HomeRoute and NewReportRoute: `<CoreStoppedBanner/>` at the top of the page content (below the header), so the
|
||||
unsaved variant's download is on every page that can show its text.
|
||||
- CoreUnavailable: `useCoreStopped()` → `<main><CoreStoppedNotice/></main>` instead of notice + retry.
|
||||
8. apps/app/src/components/canvas/AnatomyCanvas.tsx — the engine variant is derived at render: a build failure
|
||||
`engine` with `useCoreStopped()` true (or a build `engine_stopped`) → Notice with the stopped text chosen from
|
||||
`useReportStore(isUnsaved)` (reactive), no button (the page banner holds the buttons; DetailModal never opens once stopped: a zone click is a core call).
|
||||
"Réessayer" (engine only): `void coreRuntime().retry().finally(() => setAttempt(n => n + 1))`.
|
||||
9. Alerts / error lines: EditorRoute export catch → `coreFailureMessage(t, 'editor.export_failed')`;
|
||||
NewReportRoute:55 → `coreFailureMessage(t, 'sheet.core_unavailable')`; HomeRoute `importErrorMessage`
|
||||
core_unavailable → `coreFailureMessage(t, 'home.import.error_core_unavailable')`; HomeRoute hydrateImport
|
||||
`!ok`: `reason === 'held'` → held alert + navigate (unchanged), else throw `ImportError('core_unavailable')`.
|
||||
10. apps/app/src/core/sheetOps.ts:17 comment → "shows `coreFailureMessage`".
|
||||
11. i18n fr.ts / en.ts — `core.stopped` reworded (choice 2); new `core.stopped_unsaved`, `core.reload`.
|
||||
12. ESLint (apps/app/eslint.config.js): `no-restricted-syntax` on `t('core.action_failed')`,
|
||||
`t('editor.export_failed')`, `t('home.import.error_core_unavailable')`, `t('sheet.core_unavailable')` call
|
||||
literals in src, except src/core/failure.ts, and for `sheet.core_unavailable` also CoreUnavailable.tsx and
|
||||
AnatomyCanvas.tsx (the census, codebase idiom; dictionaries are not call sites).
|
||||
13. docs/development/RUST.md §9.4 (+ §8 runtime note if it describes recovery) and the CHANGELOG R3 owner-decisions
|
||||
line: restart on next action after a failed recovery; stopped notice on the core pages (reload, or unsaved
|
||||
variant with copy); export / import / new report say the stopped message.
|
||||
|
||||
## Tests
|
||||
- core-wasm runtime.test.ts: default cap = 3 (three recoveries succeed, fourth trap → stopped, retry false);
|
||||
failed recovery below the cap → stopped false, then the next call kicks a restart and the call after it
|
||||
succeeds; `ready()` after a failed recovery restarts and resolves true; third recovery fails → stopped true, no
|
||||
restart kicked; a failed first load is NOT restarted by a call (only retry()); subscribe notified (after a
|
||||
microtask) on the transition to stopped, a throwing listener does not change the state, unsubscribe stops it.
|
||||
- AnatomyCanvas: engine retry calls `coreRuntime().retry()` (spy) then rebuilds; engine_stopped shows the stopped
|
||||
text (unsaved variant when isUnsaved) and no button.
|
||||
- CoreStoppedNotice: save fine → `core.stopped` + reload button, no retry; isUnsaved → `core.stopped_unsaved` +
|
||||
download whose Blob content equals JSON.stringify(report).
|
||||
- EditorRoute: stopped → banner notice replaces `editor.save_failed`; not stopped + saveFailed → save banner
|
||||
with the copy button; beforeunload registered only while isUnsaved; export failure while stopped → stopped alert.
|
||||
- runtime: a restart after a failed recovery reuses `compiled` (compile called once).
|
||||
- HomeRoute / NewReportRoute: stopped → banner present; stopped + unsaved → download button on the page.
|
||||
- state.heldSession.test.ts:268-280 inverted: core cannot read the draft → `{ ok: false }` without
|
||||
`reason: 'held'`, draft untouched; same for hydrateImport.
|
||||
- ESLint rule proven: lint fails on a sample `t('core.action_failed')` outside failure.ts (rule test via
|
||||
`pnpm lint` on the tree + one RuleTester-free check: the tree lints clean).
|
||||
- `pnpm typecheck && pnpm test:run && pnpm lint` green; core-wasm vitest green (TS-only runtime change, no wasm
|
||||
rebuild; stamp unaffected).
|
||||
|
||||
## Known residuals (recorded, not fixed here)
|
||||
- `saveFailed` also covers a refused archive write (BDR-052 banner semantics, pre-existing): the unsaved variant
|
||||
over-warns then; the copy holds the report, the archive is the imported PDF still on disk.
|
||||
- Kinds such as `rebase_failed` (sheet defect) answer FAILED → "Réessayez" (generic; near-unreachable).
|
||||
- Home while not stopped but the engine cannot restart (offline) and saveFailed: no banner there; the editor
|
||||
banner holds the copy.
|
||||
- New report banner "Recharger la page" discards a typed form (shown from page entry, so usually before typing).
|
||||
- New report / import while an open report has saveFailed replace it (pre-existing; deliberate user action).
|
||||
- A draft that traps the core on every load → reload loop (pre-existing).
|
||||
|
||||
## Out of scope
|
||||
R4, merge, the frozen PDF engine, Rust crates, goldens; making the JSON copy importable.
|
||||
Reference in new issue
Block a user