Skip to main content

Module validation

Module validation 

Source
Expand description

The numbered rule catalogue.

A stable, cited, numbered rule set that a downstream system can reference in a ticket: “V07 on the Frankfurt gateway” means the same thing to everyone who reads it, this year and in five years.

§What runs here, and what does not

validate_records evaluates every rule that is decidable from a slice of records plus an evaluation instant. Three rules are inherently stateful — recognising a retransmission, spotting a missing file, completing a run of partials — and those live in crate::dedup, crate::sequence and crate::partial. Their outcomes join the same catalogue through Finding::duplicate, Finding::sequence_gap and Finding::reassembly, so a report has one vocabulary rather than four.

Keeping them apart is what lets validate_records be a pure function of its arguments.

§Two properties worth stating

Order independence. The adjacency rule (V16) evaluates in instant order whatever order you supply, so a shuffled input does not produce a cascade of spurious findings. The disorder itself is reported once.

Findings point into your slice. Finding::record_index refers to the input you passed, not to an internal ordering, so a caller can go straight from a finding to the record that produced it.

use mediation::{Rule, Severity, ValidationConfig, validate_records};
// A call billed for longer than it can possibly have lasted.
let record = UsageRecord::new(
    RecordType::OriginatedCall,
    party,
    "2026-07-28T10:00:00+02:00".parse().unwrap(),
    source,
)
.with_closed("2026-07-28T10:00:10+02:00".parse().unwrap())
.with_duration(Seconds::new(55));

let report = validate_records(
    &[record],
    &ValidationConfig::default(),
    datetime!(2026-07-28 12:00:00 UTC),
);

assert!(report.has(Rule::DurationExceedsSpan));
assert_eq!(report.severity_of(Rule::DurationExceedsSpan), Some(Severity::Blocking));
assert!(report.blocks_billing());

Structs§

Finding
One rule firing on one record.
ValidationConfig
What the stateless rules compare against.
ValidationReport
Everything the rules found.

Enums§

Rule
One numbered rule.
Severity
How much a finding matters.

Functions§

validate_records
Run every stateless rule over a slice of records.