fix(shadow_report): window is days, not seconds #117

Merged
alee merged 3 commits from fix/shadow-report-window into main 2026-10-18 03:24:21 +00:00
Owner

What

scripts/shadow_report.py filtered every query with julianday(observed_at) >= julianday('now') - ? / 86400.0 and bound days. julianday is already in days, so the divide made --days 14 a 14 SECOND window. Replaced all 10 occurrences with - ?.

Evidence

On the live DB, with 5-minute-old shadow rows present, the report printed "No classifier_shadow rows found"; --days 3600 (meaning one hour) showed them. The first report also showed 133% coverage because the windows did not line up. After the fix, --days 1 on the live DB shows 153 shadow rows and 99.35% coverage.

Tests

Two new tests in tests/test_shadow_encoder.py:

  • a row 2 hours old is counted with days=1;
  • a row 3 days old is excluded with days=1 and included with days=7.

Both use timedelta offsets (no day-of-month arithmetic). Against the original buggy script both FAIL; with the fix they pass. The test diff is additions only.

Full suite: 2739 passed (2737 + 2).

Not in this PR: the two minor findings from the code-review session (f-string SQL for chat_since_first, busy rows biasing the coverage figure).

🤖 Generated with Claude Code

https://claude.ai/code/session_01XtPLeRkmHJk4VeiTEUfhVR

## What `scripts/shadow_report.py` filtered every query with `julianday(observed_at) >= julianday('now') - ? / 86400.0` and bound `days`. `julianday` is already in days, so the divide made `--days 14` a 14 SECOND window. Replaced all 10 occurrences with `- ?`. ## Evidence On the live DB, with 5-minute-old shadow rows present, the report printed "No classifier_shadow rows found"; `--days 3600` (meaning one hour) showed them. The first report also showed 133% coverage because the windows did not line up. After the fix, `--days 1` on the live DB shows 153 shadow rows and 99.35% coverage. ## Tests Two new tests in `tests/test_shadow_encoder.py`: - a row 2 hours old is counted with `days=1`; - a row 3 days old is excluded with `days=1` and included with `days=7`. Both use `timedelta` offsets (no day-of-month arithmetic). Against the original buggy script both FAIL; with the fix they pass. The test diff is additions only. Full suite: 2739 passed (2737 + 2). Not in this PR: the two minor findings from the code-review session (f-string SQL for `chat_since_first`, `busy` rows biasing the coverage figure). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XtPLeRkmHJk4VeiTEUfhVR
alee added 3 commits 2026-10-18 03:23:49 +00:00
alee merged commit b8994cdbda into main 2026-10-18 03:24:21 +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#117