Skip to content

fix(#715): widen the idle-gap test's margin past shell-startup jitter - #716

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/715
Sep 17, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/715

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #715.

test_a_multi_day_idle_gap_recomputes_even_when_time_never_decreases (tests/test_log_sh.py) was flaky on CI: its 1-second simulated day (_REMEMBER_LOG_DAY_SECONDS_TEST=1) and 1.5s sleep raced ordinary shell-startup jitter against scripts/log.sh's EPOCHSECONDS-based idle-gap check. EPOCHSECONDS has 1-second wall-clock granularity, and _REMEMBER_LOG_LAST_EPOCH is captured at source time, before the test's own first log() call ever runs -- so a loaded CI runner could cross a real 1-second boundary during startup alone and trip the rollover branch a call early, producing exactly the observed failure (FILE1 one day ahead, FILE2 with an empty date component from the exhausted fake-date queue).

Confirmed the mechanism with a standalone bash repro (not the pytest test itself, since injecting jitter there would defeat its own purpose) replicating log.sh's sourcing + fake-date-shim + log() mechanism: the old parameters reproduce the CI failure signature exactly under injected jitter; the new parameters (5s simulated day, 8s sleep) are correct with and without jitter. Widened the real test to match and ran it 3x plus alongside both siblings (3 passed). No production code changed -- scripts/log.sh is untouched, per the issue's own acceptance criterion allowing a test-timing-only fix.

Also fixed a sibling test's docstring, which claimed "the SAME real sleep" as the just-widened test -- true before this change, stale after. Below-bar-adjacent finding from self-review, fixed directly rather than filed.

Added changelog.d/715.fixed.md.

[AI-generated]

test_a_multi_day_idle_gap_recomputes_even_when_time_never_decreases raced
EPOCHSECONDS' 1-second wall-clock granularity against its own 1-second
simulated day: _REMEMBER_LOG_LAST_EPOCH is captured at log.sh source time,
before the test's first log() call, so ordinary CI startup jitter could
itself cross a real 1-second boundary and trip the rollover branch a call
early -- reproduced locally by injecting a controlled sleep between source
and the first log() call, matching the CI failure signature exactly (FILE1
one day ahead, FILE2 with an empty date component from the exhausted date
queue). Widened to a 5-second simulated day and an 8-second sleep, well
clear of realistic startup jitter in both directions. No production code
changed; the sibling midnight test uses the default 86400s threshold and
was never at risk.

Co-Authored-By: Max <noreply>
…onger shares

Self-review finding (oss:auditor): after widening the sleep in the test
above from 1.5s to 8s, this positive control's docstring still said it
used "the SAME real sleep" as that test -- true before this fix, stale
after it (its own sleep 1.5 is intentionally unchanged, since a 999999s
threshold is nowhere near either margin). Says so explicitly instead.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit 4ccd67e into main Sep 17, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix/715 branch September 17, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant