fix: validate FaithfulnessEvaluator statement scores #13978
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 399 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.358
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #13978"
general
weight: 0.35
1AbdullahButt
Related Issues
Proposed Changes:
The evaluator checked reply keys and statement/score counts, but did not validate score values before averaging. String or
nullscores raised aTypeErroreven withraise_on_failure=False, and values other than 0 or 1 (5,-1,0.5) were averaged into the score.This validates the values inside
statement_scoresnext to the existing count check. Strings, nulls and numbers other than 0 or 1 use the existing failure handling:ValueErrorby default, or an error row with a NaN score excluded from the mean whenraise_on_failure=False.Float equivalents of 0 and 1 and booleans are still accepted, and final averages can still be fractional. Whether
statementsandstatement_scoresare lists at all stays with #13934.How did you test it?
null,5,2,-1,0.5, NaN and ±infinity, an all-invalid batch, andrun_async(). Four compatibility cases check thattrue,false,1.0and0.0still score 1/0/1/0.origin/mainat 979c6fd and pass with this change. The 4 compatibility cases pass on both.[0.5]: onmainit raisesTypeErrorfor["1","0"]and[1,null]and gives overall scores of 3.0, 0.0 and 0.75 for[5],[-1]and[0.5]. With this change each invalid row is an error and the valid row keeps an overall score of 1.0.pre-commit run --from-ref origin/main --to-ref HEADpasses (ruff check and format, release-note backticks, codespell).mypyonfaithfulness.pyreports no issues.Notes for the reviewer
0.5are now invalid, including ones encouraged by custom examples.raise_on_failure=Falseexcludes those inputs; it does not keep a graded score. The release note covers this underupgrade.This PR was generated with my custom AI workflow. I have run the relevant tests.
Checklist
fix: validate FaithfulnessEvaluator statement scores.