test: preserve source bytes and isolate ordinary index budget gates

This commit is contained in:
2026-09-24 15:27:09 -07:00
parent 50a5918fd6
commit 147b247398
4 changed files with 32 additions and 15 deletions
@@ -173,7 +173,7 @@ fn rich_with_extra_headers() -> SourceBundle {
let mut bundle = rich_bundle(Layer::Oa);
let source = bundle.files.get_mut("main.arcadia").unwrap();
let at = source.rfind('}').unwrap();
let extra = (20..23)
let extra = (20..26)
.map(|n| format!("oa_activity extra{n} \"Extra\" id \"{}\" {{}}\n", id(n)))
.collect::<String>();
source.insert_str(at, &extra);
@@ -183,9 +183,10 @@ fn rich_with_extra_headers() -> SourceBundle {
fn exact_ordinary_peak_after_typed_peak_preserves_the_inherited_ledger() {
let bundle = rich_with_extra_headers();
let baseline = indexed(&bundle).resolved.storage.live;
// G10 + T21 + N9 =40, final ordinary header. Earlier typed peak is
// resolved baseline+101, one below ordinary resolved baseline+102.
for (extra, fits) in [(39, false), (40, true)] {
// G13 + T21 + N12 =46, final ordinary header. Six extra leaf activities
// add six retained warnings and eighteen lower-catalog slots. The prior
// passing resolver cap97 therefore needs at most109; this stage needs111.
for (extra, fits) in [(45, false), (46, true)] {
let profile = super::super::super::super::budget::Limits {
entries: baseline.entries + extra,
..super::super::super::super::budget::Limits::source8(language::ParseLimits::UNLIMITED)
@@ -204,7 +205,7 @@ fn exact_ordinary_peak_after_typed_peak_preserves_the_inherited_ledger() {
.resolved
.storage
.live,
baseline.add(Slots::entries(9), Span::default()).unwrap()
baseline.add(Slots::entries(12), Span::default()).unwrap()
);
} else {
let diagnostic = fail(
@@ -212,7 +213,7 @@ fn exact_ordinary_peak_after_typed_peak_preserves_the_inherited_ledger() {
"Source8 lowering entry limit exceeded.",
"main.arcadia",
);
let at = bundle.files["main.arcadia"].find("extra22").unwrap();
let at = bundle.files["main.arcadia"].find("extra25").unwrap();
assert_eq!(diagnostic.diagnostic.span, span(at, at + 7));
}
}
@@ -636,11 +637,19 @@ fn every_authored_category_reference_excludes_trivia_prose_and_historical_uuid()
#[test]
fn exact_scratch_peak_reserves_live_iterative_slots_before_growth() {
let bundle = categories();
let mut bundle = categories();
let points = ["{ x 0; y 0; }"; 64].join(", ");
let source = bundle.files.get_mut("main.arcadia").unwrap();
*source = source.replace(
"routes [{ edge @link; }];",
&format!("routes [{{ edge @link; waypoints [{points}]; }}];"),
);
let baseline = indexed(&bundle).resolved.storage.live;
// Context header leavesN32; G15; four root fields occupyW4. Popping
// target then pushing its two fields reachesW5: exactly52 added slots.
for (extra, fits) in [(51, false), (52, true)] {
// Unexpanded category peak52 is below the earlier resolver catalog/Vec
// overlap. Sixty-four valid route points isolate this stage: N11 + G15,
// pending edge1 + point values64, then pop one and push x/y =>W66.
// Exactly92 slots are live; earlier catalog overlap is only74.
for (extra, fits) in [(91, false), (92, true)] {
let profile = super::super::super::super::budget::Limits {
entries: baseline.entries + extra,
..super::super::super::super::budget::Limits::source8(language::ParseLimits::UNLIMITED)
@@ -667,8 +676,8 @@ fn exact_scratch_peak_reserves_live_iterative_slots_before_growth() {
"Source8 lowering entry limit exceeded.",
"main.arcadia",
);
let start = CATEGORIES.find("references []; occurrence @right").unwrap() + 11;
assert_eq!(diagnostic.diagnostic.span, span(start, start + 2));
let start = bundle.files["main.arcadia"].rfind("y 0").unwrap() + 2;
assert_eq!(diagnostic.diagnostic.span, span(start, start + 1));
}
}
}
@@ -0,0 +1,2 @@
# This exact-byte source fixture deliberately retains its authored CRLF.
categories.arcadia -text whitespace=cr-at-eol
@@ -26,4 +26,4 @@ project p "Authored @p child" id "00000000-0000-0000-0000-000000000001" {
oa_occurrence left "Left" id "00000000-0000-0000-0000-000000000013" { parent @sub; body { Action { action @child; lifeline none; }; }; }
oa_occurrence right "Right" id "00000000-0000-0000-0000-000000000014" { parent @q; body { Action { action @implicit; lifeline none; }; }; }
contextual_link context "Context" id "00000000-0000-0000-0000-000000000015" { owner @q; source { references [@use]; occurrence @left; }; target { references []; occurrence @right; }; purpose { Precedence { guard "@child"; }; }; }
}
}