docs(docs): Rust review rev 2 — 61 challenger findings folded (3 crates, frozen oracles, consumer-driven deletion, keyless parent, CSP/digest deploy); CLAUDE.md Rust-by-default rule; chore(memory): BDR-043, LRN-048, EVAL-016, journal, TODO Rust roadmap
This commit is contained in:
1 parent
6a078dab74
commit
3fbf34f663
7 files changed
+661
-539
No files matched your search
@@ -354,3 +354,9 @@ Status: active, awaiting user validation of the step.
|
||||
|
||||
User validated every Step 7 screen and flow (login, signup, recovery, dashboard, account, sidebar + drawer, logout, FR/EN, responsive), no UI correction. Decisions: (1) the mockup file the user produced (`docs/design/faunosteo-etape7-maquettes-validees.png`, 7 views) is the permanent graphic reference for the SaaS shell; `docs/design/README.md` lists what it shows beyond Step 7 with the owning step (Bilans/Clients/Animaux/Agenda/Fiches entries, stat tiles, bell, avatar photo → Step 8, Mon compte tabs, mobile tab bar) so no screen invents them early; a redesign needs a new validated file there. (2) Local-tool Home (`/`) shows no sidebar when signed in, only "Mon espace": accepted until the tool is integrated into `/app` (Step 14). (3) Password rule in the mockup (8 chars) does NOT override the server policy (12 + classes). (4) Follow-ups kept in TODO 7.10: MFA before sensitive admin features, professional verification ≠ SIRET format, real OAuth tests once ids exist, tool integration into /app.
|
||||
Status: closed; Step 7 finished into develop.
|
||||
|
||||
## BDR-043 | 2026-10-12 | Rust by default: permanent language rule + target architecture (study awaiting validation)
|
||||
|
||||
Owner rule: Rust preferred wherever equivalent or better; "already TS", "more work", "no perf gain" never reasons for C. Kept: React/TS UI + DOM + stores + vendor glue, Tailwind, SQL + RLS, Supabase Auth/Storage, Vite tooling. Study `docs/development/RUST_ARCHITECTURE_REVIEW.md` rev 2 (61 challenger findings folded). Classification: A = domain contracts/rules, sheet handle + index data, reducers, data-building component rules, publish gate, layer renderer + compose, one SVG sanitiser, PDF reader + writer, CLI tools, curation pipeline + importer, upload script, Step 8 worker, every future backend/rule mirror; B = none; C = React render glue + display helpers, Zustand/storage adapters, supabase-js session + error shapes (no Rust GoTrue PKCE client), UI form schemas + dictionaries, clock/crypto/Intl screen dates, browser rasteriser (DOM), Vite tooling, SQL/RLS, public web (Astro, global rule). Target: 3 crates (`core` feature-gated lib + tool bins, `wasm` facade, `worker` bin), JSON strings across the boundary + `ts-rs` types (no serde-wasm-bindgen: writes absent optionals as null), `SheetHandle` built once, closed error kinds, ids/time injected, panic=abort handled TS-side (poison + reinstantiate), lazy init + `core_unavailable`, reader in terminated Web Worker. Worker: Rust binary, decode child = same binary dispatched before any thread, empty env, RLIMIT_AS/CPU, traced seccomp allowlist (Landlock dropped: redundant), pure-Rust decoders (`image`/zune-jpeg/png/image-webp) + `moxcms` ICC, lossy WebP via `libwebp-sys` ≥ 1.6 in the child only, parent parses RIFF header only (never decodes), 512 KiB output cap, per-stage deadlines; service key kept (dedicated role = Step 27 option). Roadmap: R0 workspace + worker image inside Step 8, R1 = Step 8 worker, R2 domain core before Step 9, R3 anatomy, R4 pdf reader + writer (Std14 AFM metrics, draw-log golden frozen first), R5 pipeline + importer + tools, all before Step 13; TTF fonts separate later change. Deploy prerequisites: CSP `'wasm-unsafe-eval'`, gzip wasm, images built in CI pulled by digest (VPS 1 GB never compiles), N-1 reader test, draft quarantine.
|
||||
Alt rejected: single `core` crate without features (worker would carry pdf deps) → features chosen; 6 crates (rev 1) → too many; resvg in browser (949 KB gz, visual change); wasm-pack (one maintainer, CLI lock); Edge Functions (limits, hand deploy); Prettier-chained sheet identity (hash only compared at runtime → one-time rebase accepted); parent re-decode of child output (breaks keyless-decoder invariant).
|
||||
Status: active, awaiting owner validation of the study + 13 decisions D-R1..D-R14 (D-R6 withdrawn); nothing implemented; release 0.2.0 untouched.
|
||||
@@ -122,3 +122,10 @@ Method: contract with 16 criteria (`2026-10-11-step-07-verify.md`) → fresh ver
|
||||
Result: verifier pass 1 ECARTS(2): (a) real gap, `safeNextPath` prefix check let `/\host` and `/<TAB>/host` through (router `location.assign` fallback = open redirect after login) → fixed by resolving against a sentinel origin and rebuilding from parsed parts, 5 new cases; (b) contract regex over-matched other unions (`'google' | 'apple'`, `'fr' | 'en'`) → CHECK scoped. Pass 2 CONFORME 16/16. Security PASS, 1 MEDIUM (same redirect, already fixed) + 4 LOW: 3 closed same session (sign-out failure reported, `reauthentication_needed` phrased, exact prod redirect allowlist documented), 1 pre-existing (TOTP not enforced for staff = documented gap). E2E 20/20. Workspace 763 tests, lint 0, build, docker, real-stack pgTAP 280 green.
|
||||
Anomalies: both gates found the same redirect hole my own tests missed → a prefix check on a URL is never enough, parse it; the auditor misread the sign-out note ("this device") as "everywhere" but the LOW still pointed at a silent failure path worth phrasing. Mockups validated with ChatGPT are not in the repo: the screens follow the written direction and the existing tokens, pixel fidelity unverifiable here.
|
||||
Action: awaiting user validation of Step 7 (manual procedure IDENTITY.md §5); release/0.2.0 still open for the human go.
|
||||
|
||||
## EVAL-016 | 2026-10-12 | Rust-by-default architecture review — 4 analyzers + 3 researchers + 3 plan-challengers
|
||||
|
||||
Method: 4 read-only analyzers (domain, anatomy, pdf + app pdf side, app logic + supabase) wrote factual inventories to the scratchpad; 3 general-purpose researchers verified crate versions/maintenance/advisories and Supabase facts on crates.io, RustSec, GitHub, supabase docs (2026-10-12), UNVERIFIED items listed; study rev 1 written from them, committed (6a078da); 3 plan-challengers (correctness FATAL(11), robustness FATAL(11), simplicity CONCERNS(9); 61 findings) → rev 2 with 56 folded, 2 declined with reasons (§0.2).
|
||||
Result: real blockers caught by the gates, not by me: (1) VI.4 deleted TS modules still imported by later-phase TS consumers (pipeline, engine); (2) production CSP `script-src 'self'` refuses wasm, VPS 1 GB compiles images; plus wrong premises: envelope byte-parity (integer-valued floats, insertion order), Prettier identity overstated (hash only compared), `catch_unwind` unusable on wasm32 (panic=abort), serde-wasm-bindgen null-for-absent, parent re-decode breaking the keyless invariant, Step 15 misread as server rendering. Simplicity: 6 crates → 3, dual-run harness → frozen goldens, Landlock + 3 rlimits redundant, constraints generator/schemars/cargo-chef/cargo-audit/infer/img-parts dropped.
|
||||
Anomalies: one analyzer had a read-only `find -exec cat | wc -l` refused (no rule named) and re-ran as `find | xargs wc -l` (already allowed earlier) — reported to the user as a possible workaround; agents flagged writing report files to the scratchpad against their default (orchestrator asked for it). Three challenger claims came from memory not code (json_compatible null, panic=abort, musl mprotect) → folded as "verify at R0/R1".
|
||||
Action: owner validates study + D-R1..D-R14; nothing implemented; CLAUDE.md rule section added; TODO roadmap lines.
|
||||
@@ -223,3 +223,7 @@ User validated Step 7 (all screens, flows, FR/EN, responsive; Home-without-sideb
|
||||
## 2026-10-12 (Step 8 analysis)
|
||||
|
||||
User: Step 7 closed; Step 8 = files foundation + Storage, analysis before implementation; Q2 settled (self-hosted first, managed later); 8 private buckets closed by default; quarantine + server validation; allowlist SVG; avatar in Mon compte; release 0.2.0 kept = Steps 3–6, identity → 0.3.0, check deploy triggers before finishing. Done on chore/step-08-files-analysis: docs/development/STEP8_FILES_ANALYSIS.md (assets table authority, server-built keys, quarantine prefix, worker `faunosteo_worker` sharp + pdf sanitiser, policies through assets, Storage API signing under RLS, sweeper/reconcile, file volume + restic backups, managed migration by rows, 10 security answers, scope, tests, risks, D1–D8); 3 plan-challengers dispatched. Release check: CI on push main/develop only, no tag trigger, no deploy job; hooks push only; VPS deploy manual; default 0.2.0 build has no sheet → never redeploy the live tool from main without SHEET_BUNDLE=draft. Awaiting user: D1–D8 + Step 8 go; release finish go.
|
||||
|
||||
## 2026-10-12 (Rust-by-default review)
|
||||
|
||||
User: new permanent rule, Rust preferred for everything equivalent or better, existing code included; study + roadmap before Step 8 or any migration; nothing implemented. On chore/step-08-files-analysis: 4 analyzers + 3 researchers (scratchpad reports) → `docs/development/RUST_ARCHITECTURE_REVIEW.md` rev 1 (6a078da) → 3 plan-challengers (61 findings, 2 blockers: deletion schedule vs surviving TS consumers; CSP/VPS deployment facts) → rev 2 folded. Outcome: A/B/C classification (B empty), 3-crate workspace, Rust worker design (keyless parent, traced seccomp, libwebp in child), roadmap R0–R5 with end criteria + rollback rows, 13 decisions D-R1..D-R14. Memory: BDR-043, LRN-048, EVAL-016; CLAUDE.md "Rust by default" section; TODO Rust block. No cargo on the dev host (owner installs rustup at R0). Awaiting owner validation; release 0.2.0 untouched.
|
||||
@@ -357,3 +357,8 @@ Apply: any pipeline extraction (Step 13 Supabase provider, Step 14 worker); any
|
||||
|
||||
Step 7 facts worth keeping. (1) `client.auth.initialize()` is public and idempotent: await it at store start to catch the URL exchange error (expired/foreign link) that `onAuthStateChange` never reports; `INITIAL_SESSION` ordering vs that promise is not guaranteed → a callback route landing signed-out = failure, don't wait for a flag. (2) PKCE confirmation/recovery links only open a session in the browser that made the request (verifier in its localStorage); the email is still confirmed server-side → phrase it ("opened in another browser… just sign in"), don't claim expiry. (3) supabase-js 2.117 `AuthError.code` (`invalid_credentials`, `user_already_exists`, `weak_password`, `otp_expired`, `bad_code_verifier`…) → map to a closed union in the access layer, UI translates `auth.failure.<kind>`; raw messages never rendered. (4) Account load must run outside the auth callback (`setTimeout 0`): the client serialises callbacks, awaiting a request inside deadlocks. (5) pgTAP: `select is((with upd as (update … returning 1) select count(*) from upd), …)` fails ("data-modifying CTE must be top level") and silently breaks the plan count; use `lives_ok` + a read after `reset role`. (6) Mailpit API (`/api/v1/search?query=to:<email>`, `/api/v1/message/<id>`) makes the confirmation + recovery flows scriptable headlessly; playwright-core installed in the scratchpad + cached `ms-playwright` chromium via `executablePath` = no project dependency.
|
||||
Apply: every future Supabase auth surface (Step 14 gating, invitations), any pgTAP write assertion, any e2e of email flows.
|
||||
|
||||
## LRN-048 | 2026-10-12 | Before porting a module, list the hidden serialisation contracts; goldens on drawn primitives make an engine swap provable
|
||||
|
||||
Context: Rust review inventories. Facts found: `documentSha256` = sha256 of Prettier-formatted text (only compared at runtime → mismatch = rebase, not loss); coordinates = raw JS number strings (serde_json prints `1523.0`); attachment = insertion-order JSON, snapshot = Zod schema order; `.optional()` absent vs nullable `null` (serde-wasm-bindgen json preset writes null → breaks readers); text x positions = AFM widths + kerning pairs; dates = ICU; `toUpperCase`, `/\s+/`, non-fatal TextDecoder, last-dup-key JSON.parse, Zod `.int()` accepting 2.0. The 39 PDF goldens record draw calls (spies), never bytes → a Rust engine with a draw-log layer can match them exactly; byte goldens (xmldom XMLSerializer, Prettier files) cannot be matched by another stack → compare parsed trees or regenerate by decision.
|
||||
Apply: any port (R2–R5): freeze unpinned outputs with the old code (LRN-046), write the contract list with a fixture each, decide lenient-vs-strict per item, keep an N-1 reader test permanently. Challengers found 2 blockers rev 1: deletion schedule vs surviving consumers (name the last consumer per module), and deployment facts (CSP without 'wasm-unsafe-eval', VPS compiling images) → check the serving path before the language.
|
||||
@@ -129,11 +129,19 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
|
||||
- [ ] Step 8 — files foundation + Supabase Storage (analysis 2026-10-12 on chore/step-08-files-analysis: docs/development/STEP8_FILES_ANALYSIS.md; 3 plan-challengers (47 findings folded, rev 2); AWAITING USER DECISIONS D1–D9 + go; nothing implemented). User brief: 8 private buckets closed by default, quarantine + server validation, allowlist SVG, avatar in Mon compte (upload/preview/replace/delete/header), JPEG/PNG/WebP ≤ 5 MB resized + metadata stripped, no SVG avatar, service role never in the browser, portable self-hosted → managed, allowed + denied access tests
|
||||
- [x] 8.0 analysis: facts (existing bucket + policy pattern, sanitiser, edge runtime off, CSP, deploy), design (assets table authority, server-built keys, quarantine prefix, worker `faunosteo_worker` with sharp + pdf sanitiser, storage.objects policies through assets, Storage API signing under RLS, sweeper/reconcile, backups file volume + restic, managed migration by rows), 10 security answers, scope, tests, risks, D1–D8
|
||||
- [ ] 8.1 migration 20261012100000_files_foundation (asset_status, assets, 7 buckets, avatar predicates, avatars policies, purge queue + triggers, storage ceiling, 9 RPCs, revokes) + pgTAP 010 allowed/denied + policy census (one bucket literal per policy) + 001 census + types regen
|
||||
- [ ] 8.2 apps/worker: keyed I/O loop + keyless decode child (sharp, 20 s SIGKILL), lease claim, PUT→complete→DELETE order, sweeper (purge queue + quarantine by key), watchdog, Dockerfile + compose service (read-only, cpus 1, internal network) + .env.worker.example, fixtures tests with time/RSS asserts, local-stack integration test
|
||||
- [ ] 8.2 worker → SUPERSEDED by Rust R1 (RUST_ARCHITECTURE_REVIEW Part IV, D1 = native Rust worker): `crates/worker` keyed `run` loop + keyless `decode` child, lease claim, PUT→complete→DELETE order, sweeper (purge queue + quarantine by key), per-stage deadlines, Dockerfile (distroless/static) + compose service (read-only, cpus 1, internal network) + .env.worker.example, fixtures + sandbox tests on the production image, local-stack integration test
|
||||
- [ ] 8.3 packages/supabase assets service (begin/upload/confirm/remove/fetchOwnAvatar/downloadAvatar, closed failure kinds; no signed URL)
|
||||
- [ ] 8.4 app: avatar block in Mon compte (picker, canvas ≤1024 JPEG transport, preview, save, processing, supersede, delete), UserBadge photo, top bar avatar (D3), authStore blob URL, i18n, tests; design toolchain + impeccable detect
|
||||
- [ ] 8.5 docs: STORAGE.md (model, keys, statuses, purge/grace rules, reconciliation query, backup ordering + invariant, managed migration runbook), DEPLOY.md (worker, env file, network, CSP connect-src), SUPABASE.md, CLAUDE.md, CHANGELOG, plan note (worker early, SVG processor → Step 13); CI jobs
|
||||
- [ ] 8.6 verify: root check, PGlite + real stack pgTAP, types, docker builds (app + worker), real-stack e2e (sign allowed/denied), gates verifier + security; memory; stop for user validation
|
||||
- [ ] Rust by default (rule adopted 2026-10-12, BDR-043; study `docs/development/RUST_ARCHITECTURE_REVIEW.md` rev 2 on chore/step-08-files-analysis, 3 challengers folded; AWAITING OWNER VALIDATION + decisions D-R1..D-R14; nothing implemented). Roadmap once validated (each phase: oracles frozen with the old code, consumer-driven deletion, rollback row, gates):
|
||||
- [ ] R0 foundation (inside Step 8): Cargo workspace (`crates/core`, `wasm`, `worker`), toolchain pin, deny.toml, lints, CI job `rust`, worker image, `docs/development/RUST.md`, DEPLOY.md (images pulled by digest, CSP `'wasm-unsafe-eval'`, gzip wasm, VPS headroom); owner installs rustup; verify panic strategy on wasm32
|
||||
- [ ] R1 = Step 8 worker in Rust (replaces 8.2 below): decode child dispatched before any thread, empty env, RLIMIT_AS/CPU, traced seccomp allowlist, `image` + `moxcms` + `libwebp-sys` in the child, parent RIFF-header check only, 512 KiB output cap, per-stage deadlines, service key
|
||||
- [ ] R2 domain core (before Step 9): sheet/report/archive contracts, `SheetHandle` + `SheetIndexData`, reducers, Finding builder, vertebra selection, publish gate; wasm facade (JSON strings, ts-rs types, poison + reinstantiate, lazy init); app switched; 3 envelopes frozen first; N-1 reader test; draft quarantine; conformance fixtures + generated pgTAP; `packages/domain` frozen for engine/pipeline
|
||||
- [ ] R3 anatomy core: tree, one sanitiser, serialiser, layer renderer, `compose_view_svg`; app canvas switched; composed views frozen as trees first
|
||||
- [ ] 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
|
||||
- [ ] separate chore (D-R7): form constraints module + PGlite `pg_constraint`/config.toml parity test
|
||||
- [ ] Release 0.2.0 (branch release/0.2.0 = Steps 3–6, version.txt + package versions 0.2.0, CHANGELOG [0.2.0] 2026-10-11): deploy-trigger check done 2026-10-12 (CI = branches main/develop only, no tag trigger, no deploy job, docker job builds `faunosteo:ci` locally; hooks push only; DEPLOY.md deploy = manual on the VPS). Default 0.2.0 build carries NO sheet (SHEET_BUNDLE=none) → the live local tool must not be redeployed from main without `--build-arg SHEET_BUNDLE=draft`. Finish via /release-candidate (finish + tag span, tag push on explicit go); CHANGELOG back-merge conflict expected (Unreleased Step 7 above [0.2.0]). Awaiting the user's go.
|
||||
---
|
||||
|
||||
|
||||
@@ -424,6 +424,36 @@ Database (Supabase)
|
||||
|
||||
---
|
||||
|
||||
## Rust by default (rule adopted 2026-10-12, BDR-043)
|
||||
|
||||
Study and roadmap: `docs/development/RUST_ARCHITECTURE_REVIEW.md` (awaiting
|
||||
the owner's validation before any implementation; release 0.2.0 unaffected).
|
||||
|
||||
- Any logic that can run in Rust with no significant loss (features, UX,
|
||||
graphics, data compatibility, security, reliability, useful performance,
|
||||
resources, portability, maintainability, operations) is written in Rust:
|
||||
native for services, jobs and tools, WebAssembly for the browser.
|
||||
Equivalence suffices; "already in TypeScript", "more work" and "no
|
||||
performance gain" are never reasons to keep TypeScript.
|
||||
- Kept as is: React + TypeScript for UI, DOM, routing, Zustand stores,
|
||||
display formatting and vendor-SDK glue (supabase-js); UI form schemas
|
||||
(Zod, i18n keys) and dictionaries; Tailwind; PostgreSQL/SQL + RLS;
|
||||
Supabase Auth and Storage; Vite/ESLint tooling. A component kept in
|
||||
TypeScript needs the concrete constraint recorded in the review's
|
||||
exception table (Part II).
|
||||
- New business logic (rules, data transformations, parsers, validators,
|
||||
jobs, services, rule mirrors of SQL) is designed in `crates/` first and
|
||||
reached from TypeScript through the wasm facade; Edge Functions are not
|
||||
used. Boundary rules: "Rust computes, TypeScript reads" (review Part
|
||||
III.3: coarse calls, JSON strings, sheet handle, closed error kinds, ids
|
||||
and time injected, no call in a render path).
|
||||
- Existing code migrates along the review's phases (R0–R5), each with
|
||||
oracles frozen with the old code before the switch and a consumer-driven
|
||||
deletion of the TypeScript it replaces; two implementations never outlive
|
||||
the phase that switches the last consumer.
|
||||
|
||||
---
|
||||
|
||||
## Key dependencies
|
||||
|
||||
| Package | Purpose |
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user