Skip to content

test(data): pin that a partially-failed window is never recorded absent - #274

Merged
eaitbrahim merged 1 commit into
mainfrom
test/pin-partial-window-not-absent
Aug 15, 2026
Merged

test(data): pin that a partially-failed window is never recorded absent#274
eaitbrahim merged 1 commit into
mainfrom
test/pin-partial-window-not-absent

Conversation

@eaitbrahim

Copy link
Copy Markdown
Contributor

Follow-up from the independent adversarial review of #271. No production code changes — the shipped behaviour is correct. This closes a hole in the tests.

The gap

repair.py's most dangerous rule is "a gap window may be recorded absent-at-source only if EVERY chunk completed". Getting it wrong permanently writes off a hole the venue was never fully asked about.

test_one_bad_chunk_is_not_recorded_absent_and_a_later_window_still_repairs claims to cover this. It doesn't. It fails the second chunk, so the first chunk lands 299 bars and the surviving window's key shifts from (BASE+1d, BASE+553d) to (BASE+300d, BASE+553d). probed_keys matches by exact key, so the window is skipped regardless of what probed_ok contains — its windows_absent_at_source == 0 and get_gap_probes() == [] assertions are vacuous in their own setup.

The fix

Fail the first chunk instead. Nothing is upserted, the remaining window keeps its original key, and the probed_keys gate is genuinely exercised.

Verified discriminating

With probed_ok.append(window) added to the failure path:

FAILED test_a_window_whose_FIRST_chunk_fails_is_not_recorded_absent

Note the pre-existing single-chunk test_a_failed_fetch_is_NOT_recorded_as_absent does defend this rule for the one-chunk case — so the review's "not pinned by any test" was slightly overstated. The real gap was the multi-chunk path, which is what this covers.

Gates

ruff    All checks passed!
mypy    Success: no issues found in 224 source files
pytest  2757 passed, 1 skipped

🤖 Generated with Claude Code

Follow-up from the independent review of #271. The rule "a gap window may be
recorded absent-at-source only if EVERY chunk completed" is the most dangerous
thing in `repair.py` to get wrong -- getting it wrong permanently writes off a
hole the venue was never fully asked about -- and the multi-chunk path had no
test that could see a regression in it.

`test_one_bad_chunk_is_not_recorded_absent_and_a_later_window_still_repairs`
fails the SECOND chunk. That means the first chunk lands 299 bars, so the
surviving gap window's key shifts from (BASE+1d, BASE+553d) to
(BASE+300d, BASE+553d). `probed_keys` in `repair.py` matches by EXACT key, so
that window is skipped no matter what `probed_ok` holds: its
`windows_absent_at_source == 0` and `get_gap_probes() == []` assertions are
vacuous in their own setup.

Failing the FIRST chunk instead upserts nothing, so the remaining window keeps
its original key and the gate is genuinely exercised. Verified discriminating:
with `probed_ok.append(window)` added to the failure path, this test FAILS and
the pre-existing single-chunk `test_a_failed_fetch_is_NOT_recorded_as_absent`
alone would not have covered the multi-chunk case.

No production code changes -- the shipped behaviour was already correct. This
only stops a plausible future refactor ("partial progress means the window was
probed") from passing the suite.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@eaitbrahim
eaitbrahim merged commit 0a4848f into main Aug 15, 2026
1 check passed
@eaitbrahim
eaitbrahim deleted the test/pin-partial-window-not-absent branch August 15, 2026 20:36
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