fix(shadow_report): Section 5 pass-rate format crash #118

Merged
alee merged 2 commits from fix/shadow-report-section5 into main 2026-10-18 03:45:42 +00:00
Owner

What

scripts/shadow_report.py Section 5 (Outcomes) crashed with ValueError: Invalid format specifier whenever there were outcome rows. The two pass-rate lines put a conditional inside an f-string format spec:

{pass_agreed:.2% if pass_agreed is not None else 'N/A'}

Added a small _fmt_pct(x) helper (returns "N/A" for None, else f"{x:.2%}") and used it on those two lines. Nothing else changes.

Because the crash happened mid-report, Section 6 (Verbatim) and the Addenda never printed either. It was hidden until #117 fixed the window bug, because the old 14-second window excluded every row.

Tests

Two new tests in tests/test_shadow_encoder.py (additions only, 0 deletions):

  • mixed outcomes: one agreed/succeeded and one disagreed/failed row; asserts the exact pass rates (100.00% n=1, 0.00% n=1) and that Section 6 and Addenda are printed;
  • all outcomes agreed: asserts Pass rate when disagreed: N/A (n=0).

Against the original script both FAIL with ValueError; with the fix they pass.

Verification

  • Full suite: 2741 passed (2739 + 2).
  • Live DB, --days 2: report now runs through Section 6 and the Addenda (pass rate when agreed 73.33% n=15, disagreed 85.71% n=7; both below the report's own n<30 threshold, so not meaningful yet).

🤖 Generated with Claude Code

## What `scripts/shadow_report.py` Section 5 (Outcomes) crashed with `ValueError: Invalid format specifier` whenever there were outcome rows. The two pass-rate lines put a conditional inside an f-string format spec: {pass_agreed:.2% if pass_agreed is not None else 'N/A'} Added a small `_fmt_pct(x)` helper (returns "N/A" for None, else `f"{x:.2%}"`) and used it on those two lines. Nothing else changes. Because the crash happened mid-report, Section 6 (Verbatim) and the Addenda never printed either. It was hidden until #117 fixed the window bug, because the old 14-second window excluded every row. ## Tests Two new tests in `tests/test_shadow_encoder.py` (additions only, 0 deletions): - mixed outcomes: one agreed/succeeded and one disagreed/failed row; asserts the exact pass rates (100.00% n=1, 0.00% n=1) and that Section 6 and Addenda are printed; - all outcomes agreed: asserts `Pass rate when disagreed: N/A (n=0)`. Against the original script both FAIL with `ValueError`; with the fix they pass. ## Verification - Full suite: 2741 passed (2739 + 2). - Live DB, `--days 2`: report now runs through Section 6 and the Addenda (pass rate when agreed 73.33% n=15, disagreed 85.71% n=7; both below the report's own n<30 threshold, so not meaningful yet). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
alee added 2 commits 2026-10-18 03:44:15 +00:00
alee merged commit 12b96e6ea9 into main 2026-10-18 03:45:42 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alee/6krrt#118