Skip to content

fix(stat_run): NaN guards — check_assumptions abstain, scipy CI, emit allow_nan=False#2

Open
kicrazom wants to merge 1 commit into
mainfrom
fix/stat-run-nan-guards
Open

fix(stat_run): NaN guards — check_assumptions abstain, scipy CI, emit allow_nan=False#2
kicrazom wants to merge 1 commit into
mainfrom
fix/stat-run-nan-guards

Conversation

@kicrazom

@kicrazom kicrazom commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Three correctness fixes from a read-only audit of the L0 stat engine. All reproduced as failing tests first (TDD), then fixed.

Fixes

  • check_assumptions — Shapiro/Levene return NaN for n<3; NaN < 0.05 is False, so the engine affirmatively reported "parametric assumptions hold" on untestable samples. Now abstains → working_hypothesis ("assumptions indeterminate"), surfaces testable: false, leaks no bare NaN.
  • recompute_ttestse = mean_diff / t gave ci95 = [NaN, NaN] when means are equal (t=0). Now uses scipy res.df + res.confidence_interval(0.95) (finite CI, correct at t=0); removes the now-dead manual Welch df + _var helper. Non-degenerate output unchanged.
  • json_io.emit — default allow_nan=True emitted bare NaN, which strict RFC-8259 parsers (JS JSON.parse, Go encoding/json) reject. Now allow_nan=False → fails closed to an error envelope.

Tests

+3 regression tests (test_json_io.py, test_stat_run.py). Full suite: 175 passed, 1 skipped; ruff clean.

Not included (separate decisions)

  • egress_guard L2/L3: import-audit regex misses dotted/comma imports and the level is unwired — either fix+wire or delete (own PR).
  • permutation_test / multiple_testing reimplement scipy/statsmodels — left as deliberate deterministic-core.

🤖 Generated with Claude Code

…e_ttest; emit allow_nan=False

check_assumptions: NaN Shapiro/Levene p -> working_hypothesis (was "assumptions hold")
recompute_ttest: res.df + res.confidence_interval, drop _var (ci95 was [NaN,NaN] at t=0)
json_io.emit: allow_nan=False
tests: 3 regression tests (json_io + stat_run)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant