pub async fn classifier_conformance(classifier: &dyn Classifier)Expand description
Asserts the Classifier trait contract against a classifier whose
transport is already scripted to answer
classifier_conformance_questions about
classifier_conformance_state. The suite makes exactly one
ask call — script that one request and no other.
Asserted, each panic naming the rule it caught:
- the answer map’s keys are exactly the asked question ids;
- each answer’s
valuevariant matches its question’s kind; - a choice’s chosen label, a noul’s verdict label, and (where the value names one) a score’s level are labels the question offered;
- every key of
probabilitiesis an offered label and every value is finite within0.0..=1.0— keys may omit labels (a top-1 provider is legal), they may never invent one; confidenceis finite within0.0..=1.0and agrees with the probability the same answer reports for its own chosen label, within an explicit tolerance — the invariant that keeps an adapter from reporting a confidence its own distribution contradicts;profile().max_state_charsis above zero, andtruncateof an over-limit state returns something no longer than the limit.
What the suite deliberately does not assert: that confidence
means the same number on two adapters. Calibration is not portable —
a 0.8 from a purpose-trained classifier and a 0.8 elicited from a
general language model are different numbers — so no assertion here
compares confidence values between adapters, and a threshold tuned
against one stays per-adapter (see cratefield_core::Calibration).
// In the adapter's own test, after scripting its transport:
classifier_conformance(&adapter).await;§Panics
Panics naming the broken rule when the contract is violated, and when the scripted ask fails.