Report a missing `positive_key` or `ConfusionMatrixEvaluator` key even when the report has no cases

Merged
AD
3d ago
+29-6

PrecisionRecallEvaluator, ROCAUCEvaluator and KolmogorovSmirnovEvaluator with positive_from='labels' or 'assertions' and no positive_key only raised once a case was read. When every case failed, the report had no cases and the misconfiguration went unreported.

The check now runs once in _extract_scored_cases, the helper all three share, before the loop. The message is unchanged; the per-case checks become asserts since this is their only caller.

ConfusionMatrixEvaluator had the same gap for predicted_from/expected_from='labels' without a key; its check now runs at the start of evaluate.

Left out of #12887: unknown SpanQuery keys and empty sub-queries (separate PRs), and string labels (documented behaviour, needs a decision).

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

Summary by cubic

Fixes #12887: a missing positive_key is now reported even when the report has no cases.

Previously PrecisionRecallEvaluator, ROCAUCEvaluator, and KolmogorovSmirnovEvaluator only checked for a missing positive_key per case, so an empty report (for example, when every case failed) let the misconfiguration pass silently. The check now runs once in _extract_scored_cases, which all three evaluators share, before the loop. The error message is unchanged and the per-case checks become asserts.

ConfusionMatrixEvaluator had the same gap for predicted_from/expected_from='labels' without a key; its check now runs at the start of evaluate.

Not covered here: unknown SpanQuery keys, empty sub-queries, and string labels.