test(sweep): stop the --days 0 check from racing a one-second cutoff

Measured, not guessed: the check failed 7 runs in 20, not once. The cause is
a same-second collision, reproduced deterministically - a notice minted at
20260801205457 against a cutoff of 20260801205457 survives, the same notice
60s older is closed.

coord-sweep.sh is right and is left alone. Its cutoff is second-granular and
it closes strictly older messages, which spares rather than closes at the
boundary; at any real --days value one second is unobservable. Relaxing that
guard to <= would make a destructive script more aggressive to satisfy a test.

So the test was claiming what the code does not promise: that a notice minted
earlier in the same run is necessarily older at second granularity. Under a
second of work separates the two, so it was a coin flip. Aged by 5 seconds
through the existing age_it, which keeps it well inside the default 14-day
window and clear of the boundary. No sleep: that would have hidden the answer
rather than fixed it.

Selftest 182 -> 183, 20/20 green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GfDGWyyhnM26J4p93GSk2L
This commit is contained in:
Kjell Tore Guttormsen 2026-08-01 23:01:32 +02:00
commit 8e207c6c49
3 changed files with 12 additions and 4 deletions

View file

@ -735,6 +735,14 @@ CLAUDE_COORD_DIR="$SDIR" "$SEND" --to sr --from s2 --subject "old ask" --message
CLAUDE_COORD_DIR="$SDIR" "$SEND" --to sr --from s3 --fyi --subject "new note" --message "NEW-NOTE" >/dev/null
age_it "$SDIR" sr OLD-NOTE 20200101T000000Z; check "sweep fixture: notice aged" $?
age_it "$SDIR" sr OLD-ASK 20200101T000000Z; check "sweep fixture: debt aged" $?
# NEW-NOTE is the --days 0 subject further down, and it has to be aged too - by
# seconds, not years, so the default 14-day sweep still spares it. The cutoff is
# second-granular and the sweep closes strictly older messages, so a notice
# minted in the same second as the cutoff survives, correctly. Between minting it
# above and computing the cutoff at --days 0 there is under a second of work, so
# without this the check raced the clock and failed 7 runs in 20 (measured).
age_it "$SDIR" sr NEW-NOTE "$(date -u -v-5S +%Y%m%dT%H%M%SZ)"
check "sweep fixture: same-day notice aged clear of the cutoff second" $?
sout="$(CLAUDE_COORD_DIR="$SDIR" "$SWEEP" 2>&1)"
[ "$(n_in "$SDIR/sr")" -eq 3 ]