minerva 0.2.0

Causal ordering for distributed systems
extern crate alloc;

use alloc::vec::Vec;

use crate::metis::{Dot, DotSet};
use proptest::prelude::*;

mod dot_set;
mod peek;
mod restriction;
mod vector;

/// Sub-rosters over and slightly past the generation domain, duplicates
/// included.
fn arb_roster() -> impl Strategy<Value = Vec<u32>> {
    prop::collection::vec(0u32..8, 0..8)
}

/// A receipt stream over a small dot domain, including duplicates and dot zero.
fn arb_dots() -> impl Strategy<Value = Vec<(u32, u64)>> {
    prop::collection::vec((0u32..4, 0u64..12), 0..24)
}

/// Builds a have-set by inserting every dot in order.
fn have(dots: &[(u32, u64)]) -> DotSet {
    let mut set = DotSet::new();
    for &pair in dots {
        // A drawn zero counter is no dot and cannot cross into the identity
        // type: the same no-op the door's zero refusal gave (ruling R-91).
        if let Ok(dot) = Dot::try_from(pair) {
            let _ = set.insert(dot);
        }
    }
    set
}