fix(anatomy): R5.4 records bounded in total, CHANGELOG tables projected before they are joined

This commit is contained in:
bchanot committed 2026-10-23 14:58:40 +02:00
1 parent 777c8000b8
commit 5880dfa959
9 files changed
+258 -6

No files matched your search

+27
View File
@@ -775,6 +775,33 @@ fn the_document_cannot_hold_more_values_than_the_bound() {
assert!(error.contains("more than 200000 values"), "{error}");
}
/// A rename or a remove records the whole item, before and after, with the change's texts:
/// the records are bounded in total (security gate R5.4 round 7: 400 renames of a
/// 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::record_weight;
let equine: usize = equine_draft().records.iter().map(record_weight).sum();
println!("equine records weigh {equine} units");
assert!(equine * 8 < MAX_RECORDED_WEIGHT, "{equine}");
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 mut ops = vec![json!({ "op": "add", "target": MOBILITY, "value": value })];
for round in 0..200 {
let (from, to) = if round % 2 == 0 {
("many", "other")
} else {
("other", "many")
};
ops.push(json!({ "op": "rename", "target": format!("{MOBILITY}/{from}"), "id": to }));
}
let error = mini_apply(Value::from(ops)).unwrap_err();
assert!(error.contains("the records weigh more than"), "{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]
+26
View File
@@ -149,3 +149,29 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
assert_eq!(same + refused, 798);
println!("{same} identical, {refused} refused");
}
/// One long authored cell pads every row of its level: the CHANGELOG is refused before its
/// table is joined, through the pipeline (security gate R5.4 round 7), while the records stay
/// within their own bound.
#[test]
fn a_changelog_whose_alignment_would_explode_is_refused_before_it_is_built() {
let frozen = oracle();
let mobility = "finding:hip/hip-dysfunctions/mobility";
let sets: Vec<Value> = (0..20)
.map(|i| json!({ "op": "set", "target": mobility, "field": "name.en", "value": format!("v{i}") }))
.collect();
let change = |id: &str, rationale: String, ops: Vec<Value>| {
json!({ "id": id, "level": "A", "kind": "technical",
"title": { "fr": "Essai", "en": "Test" }, "rationale": rationale,
"reference_ids": [], "ops": ops })
};
let long = change("CHG-001", "a".repeat(2_000_000), vec![sets[0].clone()]);
let rows = change("CHG-002", "Essai".to_owned(), sets);
let case = json!({ "changes_file": { "changes": [long, rows] } });
let (changelog, _) = raw_reports(&frozen, &case);
let error = changelog.unwrap_err();
assert!(
matches!(&error, PipelineError::Guard(message) if message.contains("exceeds the")),
"{error}"
);
}