sofhiaazzhr Claude Opus 4.8 commited on
Commit
8400a9e
·
1 Parent(s): 2082eba

[NOTICKET] fix(tools): analyze_ab_test quality — KeyError on the too-few-rows path

Browse files

The quality block (added in 2082eba1) read test['p_value'] directly, but _welch_test's too-few-rows branch returns no 'p_value' key -> KeyError, so analyze_ab_test crashed on a valid 'too few rows for a t-test' case (became an error envelope via the never-throw seam instead of a graceful result). Fix: test.get('p_value'). The too-few case now returns significant=None + quality {value: None, weak: True}. Caught by a local ab_test test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Files changed (1) hide show
  1. src/tools/analytics/ab_test.py +1 -1
src/tools/analytics/ab_test.py CHANGED
@@ -207,7 +207,7 @@ def analyze_ab_test(
207
  # zero variance) — also weak, for the same reason. CK7 surfaces it.
208
  "quality": {
209
  "metric": "p_value",
210
- "value": None if test["p_value"] is None else round(test["p_value"], 4),
211
  "floor": alpha,
212
  "weak": not test["significant"],
213
  "note": (
 
207
  # zero variance) — also weak, for the same reason. CK7 surfaces it.
208
  "quality": {
209
  "metric": "p_value",
210
+ "value": None if test.get("p_value") is None else round(test["p_value"], 4),
211
  "floor": alpha,
212
  "weak": not test["significant"],
213
  "note": (