docs(docs): R5.3 fourth final round declared (RUST.md §11.12-11.13), security final4, verify record

This commit is contained in:
bchanot committed 2026-10-23 10:32:45 +02:00
1 parent 07d63076d3
commit 3ece1a64b1
3 files changed
+211 -12

No files matched your search

+35 -12
View File
@@ -2885,7 +2885,7 @@ until the switch; no fingerprint change; the cleaned `horse.svg` is read as froz
re-cleaned; the review drawings and the two Markdown reports are R5.4. Contract
`.claude/tasks/contracts/2026-10-22-rust-r5-draft.md`.
`crates/core/src/curation/draft` (2,877 lines, feature `curation`):
`crates/core/src/curation/draft` (2,912 lines, feature `curation`):
| Module | Ports |
|---|---|
@@ -2916,18 +2916,19 @@ Parity, every expectation written by the TypeScript (`tests/curation_draft.rs`,
- the 612 legacy leaves 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, the FR snapshots kept;
- 77 synthetic changesets on the mini sheet (`oracles/r5/curation-synthetic.json`,
generator `packages/anatomy/tests/r5.curation-synthetic-oracles.test.ts`): 11 accepted
- 81 synthetic changesets on the mini sheet (`oracles/r5/curation-synthetic.json`,
generator `packages/anatomy/tests/r5.curation-synthetic-oracles.test.ts`): 14 accepted
cases (every op kind, numeric and anchored positions, subtree scopes with skipped equal
values, the review rule on levels A, B and C, the five rename cascades and a reference
rename, re-homing, two chained changes, the two migration-map debt cases below) byte for
rename, re-homing, two chained changes, the two migration-map debt cases below, the three
`JSON.parse` cases of the aligned paragraph) byte for
byte on the formatted document, the records, the stats, the migration map and the seed
SQL; 63 refusals (23 schema, `null` on `scope`, `position` and `field` and the shape
family below included, 40 applier, integrity and shape gates included) refused alike, with
the same reason: the same message for an op or change refusal (change id and op index
included), the same stage for a schema or gate refusal; 7 references files refused alike;
two declared
differences below (one refusal, one acceptance), each held by its own test.
four declared synthetic cases below (three refusals, one acceptance), each held by its own
test (14 compared + 63 refused alike + 4 declared = 81).
Differences declared (none reachable by the committed files, since the folders are
reproduced byte for byte):
@@ -2943,6 +2944,7 @@ reproduced byte for byte):
| a `set` field path ending in `__proto__` (`name.__proto__`) | the prototype setter swallowed the write: change accepted, one record, the document unchanged (or, when the holder was absent, `description: {}` added by `writeField`) | the key is written and the strict document gate refuses it (the R5.2 family: a name of `Object.prototype` is a plain key) |
| an authored key starting with NUL (`"\u0000touched"`) in a value, or a field path segment starting with NUL (`name.\u0000touched`) | refused at the strict document gate when the key reaches the document, accepted when a later op overwrites or removes it | refused (`reserved key`): at parse for a value, at the op for a field path; the prefix is reserved for the applier's transient touch marks, which the cleanup strips at every depth, so a written key would be lost while a record claims it (found by the final gates, test `a_reserved_or_unbounded_field_path_is_refused_without_writing`) |
| a null, a string, a number or a boolean among the `children` or `categories` of an added item | a TypeError where a walk met it (`descendants`, the review marking: refused), silently skipped by a rename's citation walk (accepted when a later op removed the item), refused by the gate when it stayed | refused at the add (`… entry that is not an object`), whatever follows (three cases frozen from the TypeScript, one declared: `declared-children-string-renamed-then-removed`) |
| a `children` or `categories` of an added item that is present but not a list (an object, a string, `null`) | replaced by `[]` when a later op added under the item (`childrenOf`): the author's value lost without a word | refused at the add (`… that is not a list`); `children_path` never replaces a present value (declared case `declared-children-object-then-added-to`) |
| a `set` whose path goes through a string (`name.fr.x`): `writeField` replaces the string by an object | `before` recorded as undefined (null), the replaced string in no record; refused by the gate unless a later op overwrites the field | the same (kept, recorded here) |
| a field path of more than 8 segments (the deepest settable path has 2) | accepted, the gate refused the stray keys | refused at the op: a resource bound (20,000 segments overflowed the stack before it) |
| a document nested more than 64 levels after an op (the equine document has 10), by repeated `add` or `move`, or a deep value | accepted when valid | refused at the op: a resource bound checked after every op with an iterative walk (test `the_document_cannot_be_nested_past_the_bound_by_repeated_adds`) |
@@ -2963,6 +2965,14 @@ findings only (33) and no reference, so the equine map is untouched. A future ch
renaming a view, zone, region, category or a cited reference must not be published before
the fix (a declared behaviour change on both sides, after R5).
Aligned on `JSON.parse`, not a difference: an authored value keeps JavaScript's key order (array
index keys such as `"1"` first, ascending, then the others in insertion order) and an integer
beyond 2^53 is read as the double JavaScript holds (`9007199254740993` → `9007199254740992`),
at parse (`text::js_normalize`) and when a field path writes a key (`text::js_insert`), so a
record never holds a value its own document lacks (found by the fourth final verifier; cases
`js-index-key-in-value-overwritten`, `js-index-segment-overwritten`, test
`an_integer_beyond_2_53_is_read_as_the_double_json_parse_gives`).
Aligned on Zod, not a difference: serde's derives read a struct from a positional array
(`"title": ["Titre", "Title"]`, a whole change or reference as an array) and a unit enum
variant from a one-key map (`"level": {"A": null}`, `scope`, `review_status`, `laterality`,
@@ -3030,7 +3040,15 @@ seed guard tested only as a bare function, `before: null` over a replaced string
non-object children refused at the add; reads confined to the seed by canonical path; array
length compared; only folders this run created are used; `claim_destination` takes the seed
and is tested on a fixture (`the_claim_refuses_a_destination_inside_the_seed_and_creates_nothing`).
Declared: the replaced-string `before`, the memory factor.
Declared: the replaced-string `before`, the memory factor. Fourth final round on 6c0fe88:
verifier ECARTS(2) (C1, C2, C4 to C12 met, 0 accept/refuse split in 25,000 random changesets;
records differing from the TypeScript on array index keys and on integers beyond 2^53; the
declared-case count wrong) and security PASS with one MEDIUM (a present non-list `children`
silently replaced by `[]`) and LOWs (`--check` listing through a generated folder that is a
link, a mount alias of the seed, the walk cost understated, the claim test fixture in the
shared temporary folder). Fixed: `js_normalize` and `js_insert`; non-list `children` and
`categories` refused at the add and never replaced; `--check` confined to the seed's folders;
the identity guard; a 200,000-value bound; the fixture under `target/`.
### 11.13 Checkpoint R5.3
@@ -3040,16 +3058,21 @@ the readers of imported PDFs (`archive/read.rs`, `report/read.rs`, `pdf/import.r
accept an object written as an array or an enum written as a map where the frozen Zod reader
refused it. Not probed on those readers, not changed: a fix there needs the owner's per-file go.
Residual risks, measured by the final security gate and kept: memory has no cap beyond the
16 MiB read bound (a hostile 211 KB changeset of subtree sets on a 2,000-node addition asks
for more than 2 GB; the port clones the op into every record where the TypeScript shared it,
about twice its memory); the depth check walks the document
after every op (a 2.4 MB changeset takes about 10 s); `--out` assumes a single-user machine
Residual risks, measured by the final security gates and kept: the document is bounded (64
levels, 200,000 values, checked after every op; the equine document has 10 and 6,374), but
the records are not: a hostile changeset of subtree sets with a large value still costs
memory in proportion to ops × items × value size (211 KB asked for more than 2 GB before the
value bound; the port clones the op into every record where the TypeScript shared it, about
twice its memory); the bound walk runs after every op (at most 200,000 values each, a few
milliseconds; a 16 MiB changeset of tiny ops could take minutes); `--out` assumes a single-user machine
(a concurrent process able to write the destination's parent could still swap a component
between a check and its use, never overwriting: every file is `create_new`); invalid UTF-8
and repeated keys are read as the TypeScript read them. Residual risks of the slice: the
`--check` allowance for the six R5.4 files hides nothing about the
produced files but means the draft folder is not yet compared whole (R5.4 removes it); the
seed guard of `--out` compares canonical paths and file identity (device, inode) of every
ancestor, so a second mount path of the seed is refused too; `--check` refuses a generated
folder that is not itself a folder of the seed (a link there is never listed through); the
touch marks are a reserved prefix (a NUL character starts it), refused in any authored value
at parse and in any field path segment at the op, and removed after each change, so no mark
reaches a record or the document; the migration-map replay quirk above