Skip to content

gate_diagnostics: treat non-finite min_pscore/match_rate/ESS as missing (audit #252 Finding B) #259

Description

@dgenio

Background

Deferred follow-up from the PR #252 fresh-audit (Finding B). The audit fix was reverted in bef07c3 so it could be handled separately with the simulation proof that statistical-evaluation changes require.

Problem

In gate_diagnostics (src/skdr_eval/recommendation.py), the overlap/match-rate and ESS checks coerce their inputs with a NaN-only guard:

min_ps_val = (
    float(min_ps) if min_ps is not None and not np.isnan(float(min_ps)) else None
)

This treats a non-finite ±inf as a real value rather than "missing". Because the overlap and ESS failures only fire on the finite-small side, an +inf can't currently produce a wrong fail, but it is inconsistent with the recommendation/card paths, which route the same diagnostics through the shared _coerce_optional_float helper (which maps NaN and ±inf → None).

Proposed change

Route min_pscore, match_rate, and ESS through _coerce_optional_float in gate_diagnostics, so non-finite values are reported as "not available" consistently with the rest of the pipeline.

Critical caveat — do NOT coerce pareto_k

pareto_k must keep its current NaN-only guard. A non-finite (+inf) Pareto-k is the catastrophic-tail case and must remain a hard fail; only NaN ("not estimated") should be treated as missing. Coercing pareto_k through _coerce_optional_float would silently downgrade a catastrophic result to "not available" — a real verdict regression.

Acceptance criteria

  • min_pscore / match_rate / ESS non-finite → reported as missing (value None, no spurious fail).
  • pareto_k == +inf → still fail / overall == "fail".
  • pareto_k == NaN → missing (value None, not a fail).
  • Simulation proof that the change is verdict-neutral on finite inputs (recovers the known ground-truth gate verdicts), per .claude/CLAUDE.md §2 and docs/agent-context/invariants.md.
  • make validate passes.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions