test(members): drive an increasing clock in roster order test (#8499) - #8645
Conversation
test_roster_orders_by_message_ts_not_file_mtime appends one message to each of two freshly created transcript files back-to-back and asserts strict `<` on their last_active_ts. monotonic_transcript_ts only corrects against prior rows of the SAME file, so both appends take raw clock reads; on Windows' ~15.6ms tick the reads collide and the strict comparison fails on equal timestamps. Patch kiro_crew.history.datetime in the test with a strictly increasing tz-aware clock (mirrors the prior art in test_history.py::test_recent_from_source_sorted_by_ts) so the chronological order the test asserts is encoded in the timestamps on every OS. The os.utime mtime bump on the older thread's file is kept unchanged — that is the behaviour under test. No production code changed: cross-file ordering is not something the code promises. Closes #8499
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Deterministic clock injection attacks the actual flake cause (clock granularity), matching repo flake discipline and existing prior art — no design-level concerns. [DESIGN-REVIEWED] 0330c88 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsThe change is test-only and internally consistent: No findings. [OPUS-REVIEWED] 0330c88 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
NicholasRBowers
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: test-files-only change driving a strictly-increasing monkeypatched clock in test_members_dm_thread.py to fix a coarse-clock timestamp collision (#8499); no runtime code touched.
Summary
test/test_members_dm_thread.py::TestMembersRoster::test_roster_orders_by_message_ts_not_file_mtimeis flaky on the Windows CI shard. It appends one message to each of two freshly created transcript files back-to-back and asserts strict<on theirlast_active_ts.monotonic_transcript_tsonly corrects against prior rows of the SAME file, so both appends take rawdatetime.now()reads; on Windows' ~15.6 ms clock tick the reads collide and the assertion fails on equal timestamps. The production code is correct — cross-file ordering is not something it promises; the test assumed clock resolution it does not control.Test-only fix: monkeypatch
kiro_crew.history.datetimein the test with a strictly increasing, tz-aware clock (mirrors the existing prior art intest/test_history.py::test_recent_from_source_sorted_by_ts), so the chronological order the test asserts is encoded in the timestamps on every OS. Two refinements over the prior art, from pre-push review: the stand-in subclassesdatetime.datetimesofromisoformatstays available while patched (keeps_parse_transcript_tsundegraded), and a comment marks the deliberate fake-message-clock vs real-os.utime-clock contrast so a later reader does not "align" them.The
os.utimemtime bump on the OLDER thread's file is unchanged — that is the behaviour under test (mtime must not reorder rows). The assertion stays strict<. No changes tosrc/kiro_crew/history.pyor roster code.Closes #8499
Testing
isort --check-only,flake8,mypy src/kiro_crew/— all pass locallyPre-push review
Two model-pinned read-only reviewers on the staged diff: