fix(anatomy): R5.4 aligned report tables bounded before they are built, declared case fully held, docs
This commit is contained in:
1 parent
aeb5050502
commit
777c8000b8
8 files changed
+215
-21
No files matched your search
@@ -1,8 +1,8 @@
|
||||
//! The draft side of the pipeline (R5.3): the authored changeset applied on the legacy
|
||||
//! baseline, the report migration map, the document statistics and the seed SQL
|
||||
//! (`packages/anatomy/src/curation`, without the review drawings and the Markdown reports of
|
||||
//! R5.4). Parity with the TypeScript is proven by `tests/curation_draft.rs` against the
|
||||
//! committed `draft/` folder, `oracles/r5/pipeline.json` and `oracles/r5/curation-synthetic.json`.
|
||||
//! The draft side of the pipeline (`packages/anatomy/src/curation`): the authored changeset
|
||||
//! applied on the legacy baseline, the report migration map, the document statistics and the
|
||||
//! seed SQL (R5.3), the CHANGELOG, the review report and the review drawings (R5.4). Parity with
|
||||
//! the TypeScript is proven by `tests/curation_draft.rs` and `tests/curation_review.rs` against
|
||||
//! the committed `draft/` folder and the `oracles/r5` files.
|
||||
|
||||
pub mod app_review;
|
||||
pub mod apply;
|
||||
|
||||
@@ -130,6 +130,12 @@ pub(crate) fn split_row(line: &str) -> Vec<String> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The largest aligned table written, in display columns (rows × padded row width): every row
|
||||
/// is padded to the widest cell of each column, so one long authored cell multiplies by the row
|
||||
/// count (an 80 KB rationale over 14,000 records asked for 1 GB). The equine CHANGELOG's widest
|
||||
/// table holds about 0.5 MB.
|
||||
pub const MAX_TABLE_COLUMNS_TOTAL: usize = 32 * 1024 * 1024;
|
||||
|
||||
fn align(lines: &[&str]) -> Result<Vec<String>, PipelineError> {
|
||||
let rows: Vec<Vec<String>> = lines.iter().map(|line| split_row(line)).collect();
|
||||
let columns = rows.first().map_or(0, Vec::len);
|
||||
@@ -144,6 +150,13 @@ fn align(lines: &[&str]) -> Result<Vec<String>, PipelineError> {
|
||||
widths[column] = widths[column].max(display_width(text)?);
|
||||
}
|
||||
}
|
||||
let row_width = widths.iter().sum::<usize>() + 3 * columns + 1;
|
||||
if row_width.saturating_mul(rows.len()) > MAX_TABLE_COLUMNS_TOTAL {
|
||||
return Err(PipelineError::Guard(format!(
|
||||
"an aligned table of {} rows × {row_width} columns exceeds the {MAX_TABLE_COLUMNS_TOTAL} bound",
|
||||
rows.len()
|
||||
)));
|
||||
}
|
||||
let mut out = Vec::with_capacity(rows.len());
|
||||
for (index, row) in rows.iter().enumerate() {
|
||||
out.push(if index == 1 {
|
||||
|
||||
Reference in new issue
Block a user