docs(docs): R5.3 final-gate fixes declared (RUST.md §11.12-11.13), security final audit, verify record

This commit is contained in:
bchanot committed 2026-10-23 01:08:08 +02:00
1 parent 9f11499f2c
commit 314cf04e6a
3 files changed
+262 -8

No files matched your search

+18 -8
View File
@@ -2899,9 +2899,9 @@ re-cleaned; the review drawings and the two Markdown reports are R5.4. Contract
| `stats.rs` | `documentStats`: 17 fields in the TypeScript order, the fixed-key counters extended by unlisted values |
| `seed.rs` | `renderDraftSeedSql`: header, sheet insert, asset inserts, `insert_sheet_draft`, converging update, the dollar-tag refusal, `trimEnd` |
| `pipeline.rs` | `buildEquineDraft` (CHG-000 from the frozen asset's sha256, byte size and uuid, the head view box parsed from the legacy SVG; the reserved id refused), `renderDraftArtifacts` for the R5.3 files (`document.json`, `assets.json`, `sheet-ref.json` with `document_sha256` = sha256 of the `document.json` bytes, `report-migration-map.json`, `equine_draft.sql`), `parseViewBox` |
| `bin/import_equine.rs` | both folders; `--check` compares the produced files with the committed seed and lists the six R5.4 files of the draft as pending (`shortcut:` comment, removed at R5.4); `--out <dir>` writes `<dir>/legacy-import` and `<dir>/draft` into a destination that is absent or an empty folder, refuses an empty path, a symbolic link, a path that is not a folder, a folder holding any file; an absent destination is created before any write (nothing can appear between the check and the writes) and the files go to its canonical path, which the success line prints (a symbolic link among the parent folders is visible there); a relative path is typed from `INIT_CWD` when absolute, else the current folder; nothing is ever deleted |
| `bin/import_equine.rs` | both folders; `--check` compares the produced files with the committed seed and lists the six R5.4 files of the draft as pending (`shortcut:` comment, removed at R5.4); `--out <dir>` writes `<dir>/legacy-import` and `<dir>/draft` into a destination that is absent or an empty folder; it refuses an empty path, a path holding `..`, a missing parent folder, a destination inside the seed folder, a symbolic link (a trailing `/` or `/.` included), a path that is not a folder and a folder holding any entry; the parent's symbolic links are resolved and the canonical destination is printed before the first write; every folder under it is created with `create_dir` and every file with `create_new`, so an entry that appears after the claim (file, folder or symbolic link) is refused, never followed or truncated; a relative path is typed from `INIT_CWD` when absolute, else the current folder (the repository root when `scripts/import-equine.sh` is run directly, since it moves there; `pnpm r5:import-equine` is the reference); a non-UTF-8 argument is a usage error; nothing is ever deleted |
Parity, every expectation written by the TypeScript (`tests/curation_draft.rs`, 10 tests):
Parity, every expectation written by the TypeScript (`tests/curation_draft.rs`, 13 tests):
- the five R5.3 text files of the committed `draft/` byte for byte, the frozen `horse.svg`
described by its sha256, size and asset id; `pnpm r5:import-equine --check`: 12 files, 0
@@ -2939,8 +2939,10 @@ reproduced byte for byte):
| nesting deeper than 128 levels (an `add` of a 70-level finding chain) | accepted | refused at parse (serde_json's depth limit, kept as a resource bound) |
| a number beyond the double range (`1e400`) in a value a later op overwrites or removes | `JSON.parse` read Infinity, the value was discarded, the change accepted (a surviving value is refused by both at the gate) | refused at parse (serde_json's range check) |
| a `set` field path ending in an inherited `Object.prototype` member (`name.constructor`, `name.toString`, `name.valueOf`…) | `readField` returned the inherited function and the record's `structuredClone` threw (`… could not be cloned`): change refused at the op | the member is an ordinary missing key: written, `before` recorded as null. Kept alone, the shape gate refuses it (every object of the sheet contract is strict). Replaced by a later op of the run (a `set name` on the same item), the change is accepted: the document is byte for byte the one the later op alone gives, one extra record traces the overwritten write. Nothing is bypassed: the settable table checks the first segment on both sides (`constructor` as a field: `unknown field`), no value is read through a prototype, the integrity gate runs on the final document (test `an_inherited_member_name_is_a_plain_key_and_bypasses_nothing`, five member names). Accepted by the owner 2026-10-23 |
| a `set` field path ending in `__proto__` (`name.__proto__`) | the prototype setter swallowed the write: change accepted, document unchanged, one record | 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 | refused at the strict document gate when the value reaches the document, accepted when a later op overwrites or removes it | refused at parse (`reserved key`): the prefix is reserved for the applier's transient touch marks |
| 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 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`) |
Technical debt, kept during R5 (owner decision 2026-10-23, reproduced as is, never corrected
silently): `applyRecord` of the migration map reads `record.op` whatever `record.target` is.
@@ -2966,7 +2968,7 @@ never matches; `String(x)` of a missing id is `"undefined"`; the error messages
(`unknown target "…" (no "…")`, `position N out of range`, …) are the TypeScript ones with
the change id and op index prefixed.
Tests: `cargo test -p faunosteo-core --features curation` (draft 10, importer 5, formatting
Tests: `cargo test -p faunosteo-core --features curation` (draft 13, importer 5, formatting
6, plus the crate's suites); anatomy 142 (the generator added); `pnpm rust:check` green.
Gates: security auditor PASS (semgrep 0 findings, 6 LOW; fixed: the head view box read with
@@ -2989,14 +2991,22 @@ and three refusals by design now declared above (lone surrogate, depth, `__proto
met C1 to C12 and found the documentation incomplete: the curation files are now read lossily
as the TypeScript read them (a Latin-1 byte had been refused), two contrived splits are
declared above (`1e400` in a discarded value, an inherited member in a field path), and the
NUL-key row and the counts are corrected.
NUL-key row and the counts are corrected. Final round on 8654905 (owner 2026-10-23): verifier
ECARTS(2) and security PASS with 2 MEDIUM, one shared root: a NUL-prefixed field path segment
was written then stripped with the marks, its value lost while a record claimed it (fixed:
refused at the op); 20,000 field segments overflowed the stack (fixed: 8 segments, 64 levels
checked after every op); `--out` writes were not exclusive after the claim (fixed:
`create_dir` and `create_new`); `..`, a missing parent and a destination inside the seed are
refused, the destination printed before writing, a non-UTF-8 argument refused; the binary's
refusals are tested against the built binary (`out_refuses_every_unsafe_destination_and_writes_nothing`).
### 11.13 Checkpoint R5.3
Residual risks: 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
touch marks are a reserved key (a NUL character starts it), refused in any authored value at
parse and removed after each change, so no mark reaches a record or the document; the migration-map replay quirk above
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
is reproduced, not fixed; the emoji, Markdown and Unicode-table risks of §11.11 stand.
Conditions for R5.4: the owner's validation of this checkpoint; the review drawings