weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
use super::*;

#[test]
fn resident_ifds_batch_accounting_overflow_returns_typed_error() {
    let mut batch = ResidentIfdsBatch::<usize>::new();
    batch.resident_dispatches = u64::MAX;

    let error = batch
        .record_resident_dispatch_io(1, 1, 1)
        .expect_err("resident IFDS dispatch accounting overflow must not panic or wrap");

    assert!(
        error.contains("dispatch counter overflowed u64")
            && error.contains("Fix: rotate the batch facade"),
        "resident IFDS accounting overflow must explain the failed counter and the operator action"
    );
    assert_eq!(batch.stats().resident_dispatches, u64::MAX);
}

#[test]
fn resident_ifds_batch_production_accounting_has_no_panic_path() {
    let facade_source = include_str!("../../ifds_resident_batch.rs");
    let solve_source = include_str!("../solve.rs");
    let retained_scratch_source = include_str!("../retained_scratch.rs");
    let single_scratch_source = include_str!("../../ifds_resident_types/resident_scratch.rs");
    let single_scratch_alloc_source = include_str!("../../ifds_resident_alloc/single_scratch.rs");
    let parallel_scratch_source = include_str!("../../ifds_resident_types/parallel_scratch.rs");
    let parallel_scratch_alloc_source = include_str!("../../ifds_resident_alloc/parallel_scratch.rs");
    let forbidden = [
        concat!(".", "expect("),
        concat!("panic", "!("),
        concat!("unimplemented", "!("),
        concat!("todo", "!("),
        concat!(".", "saturating_add"),
    ];

    for needle in forbidden {
        assert!(
                !facade_source.contains(needle),
                "resident IFDS batch facade production accounting must return typed errors instead of using {needle}"
            );
        assert!(
                !solve_source.contains(needle),
                "resident IFDS batch solve production accounting must return typed errors instead of using {needle}"
            );
        assert!(
                !retained_scratch_source.contains(needle),
                "resident IFDS retained scratch production accounting must return typed errors instead of using {needle}"
            );
        assert!(
                !single_scratch_source.contains(needle),
                "resident IFDS single scratch production accounting must use allocation-time checked retained-byte invariants instead of {needle}"
            );
        assert!(
                !single_scratch_alloc_source.contains(needle),
                "resident IFDS single scratch allocation must return typed errors instead of using {needle}"
            );
        assert!(
                !parallel_scratch_source.contains(needle),
                "resident IFDS parallel scratch production accounting must use allocation-time checked retained-byte invariants instead of {needle}"
            );
        assert!(
                !parallel_scratch_alloc_source.contains(needle),
                "resident IFDS parallel scratch allocation must return typed errors instead of using {needle}"
            );
    }
}