Skip to content

fix(coherence): reject NaN/infinite inputs in validate_numeric_agreement (closes #15) - #25

Merged
elasticdotventures merged 1 commit into
mainfrom
fix/numeric-agreement-nan
Sep 7, 2026
Merged

elasticdotventures merged 1 commit into
mainfrom
fix/numeric-agreement-nan

Conversation

@elasticdotventures

Copy link
Copy Markdown
Member

Summary

Fixes #15. validate_numeric_agreement folded its input with f64::min/f64::max, which per IEEE-754 silently drop NaN operands:

  • [100.0, NaN] → min=100, max=100, spread=0 → Satisfied
  • [NaN, NaN] → spread=-inf ≤ any tolerance → Satisfied (total garbage reporting perfect agreement)

For a coherence/trust-checking primitive this is the worst failure mode — a false negative on undefined input.

Fix

Explicit guards before the fold:

  • non-finite or negative tolerance → Violated
  • any non-finite input value (NaN, ±inf) → Violated

Regression tests (4 new, all pass locally — 9/9 in the module)

  • nan_mixed_with_values_is_violated_not_satisfied
  • all_nan_input_is_violated_not_satisfied
  • infinite_value_is_violated
  • negative_or_nan_tolerance_is_violated

Closes #15

f64::min/f64::max silently drop NaN operands, so [100.0, NaN] folded to
spread 0 → Satisfied, and all-NaN input folded to spread -inf ≤ any
tolerance → Satisfied. Both are false negatives in a trust-checking
primitive — the worst failure mode.

Now: non-finite tolerance (NaN, ±inf) or tolerance < 0 → Violated;
any non-finite input value → Violated. Regression tests cover mixed NaN,
all-NaN, infinite input, and negative/NaN/infinite tolerance.

Closes #15
@elasticdotventures
elasticdotventures merged commit f278ea8 into main Sep 7, 2026
2 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.

coherence.rs: validate_numeric_agreement silently treats NaN as agreement

1 participant