Skip to main content

Rule

Trait Rule 

Source
pub trait Rule: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn evaluate(&self, case: &Case) -> Option<Diagnosis>;
}
Expand description

One diagnostic rule.

A rule looks at a Case and either fires (returns a Diagnosis) or stays silent (returns None). Rules are pure: they do not mutate the case, do not read environment variables, and do not perform network I/O. Local file reads (logs, secrets) go through Case::load_log and Case::load_secret.

Send + Sync is required so that the registered rules can sit behind a Box<dyn Rule> and be safely shared across threads if a future caller wants to parallelise the sweep — the current orchestrator runs them sequentially because the per-case latency is single-digit microseconds.

Required Methods§

Source

fn id(&self) -> &str

Stable identifier used in reports, logs, snapshot tests, and the calibration corpus. Must be unique within all_rules and match the corresponding fixture’s expected_rule_id.

Source

fn evaluate(&self, case: &Case) -> Option<Diagnosis>

Evaluate this rule against the case. Return Some(diagnosis) to fire, None to stay silent.

Implementations should return early with None whenever a required signal is absent (no auth context, no webhook secret, no log file, etc.). The orchestrator does not penalise silent rules; only firing rules contribute to the report.

Implementors§