use super::*;
#[test]
fn fixed_point_resident_batch_rejects_frontier_over_budget_before_upload() {
let backend = FakeResidentBackend::new();
let graph = graph_fixture();
let pipeline = Arc::new(FakeResidentPipeline::new());
let mut batch = FixedPointResidentBatch::with_memory_budget(usize::MAX, 16, 3);
let error = batch
.reaching(
&backend,
pipeline,
&graph,
&[0b01],
1,
&DispatchConfig::default(),
)
.expect_err("frontier budget must reject graph before resident upload");
assert!(
error.contains("requires 4 bytes") && error.contains("allows 3"),
"frontier budget error must report required and allowed bytes"
);
assert!(
backend.uploads.lock().unwrap().is_empty(),
"frontier budget rejection must happen before invariant graph uploads"
);
assert_eq!(backend.batch_uploads.load(Ordering::Relaxed), 0);
assert_eq!(
batch.stats(),
FixedPointResidentBatchStats {
graph_cache: FixedPointResidentGraphCacheStats::default(),
execution_plan_cache: FixedPointExecutionPlanCacheStats::default(),
frontier_allocations: 0,
frontier_reuses: 0,
frontier_clears: 0,
resident_dispatches: 0,
frontier_upload_bytes: 0,
result_readback_bytes: 0,
resident_graph_cold_uploads: 0,
resident_graph_warm_reuses: 0,
resident_graph_upload_bytes: 0,
resident_graph_avoided_upload_bytes: 0,
frontier_resident: false,
frontier_bytes: 0,
}
);
}
#[test]
fn fixed_point_resident_batch_rejects_wrong_graph_family_before_upload() {
let backend = FakeResidentBackend::new();
let live_graph = FixedPointForwardGraph::new_for_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::Live,
"fixed_point_resident_batch_wrong_family",
2,
&[0, 1, 1],
&[1],
&[vyre_primitives::predicate::edge_kind::CONTROL],
)
.expect("typed live graph must pack");
let pipeline = Arc::new(FakeResidentPipeline::new());
let mut batch = FixedPointResidentBatch::new();
let error = batch
.reaching(
&backend,
pipeline,
&live_graph,
&[0b01],
1,
&DispatchConfig::default(),
)
.expect_err("reaching must reject live graph before resident upload");
assert!(
error.contains("expected Reaching"),
"unexpected diagnostic: {error}"
);
assert!(
backend.uploads.lock().unwrap().is_empty(),
"wrong-family graph must be rejected before resident graph upload"
);
assert_eq!(backend.batch_uploads.load(Ordering::Relaxed), 0);
assert_eq!(
batch.graph_cache_stats(),
FixedPointResidentGraphCacheStats::default()
);
}
#[test]
fn fixed_point_resident_batch_rejects_wrong_cached_execution_plan_family() {
let backend = FakeResidentBackend::new();
let live_graph = FixedPointForwardGraph::new_for_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::Live,
"fixed_point_resident_batch_wrong_cached_plan_family",
2,
&[0, 1, 1],
&[1],
&[vyre_primitives::predicate::edge_kind::CONTROL],
)
.expect("typed live graph must pack");
let mut batch = FixedPointResidentBatch::new();
let error = match batch.cached_execution_plan_for_prepared_graph(
&backend,
crate::fixed_point_graph::FixedPointAnalysisKind::Reaching,
&live_graph,
) {
Ok(_) => panic!("cached plan API must reject mismatched analysis family"),
Err(error) => error,
};
assert!(
error.contains("expected Reaching"),
"unexpected diagnostic: {error}"
);
assert_eq!(
batch.execution_plan_cache_stats(),
FixedPointExecutionPlanCacheStats::default()
);
}