Expand description
The rule layer.
Eight rules cover seven failure modes; the webhook case is split into a signature-mismatch rule and a timestamp-staleness rule so they can fire independently and arbitration ranks them by confidence. Public surface:
- The
Ruletrait. One implementation per failure mode. all_rules— returns the registered rules in evaluation order.diagnose— runs every rule, sorts by descending confidence, returns aReport.diagnose_traced— same asdiagnosebut also returns aRuleTraceper rule (wall-clock timing + outcome). Used by the CLI’s--traceflag and bybenches/diagnose.rs.
§Adding a rule
- Add a private struct that implements
Rule. - Register it in
all_rules. - Add a positive fixture (
fixtures/cases/<name>/case.json) and a paired negative under_negatives/that looks similar but must not classify. - Add an
expected_rule_idlabel to every calibration fixture that should exercise the rule. - Document the rule’s confidence rubric in
docs/confidence_model.md. - Run
cargo testandcargo insta reviewto accept the new snapshots.
§Confidence model
Confidence values are not arbitrary; the rubric in
docs/confidence_model.md lays out the bands (dispositive,
strong, moderate, inadmissible) and tests/calibration.rs
enforces them via Brier score over the labelled corpus.
Structs§
- Rule
Trace - Per-rule trace entry produced by
diagnose_traced.
Traits§
- Rule
- One diagnostic rule.
Functions§
- all_
rules - Return the registered rules in evaluation order.
- diagnose
- Run every rule, sort firing diagnoses by descending confidence, and return
a
Reportwith the top hit asprimaryand the rest inalso_considered. - diagnose_
traced - Same as
diagnosebut also returns a per-rule trace recording each rule’s wall-clock evaluation time and whether it fired.