chore(memory): R5.3 contract, security and verifier audits, TODO, plan status, journal
This commit is contained in:
1 parent
94280a4c56
commit
8010661de6
6 files changed
+303
-3
No files matched your search
@@ -309,7 +309,12 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
|
||||
- [x] owner decisions (2026-10-22, BDR-068): D-R5 = B `sha256-rfc8785-validated-v1` (applied at R5.6 only), aliases from trusted frozen documents only, F1 go, byte-exact by default + declared differences, historical SVG bytes kept, `.prettierignore` on Rust-written paths + reproducible check, `ureq` preferred at R5.5; stop after R5.2
|
||||
- [x] R5.1b F1 fix (aed6b1e): `zmij` digits; V8 oracle `oracles/r5/numbers.json` 44,322 rows (1,552 mismatches before, 0 after); 840.1692504882812 test; `zod_oracle` checks oracle bytes vs core compact print (red on old printer); consumers audited R2-R4: rust:check + wasm + check green, no oracle/golden/digest moved
|
||||
- [x] R5.2 legacy importer in Rust (feature `curation`, `crates/core/src/curation/**`, 3,187 lines) + `import-equine --check | --out`: legacy-import/ 4 texts + 2 SVG byte-exact, pipeline.json legacy parts equal, raw report = pre-Prettier digest, determinism, 10 synthetic TS cases (2 byte-exact, 8 refused alike), format probes (968 JSON, 10 tables, slugs, uuids, Number, Math.round, key order); declared differences RUST.md §11.10; contract `.claude/tasks/contracts/2026-10-22-rust-r5-f1-importer.md` → checkpoint, STOP before R5.3
|
||||
- [ ] R5.3 changeset applier, migration map, stats, seed SQL (draft JSON + SQL under the decided fingerprint, 825 records, 612 leaves)
|
||||
- [x] R5.3 changeset applier, migration map, stats, seed SQL (done e0f149b, checkpoint delivered, STOP before R5.4; owner go 2026-10-22 « Validation R5.1b / R5.2 et autorisation R5.3 »: `pnpm r5:import-equine --check | --out <dest>` names the Rust binary, `pnpm import:equine` kept; no fingerprint switch; `horse.svg` frozen bytes read, never re-cleaned; R5.4 files (review SVGs, CHANGELOG, REVIEW-REPORT) out of scope; stop at the checkpoint)
|
||||
- [x] R5.3a `crates/core/src/curation/draft/{schema,targets,fields,ops,rename,apply}.rs`: changeset + references files parsed strictly (Zod shape order on re-emit, `priority` default, level C question, duplicate ids), target grammar, settable fields, the six ops on the plain JSON document (`serde_json::Value`, insertion order), rename propagation, review rule (touched items → `to_confirm`, identity through a transient marker key), shape + integrity gate through the R2 core (`AnatomicalSheetDocument` + `validate_sheet_document`)
|
||||
- [x] R5.3b `draft/{migration_map,stats,seed,pipeline}.rs`: replay of rename/remove/move records over the 792 legacy paths, re-homing, stats; `documentStats` (17 fields, JS key order); `renderDraftSeedSql` byte-exact; `build_equine_draft` (CHG-000 from the frozen `horse.svg` bytes and the head view box) + `render_draft_artifacts` (document, assets, sheet-ref with sha256 of the document bytes, migration map, seed SQL)
|
||||
- [x] R5.3c `import-equine`: both folders (`<dest>/legacy-import`, `<dest>/draft`), `--check` compares the produced files and lists the R5.4 files as pending (not counted), `--out` refuses a non-empty folder, a symlink, a file, an empty path; `scripts/import-equine.sh` + root script `r5:import-equine`
|
||||
- [x] R5.3d proofs (draft 5 files byte-exact, 12/12 `--check`, 46 changes + 825 records + stats equal, 612 leaves 442/141/29, 58 synthetic cases: 9 byte-exact + 49 refused alike + 5 references files, rust:check green): `tests/curation_draft.rs` (draft files byte-exact vs committed, `pipeline.json` draft section: 46 changes, 825 records, stats, migration stats, assets, issues; determinism; 612-leaf walk through the core's migration on the produced map); TS generator `r5.curation-synthetic-oracles.test.ts` → `oracles/r5/curation-synthetic.json` (mini sheet: every op kind, positions, subtree scopes, review rule B/C, renames with cascades, re-homing, refusals) run by the Rust suite; `pnpm rust:check`, `pnpm check:all`
|
||||
- [x] R5.3e (security PASS 6 LOW / 3 fixed; verifier 4 passes, last C1-C12 met + C13 docs fixed after; check:all green 00:10:03) gates: security auditor (diff), independent verifier on the contract `.claude/tasks/contracts/2026-10-22-rust-r5-draft.md`; docs RUST.md §11.12-11.13, CHANGELOG, CLAUDE.md commands; memory → checkpoint report, STOP before R5.4
|
||||
- [ ] R5.4 review overlays + app drawings on the R3 layer/compose (parsed trees), CHANGELOG + REVIEW-REPORT
|
||||
- [ ] R5.5 `upload-sheet-assets` bin + runbook (local stack run)
|
||||
- [ ] R5.6 D-R5 switch (convention, aliases, membership test in gated readers with per-file go, seed regenerated once by the Rust tool, `.prettierignore`, CHANGELOG)
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# CONTRACT: Rust R5.3, the draft side of the anatomical pipeline (changeset applier, migration map, stats, seed SQL)
|
||||
|
||||
- date: 2026-10-22 | branch `feature/rust-r5-pipeline-core` | plan `.claude/tasks/plans/2026-10-22-rust-r5-pipeline-core.md` §B.5 row R5.3
|
||||
- brief: owner 2026-10-22 « Validation R5.1b / R5.2 et autorisation R5.3 » (applied as written; its §1 to §9 are the clauses below)
|
||||
- predecessor: R5.2 contract `.claude/tasks/contracts/2026-10-22-rust-r5-f1-importer.md` (the legacy importer, `import-equine --check | --out`)
|
||||
|
||||
## Scope
|
||||
|
||||
Port `packages/anatomy/src/curation/{schema,targets,fields,ops,rename,apply,types,migration-map,stats,seed,pipeline}.ts`
|
||||
(the draft side without the review drawings and the two Markdown reports, which are R5.4) into
|
||||
`crates/core/src/curation/draft/**` behind the existing `curation` feature, and extend the
|
||||
`import-equine` binary to the `draft/` folder. Out of scope: `overlay.ts`, `app-review.ts`,
|
||||
`changelog.ts`, `review-report.ts`, `assets.ts` (`stripLegacyAnnotations`: the cleaned `horse.svg`
|
||||
is frozen, read as bytes), the fingerprint convention (R5.6), the upload tool (R5.5), any deletion
|
||||
under `packages/`.
|
||||
|
||||
## Clauses (each one checkable)
|
||||
|
||||
C1. **Inputs.** The core reads the legacy `ImportResult` (R5.2), the bytes of the frozen
|
||||
`draft/assets/horse.svg`, the head view box text, `curation/references.json` and
|
||||
`curation/changes.json` as texts. No `std::fs`, no clock in `crates/core/src/curation/**`
|
||||
(the binary `crates/core/src/bin/import_equine.rs` is the only file allowed the file system).
|
||||
|
||||
C2. **Strict schemas.** `changes.json` and `references.json` are refused on: an unknown key in any
|
||||
object, a wrong type, an `id` not matching `^CHG-\d{3,}$`, an empty `title.fr` / `title.en` /
|
||||
`rationale` / target / field / rename id / cited reference id / `question`, an empty `ops`, an
|
||||
empty `cite.reference_ids`, a level C change without a `question`, a duplicate change id, a
|
||||
duplicate reference id, a position that is not a non-negative integer or a strict
|
||||
`{after}` / `{before}` object, a reference failing the R2 `Reference` contract. `priority`
|
||||
defaults to `medium`. Declared difference: a `set` without `value` is refused (TypeScript
|
||||
wrote `undefined`, i.e. dropped the key).
|
||||
|
||||
C3. **Applier semantics** (`apply.rs`, `ops.rs`, `rename.rs`, `targets.rs`, `fields.rs`): the
|
||||
six ops behave as `ops.ts` on the plain JSON document (insertion order of keys, `review_status`
|
||||
appended last when created), with the settable table of `fields.ts`, the target grammar of
|
||||
`targets.ts`, the rename cascade of `rename.ts` (one record per rewrite), `assertDeclared`,
|
||||
`assertNotReviewed`, and the review rule of `apply.ts` (every touched finding or annotation of a
|
||||
B or C change set `to_confirm` with a record, first-touch order, items removed from the document
|
||||
skipped). Any op that cannot apply exactly refuses with the change id and op index; the result
|
||||
then passes the R2 shape (`AnatomicalSheetDocument`) and integrity (`validate_sheet_document`)
|
||||
gate, errors refuse, warnings are returned.
|
||||
|
||||
C4. **Records.** Every record is `{change, op, target, field, before, after}` with `change` in
|
||||
the Zod shape order (`id, level, kind, title, rationale, reference_ids, question?, priority`),
|
||||
`op` in the Zod shape order of its kind, absent values as `null`.
|
||||
|
||||
C5. **Migration map** (`migration_map.rs`): `buildReportMigrationMap` as `migration-map.ts`
|
||||
(replay of rename / remove / move records, zone renames, annotation and view renames, the
|
||||
finalPaths check, unique re-homing, stats `nodes / identical / remapped / rehomed / removed`).
|
||||
|
||||
C6. **Stats** (`stats.rs`): `documentStats` with its 17 fields in the TypeScript key order,
|
||||
the fixed-key counters (`point, zone, detail_trigger`; `inherited, reviewed, to_confirm`)
|
||||
extended by unlisted values as JavaScript does.
|
||||
|
||||
C7. **Seed SQL** (`seed.rs`): `renderDraftSeedSql` byte for byte (header, sheet insert, asset
|
||||
inserts, `insert_sheet_draft`, converging update, the dollar tag refusal, `trimEnd`).
|
||||
|
||||
C8. **Draft artifacts** (`pipeline.rs`): `build_equine_draft` runs CHG-000 (asset record of the
|
||||
frozen bytes: sha256, byte size, uuid; `view:main.svg_asset_id`, `view:head.svg_asset_id = null`,
|
||||
`view:head.view_box` from the head SVG's viewBox) then the authored changes, refuses a changeset
|
||||
reusing `CHG-000`; `render_draft_artifacts` returns `document.json`, `assets.json`,
|
||||
`sheet-ref.json` (`document_sha256` = sha256 of the `document.json` bytes, the historical rule),
|
||||
`report-migration-map.json`, `equine_draft.sql`, in the TypeScript order, plus the byte copy
|
||||
`assets/horse.svg`.
|
||||
|
||||
C9. **Parity proofs** (`crates/core/tests/curation_draft.rs`): the six R5.3 files of the
|
||||
committed `draft/` byte for byte; the `pipeline.json` draft section (sheetId, 46 changes, 1
|
||||
asset, statsBefore, statsAfter, issues, migrationStats, 825 records) equal under the JS compact
|
||||
print; two runs byte-equal; the 612 legacy leaves migrated through the core's `read_report_document`
|
||||
on the produced map: 442 identical, 141 moved, 29 removed, every resolved leaf a leaf of the
|
||||
produced document, the 29 flagged paths exactly those the map sends to null.
|
||||
|
||||
C10. **Synthetic differential** (`oracles/r5/curation-synthetic.json`, generator
|
||||
`packages/anatomy/tests/r5.curation-synthetic-oracles.test.ts`, `MAKE_R5_ORACLES=1`): changesets
|
||||
on the mini sheet covering every op kind, numeric and anchored positions, subtree scopes, the
|
||||
review rule on levels A / B / C, the five rename cascades, a reference rename, re-homing, and the
|
||||
refusal classes of `curation.apply.test.ts` and `curation.schema.test.ts`; each accepted case
|
||||
freezes the formatted document, the records, the stats, the migration map and the seed SQL, each
|
||||
refused case the refusal; the Rust suite reproduces every accepted case byte for byte and refuses
|
||||
every refused case.
|
||||
|
||||
C11. **Binary and script.** `import-equine --check` compares `legacy-import/` and `draft/` with
|
||||
the committed folders and writes nothing; the R5.4 files (`review/*.svg`, `CHANGELOG.md`,
|
||||
`REVIEW-REPORT.md`) are listed as pending and not counted (marked `shortcut:` for R5.4).
|
||||
`import-equine --out <dest>` writes `<dest>/legacy-import/**` and `<dest>/draft/**`, refuses an
|
||||
empty path, a path that exists and is not a directory, a symlink, a folder holding any file;
|
||||
never deletes. `scripts/import-equine.sh` + root script `r5:import-equine` forward the
|
||||
arguments; `pnpm import:equine` (TypeScript) unchanged.
|
||||
|
||||
C12. **Frozen references untouched.** No file under `supabase/seed/**`, `crates/core/tests/oracles/**`
|
||||
(except the new `curation-synthetic.json`), `apps/app/tests/fixtures/**`,
|
||||
`packages/core-wasm/tests/n-1/**` changes; `documentSha256` stays `27c7383c…2660`; no gated
|
||||
reader (`domain/{archive/read,report/rebase,report/read,session}.rs`, `pdf/{read,json_js,import}.rs`)
|
||||
changes; `packages/anatomy` and `packages/domain` keep every test (anatomy gains the generator).
|
||||
|
||||
C13. **Gates.** `pnpm rust:check` green, `pnpm check:all` green, security auditor PASS on the
|
||||
diff, this contract verified CONFORME by a fresh verifier; RUST.md §11.12 (R5.3) and §11.13
|
||||
(checkpoint) written, CHANGELOG Unreleased, CLAUDE.md command list; differences declared one by
|
||||
one. No merge, no R5.4, no fingerprint switch, no release, no deploy.
|
||||
@@ -3,7 +3,7 @@
|
||||
- date: 2026-10-22 | rev 1 (R5.1 only; the later slices are a proposal for the R5.1 checkpoint) | branch: `feature/rust-r5-pipeline-core` (cut from develop 9c0117a, R4 merged)
|
||||
- spec: owner brief 2026-10-22 « Clôture R4 validée et autorisation R5.1 » (§A.0); `docs/development/RUST_ARCHITECTURE_REVIEW.md` II.2 rows "anatomy curation pipeline" and "upload-sheet-assets" (lines 299, 300), VI.1 row R5 (636), VI.3 (655), VI.4 (662 to 668), D-R5 (837, 873), Annex C D-R5 amendment (974); BDR-043, BDR-045; CLAUDE.md "Anatomical sheet model", "Schemas", archive-reader gate
|
||||
- facts: `.claude/audits/R5_PIPELINE_INVENTORY.md` (the TypeScript pipeline), `.claude/audits/R5_DOCUMENT_SHA256_CENSUS.md` (the fingerprint), the oracles under `crates/core/tests/oracles/r5/`, the study scripts `scripts/r5-fingerprints.mjs` and `packages/supabase/scripts/r5-jsonb-fingerprint.mjs`
|
||||
- status: R5.1 validated 2026-10-22; D-R5 decided (A.5); R5.1b and R5.2 done, checkpoint R5.2 pending; R5.3 on the owner's go.
|
||||
- status: R5.1 validated 2026-10-22; D-R5 decided (A.5); R5.1b and R5.2 validated 2026-10-22; R5.3 done (contract `.claude/tasks/contracts/2026-10-22-rust-r5-draft.md`, RUST.md §11.12), checkpoint R5.3 pending; R5.4 on the owner's go.
|
||||
- not in scope of R5.1: any Rust implementation of the pipeline, any change to `documentSha256` or to the readers, the deletion of `packages/anatomy` or `packages/domain`, any golden or historical reference regeneration, release 0.2.0, deployment, SaaS features.
|
||||
|
||||
# Part A. For the owner
|
||||
@@ -91,7 +91,7 @@ Encoding change vs content change: the today / A / B columns of one row are thre
|
||||
|
||||
`crates/core/src/json.rs` takes the shortest digits from `format!("{:e}")` (Grisu); on an exact decimal tie between two shortest candidates ECMAScript picks the even one, Grisu the upper one. Measured: `840.1692504882812` (legacy annotation `cx`, from Horse.svg) prints `…813`; 7,401 of 100,000 float32-exact values in 0..2000 and 769 of 100,000 random doubles differ; `zmij` (serde_json's formatter) differs on none. Reached by the canvas layer (R3), the PDF writer, the archive attachment, the R2 contract tests. Invisible today: the curated draft carries no tie value, and `sheet_contract.rs` re-prints its expected text through `to_js_pretty`, so the oracle cannot see it. Proposed fix (after your go, before R5.2): digits from `zmij` (or `serde_json::to_string(&f64)`), the two tie values and the 8 long decimals of the legacy SVG as unit tests, `zod_oracle` comparing against the JS text recorded in the oracle rather than a re-print.
|
||||
|
||||
### B.3.5 Compatibility mechanism (proposal, not implemented)
|
||||
### B.3.5 Compatibility mechanism (approved at A.5, applied at R5.6)
|
||||
|
||||
The sheet side carries the convention and the aliases; the report contract does not change.
|
||||
|
||||
|
||||
Reference in new issue
Block a user