Skip to main content

Mastra scorer parity

madbench supports the 16 scorer IDs from mastra scorers list as built-in Check types. This is Check parity: madbench can grade the same kinds of outputs with the same scorer IDs. It does not add a Mastra clone/scaffold CLI such as mastra scorers add; YAML and API shape stay unchanged.

Use them like any other check:

checks:
- type: answer-relevancy
threshold: 0.7
- type: keyword-coverage
value: ["auth", "tests", "documentation"]
threshold: 1.0

type, value, threshold, and metric keep their existing madbench meaning. Engine runs automatically expose the scenario prompt to scorers as Vars["prompt"]. API callers can set ScoreRequest.Prompt; it is injected into Vars["prompt"] unless the caller already supplied one.

For implementation provenance, pinned package versions, and exactness level per scorer, see the scorer registry.

Writing scorer Checks​

The Mastra-compatible IDs are normal madbench Checks. Put the scorer ID in type, configure expected data with value or the scorer's own keys beside it, and override threshold only when the default does not match your Bench.

Code Checks are deterministic and run without a judge Model:

checks:
- type: completeness
value: "Mention auth, tests, and documentation"
threshold: 0.7
- type: keyword-coverage
value: ["auth", "tests", "documentation"]
threshold: 1.0
- type: content-similarity
value: "The expected final answer."
threshold: 0.8
- type: textual-difference
value: "The expected final answer."
threshold: 0.8
- type: tone
referenceTone: "calm, concise, and helpful"
threshold: 0.7

Tool-call accuracy can be checked deterministically from the captured session:

checks:
- type: code-tool-call-accuracy
expectedTool: "Read"
threshold: 1.0
- type: code-tool-call-accuracy
expectedToolOrder: ["Grep", "Read", "Edit"]
strictMode: false
threshold: 1.0

AI Checks use the configured judge provider and the same Scenario prompt made available as Vars["prompt"]:

checks:
- type: answer-relevancy
threshold: 0.7
- type: prompt-alignment
threshold: 0.7
- type: toxicity
threshold: 0.9
- type: faithfulness
context: "The source material or retrieved context."
threshold: 0.7

For context Checks, pass context through the context: key or variables in the same Bench style you already use for other semantic judges:

checks:
- type: context-relevance
context:
- "Relevant chunk one."
- "Distracting chunk two."
threshold: 0.7
- type: context-precision
context:
- "Best chunk first."
- "Useful chunk second."
threshold: 0.7

Scorer IDs​

GroupIDTypeDefault threshold
Output qualityanswer-relevancyLLM judge0.7
Output qualitytoxicityLLM judge, risk-inverted0.7
Output qualityprompt-alignmentLLM judge0.7
Output qualitycompletenesscode0.7
Output qualitykeyword-coveragecode1.0
Output qualitytonecode0.7
Accuracy and reliabilitybiasLLM judge, risk-inverted0.7
Accuracy and reliabilityfaithfulnessLLM judge0.7
Accuracy and reliabilityhallucinationLLM judge, risk-inverted0.7
Accuracy and reliabilityllm-tool-call-accuracyLLM judge0.7
Accuracy and reliabilitynoise-sensitivityLLM judge, risk-inverted0.7
Accuracy and reliabilitycontent-similaritycode0.7
Accuracy and reliabilitytextual-differencecode0.7
Accuracy and reliabilitycode-tool-call-accuracycode1.0
Context qualitycontext-precisionLLM judge0.7
Context qualitycontext-relevanceLLM judge0.7

Existing madbench judge names are preserved, including llm-rubric, answer-relevance, and context-faithfulness.

Risk scorer evidence​

Result.Score is always high-is-good. Risk-oriented scorers ask the judge for raw risk, store it in evidence, and invert it into the primary score:

{
"score": 0.91,
"evidence": {
"raw_toxicity": 0.09,
"threshold": 0.7
}
}

Risk evidence keys:

IDRaw evidence key
toxicityraw_toxicity
biasraw_bias
hallucinationraw_hallucination
noise-sensitivityraw_noise_sensitivity

Cross-framework parity​

The real parity test harness lives in tests/mastra-parity/. Its default run covers deterministic code Checks: it runs shared testdata through Mastra's published scorer package and through madbench, then fails if pass/fail outcomes or code scores diverge. The comparison is strict: deterministic score drift is not allowed. completeness, keyword-coverage, and tone use an embedded JS bridge in madbench so those NLP/sentiment paths stay aligned with Mastra's JS dependency stack:

cd tests/mastra-parity
./verify-parity.sh

The checked-in shared data is intentionally called testdata.json. AI Check scorer IDs are covered by mock-provider tests in pkg/check/llmjudge; live cross-framework AI Check parity requires both tools to be configured with the same judge Model and credentials.