fix(anatomy): R5.4 records charged at each record, review drawings bounded before rendering

This commit is contained in:
bchanot committed 2026-10-23 15:21:31 +02:00
1 parent 5880dfa959
commit 8bdb079f70
10 files changed
+357 -75

No files matched your search

+55 -7
View File
@@ -764,14 +764,26 @@ fn an_integer_beyond_2_53_is_read_as_the_double_json_parse_gives() {
);
}
/// The records bound now stops a growing changeset first (every added value is recorded); the
/// document bound still holds a baseline near it: one small add past 200,000 values is refused.
#[test]
fn the_document_cannot_hold_more_values_than_the_bound() {
let children: Vec<Value> = (0..70_000)
.map(|i| json!({ "id": format!("n{i}"), "name": { "fr": "a", "en": "a" } }))
.collect();
let value = json!({ "id": "many", "name": { "fr": "a", "en": "a" }, "children": children });
let op = json!({ "op": "add", "target": MOBILITY, "value": value });
let error = mini_apply(json!([op])).unwrap_err();
let frozen = oracle("curation-synthetic.json");
let references = parse_references(&to_js_compact(&frozen["references_file"]).unwrap()).unwrap();
let mut baseline = frozen["baseline"].clone();
baseline["padding"] = Value::from(vec![Value::Null; 199_950]);
let value = json!({ "id": "small", "name": { "fr": "a", "en": "a" },
"children": (0..20).map(|i| json!({ "id": format!("n{i}"), "name": { "fr": "a", "en": "a" } }))
.collect::<Vec<_>>() });
let file = json!({ "changes": [{
"id": "CHG-001", "level": "A", "kind": "technical",
"title": { "fr": "Essai", "en": "Test" }, "rationale": "Essai",
"reference_ids": [], "ops": [{ "op": "add", "target": MOBILITY, "value": value }],
}]});
let changeset = parse_changeset(&to_js_compact(&file).unwrap()).unwrap();
let error = apply_changeset(&baseline, &references, &changeset.changes)
.unwrap_err()
.to_string();
assert!(error.contains("more than 200000 values"), "{error}");
}
@@ -780,7 +792,7 @@ fn the_document_cannot_hold_more_values_than_the_bound() {
/// 5,000-child item asked for 4.3 GB). The equine changeset stays far below the bound.
#[test]
fn the_records_cannot_outgrow_their_bound() {
use faunosteo_core::curation::draft::apply::MAX_RECORDED_WEIGHT;
use faunosteo_core::curation::draft::records::MAX_RECORDED_WEIGHT;
use faunosteo_core::curation::draft::records::record_weight;
let equine: usize = equine_draft().records.iter().map(record_weight).sum();
println!("equine records weigh {equine} units");
@@ -802,6 +814,42 @@ fn the_records_cannot_outgrow_their_bound() {
assert!(error.contains("the records weigh more than"), "{error}");
}
/// One op, or the B/C marking, records once per item it reaches: the bound is charged at each
/// record, before the change and the op are cloned into it (security gate R5.4 round 8: a level
/// B add of 10,000 children with a 128 KiB rationale reached 1.37 GB inside one marking).
#[test]
fn the_records_bound_holds_inside_one_op_and_the_marking() {
let children: Vec<Value> = (0..5_000)
.map(|i| json!({ "id": format!("n{i}"), "name": { "fr": "a", "en": "a" } }))
.collect();
let value = json!({ "id": "many", "name": { "fr": "a", "en": "a" }, "children": children });
let add = json!({ "op": "add", "target": MOBILITY, "value": value });
let frozen = oracle("curation-synthetic.json");
let references = parse_references(&to_js_compact(&frozen["references_file"]).unwrap()).unwrap();
let description = json!({ "fr": "d".repeat(4_096), "en": "d" });
let subtree = json!({ "op": "set", "target": format!("{MOBILITY}/many"), "field": "description",
"value": description, "scope": "subtree" });
let cases = [
("B", "r".repeat(8_192), json!([add])),
("A", "Essai".to_owned(), json!([add, subtree])),
];
for (level, rationale, ops) in cases {
let file = json!({ "changes": [{
"id": "CHG-001", "level": level, "kind": "technical",
"title": { "fr": "Essai", "en": "Test" }, "rationale": rationale,
"reference_ids": [], "ops": ops,
}]});
let changeset = parse_changeset(&to_js_compact(&file).unwrap()).unwrap();
let error = apply_changeset(&frozen["baseline"], &references, &changeset.changes)
.unwrap_err()
.to_string();
assert!(
error.contains("the records weigh more than"),
"{level}: {error}"
);
}
}
/// A `__proto__` segment had no faithful reading in the TypeScript (a prototype set, a
/// polluted `Object.prototype`, or nothing written): the port refuses it at the op.
#[test]