← Back to Pull requests

fix: validate FaithfulnessEvaluator statement scores #13978

Open
unknown opened this pull request with 399 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 28, 2026 06:39 UTC
Author

Related Issues

  • fixes #13977
  • Proposed Changes:

    The evaluator checked reply keys and statement/score counts, but did not validate score values before averaging. String or null scores raised a TypeError even with raise_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_scores next to the existing count check. Strings, nulls and numbers other than 0 or 1 use the existing failure handling: ValueError by default, or an error row with a NaN score excluded from the mean when raise_on_failure=False.

    Float equivalents of 0 and 1 and booleans are still accepted, and final averages can still be fractional. Whether statements and statement_scores are lists at all stays with #13934.

    How did you test it?

  • New unit tests cover both failure modes for strings, null, 5, 2, -1, 0.5, NaN and ±infinity, an all-invalid batch, and run_async(). Four compatibility cases check that true, false, 1.0 and 0.0 still score 1/0/1/0.

  • The 19 invalid-score cases fail against origin/main at 979c6fd and pass with this change. The 4 compatibility cases pass on both.

  • Faithfulness unit tests: 41 passed, 2 integration tests deselected.

  • The issue reproducer, extended with [0.5]: on main it raises TypeError for ["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 HEAD passes (ruff check and format, release-note backticks, codespell). mypy on faithfulness.py reports no issues.
  • Notes for the reviewer

  • Fractional statement scores such as 0.5 are now invalid, including ones encouraged by custom examples. raise_on_failure=False excludes those inputs; it does not keep a graded score. The release note covers this under upgrade.

  • #13934 changes the same docstring, validation area and test file; whichever lands second needs to reconcile the two.

  • @juemimgcd has a value-validation fix for this issue on their fork (comment on #13977). Happy to coordinate with them or a maintainer on which one goes in.
  • This PR was generated with my custom AI workflow. I have run the relevant tests.

    Checklist

  • I have read the contributors guidelines and the code of conduct.

  • I have updated the related issue with new insights and changes.

  • I have added unit tests and updated the docstrings.

  • I've used one of the conventional commit types for my PR title: fix: validate FaithfulnessEvaluator statement scores.

  • I have documented my code.

  • I have added a release note file, following the contributors guidelines.

  • I have run pre-commit hooks and fixed any issue.
  • Diff: 399 lines (+299 / -100) across 4 files Reviewer: 1AbdullahButt Review duration: 4237m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23% · Safe to merge
    23%