fix(anatomy): R5.4 drawings projection charges each drawing's fixed parts
This commit is contained in:
1 parent
411e1058c0
commit
c4e717da86
5 files changed
+193
-8
No files matched your search
@@ -202,7 +202,7 @@ fn view_ids(document: &Value) -> Vec<String> {
|
||||
}
|
||||
|
||||
/// The review drawings' bytes, projected as an upper bound before any is rendered (the equine
|
||||
/// draft projects 1.4 MB for 0.56 MB written): every drawing repeats the whole cleaned drawing,
|
||||
/// draft projects 1.41 MB for 0.56 MB written): every drawing repeats the whole cleaned drawing,
|
||||
/// two per view, and each annotation of a view adds its markup. Views added by a changeset
|
||||
/// multiply the drawing (2,000 views asked for 547 MB, security gate R5.4 round 8); unnamed
|
||||
/// triggers repeat the opened view's names in theirs (a 485 KB changeset wrote a 131 MB
|
||||
@@ -247,6 +247,10 @@ fn longest_view_name(documents: [&Value; 2]) -> Result<usize, PipelineError> {
|
||||
Ok(longest)
|
||||
}
|
||||
|
||||
/// What a drawing writes besides the cleaned drawing and its annotations: the layer group, the
|
||||
/// overlay's group and legend (under 1 KB each; a view without annotations carries them alone).
|
||||
const DRAWING_FIXED_BYTES: usize = 4096;
|
||||
|
||||
/// The projected bytes of the review drawings: per view, the overlay (both documents' markers)
|
||||
/// and the application's drawing (the curated layer), each over the cleaned drawing.
|
||||
pub fn review_drawings_bytes(draft: &DraftResult) -> Result<usize, PipelineError> {
|
||||
@@ -255,7 +259,8 @@ pub fn review_drawings_bytes(draft: &DraftResult) -> Result<usize, PipelineError
|
||||
for view_id in view_ids(&draft.document) {
|
||||
let after = layer_bytes(&draft.document, &view_id, names)?;
|
||||
let before = layer_bytes(&draft.baseline, &view_id, names)?;
|
||||
let view = draft.cleaned_svg.len().saturating_mul(2) + before + after.saturating_mul(2);
|
||||
let drawings = draft.cleaned_svg.len() + DRAWING_FIXED_BYTES;
|
||||
let view = drawings.saturating_mul(2) + before + after.saturating_mul(2);
|
||||
total = total.saturating_add(view);
|
||||
}
|
||||
Ok(total)
|
||||
|
||||
@@ -243,7 +243,7 @@ fn the_rule_fallback_refuses_what_the_tree_does_not_carry() {
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Synthetic cases written by the TypeScript (`oracles/r5/review-synthetic.json`).
|
||||
|
||||
/// Cases the port refuses where the TypeScript wrote a file (declared in RUST.md §11.12).
|
||||
/// Cases the port refuses where the TypeScript wrote a file (declared in RUST.md §11.10 and §11.14).
|
||||
const DECLARED_REFUSALS: [&str; 1] = ["declared-emoji-in-a-cell"];
|
||||
|
||||
struct Rendered {
|
||||
@@ -546,3 +546,24 @@ fn unnamed_triggers_repeating_a_long_view_name_are_refused_before_rendering() {
|
||||
"{error}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The drawings projection is an upper bound of what is written: on the equine draft, and on
|
||||
/// a draft whose annotations are all gone, where only the drawings' fixed parts remain
|
||||
/// (verifier R5.4 round 11: 477 bytes over before the per-drawing allowance).
|
||||
#[test]
|
||||
fn the_drawings_projection_bounds_what_is_written() {
|
||||
use faunosteo_core::curation::draft::pipeline::review_drawings_bytes;
|
||||
let written = |draft: &DraftResult, anomalies: &[Anomaly]| -> usize {
|
||||
render_draft_artifacts(draft, anomalies)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|(name, _)| name.starts_with("review/"))
|
||||
.map(|(_, text)| text.len())
|
||||
.sum()
|
||||
};
|
||||
let (result, mut draft) = equine();
|
||||
assert!(review_drawings_bytes(&draft).unwrap() >= written(&draft, &result.anomalies));
|
||||
draft.document["annotations"] = Value::Array(Vec::new());
|
||||
draft.baseline["annotations"] = Value::Array(Vec::new());
|
||||
assert!(review_drawings_bytes(&draft).unwrap() >= written(&draft, &result.anomalies));
|
||||
}
|
||||
Reference in new issue
Block a user