docs(docs): R5.4 third gate round declared (allowlist guard, empirical guarantee), audits

This commit is contained in:
bchanot committed 2026-10-23 12:39:18 +02:00
1 parent 124d954a0d
commit 6d4fdd65b2
3 files changed
+231 -34

No files matched your search

+39 -34
View File
@@ -3101,7 +3101,7 @@ Owner go « Validation R5.3 et autorisation conditionnelle R5.4 » (2026-10-23),
fresh verification of the final R5.3 state: met on c6e0d85 (CONFORME 13/13, security PASS with
LOWs only, §11.12). Contract `.claude/tasks/contracts/2026-10-23-rust-r5-review.md`.
`crates/core/src/curation/draft` gains 1,177 lines (4,204 in all):
`crates/core/src/curation/draft` gains 1,458 lines (4,366 in all), plus `curation/report_guard.rs` (140):
| Module | Ports |
|---|---|
@@ -3116,7 +3116,7 @@ LOWs only, §11.12). Contract `.claude/tasks/contracts/2026-10-23-rust-r5-review
| `pipeline.rs` | `render_draft_artifacts` complete, in the TypeScript order: document, assets, sheet-ref, migration map, the overlays and the application's drawings per view, CHANGELOG, REVIEW-REPORT, seed SQL |
| `bin/import_equine.rs` | `--check` compares the 6 + 12 files with explicit criteria (byte identity; the application's drawings may fall back on parsed trees under the declared rule, printed as `declared:`); a file missing, not produced or different fails; the pending list and its `shortcut:` are gone; `--out` writes the 18 files |
Parity, every expectation written by the TypeScript (`tests/curation_review.rs`, 8 tests):
Parity, every expectation written by the TypeScript (`tests/curation_review.rs`, 9 tests):
- `CHANGELOG.md` (1,114,533 bytes) and `REVIEW-REPORT.md` of the committed draft byte for byte;
their raw texts equal the ledger's pre-Prettier digests, the aligned texts its digests;
@@ -3151,35 +3151,39 @@ existing citations is hashed; the stale test comment fixed; the §11.12 nits (th
covers a later removal; the 200,000-value row; the line count at the close; the
set-without-value case counted among the schema refusals).
Markdown beyond the table alignment (found by the first R5.4 gates: the fresh verifier's
differential of 10,500 changesets showed that Prettier also rewrites Markdown in authored text,
the security gate that it could break the reports' structure). The port reproduces only the
table alignment, so it refuses, with the closed kind `UnsupportedMarkdown`, every text Prettier
would rewrite, never writing a report that differs silently. The rules come from a sweep written
by the TypeScript (`oracles/r5/markdown-sweep.json`, generator
`packages/anatomy/tests/r5.markdown-sweep-oracles.test.ts`: 31 characters in six positions,
whitespace patterns and Markdown constructs, each placed in a title, a rationale, a question, a
citation and a changed label; 247 probes): a carriage return or a tab anywhere, code spans
included; outside code spans, an inline link, image or
reference (`](`, `][`), a `[[ … ]]` with inner spaces, an autolink (`<scheme:…>`, `<…@…>`), a
character reference (`&name;`, `&#n;`, `&#xh;`; the last three refused whole although Prettier
keeps some of them), `*` outside a well-formed
`**strong**` span, an underscore not between two ASCII letters or digits (Prettier escapes one
next to an accented letter or a CJK, kana or Hangul character), a backslash before a space or
at the end or an authored one before the cell escape `\|`, two spaces in a row, a tab, a carriage
return, an odd number of backticks, an empty code span or one with an outer space; a table row
whose cell count differs from its header; a control character (a line break included) in a
title, rationale, question, citation, URL, DOI or vet-flag value written in a list item. Result
(test `every_probe_is_formatted_as_the_typescript_or_refused`): 187 probes byte for byte with the
TypeScript, 60 refused, 0 silent difference; a probe made only of what the equine reports use,
outside the constructs, is never refused (a polygon's `[[10,10],…]` and the DOI's
`<0697:toih>` pass). The equine reports and the R5.2 import report pass the guard unchanged.
Markdown beyond the table alignment (found by the R5.4 gates: three verifier differentials and
three security probes, each round finding a Prettier rewrite the previous rules missed). Prettier
also rewrites Markdown in authored text (escapes, emphasis, whitespace, links); the port
reproduces only the table alignment. After a denylist that leaked round after round, the guard of
the draft's two reports (`curation/report_guard.rs`, `format_report`; the R5.2 import report keeps
`format_markdown`, verified at R5.2) is an allowlist: outside code spans, letters and digits,
single spaces (none at a line end), the punctuation `.,;:!?'"«»()[]{}/-–—…%°≠=+#&<>’‘“”±→×≤≥|`, an
underscore between two ASCII letters or digits and not glued to a URL (`http://`, `https://`,
`www.`), a backslash before `"` or `|` (a JSON quote, the cell escape), `**word**` with one run of
letters between spaces or line edges (the import report's form), and no inline construct (an
inline link, image or reference `](`, `][`; a `[[ … ]]` padded inside; `<` before a letter, `/`,
`!` or `?`: an HTML tag or an autolink; a character reference `&name;`, `&#n;`); inside code spans
(generated ids and targets), anything but a carriage return or a tab, never empty, no outer space;
a table row with another cell count than its header and a control character in a list-item field
(title, rationale, question, citation, URL, DOI, vet-flag value) are refused too. Everything else
is refused with `UnsupportedMarkdown`, so an unknown form is refused by default.
The guarantee is empirical, not a proof of Prettier's behaviour: the TypeScript sweep
(`oracles/r5/markdown-sweep.json`, generator `packages/anatomy/tests/r5.markdown-sweep-oracles.test.ts`,
digests of the raw and formatted reports) holds 762 probes: 48 characters in six positions,
whitespace patterns, Markdown constructs, the families each gate round found, and 400 strings from a
seeded generator, each placed in a title, a rationale, a question, a citation, a label after a
word and a label alone (a cell start). Result (test `every_probe_is_formatted_as_the_typescript_or_refused`):
304 probes byte for byte with the TypeScript, 458 refused, 0 silent difference; a probe made only
of what the equine reports use, outside the constructs, is never refused (a polygon's
`[[10,10],…]`, the DOI's `<0697:toih>` and the URLs' inner underscores pass). The equine reports
pass the guard unchanged.
| Input | TypeScript | Rust |
|---|---|---|
| authored text with Markdown Prettier rewrites (`*x*`, `_x`, `a b`, a tab, a line break in a list item, `` `` ``, `a\|b`, `[a](<b>)`, `[a](b "t")`, `[[ a ]]`, `&#42;`…) or one of the constructs refused whole (links, autolinks, character references) | written, then rewritten by Prettier (escapes, `_emphasis_`, collapsed spaces, indented continuation lines; a row with an extra cell) | refused (`UnsupportedMarkdown`) |
| authored text outside the allowlist: Markdown Prettier rewrites (`*x*`, `_x`, `x_**a**`, `**a****b**`, `Voir_https://…`, `a b`, a non-ASCII space, a tab, a line break in a list item, `` `` ``, `a\|b`, `[a](<b>)`, `[[ a ]]`, `&#42;`…), the constructs refused whole (links, HTML tags, autolinks, character references) and any character outside the admitted set (combining marks, pictographs, symbols) | written, then rewritten by Prettier (escapes, `_emphasis_`, collapsed spaces, indented continuation lines, normalised links; a row with an extra cell), or kept | refused (`UnsupportedMarkdown`), even where Prettier would have kept the text |
| a pictograph in a table cell (an emoji, and ©, ®, ™, ✓, ★, ⚠ and the other characters `text::is_emoji_candidate` lists) | measured with Prettier's tables | refused (`UnsupportedWidth`, R5.2): the set is wider than the emoji, the refusal stays loud |
| an id an `add` writes (the item's, and those nested in its `children` or `categories`) or a `rename` id that is not a stable id (a region code for a region), or a field segment holding a control character or a backtick | accepted when a later op removed or renamed the item: the raw id stayed in the records and reached the reports' code spans (a line break there forged a section, security gate R5.4 round 2) | refused at the op, the check the final document applies anyway (test `ids_and_field_segments_that_could_forge_report_structure_are_refused`) |
| an id an `add` writes (the item's, and those nested in its `children` or `categories`) or a `rename` id that is not a stable id (a region code for a region), or a field segment holding a control character (NUL included) or a backtick | accepted when a later op removed or renamed the item: the raw id stayed in the records and reached the reports' code spans (a line break there forged a section, security gate R5.4 round 2) | refused at the op, the check the final document applies anyway (test `ids_and_field_segments_that_could_forge_report_structure_are_refused`) |
| a label, id or path holding a code point XML 1.0 refuses, or a carriage return, in a review drawing | written (a non-well-formed file; a raw CR read back as a line feed) | refused: the drawing is not written |
The drawing comparison hides nothing (security gate, MEDIUM): the rule fallback of `--check`
@@ -3193,7 +3197,7 @@ holds (a 100,000-level file is refused, never a stack overflow). The overlay pri
that overflowed as `Infinity`, as `String(number)` did. The renderers are indexed (citation
counts in one walk, previous markers and kept ids hashed, subjects grouped per change).
Tests: `cargo test -p faunosteo-core --features curation` (review 8, Markdown 1, draft 16,
Tests: `cargo test -p faunosteo-core --features curation` (review 9, Markdown 1, draft 16,
importer 5, binary 3, formatting 6, plus the crate's suites); anatomy 144 (two generators added).
### 11.15 Checkpoint R5.4
@@ -3202,12 +3206,13 @@ Graphic differences for the owner's validation: none in shapes, colours, positio
one text difference in `app-main.svg` (the trigger's English name and tooltip), already decided
at R3 and identical to the editor canvas.
Residual risks: the reports refuse what Prettier would rewrite (emphasis, escapes, whitespace
runs, line breaks in list items) and the pictographs the width table does not reproduce: a
future changeset using them stops the pipeline, visibly, until the port grows a Markdown printer
or the text changes; inline links, autolinks and character references are refused as well, even
where Prettier would keep them; raw HTML in authored text (`<b>…</b>`) is kept as the TypeScript
kept it, byte for byte (GFM renders it; Gitea strips it); the comparison of the application's drawings accepts
Residual risks: the reports admit an allowlist of characters and forms and refuse the rest,
including text Prettier would have kept (links, HTML, character references, symbols, combining
marks, non-ASCII spaces, most uses of `*` and `_`): a future changeset using them stops the
pipeline, visibly, until the allowlist is widened from new TypeScript probes or the port grows a
Markdown printer; the allowlist itself is proven by probes, not by a model of Prettier, so a
combination of admitted characters no probe covered could still differ (the sweep's random part
and the three gate differentials found none in their last rounds); the comparison of the application's drawings accepts
exactly the trigger-name rule, byte for byte; the frozen
`horse.svg` is read, never regenerated, so a future change of the drawing needs its own
decision; the residual risks of §11.13 stand.