Repository navigation
Description
Symptom
A CI leg fails with a recap body missing from the hook's output, while the rest of the suite passes. Observed on pytest (macos-latest, 3.9), job #99016466076, in PR #421:
tests/test_stdin_source_top_level_wins_344.py:126: AssertionError
AssertionError: today-2026-08-28.md body missing -- nested-after-top-level stopped winning
The check-failure event for that run is timestamped 2026-08-29T00:00:57Z. The test was looking for today-2026-08-28.md 57 seconds after UTC midnight on the 29th -- which is the mechanism below, visible in the artefact rather than inferred from it.
Location
tests/test_stdin_source_top_level_wins_344.py:52, at module scope:
TODAY_FILE = "today-" + time.strftime("%Y-%m-%d") + ".md"scripts/session-start-hook.sh:168 computes its own $TODAY at runtime, and :1379 excludes only today-${TODAY}.md from its staging count.
Mechanism
pytest collects every test module before executing any test, so TODAY_FILE is frozen at collection time while the hook subprocess computes $TODAY when it actually runs. On a long run those two can straddle a UTC midnight -- this suite's macOS legs take 8-9 minutes.
When they disagree, the fixture's own today-file is no longer the one the hook excludes from staging. The hook counts it as stageable, forks run-consolidation.sh against it in the background, and that races the test's own read of the injected recap body. The observed output carries === MEMORY CONSOLIDATION ===\n1 day(s) of memory to compress -- the consolidation the test never intended to trigger.
Grade: reasoned from code plus one timestamped instance, not reproduced. A real reproduction needs a real midnight crossing; the lane that hit it did not reproduce it in 8 runs across main and its own branch, before and after rebasing, which is consistent with a once-a-day window rather than evidence against it.
The repository already has day-boundary-race coverage elsewhere -- tests/test_ndc_day_boundary.py, tests/test_doctor_timezone_357.py -- so the pattern exists; this file predates it or was never brought into it.
What would settle it
Either freeze the date for the test (inject it so the fixture and the hook cannot disagree) or re-derive TODAY_FILE inside each test rather than at import. A pin that actually tests the fix has to drive the two dates apart deliberately -- set the hook's clock forward a day past the fixture's, and assert the recap body still arrives -- rather than waiting for midnight.
Worth checking whether any other test module freezes a date at import scope; if so, they share this exposure and belong in the same fix.
Found by the #405/#417 lane (PR #421) while diagnosing a red leg it turned out not to have caused.
Activity
fix: freeze the fixture and hook clock together in the Digital-Proces…