From cdd43ac431be66a0af4e4fe7c22335d77e2ef474 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 1 Nov 2026 22:55:23 +0100 Subject: [PATCH] test(supabase): avatar e2e on the sandbox only, per-session seed secret pnpm e2e:avatar is now an alias of pnpm db:sandbox avatar-e2e and the DEV script scripts/avatar-e2e.sh is removed; the suite fails on any target but the sandbox gateway and database; an occupied port 57800 stops the run before anything starts. The sandbox replaces the seed accounts' DEV password by a per-session secret. --- CLAUDE.md | 8 +-- README.md | 5 +- docs/development/BROWSER_TESTS.md | 2 +- docs/development/ENVIRONMENTS.md | 2 +- docs/development/IDENTITY.md | 2 +- docs/development/SUPABASE.md | 10 ++-- docs/development/TEST_STRATEGY.md | 2 +- docs/development/WORKSPACE.md | 2 +- package.json | 2 +- .../supabase/tests/e2e/avatar-flow.e2e.ts | 27 +++++---- .../tests/sandbox/seed-owner-mfa.sandbox.ts | 5 +- packages/supabase/tests/sandbox/stack.ts | 2 + packages/supabase/vitest.e2e.config.ts | 4 +- scripts/avatar-e2e.sh | 59 ------------------- scripts/db-sandbox.sh | 30 ++++++++-- scripts/dev-env.sh | 2 +- 16 files changed, 64 insertions(+), 100 deletions(-) delete mode 100755 scripts/avatar-e2e.sh diff --git a/CLAUDE.md b/CLAUDE.md index b03b69b5..8cc67e09 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -149,7 +149,7 @@ pnpm rust:check:docker # the same rust-check.sh inside the builder image pnpm wasm:build:docker # the same wasm-build.sh inside the builder image pnpm worker:test # Docker only: crates/worker/Dockerfile stage test, sandbox tests + seccomp derivation on the musl binary pnpm worker:image # Docker only: runtime image faunosteo_worker:dev (distroless/static, `run --check`) -pnpm e2e:avatar # scripts/avatar-e2e.sh: worker container against the local DEV stack + packages/supabase/tests/e2e (owner's call only; `pnpm db:sandbox avatar-e2e` runs the same suite on the throwaway stack) +pnpm e2e:avatar # = pnpm db:sandbox avatar-e2e: the worker container and packages/supabase/tests/e2e on the throwaway stack only (the suite refuses any other target; no DEV variant since 2026-11-01) ``` ## Test commands @@ -270,7 +270,7 @@ faunosteo/ ├─ packages/supabase/ ← @faunosteo/supabase │ ├─ src/{index,client,database.types,anatomical-sheets,assets}.ts ← typed client, generated types, publish gate, avatar flow (closed AssetFailure kinds) │ ├─ src/{records,workspaces,clients,species,animals,relations,field-limits}.ts ← V1-1 record access (closed RecordFailure kinds, keyset pages), D-R7 bounds -│ ├─ tests/e2e/avatar-flow.e2e.ts + vitest.e2e.config.ts ← real-stack end-to-end (`pnpm db:sandbox avatar-e2e`; `pnpm e2e:avatar` on DEV), skipped without the stack env and its database container +│ ├─ tests/e2e/avatar-flow.e2e.ts + vitest.e2e.config.ts ← real-stack end-to-end (`pnpm e2e:avatar` = `pnpm db:sandbox avatar-e2e`), fails on any target but the sandbox gateway and database │ └─ tests/{client,anatomical-sheets}.test.ts, tests/db/ ← PGlite harness, shim, pgTAP runner, schema↔types test ├─ supabase/ │ ├─ config.toml, seed.sql ← CLI config (public schema only), local dev accounts @@ -287,7 +287,7 @@ faunosteo/ │ ├─ core/ ← faunosteo-core: domain/{js,sheet,report,archive,editor,session} (contracts and rules; sheet/{size,keys,caps,review,report,verdict,preview,edit} since V1-2.2: server document measure, review groups and digests, the server verdict, PreviewSheet, the editor's commands, RUST.md §12), anatomy/{svg/{prescan,tree,sanitize,refs,number,serialize,clean},layer,compose} (R3: the one SVG reader, the layer, canvas + highlight composition), pdf/{read,json_js,import,write,compare} (R4: reader, writer and session, the archive check tool behind feature `cli`), ops.rs + facade.rs (`call`, `call_with_sheet`), json (JS number printing), curation/{text,ids,prettier_json,markdown,report_guard,legacy/*,draft/*} (R5, feature `curation`: Prettier layout, the legacy importer, the changeset applier, migration map, stats, seed SQL, CHANGELOG, REVIEW-REPORT, review drawings), curation/upload.rs (R5.5, feature `upload`: the upload rules, pure) + bin/report_compare.rs (`pnpm report:compare`) + bin/import_equine.rs (`pnpm r5:import-equine`) + bin/upload_sheet_assets/ (`pnpm assets:upload`, ureq; the three tools allowed std::fs); tests/{oracles,conformance,fixtures,pdf/LEDGER.tsv} frozen from the TypeScript (oracles/r3, oracles/r4, fixtures/svg/hostile); no I/O, no clock (lint-enforced) │ ├─ wasm/ ← faunosteo-wasm: wasm-bindgen facade (core_version, call, SheetHandle, PreviewBuilder → PreviewSheet, clean_svg; trap exports in the proofs build only) │ └─ worker/ ← faunosteo-worker: plain main; `decode` sandboxed child (rlimits, seccomp allowlist, image → libwebp), parent Spawner + RIFF check; V1-2.3 `verify` sandboxed child (framed input → the core's `compute_verdict`) and `run --jobs sheet-verify` (verify_job, VerifyBackend: M6 RPCs + drawing downloads); R1 `run` loop: config, log (JSON lines, allowlist), keys, backend trait + http (ureq, PostgREST rpc + Storage objects), job, sweep, watchdog; Dockerfile, scripts/derive-seccomp.sh -├─ scripts/{rust-env,rust-check,wasm-build,check-all,avatar-e2e,report-compare,import-equine,upload-sheet-assets,sheet-assets-e2e,floor-clarification-check}.sh, wasm-stamp.mjs ← native Rust gate, wasm build (pkg + pkg-proofs + stamp), the pre-merge gate (`pnpm check:all`), the real-stack avatar e2e, the archive check tool (`pnpm report:compare`), the Rust pipeline (`pnpm r5:import-equine`) +├─ scripts/{rust-env,rust-check,wasm-build,check-all,report-compare,import-equine,upload-sheet-assets,sheet-assets-e2e,floor-clarification-check}.sh, wasm-stamp.mjs ← native Rust gate, wasm build (pkg + pkg-proofs + stamp), the pre-merge gate (`pnpm check:all`), the real-stack avatar e2e, the archive check tool (`pnpm report:compare`), the Rust pipeline (`pnpm r5:import-equine`) ├─ scripts/{dev-env,supabase,dev}.sh ← the DEV origin (LAN address) in one place; CLI wrapper; `pnpm dev` on that origin ├─ docker-compose.yml ← `app` service; `worker` and `worker-verify` (V1-2.3, `run --jobs sheet-verify`) services under the `worker` profile (read-only, cap_drop ALL, external Supabase network, `.env.worker`) ├─ docker/rust-builder.Dockerfile, rust-run.sh, csp-proof/ ← reproducible Rust builder (alternative) + the CSP proofs (R0 module, R2 app image: app-image.sh) @@ -489,7 +489,7 @@ release 0.2.0 unaffected. - After PDF roundtrip tests fail: check the attachment bytes (the N-1 scanner reads them in the envelope suites), then the layered reader (report first, envelope metadata, snapshot/branding/labels), then the core's inflation (`pdf/read/inflate.rs`). Goldens under `apps/app/tests/fixtures/goldens/step6` and the R4 digests under `goldens/r4` are never regenerated without a user decision. - Node 24 / pnpm 10.13.1: `corepack enable` or `corepack pnpm`; never a global install. - Rust: native on the Ubuntu development machine (user-level rustup, never a global package, never on the VPS); `pnpm rust:check` and `pnpm wasm:build` run natively, the `:docker` variants reproduce them in the builder image. Before every Rust commit: `pnpm rust:check` green, `pnpm worker:test` green when `crates/worker` changed (Docker only: the sandbox tests and the seccomp derivation never run natively), the ts-rs types under `packages/core-wasm/types` committed, `Cargo.lock` committed. Before a merge: `pnpm check:all`. No CI runs on the forge: a workflow file is never cited as a passed check. The core takes ids, time and bytes as inputs (clippy `disallowed_methods`); the worker child is the only process that decodes untrusted bytes. -- Storage or worker change: `pnpm db:sandbox avatar-e2e` (the avatar suite `packages/supabase/tests/e2e` and the real worker on the throwaway stack) in addition to `pnpm worker:test`; `pnpm e2e:avatar` starts a worker against the DEV stack and runs only on the owner's go (owner decision 2026-11-01); `docker compose --profile worker` serves the worker from `.env.worker` (never the app `.env`). +- Storage or worker change: `pnpm db:sandbox avatar-e2e` (the avatar suite `packages/supabase/tests/e2e` and the real worker on the throwaway stack) in addition to `pnpm worker:test`; `pnpm e2e:avatar` is its alias (owner decision 2026-11-01: no avatar e2e against DEV, `scripts/avatar-e2e.sh` removed); `docker compose --profile worker` serves the worker from `.env.worker` (never the app `.env`). - SQL change: `pnpm --filter @faunosteo/supabase test:run` (PGlite) before commit; `pnpm db:reset && pnpm db:test` on the real stack when Docker is available; regenerate types (`pnpm db:types`). diff --git a/README.md b/README.md index 23d07727..3c4cb676 100644 --- a/README.md +++ b/README.md @@ -111,9 +111,8 @@ pinned toolchain from `rust-toolchain.toml` on first use; see `docs/development/RUST.md` §1 for the three `cargo install` / `rustup target add` lines and the Docker alternative. The files worker (profile photos, Step 8) runs as a container beside the local Supabase stack: -`pnpm worker:image`, then `pnpm db:sandbox avatar-e2e` for the real-stack -end-to-end run on the throwaway stack (`pnpm e2e:avatar` runs it against the -local DEV stack), or `docker compose --profile worker up worker` with a `.env.worker` +`pnpm worker:image`, then `pnpm e2e:avatar` (= `pnpm db:sandbox avatar-e2e`) for the +real-stack end-to-end run on the throwaway stack, or `docker compose --profile worker up worker` with a `.env.worker` (`docs/development/STORAGE.md`). Docker Compose (matches production topology): diff --git a/docs/development/BROWSER_TESTS.md b/docs/development/BROWSER_TESTS.md index 7ad8429d..3ec7f7cb 100644 --- a/docs/development/BROWSER_TESTS.md +++ b/docs/development/BROWSER_TESTS.md @@ -102,7 +102,7 @@ Chromium (Playwright prints the install command), a stale core module `pnpm check:all` runs `pnpm e2e:ui` when the pinned Chromium is installed; otherwise it prints `SKIPPED` with the reason and the install command, and goes on. `pnpm e2e:shell` needs the sandbox and stays a separate run, like -`pnpm db:sandbox avatar-e2e`. The last lines of a green run state each browser suite: +`pnpm e2e:avatar` (= `pnpm db:sandbox avatar-e2e`). The last lines of a green run state each browser suite: `PASSED`, `SKIPPED` (environment missing, with the reason) or `NOT RUN` (`e2e:shell`). A suite that runs and fails stops `check:all` with `== FAILED: ` and a non-zero exit, never a warning. Both suites keep diff --git a/docs/development/ENVIRONMENTS.md b/docs/development/ENVIRONMENTS.md index b40be575..c567c88f 100644 --- a/docs/development/ENVIRONMENTS.md +++ b/docs/development/ENVIRONMENTS.md @@ -35,7 +35,7 @@ never hard-coded in the sources. Consumers: `scripts/supabase.sh` (every CLI call: `pnpm supabase …`, `pnpm db:start|stop|reset|test|types`), `scripts/dev.sh` (`pnpm dev`), -`scripts/avatar-e2e.sh`. The address changes with `FAUNOSTEO_DEV_HOST=…` +`scripts/db-sandbox.sh`. The address changes with `FAUNOSTEO_DEV_HOST=…` in front of the command, without touching a source file. Calling the CLI binary directly (`node_modules/.bin/supabase start`) leaves the literal `env(...)` text in the services: always go through `pnpm`. diff --git a/docs/development/IDENTITY.md b/docs/development/IDENTITY.md index a77a2618..b2b78b05 100644 --- a/docs/development/IDENTITY.md +++ b/docs/development/IDENTITY.md @@ -130,7 +130,7 @@ VITE_AUTH_PROVIDERS=google pnpm dev # http://:5173 from any device of th (SUPABASE.md §8). 10. Profile photo (Step 8, worker container running: `pnpm worker:image` then `docker compose --profile worker up worker` or the container of - `scripts/avatar-e2e.sh`): Mon compte → Modifier la photo with a phone + `pnpm e2e:avatar` on the sandbox): Mon compte → Modifier la photo with a phone JPEG → preview → Enregistrer → "Traitement en cours…" → the photo in the circle, the sidebar, the drawer (mobile) and the top bar (name beside it on desktop, alone on mobile) linking to Mon compte; a renamed PNG is diff --git a/docs/development/SUPABASE.md b/docs/development/SUPABASE.md index 7a8538a1..50ae4a48 100644 --- a/docs/development/SUPABASE.md +++ b/docs/development/SUPABASE.md @@ -35,7 +35,7 @@ packages/supabase/ ├─ src/anatomical-sheets.ts publishSheetVersion(): the core's verdict (`sheet.check`) as gate before the RPC ├─ src/assets.ts avatar flow: begin / quarantine upload / confirm / remove / own state / download, closed AssetFailure kinds ├─ tests/db/ PGlite harness: runs the pgTAP files without Docker -└─ tests/e2e/ real-stack end-to-end (avatar flow with the worker container), `pnpm e2e:avatar` +└─ tests/e2e/ real-stack end-to-end (avatar flow with the worker container), `pnpm e2e:avatar` on the sandbox crates/core/src/domain/sheet/ canonical sheet document and its integrity rules (Rust core; `packages/domain` deleted at R5.7) ``` @@ -167,8 +167,7 @@ User files land in private buckets and are processed by the Rust worker ```bash pnpm worker:image # faunosteo_worker:dev -pnpm e2e:avatar # starts the container on supabase_network_faunosteo, runs tests/e2e, stops it (DEV: the owner's call) -pnpm db:sandbox avatar-e2e # the same suite and worker image on the throwaway stack (§5.1), the check of a storage or worker change +pnpm e2e:avatar # = pnpm db:sandbox avatar-e2e: the suite and the worker on the throwaway stack (§5.1) only docker compose --profile worker up worker # the same container from docker-compose.yml, reading .env.worker ``` @@ -515,8 +514,9 @@ the scripts: on the sandbox, clean and with those conditions reproduced (scenarios and mutations in the journal of 2026-10-27). DEV is not validated by `db:test` until a run there passes. -- `pnpm e2e:avatar`: not part of this procedure; optional, the owner's call. - It writes on DEV beyond its own fixture: it creates a temporary confirmed +- `pnpm e2e:avatar`: not part of this procedure. Since 2026-11-01 it runs on + the sandbox only (owner decision; the DEV script `scripts/avatar-e2e.sh` is + removed). Its DEV run, as recorded on 2026-10-26, wrote on DEV beyond its own fixture: it creates a temporary confirmed account `e2e-avatar-