use crate::descriptor::NamespacedName;
use crate::generate::{
CaseIndex, CaseWidth, GenerationCensus, GenerationHalt, GenerationPlanRefusal,
};
use crate::report::{FindingCause, TrialFinding};
#[path = "type_guard.rs"]
mod guard;
const CAUSE_FAMILY: &str = "macroonz.interleave";
pub const EXPLORATION_STARVED: FindingCause =
FindingCause::named(CAUSE_FAMILY, "exploration-starved");
pub const ADDRESSABLE_STRANDS: usize = 256;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Strand<Command> {
name: NamespacedName,
commands: Vec<Command>,
}
#[must_use = "a refusal is the reason a strand was not built"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StrandRefusal {
EmptyStrand(NamespacedName),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StrandSet<Command> {
strands: Vec<Strand<Command>>,
steps: usize,
width: CaseWidth,
}
#[must_use = "a refusal is the reason a strand set was not built"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StrandSetRefusal {
DuplicateStrand(NamespacedName),
MoreStrandsThanAddressable {
strands: usize,
},
StepsUnaddressable,
FewerThanTwoStrands {
strands: usize,
},
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Interleaving {
choices: Vec<u8>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InterleavedSequence<Command> {
interleaving: Interleaving,
commands: Vec<Command>,
}
pub(super) struct Realization<Command> {
pub(super) choices: Vec<u8>,
pub(super) commands: Vec<Command>,
pub(super) radixes: Vec<usize>,
}
#[must_use = "a refusal is the reason an interleaving was not encoded"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EncodingRefusal {
StepsMismatch {
declared: usize,
steps: usize,
},
ChoiceOutsideStrands {
at: usize,
choice: u8,
},
StrandExhausted {
at: usize,
choice: u8,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ExplorationBound {
interleavings: u32,
samples: u32,
}
#[must_use = "a refusal is the reason an exploration bound was not built"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExplorationBoundRefusal {
ZeroInterleavings,
ZeroSamples,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum InterleavingSpace {
Counted(u128),
BeyondCount,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExplorationMode {
Exhaustive,
Sampled {
census: GenerationCensus,
halt: GenerationHalt,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ExplorationSite {
Enumerated {
ordinal: u64,
},
Sampled {
case: CaseIndex,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Counterexample {
site: ExplorationSite,
interleaving: Interleaving,
finding: TrialFinding,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ExplorationStanding {
SpaceExhaustedAllHold,
SampledAllHold,
CounterexampleFound(Counterexample),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExplorationReading {
space: InterleavingSpace,
mode: ExplorationMode,
explored: u64,
standing: ExplorationStanding,
}
#[must_use = "a refusal is the reason an exploration did not run"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExplorationRefusal {
SampleBytesOverflow {
samples: u32,
steps: usize,
},
SamplingPlanRefused(GenerationPlanRefusal),
}