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
| Group | ID | Type | Default threshold |
|---|---|---|---|
| Output quality | answer-relevancy | LLM judge | 0.7 |
| Output quality | toxicity | LLM judge, risk-inverted | 0.7 |
| Output quality | prompt-alignment | LLM judge | 0.7 |
| Output quality | completeness | code | 0.7 |
| Output quality | keyword-coverage | code | 1.0 |
| Output quality | tone | code | 0.7 |
| Accuracy and reliability | bias | LLM judge, risk-inverted | 0.7 |
| Accuracy and reliability | faithfulness | LLM judge | 0.7 |
| Accuracy and reliability | hallucination | LLM judge, risk-inverted | 0.7 |
| Accuracy and reliability | llm-tool-call-accuracy | LLM judge | 0.7 |
| Accuracy and reliability | noise-sensitivity | LLM judge, risk-inverted | 0.7 |
| Accuracy and reliability | content-similarity | code | 0.7 |
| Accuracy and reliability | textual-difference | code | 0.7 |
| Accuracy and reliability | code-tool-call-accuracy | code | 1.0 |
| Context quality | context-precision | LLM judge | 0.7 |
| Context quality | context-relevance | LLM judge | 0.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:
| ID | Raw evidence key |
|---|---|
toxicity | raw_toxicity |
bias | raw_bias |
hallucination | raw_hallucination |
noise-sensitivity | raw_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.