WIP: one scratch App for the width guard (improvise-b9f2)

This commit is contained in:
Edward Langley
2026-09-22 23:00:59 -07:00
parent 288db9b269
commit 5d56196f56
@@ -61,13 +61,12 @@ fn one_coordinate_drills(model: &Model) -> Vec<Vec<String>> {
drills
}
/// Records a compared drill's own effects freeze in a fresh `App`, counted only when
/// the drill narrowed the store: a whole-store drill never reads the index.
fn records_narrowed(effects: Vec<Box<dyn Effect>>) -> usize {
let mut app = fixture();
let store = app.model_state.workbook.model.data.live_records().count();
app.apply_effects(effects);
let frozen = app.drill_state.map_or(0, |drill| drill.records.len());
/// Records a compared drill's own effects freeze in `scratch`, counted only when the
/// drill narrowed the store: a whole-store drill never reads the index.
fn records_narrowed(scratch: &mut App, effects: Vec<Box<dyn Effect>>) -> usize {
let store = scratch.model_state.workbook.model.data.live_records().count();
scratch.apply_effects(effects);
let frozen = scratch.drill_state.as_ref().map_or(0, |drill| drill.records.len());
if frozen < store { frozen } else { 0 }
}
@@ -116,6 +115,7 @@ fn compare(a: &CmdContext, others: &[CmdContext]) -> Comparison {
let drill = DrillIntoCell {
key: CellKey::new(vec![]),
};
let mut scratch = fixture();
for name in a.registry.names().collect::<Vec<_>>() {
let before = found.compared;
for args in &candidates {
@@ -124,7 +124,7 @@ fn compare(a: &CmdContext, others: &[CmdContext]) -> Comparison {
};
let left = format!("{effects:?}");
if name == drill.name() {
found.widest_drill = found.widest_drill.max(records_narrowed(effects));
found.widest_drill = found.widest_drill.max(records_narrowed(&mut scratch, effects));
}
found.compared += 1;
for b in others {