feat(domain): R4.2e OD-3 value cap (400,000), rescue-copy guard, 1 GiB linear ceiling, budget measurements
json_js::MAX_JSON_VALUES from the R4.2e measurements (CAP envelope 39,652 values, 612-leaf export 23,803; ~100 B of tree per value, a 16 MiB dense document 784 MiB with the cap off, 16 MiB with it); draft.restore refuses an over-budget copy as invalid; --max-memory 1 GiB proven to trap on the proofs build; cargo pdf_budget prints the value table, the Node budget suite prints the per-class cost (fresh instance, W4 asserted).
This commit is contained in:
1 parent
f8579bc19a
commit
6ee04c96c5
13 files changed
+599
-14
No files matched your search
@@ -18,6 +18,7 @@ use crate::domain::report::{LateralSide, Observation, Report, SheetRef, Vertebra
|
||||
use crate::domain::session::{self, ImportFailure, RestoreFailure};
|
||||
use crate::domain::sheet::{LoadedSheet, SheetIndexData, check_sheet_document};
|
||||
use crate::facade::{Failure, parse_input, to_value};
|
||||
use crate::pdf::json_js::{MAX_JSON_VALUES, prescan};
|
||||
|
||||
type Outcome = Result<Value, Failure>;
|
||||
|
||||
@@ -314,6 +315,11 @@ fn versioned(kind: &'static str, found: Option<f64>) -> Failure {
|
||||
/// draft, and leaves it where it is.
|
||||
fn draft_restore(sheet: &LoadedSheet, input: &str) -> Outcome {
|
||||
let input: DraftRestoreInput = parse_input(input)?;
|
||||
// OD-3: a token-dense text is refused before the parser allocates its tree; the caller
|
||||
// sets the text aside verbatim, as for any unreadable draft (`invalid`).
|
||||
if prescan(input.draft.as_bytes()).values > MAX_JSON_VALUES {
|
||||
return Err(Failure::new("invalid", "json value budget exceeded"));
|
||||
}
|
||||
session::restore_draft(sheet, &input.draft, input.archive.as_deref())
|
||||
.map_err(|failure| match failure {
|
||||
RestoreFailure::UnsupportedVersion(found) => versioned("unsupported_version", found),
|
||||
|
||||
Reference in new issue
Block a user