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:
bchanot committed 2026-10-18 16:06:36 +02:00
1 parent f8579bc19a
commit 6ee04c96c5
13 files changed
+599 -14

No files matched your search

+29
View File
@@ -50,6 +50,35 @@ impl SheetHandle {
}
}
/// R4.2e proof: the import with the OD-3 value cap off, so that a token-dense document runs
/// into the linear memory ceiling and traps (never in the module the application ships).
#[cfg(feature = "proofs")]
#[wasm_bindgen]
pub fn import_pdf_unbounded_for_test(bundle: &str, bytes: &[u8]) -> Result<String, JsError> {
use faunosteo_core::pdf::import::import_pdf;
use faunosteo_core::pdf::read::probe::ProbeLimits;
let sheet = faunosteo_core::facade::load_sheet(bundle)
.map_err(|failure| JsError::new(&format!("{}: {}", failure.kind, failure.detail)))?;
Ok(match import_pdf(&sheet, bytes, ProbeLimits::UNBOUNDED) {
Ok(_) => "ok".to_owned(),
Err(failure) => format!("{failure:?}"),
})
}
/// R4.2e proof: the linear memory ceiling (`--max-memory`, `.cargo/config.toml`). Allocates
/// and touches `mib` MiB; past the ceiling the allocation fails and Rust aborts, a trap.
#[cfg(feature = "proofs")]
#[wasm_bindgen]
pub fn allocate_for_test(mib: u32) -> u32 {
let bytes = vec![1u8; (mib as usize) * 1024 * 1024];
std::hint::black_box(&bytes);
bytes
.iter()
.step_by(1024 * 1024)
.map(|b| u32::from(*b))
.sum()
}
/// R0 proof: on wasm32 a panic is a trap (panic = abort), reaching JavaScript as a
/// `WebAssembly.RuntimeError`; the caller re-instantiates the module.
#[cfg(feature = "proofs")]