Skip to content

fix(ingest): parse fraction scores and flag unexpected score scales - #176

Merged
k-dickinson merged 2 commits into
k-dickinson:mainfrom
pnascimento9596:fix/169-ingest-fraction-and-scale-check
Aug 9, 2026
Merged

k-dickinson merged 2 commits into
k-dickinson:mainfrom
pnascimento9596:fix/169-ingest-fraction-and-scale-check

Conversation

@pnascimento9596

@pnascimento9596 pnascimento9596 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Parse strict decimal A/B and A out of B score strings as ratios.
  • Add a Benchmark Health scale_sanity finding for mixed or unexpected score ranges.
  • Document the new check and both changes in the changelog.

Decision conformance

  1. Fraction inputs use the shared coerce_score path. Zero or negative denominators and negative numerators remain errors. Values are not capped at 1.0.
  2. Scale sanity warns when positive metric maxima differ by at least 20x, or when at least 80% of one metric has a 0-1 or 0-100 shape with values on the other scale. It passes clean data and skips when there is not enough data to check.

Flagged decision

existing datasets with mixed scales will now drop to MODERATE, and that is the point of the check, but it is a behavior change on previously-quiet inputs.

Fixture grounding

No fraction-style score export was present on upstream/main at d508963ce1940b30a2d510b7f496c97ffc0dbdf0 in tests/fixtures/, the ingestion and adapter tests, docs/, or src/evaltrust/adapters/. The accepted fraction forms are grounded in the maintainer's issue examples only. A of B remains rejected.

Validation

  • Captured failing-first tests for 3/5 coercion and mixed-scale suite findings.
  • Cross-checked numeric fractions against Python's fractions.Fraction.
  • Proved the 562-case legacy coercion vector byte-identical before and after the change: b719c1864ebc5933bb91bb3204c93f248bbd2155fb3c0160d03a928d85195879.
  • Proved the clean verdict vector byte-identical before and after the change: 351d1c661530fdebb9fe58ff18c398f097924a216d5d72adc85606822715f629.
  • Passed the full suite on Python 3.10, 3.11, 3.12, and 3.13: 1125 passed, 1 skipped on each version.
  • Completed independent fresh-context verification and independent external adversarial review.

Changelog

  • Added: score-scale sanity check.
  • Fixed: fraction-style score ingestion.

Closes #169

Summary by CodeRabbit

  • New Features

    • Added support for ingesting fraction-style scores such as 3/5 and 4 out of 5.
    • Added benchmark health checks for inconsistent score scales and mixed unit/percentage-style scores.
    • Audits now report observed score ranges and scale-related warning triggers.
  • Bug Fixes

    • Invalid or unsafe fraction inputs are rejected safely.
    • Scale mismatches can now appropriately lower benchmark confidence verdicts.
  • Documentation

    • Documented score-scale sanity check outcomes, including PASS, WARN, and SKIP statuses.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f2407d8-c717-4dd1-9fc3-b5747e912241

📥 Commits

Reviewing files that changed from the base of the PR and between 78873c5 and 043b632.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • docs/checks.md
  • src/evaltrust/adapters/common.py
  • src/evaltrust/audit/benchmark_health.py
  • src/evaltrust/audit/runner.py
  • src/evaltrust/audit/suite.py
  • tests/test_benchmark_health.py
  • tests/test_ingest_common.py
  • tests/test_suite.py
🚧 Files skipped from review as they are similar to previous changes (8)
  • src/evaltrust/audit/suite.py
  • tests/test_suite.py
  • tests/test_benchmark_health.py
  • src/evaltrust/audit/runner.py
  • tests/test_ingest_common.py
  • CHANGELOG.md
  • docs/checks.md
  • src/evaltrust/audit/benchmark_health.py

📝 Walkthrough

Walkthrough

The PR adds fraction-style score coercion and a benchmark health scale-sanity check. The check evaluates observed metric ranges, propagates range metadata through audits, reports PASS/WARN/SKIP findings, and updates tests and documentation.

Changes

Fraction-style score parsing

Layer / File(s) Summary
Fraction coercion and validation
src/evaltrust/adapters/common.py, tests/test_ingest_common.py, CHANGELOG.md
coerce_score parses A/B and A out of B values, rejects invalid components, and returns decimal ratios. Tests cover valid, invalid, and extreme fractions.

Score-scale sanity auditing

Layer / File(s) Summary
Scale-sanity finding
src/evaltrust/audit/benchmark_health.py
Benchmark health evaluates metric maxima and normalized or percentage-shaped score distributions. It returns PASS, WARN, or SKIP findings with range and trigger details.
Observed-range metadata flow
src/evaltrust/audit/suite.py, src/evaltrust/audit/runner.py
The suite collects finite per-metric ranges and passes them through run_audit and comparison dispatch to benchmark health.
Scale-sanity validation and documentation
tests/test_benchmark_health.py, tests/test_suite.py, docs/checks.md, CHANGELOG.md
Tests cover scale warnings, matching scales, ordinary rubric scores, insufficient data, verdict changes, and finding details. Documentation describes the new check.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AuditSuite
  participant AuditRunner
  participant BenchmarkHealth
  AuditSuite->>AuditSuite: collect observed metric ranges
  AuditSuite->>AuditRunner: call run_audit with observed_ranges
  AuditRunner->>BenchmarkHealth: run benchmark health audit
  BenchmarkHealth-->>AuditRunner: return scale_sanity finding
Loading

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes both primary changes: fraction score parsing and unexpected score-scale detection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pnascimento9596
pnascimento9596 marked this pull request as ready for review August 4, 2026 17:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/evaltrust/audit/benchmark_health.py`:
- Around line 208-216: Update the `how_to_fix` message in the benchmark health
result so scale-sanity findings recommend normalizing scores to a shared scale,
without presenting `score_ceiling` as a remedy. Describe `score_ceiling` only as
separate saturation configuration, while preserving the existing status-specific
guidance and insufficient-data message.
- Around line 158-174: Update the mixed-scale checks in _audit benchmark scale
detection at src/evaltrust/audit/benchmark_health.py lines 158-174 to require
unambiguous fractional normalized values (strictly between 0 and 1), unless
declared scale metadata is available, before either warning path can trigger;
preserve existing thresholds otherwise. In tests/test_benchmark_health.py lines
136-142, replace the ambiguous [0, 1] contamination case with clearly fractional
normalized contamination and add a regression case confirming clean scores
spanning 0–100 do not produce a mixed-scale warning.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 071b4cc7-2f9d-4194-8e92-c2c1b209928f

📥 Commits

Reviewing files that changed from the base of the PR and between d508963 and a110db5.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • docs/checks.md
  • src/evaltrust/adapters/common.py
  • src/evaltrust/audit/benchmark_health.py
  • src/evaltrust/audit/runner.py
  • src/evaltrust/audit/suite.py
  • tests/test_benchmark_health.py
  • tests/test_ingest_common.py
  • tests/test_suite.py

Comment thread src/evaltrust/audit/benchmark_health.py Resolved
Comment thread src/evaltrust/audit/benchmark_health.py Resolved
@k-dickinson

k-dickinson commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

@pnascimento9596 Fix the conflict, then good to merge

@pnascimento9596
pnascimento9596 force-pushed the fix/169-ingest-fraction-and-scale-check branch from 22f280c to 043b632 Compare August 5, 2026 08:23
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@k-dickinson

Copy link
Copy Markdown
Owner

rebase is clean and the suite is green. good to merge.

@k-dickinson k-dickinson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to merge lol

@k-dickinson
k-dickinson merged commit 420c382 into k-dickinson:main Aug 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ingestion hardening: fraction-style scores and score-scale sanity check

2 participants