diff --git a/crates/doc/src/model_cache.rs b/crates/doc/src/model_cache.rs index d0bd2014f8..4ee5484dce 100644 --- a/crates/doc/src/model_cache.rs +++ b/crates/doc/src/model_cache.rs @@ -538,11 +538,15 @@ impl SavedModel { }; out_features.push(f); } - let records = json!({ + let mut records = json!({ "features": out_features, "states": out_states, "model_bodies": out_bodies, "names": kept_of(names.as_slice(), &names_used), "sketches": kept_of(sketches.as_slice(), &sketches_used), "sheets": sheets, - "validation": self.records.get("validation").cloned().unwrap_or(Json::Null), }); + // The check mode the results were evaluated under, as the model records it (a model + // that records none stays without one: adopting it is refused either way). + if let (Some(validation), Some(out)) = (self.records.get("validation"), records.as_object_mut()) { + out.insert("validation".into(), validation.clone()); + } let kept: Vec = (0..self.bodies.len()).filter(|i| kernel_used.get(*i) == Some(&true)).collect(); let bodies = kept.iter().filter_map(|i| self.bodies.get(*i).cloned()).collect(); Some((SavedModel { records, bodies }, kept, used)) diff --git a/crates/io/src/design.rs b/crates/io/src/design.rs index e6538d1d93..a91ef4e90a 100644 --- a/crates/io/src/design.rs +++ b/crates/io/src/design.rs @@ -1087,7 +1087,10 @@ mod tests { .map(|(i, ms)| json!({"id": i + 1, "fingerprint": "0000000000000000", "ms": ms, "skipped": false, "state": i})) .collect(); solidcraft_doc::SavedModel { - records: json!({"features": features, "states": states, "model_bodies": records, "names": [{"faces": [], "info": []}], "sketches": [], "sheets": []}), + records: json!({ + "features": features, "states": states, "model_bodies": records, "names": [{"faces": [], "info": []}], "sketches": [], + "sheets": [], "validation": "each_feature", + }), bodies, } } @@ -1113,6 +1116,7 @@ mod tests { let (states, kept, all, within) = thinned(40); assert_eq!((states, kept.len(), within), (vec![true; 4], 40, true)); assert_eq!(all.records, model.records); + assert_eq!(thinned(16).2.records["validation"], "each_feature", "the check mode it was evaluated under"); // The final state and the slowest other (50 ms): the shared bodies count once, else // these two states would need 32 bodies' room. for bodies in [24, 31] {