[Recording] Replace the capture tests that assert the broken clock model #326
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: HIGH. Found in the August 2026 session lifecycle review (#319).
The defect
The bot's own tests currently lock in the bug.
bot/tests/test_recording.py:534-548(test_sink_late_joiner_gets_leading_silence) asserts that a late joiner is padded to the first speaker's frame count — which is precisely the broken behaviour.bot/tests/test_recording.py:564-581builds a "timeline" of three packets and calls it 60 ms.Any correct fix makes these tests fail. They have to be rewritten as part of the fix, not after it, or the fix looks like a regression.
Proposed fix — the invariant test that should have existed
Make the sink testable by injecting a clock:
PerUserPCMSink(out_dir, session_id, *, started_at: float, clock=time.monotonic). Everything below is pure-unit — no Discord, no network — extending the existing_FakeDecoderpattern atbot/tests/test_recording.py:492-506, and runs in the current CI matrix. This matters because perdocsand the deploy notes the dev stack has no Discord token and cannot exercise the bot end to end at all.Core test —
test_track_duration_equals_wall_clock: fake clock; user A speaks 0-1 s and again 60-61 s; user B first speaks at 120 s;close()at 300 s. Assert both WAVs are 300 s within 300 ms, that A has speech bytes at the 60 s offset, that A is pure silence at 30 s, and that B is silent for its first 119 s.This fails against today's code in three independent ways: A's file is ~2 s not 300 s, B's leading pad equals A's byte count rather than 120 s, and nothing tail-pads.
Companion tests:
_session_bytessemantics.Acceptance criteria
test_sink_late_joiner_gets_leading_silenceand the 60 ms timeline test are rewritten, not deleted silentlyPerUserPCMSinkaccepts an injectable clockShipped — closing as part of a v3.11.5 bookkeeping sweep. No issue-number citation in the code, so verified on its merits.
bot/tests/test_recording.pynow asserts the corrected clock model rather than the broken one:test_track_duration_equals_wall_clocktest_sink_cleanup_pads_using_the_clocktest_sink_small_jitter_does_not_pad_inside_speechtest_sink_dtx_packet_writes_one_silence_frametest_sink_pads_are_frame_alignedThat set covers each property the broken model got wrong: tracks span wall clock rather than talk time, gaps below
GAP_THRESHOLD_SECONDSare absorbed instead of padded inside speech, DTX becomes exactly one 20 ms silence frame, pads stay frame-aligned so channels cannot swap, andclose(pad_to=…)tail-pads from the clock.Worth noting this issue was the important half of the hotfix. #320 was invisible for months precisely because the tests encoded the wrong model and passed — replacing them is what makes the fix hold.