Skip to content

test(members): drive an increasing clock in roster order test (#8499) - #8645

Merged
NicholasRBowers merged 1 commit into
mainfrom
fix/members-roster-order-test-clock-8499
Sep 5, 2026
Merged

test(members): drive an increasing clock in roster order test (#8499)#8645
NicholasRBowers merged 1 commit into
mainfrom
fix/members-roster-order-test-clock-8499

Conversation

@CrysisDeu

Copy link
Copy Markdown
Collaborator

Summary

test/test_members_dm_thread.py::TestMembersRoster::test_roster_orders_by_message_ts_not_file_mtime is 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 their last_active_ts. monotonic_transcript_ts only corrects against prior rows of the SAME file, so both appends take raw datetime.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.datetime in the test with a strictly increasing, tz-aware clock (mirrors the existing prior art in test/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 subclasses datetime.datetime so fromisoformat stays available while patched (keeps _parse_transcript_ts undegraded), 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.utime mtime 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 to src/kiro_crew/history.py or roster code.

Closes #8499

Testing

  • isort --check-only, flake8, mypy src/kiro_crew/ — all pass locally
  • Diff-scoped black gate and brand gate pass post-commit
  • Full pytest runs in CI (local test execution is disabled on this host by operator policy)

Pre-push review

Two model-pinned read-only reviewers on the staged diff:

  • GPT lane (gpt-5.6-sol): PASS, no findings
  • Opus lane (claude-opus-5): PASS, 3 Low advisories — 2 applied (datetime subclass; two-clocks comment), 1 deferred (shared conftest fixture for the duplicated fake-clock helper, out of this fix's file scope)

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
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 0330c88e7849468c590b18aeebe2e4844c8c6850 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 0330c88e7849468c590b18aeebe2e4844c8c6850 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 0330c88

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 0330c88e7849468c590b18aeebe2e4844c8c6850: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 0330c88e7849468c590b18aeebe2e4844c8c6850 — this comment is updated in place on each push.

Review details

The change is test-only and internally consistent: kiro_crew.history imports datetime as a name (from datetime import datetime), so monkeypatch.setattr("kiro_crew.history.datetime", _IncDateTime) correctly intercepts the two datetime.now().astimezone() reads in append; the _IncDateTime subclass keeps fromisoformat/.astimezone() working, and the incrementing clock makes the old-key row (base+1s) strictly precede the new-key row (base+2s), so the < assertion holds deterministically. No candidates to falsify and nothing grounded to add.

No findings.

[OPUS-REVIEWED] 0330c88

Verdict parsed from the review's SHA-scoped output markers for commit 0330c88e7849468c590b18aeebe2e4844c8c6850.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 0330c88e7849468c590b18aeebe2e4844c8c6850: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 5, 2026
@NicholasRBowers
NicholasRBowers enabled auto-merge (squash) September 5, 2026 04:27

@NicholasRBowers NicholasRBowers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@NicholasRBowers
NicholasRBowers merged commit 1799bf1 into main Sep 5, 2026
64 checks passed
@NicholasRBowers
NicholasRBowers deleted the fix/members-roster-order-test-clock-8499 branch September 5, 2026 04:27
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(members): roster ordering test asserts cross-file timestamp order the code does not guarantee (Windows red)

2 participants