docs(docs): R5.7 pre-merge record, final security audit, doc precisions

This commit is contained in:
bchanot committed 2026-10-25 13:57:56 +01:00
1 parent 27bf59cd4b
commit 97529f95b8
5 files changed
+241 -5

No files matched your search

@@ -0,0 +1,48 @@
# R5.7 pre-merge checks (2026-10-25)
Owner brief « Validation R5.7 et dernière vérification pré-fusion ». State checked: `feature/rust-r5-pipeline-core` at
`27bf59c` (code and tests); the commit that adds this file changes docs and `.claude/` records only (SUPABASE.md layout,
the `.bin/tsx` wording in RUST.md §11.23 and in the contract clarification, TODO, registries).
## Decision C6
Owner accepted `tsx` in `pnpm-lock.yaml` as vite's optional peer only. Contract C6 amended with a Clarification section.
`pnpm why tsx -r`: `tsx` 4.23.15 reached only as `vite` 7.3.6's peer (`peerDependenciesMeta.tsx.optional: true`) through the
devDependencies of `apps/app`, `packages/core-wasm`, `packages/supabase`; no importer, no manifest, no script; snapshot
`optional: true`. No lockfile hand edit, no override.
## Checks run on 27bf59c
| Check | Result |
|---|---|
| `pnpm install --frozen-lockfile` | rc 0, "Lockfile is up to date", lockfile sha256 unchanged |
| `pnpm dedupe --check` | rc 0 |
| `pnpm check:all` (starts with `scripts/rust-check.sh` = `pnpm rust:check`) | green 13:37:52 → 13:41:41: fmt, clippy, 177 cargo result lines all ok (1548 passed, 0 failed, 3 ignored, none a ledger target), ts-rs drift none, cargo-deny + advisories ok, wasm, typecheck, vitest app 446 / core-wasm 60 / supabase 40, lint, build, app image, worker sandbox tests, worker runtime image |
| `pnpm import:equine --check` | legacy-import 6 files, draft 12 files, 0 differences (app-main under the declared R3 rule) |
| `pnpm report:compare` on `apps/app/tests/fixtures/*.pdf` and `fixtures/pdf` | rc 0 |
| `pnpm audit` | 57 advisories (2 critical, 33 high, 21 moderate, 1 low), every version identical on `develop`: none introduced by R5. Runtime-reachable: zod 3.25.76 (GHSA-mrhx-c7xc-m3w5, patched only in zod 4). Rest dev tooling (pnpm 10.13.1, tinypool via vitest, vite 7.3.6 dev server, happy-dom, brace-expansion, js-yaml, nanoid, postcss, source-map-js). Separate chore, owner decision (majors excluded by the brief) |
| Suites named by the brief | RFC 8785 and aliases `sheet_fingerprint` 11, `r5_6_switch` 14, app `r5-6.switch`; reports v2/v3 `report_rules` 17, `report_contract` 4, `archive_rules` 38, `characterisation` 4; N-1 `n-1.reader`, `n-1.scanner`; PDF `pdf_*` (import 4, compare 16, session 6, …), app `pdf.roundtrip`, core-wasm `pdf-import`; rebase and history: `archive_rules`, the 612 leaves (`curation_leaves` 8, app `migration.leaves`); seed and sheet `curation_*`, `sheet_rules` 25, `sheet_conformance` 3; census `r4.census` 8, `r5.census` 10 |
| Moved fixtures | sha256 `e96b0882…729c`, `ba79698c…fde7`, equal to 756b7ef |
| Old packages required nowhere | `git grep` over scripts, docker, `.gitea`, Dockerfile, compose, configs, tests, package sources: comments and census bans only |
## Ledger
407 rows: 256 ported, 149 replaced, 2 deleted (JS aliasing check with no Rust meaning; TS generator of
`fixtures/horse-slice.json`, read by 4 Rust suites). Replaced rows active: every cargo target a non-ignored `#[test]`
(census now refuses `#[ignore]` after `#[test]`, cd69f0e), every cited oracle read by a test.
## Gates
- Fresh verifier: CONFORME, C1 to C10 MET (C6 under the clarification), 14 scratch reintroduction probes all fail the
census. Precisions it raised, fixed in the docs commit: this file did not yet exist; SUPABASE.md §1 still drew
`packages/domain`; `.bin/tsx` is linked under the three packages (not the root).
- Fresh security audit: PASS (`2026-10-25-rust-r5-7-security-final.md`). MEDIUM pre-existing `pnpm audit`; LOW census
regex accepts `#[ignore]` before `#[test]` or `#[cfg_attr(…, ignore)]` (no instance; left for the owner, a fix would
invalidate this `check:all`); LOW clippy allow header; LOW pre-existing SQL policy warning outside the diff.
## Git
Branch clean, equal to `origin/feature/rust-r5-pipeline-core`; `develop` = `origin/develop` = `9c0117a`, ancestor of the
branch (76 commits ahead, 0 behind): `git merge-tree` clean, a `--no-ff` merge has no conflict. No secret pattern in the
added lines; no env file, key or binary added; largest added files are the R5.1 oracles `numbers.json` (1.8 MB) and
`pipeline.json` (1.4 MB). `main` 605ee7c and `release/0.2.0` f8d9425 untouched.
@@ -0,0 +1,187 @@
# Security gate, final: Rust R5.7 (deletion of packages/anatomy and packages/domain)
Date 2026-10-25. Branch `feature/rust-r5-pipeline-core`. Scope `756b7ef..27bf59c`
(152 paths: 8 added, 32 modified, 2 renamed, 110 deleted; 2 055 insertions, 17 542 deletions,
7 commits `0da7d3a`..`27bf59c`). Fresh auditor; the previous report
`2026-10-25-rust-r5-7-security.md` was read only for the status check the brief asked for.
```
SECURITY — VERDICT: PASS
TOOL: semgrep 1.168.0 — p/security-audit, p/secrets, p/owasp-top-ten
SCOPE: 42 files (the existing files of the diff; 110 deleted paths inspected through git)
BLOCKING:
(none)
REPORTED (non-blocking):
- [MEDIUM] pnpm-audit (pre-existing, no version touched by the diff) — pnpm-lock.yaml — 57 advisories on unchanged versions: 2 critical (tinypool 1.1.1 via vitest, dev), 33 high (pnpm 10.13.1 itself x17, brace-expansion, js-yaml, nanoid, postcss, source-map-js, happy-dom, zod 3.25.76), 21 moderate, 1 low
- [LOW] census-regex-gap — apps/app/tests/unit/r5.census.test.ts:300 — `#[ignore]` placed before `#[test]`, or `#[cfg_attr(…, ignore)]`, still passes the ledger-target check (no instance in the tree)
- [LOW] new-suppression (clippy allow, not a security-tool suppression) — crates/core/tests/curation_leaves.rs:6 — identical header in all 41 files under crates/core/tests
- [LOW] SB-POLICY-NOT-OWNER (guardrails WARN, pre-existing, file not in the diff) — supabase/migrations/20261008110000_anatomical_sheets.sql:1177
PROOF: semgrep 158 rules (725 loaded, 3 packs) on 42 files → 0 findings, 0 errors, 0 skipped; checklist 8 checks → 0 findings; guardrails scan.py api,supabase → 0 FAIL, 1 WARN (outside diff), 1 MANUAL (not reported); anti-gaming 1 new clippy allow (LOW), 0 removed; cargo deny check advisories → ok; pnpm audit → 57 advisories, 0 introduced; ledger 407 rows / 566 cargo targets → 566 active #[test], 0 #[ignore]
```
## Semgrep
`semgrep scan --config p/security-audit --config p/secrets --config p/owasp-top-ten
--metrics=off --quiet --json <42 paths>`: 0 results, 0 errors, 0 skipped paths, stderr empty.
The verbose rerun reports 725 rules loaded, 158 applicable to the languages present, 42 files.
## Checklist (8 checks, 0 findings)
| Check | Result |
|---|---|
| Hardcoded secret, token, key, auth URL in added lines | None. Hits are variable names in prose (`SUPABASE_SERVICE_ROLE_KEY` in CLAUDE.md and the previous audit), no value. URLs in added lines are all LEDGER.tsv case descriptions (`https://x.test/…`, `http://localhost:5173`, `https://faunosteo.com`, the partner credit, `https://zenquality.fr`): test and product data, no credential. No IP, no `/home/`, no `/Users/`. |
| SQL by concatenation | No new SQL. `seed.rs` keeps `sql_text` quote doubling and the `$equine_doc$` dollar tag with the refusal at line 94 (`DOCUMENT_DOLLAR_TAG`). The diff on that file is a 3-line doc comment. |
| Unsanitized render (innerHTML, eval, raw) | None. |
| Sensitive endpoint without authz | No endpoint, policy or RPC in the diff. |
| Stack trace / internal path to the user | None. |
| Secret or PII to a log | None. |
| Tracked `.env` or credential file | Only `.env.example` is tracked (`git ls-files`); `.gitignore` and `.dockerignore` exclude `.env`, `.env.*`, the gateway htpasswd and the Mailpit password. No binary in the diff (`git diff --numstat` shows no `-` row); the largest added file is `LEDGER.tsv` (173 KB, UTF-8 text). |
| Guardrails scanner (api,supabase, 1219 files) | 0 FAIL. 1 WARN `SB-POLICY-NOT-OWNER` on `species_select_active` (pre-existing, file not in the diff). 1 MANUAL `SB-RLS-LIVE`, not reported here. |
## Anti-gaming
One new suppression-like marker in the added lines:
`#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]` at
`crates/core/tests/curation_leaves.rs:6`. It is a clippy allow, not a semgrep, bandit or
ESLint-security suppression, and every one of the 41 files under `crates/core/tests/` carries the
same single header (`disallowed_methods` forbids I/O and clock in the library; integration tests
read fixtures). LOW, not blocking. No `nosemgrep`, `nosec`, `eslint-disable`, `@ts-ignore`,
`@ts-expect-error`, `.skip` or `#[ignore]` added; no suppression removed.
## Supply chain
### Lockfile
`pnpm-lock.yaml`: 1 insertion, 69 deletions.
- Removed: importers `packages/anatomy` and `packages/domain`; the `packages:` and `snapshots:`
entries of `@xmldom/xmldom@0.9.12`; the `deprecated:` metadata line of `eslint@9.39.4`
(registry metadata, same version).
- Added: the single line `optional: true` on the `tsx@4.23.15` snapshot. `tsx` appears in no
manifest (`git grep '"tsx"' -- '*/package.json'` → none); it stays resolved only as vite's
optional peer, per the owner decision C6 (`27bf59c`).
- No new package, no version change, no `overrides`, `patchedDependencies`, `onlyBuiltDependencies`
change (`pnpm-workspace.yaml` untouched).
### cargo deny
`. scripts/rust-env.sh` (read first: appends `~/.cargo/bin` to PATH when no cargo is found,
installs nothing) then `cargo deny check advisories` (cargo-deny 0.20.2, `deny.toml`
`yanked = "deny"`, `ignore = []`): `advisories ok`. No build, no `target/` access.
### pnpm audit (read-only)
`pnpm audit --json` with the local pnpm 10.13.1: 57 advisories, `{critical: 2, high: 33,
moderate: 21, low: 1}`. Every advisory sits on a package version the lockfile diff did not
change, so none is introduced by this scope; they are reported, not gated, and belong to a
separate `chore/*`. Breakdown by reachable surface:
| Package (version) | Advisories | Surface |
|---|---|---|
| pnpm 10.13.1 (root devDependency, `packageManager`, Dockerfile `corepack prepare pnpm@10.13.1`) | 17 high + 8 moderate, patched in 10.26 … 10.34.5 (lifecycle-script bypass, lockfile integrity bypass, env-var command injection, manifest identity spoof running attacker lifecycle, secrets exfiltration through `pnpm-workspace.yaml` proxy placeholders, several path traversals) | developer machine and the Docker builder stage; the Docker build runs `pnpm install --frozen-lockfile` on a repository-controlled lockfile. The CLAUDE.md pin rationale ("10.x line stays pinned") is compatible with 10.34.5. |
| tinypool 1.1.1 (vitest) | 2 critical (prototype-pollution RCE in worker options) | dev only (test runner) |
| brace-expansion 1.1.14 / 5.0.6 (eslint, typescript-eslint) | 8 high + 2 moderate (DoS) | dev only |
| js-yaml 4.3.0 (eslint) | 2 high (CPU DoS) | dev only |
| vitest 3.2.7, @vitest/mocker | 3 moderate | dev only |
| happy-dom 20.10.6 | 1 high | dev only |
| vite 7.3.6 | 1 high, 4 moderate, 1 low (launch-editor, `server.fs.allow`) | dev server and build |
| postcss 8.5.14, nanoid 3.3.12, source-map-js 1.2.1 (vite, tailwind) | 2 high + 1 moderate, 2 high, 1 high | build time |
| zod 3.25.76 (apps/app, core-wasm, supabase runtime dependency) | 1 high "memory exhaustion on oversized constrained collections", patched in zod 4.6.6 only | runtime, browser-side form validation of the user's own input: self-DoS of one's own tab, no server impact |
## No lost validation
`crates/core/tests/curation/LEDGER.tsv`: 407 rows (144 anatomy, 263 domain), dispositions
`ported` 256, `replaced` 149, `deleted` 2, `kept` 0. Targets: 566 `cargo …::<test>` parts (154
distinct functions), 8 `vitest …` parts, 25 `import-equine --check`.
Independent resolution (script in the auditor's scratchpad, not the census): for each cargo target
every `fn <name>(` under the named binary's files was located and its whole contiguous attribute
block inspected, in any attribute order. Result: 566/566 resolve to a function carrying `#[test]`
with no `ignore` token in the block; 0 unresolved, 0 non-test, 0 ignored. The 8 vitest files
exist. The one `#[ignore]` in the crate (`pdf_serialize.rs:811`, release-only timing) predates
the diff (`babe7b7`, 2026-10-18, present at `756b7ef`) and is not a ledger target.
| Control named in the brief | Ledger rows | Rust test (active `#[test]`) | Implementation |
|---|---|---|---|
| Sheet integrity rules | 69 (40 ported, 29 replaced) | `sheet_rules::{view_main_count, view_id_duplicate, view_parent_missing, view_parent_cycle_*, view_unreachable, view_asset_missing_*, annotation_id_duplicate_across_views, …}`, `sheet_rules::the_curated_draft_validates_with_no_issue`, `sheet_rules::the_horse_slice_has_no_issue` | `crates/core/src/domain/sheet` |
| Changeset refusals | 174 (120 ported, 53 replaced, 1 deleted: purity, see below) | `curation_draft::the_synthetic_cases_match_the_typescript_or_are_refused_alike` + oracle `oracles/r5/curation-synthetic.json`, plus the per-case ported tests in `curation_draft.rs` | `crates/core/src/curation/draft/{apply,ops,targets,fields}.rs` |
| Reserved ids | 4 (3 ported, 1 replaced) | `curation_draft::a_changeset_reusing_the_reserved_asset_change_id_is_refused`, `report_rules::report_v3_schema_defaults_and_refusals` | `curation/draft`, `domain/report` |
| Seed dollar-quote guard | 1 ported | `curation_draft::a_document_holding_the_dollar_quote_tag_is_refused_by_the_seed` (`curation_draft.rs:1075`, asserts the error names `$equine_doc$`) | `curation/draft/seed.rs:13,94` |
| SVG sanitising | 24 (10 ported, 12 replaced, 2 deleted: not sanitiser cases, matched on wording) | `svg_sanitiser::{every_hostile_case_gives_the_typescript_verdict_or_a_declared_one, every_generated_case_…, the_product_svgs_come_out_untouched, a_rejection_names_a_closed_reason}` iterating the 42 `fixtures/svg/hostile/*.svg` against `oracles/r3/sanitiser.json` (452 KB); `sheet_shape::refuses_what_zod_refuses` for the `javascript:` reference | `crates/core/src/anatomy/svg/{prescan,sanitize,refs}.rs` |
The two `deleted` rows carry no control: "applyChangeset never mutates its inputs" is a JavaScript
aliasing check with no Rust meaning (`apply_changeset(baseline: &Value, …)`, `apply.rs:210`);
"horse slice JSON fixture equals the TypeScript lean input" was the TS generator of
`fixtures/horse-slice.json`, now the source file, read by `sheet_index`, `sheet_rules` and
`sheet_shape`.
Declared functional loss, confirmed as not a security loss: the xmldom re-cleaning of a legacy SVG
(`packages/anatomy/src/curation/assets.ts`, FILES.tsv row `replaced`) is not ported; the pipeline
reads the committed `draft/assets/horse.svg` and the application loads every drawing through
`anatomy::svg::read_svg` regardless of origin.
The four `crates/core/src` changes in the diff (`anatomy/mod.rs`, `curation/mod.rs`,
`domain/mod.rs`, `curation/draft/seed.rs`) are doc comments only (11 insertions, 2 deletions,
no code line).
## Dockerfile and build
`Dockerfile`: the two `COPY packages/{domain,anatomy}/package.json` lines are removed; the
builder stage copies exactly the four manifests the lockfile has importers for (`.`, `apps/app`,
`packages/supabase`, `packages/core-wasm`) before `pnpm install --frozen-lockfile`, then
`COPY . .`. The folders `packages/anatomy`, `packages/domain` and `packages/pdf` still exist on
disk with a git-ignored `node_modules/` only (0 tracked files each) and `.dockerignore` excludes
`**/node_modules/`, so nothing of them enters the image. `crates/worker/Dockerfile`,
`docker/rust-builder.Dockerfile`, `scripts/`, `.gitea/workflows`, tsconfig, vite and vitest
configs: no reference to the deleted paths (`git grep` over tracked non-doc files returns only the
ESLint ban list, the two census tests and Rust `//!` provenance comments).
`package.json`: `import:equine:legacy` removed; `packages/supabase/package.json`:
`assets:upload:legacy` removed with its script `scripts/upload-sheet-assets.ts` (the Rust
`upload-sheet-assets` binary remains the operator path). `apps/app/eslint.config.js` adds
`@faunosteo/anatomy` and `@xmldom/xmldom` to the `no-restricted-imports` ban.
## Census tests cannot pass vacuously
`r5.census.test.ts` asserts positives before negatives: the manifest list must contain the four
remaining packages; the lockfile importer set must equal the manifest set exactly;
`packages.length > 100` and a `zod@` key; more than 100 scanned sources containing the
`@faunosteo/core-wasm` specifier; the Dockerfile `COPY` list must contain the two package
manifests and each must exist; FILES.tsv > 80 rows with every counterpart present (112 rows:
55 ported, 48 replaced, 9 deleted, all package tooling or test helpers); LEDGER.tsv exactly 407
rows (144 + 263); every oracle path present; every cargo target resolved to a `#[test]` fn; the
two moved fixtures pinned by SHA-256 (verified: `e96b0882…b729c` and `ba79698c…fde7` match
`sha256sum`). `r4.census.test.ts` extends the bans and checks the importer split finds
`['.', 'apps/app', 'packages/core-wasm']` before asserting absences.
Residual gap (LOW): the ledger regex at `r5.census.test.ts:300-302` anchors on `#[test]` and
then refuses attributes starting with `ignore`. Probed with Node against the exact regex:
| Input | Census |
|---|---|
| `#[test]` / `fn foo(` | accepted |
| `#[test]` / `#[ignore]` / `fn foo(` | refused (correct) |
| `#[test]` / `#[ignore = "r"]` / `fn foo(` | refused (correct) |
| `#[ignore]` / `#[test]` / `fn foo(` | accepted (bypass: rustc accepts both orders, `cargo test` skips it) |
| `#[test]` / `#[cfg_attr(debug_assertions, ignore)]` / `fn foo(` | accepted (bypass) |
| `fn foo(` alone, or `#[test] fn bar` then `fn foo` | refused (correct) |
No ledger target is in either shape today (independent order-agnostic check above). Hint: scan the
whole attribute block above `fn <test>(` and refuse any `ignore` token in it, or assert
`cargo test -- --list` output in `check-all.sh`.
## Status of the previous audit's two LOW findings
| Previous finding | Status at 27bf59c |
|---|---|
| LOW clippy allow header, `curation_leaves.rs:6` | Unchanged. Same header as the 41 sibling test files; still LOW, still not a security-tool suppression. |
| LOW census accepted any `fn <name>(` | Fixed. `475a41d` requires `#[test]` with only attributes or doc lines between (`#\[test\]\s*(?:(?:#\[[^\]]*\]\|///[^\n]*)\s*)*fn`), `cd69f0e` adds `(?!ignore)` on those attributes. Residual gap above (attribute order, `cfg_attr`), LOW, no instance in the tree. |
## Not done (out of scope or forbidden)
No command executed from the repository other than semgrep, the guardrails scanner, `pnpm audit`
(read-only, registry query), `cargo deny check advisories` (no build) and read-only git, grep,
sha256sum. No `cargo clean`, `pnpm install`, `pnpm format`, no test suite run (a `pnpm check:all`
ran concurrently in the tree). The runtime behaviour of the ported Rust tests is attested by that
gate, not by this audit; this audit attests they exist, carry `#[test]`, are not ignored, and map
each ledger row.
@@ -62,7 +62,8 @@ Measured path (`pnpm why tsx -r`, 2026-10-25): `tsx` 4.23.15 is reached only as
`tsx: ^4.8.1` under `peerDependencies` with `peerDependenciesMeta.tsx.optional: true`), through `vite`, `vitest`,
`@vitest/mocker`, `vite-node`, `@tailwindcss/vite` and `@vitejs/plugin-react-swc` in the devDependencies of `apps/app`,
`packages/core-wasm` and `packages/supabase`; its snapshot block carries `optional: true`; no importer lists it; no
`node_modules/.bin/tsx` is linked.
root `node_modules/.bin/tsx` is linked (pnpm links the peer's bin under the
`node_modules/.bin` of `apps/app`, `packages/core-wasm` and `packages/supabase`; no script calls it; verifier precision 2026-10-25).
The exception does not hide a consumer: `r5.census.test.ts` still fails if a manifest declares `tsx` (any dependency field),
if a manifest script names `tsx`, `@faunosteo/{anatomy,domain}` or `packages/{anatomy,domain}` or ends in `:legacy`, if an importer block lists `tsx`, if the
+2 -1
View File
@@ -3817,7 +3817,8 @@ the N-1 suites (`n-1.reader`, `r5-6.n-1`, `n-1.scanner`), seed and sheet integri
**Owner validation and pre-merge checks (2026-10-25, brief « Validation R5.7 et dernière vérification pré-fusion »).**
R5.7 is validated. Decision C6: `tsx` may stay named in the lockfile as long as it is only the optional peer of vite
(`pnpm why tsx -r`: `tsx` 4.23.15 reached only as `vite` 7.3.6's peer, `peerDependenciesMeta.tsx.optional: true`, through the
devDependencies of the app, `core-wasm` and `supabase`; no importer lists it, no `node_modules/.bin/tsx`); no lockfile hand edit,
devDependencies of the app, `core-wasm` and `supabase`; no importer lists it, no root `node_modules/.bin/tsx`; pnpm links the peer's bin under the three packages' own
`node_modules/.bin`, which no script calls); no lockfile hand edit,
no override; the contract records the clarification and the census still fails on a declared `tsx`, a manifest script naming it or an
importer listing it. The 149 `replaced` rows were checked active: every cargo target runs in `cargo test` (none `#[ignore]`d,
now asserted by the census), the two vitest targets name existing cases, and every cited oracle is read by a test (the 26
+2 -3
View File
@@ -29,12 +29,11 @@ supabase/
packages/supabase/
├─ src/client.ts createBrowserClient() (anon key, PKCE)
├─ src/database.types.ts `supabase gen types` output
├─ src/anatomical-sheets.ts publishSheetVersion(): Zod + integrity gate before the RPC
├─ 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`
packages/domain/
└─ src/anatomical-sheet/ canonical sheet document (Zod), validateSheetDocument, createEmptySheetDocument
crates/core/src/domain/sheet/ canonical sheet document and its integrity rules (Rust core; `packages/domain` deleted at R5.7)
```
## 2. Prerequisites