Repository navigation
test: reset the member eventlog service singleton between tests - #15534
Conversation
`eventlog.service.get_service()` memoises one `MemberEventLogService` per process and rebuilds it only when the crew-log root moves. The root follows `KIROCREW_HOME`, which the autouse `_isolate_kirocrew_home` fixture repoints at a fresh tmp dir per test. A test that touches the service therefore leaves a live singleton bound to its own home, and the next test on the same xdist worker inherits it after that home is torn down. On POSIX the next `get_service()` rebuilds against the new home and nothing is observed. On Windows the leaked `MemberLog` still holds open OS handles under the dead directory, which blocks the tmp-dir teardown and makes the inheriting test's first write fail: `members.record_activity` catches the OSError and returns False. That is the Windows-only red on `TestMemberActivityRoute::test_the_read_never_asks_the_log_for_every_event` and `::test_colliding_slugs_do_not_mix_histories` -- the first `record_activity` line of each, which asserts a True return. `fix(members): order the Recent roster by the crew log (#15277)` added `test/test_members_roster_recency.py`, whose `TestRosterReadTakesTheFoldedRecency` tests call `get_service()`/`ensure`/`append` without the module's `set_service(None)` reset. That shifted the pytest-split shard-8 ordering so the leaked service lands just before `TestMemberActivityRoute` on the same Windows worker, surfacing a latent isolation hole that seven other test files share. Fix: an autouse `_reset_member_eventlog_singleton` conftest fixture that clears the singleton at both ends of every test, matching the existing `_restore_autonudge_singleton` / reasoning-effort floors. A two-test pin in `TestEventlogSingletonDoesNotLeakAcrossTests` locks the cause (a singleton crossing the boundary) on both platforms; it fails without the fixture and passes with it.
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Confirm Windows shard 8 is green on this PR's own CI run before merge — that run is the only witness to the actual symptom. Suggestions
[DESIGN-REVIEWED] 20c436d Description read[DESCRIPTION-READ] b1e58c2c82ce84e9345f4ff0052702a3c076f5bf68d98f7d737c6f6d1257631c That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
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 5 Review — ✅ no blocking findingsReviewed Review detailsThe added leak guard cannot fail — its only assertion is satisfied by the floor's own setup reset before the test body runs. FINDING — test/test_members_dm_thread.py:2607 — FINDING — test/test_members_dm_thread.py:2587 — FINDING — test/conftest.py:955 — the cited witness is false: the docstring (and test_members_dm_thread.py:2575) blames FINDING — test/conftest.py:937 — a new process-global floor lands without the same-commit spec update [OPUS-REVIEWED] 20c436d Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
buluoray
left a comment
There was a problem hiding this comment.
Approving. I checked the change against source at 20c436d964:
kiro_crew.eventlog.serviceonmainkeeps a module-level_singletonbehindget_service()/set_service(), so an autouse fixture callingset_service(None)at both setup and teardown clears exactly that singleton. Nothing in production code changes.- The new
TestEventlogSingletonDoesNotLeakAcrossTestspair tests the cause (the singleton crossing a test boundary) rather than the Windows-only symptom, so it also guards against this on Linux. - All Windows shards are green on this head, shard 8 included. GPT 5.6 and Opus 5 found nothing blocking.
Non-blocking follow-up: #15547 hit this shard 8 red three times, on three different tests. Two are the TestMemberActivityRoute record_activity → False case this PR describes. The third was TestResumeGuards::test_concurrent_member_resume_does_not_duplicate_history ("history duplicated: 2 copies"), which doesn't obviously go through the event-log service. If it still fails on Windows after this merges, it has a separate cause.
…e retirement test/test_members_dm_thread.py flakes on shard 8 across multiple PR boards after #15534 merged, on both Linux and Windows. The CI traceback anchors it: test_returns_recorded_entries_newest_first_with_allowlist_fields assert record_activity(CREW, 'dashboard_chat-1', 'persistent', via='chat') AssertionError: assert False The write side returns False on the FIRST call in a fresh test, after earlier tests ran on the same xdist worker. Root cause. get_service() memoises one MemberEventLogService per process and rebuilds it only when the crew-log root moves (which every test does and production never does). The service sits in a REFERENCE CYCLE: its projection registry holds set_on_change(service._on_change), a bound method back to the service. So set_service(None) -- which the autouse _reset_member_eventlog_singleton floor calls at each boundary -- drops the last external reference but does not free the graph; the cycle keeps it alive until the cyclic collector runs. Each cached MemberLog's CrewLog releases its write lease through a weakref.finalize that fires only then, and holds its file descriptor until then. On POSIX that deferral is invisible (an advisory lock on a torn-down directory harms nothing, and the next acquire against a fresh path just works), which is why the leak could not be reproduced on Linux by running the file, targeted interleaves, or the full real shard-8 selection. On Windows the still-open descriptor keeps a mandatory lock that pins the (torn-down) home directory, so the directory cannot be removed and the next writer on the inheriting worker fails -- record_activity returns False. #15534 reset the singleton REFERENCE at both ends, which was necessary but not sufficient: the reference-cycle keeps the handles alive regardless. Fix (root, deterministic). Retirement now releases the handles NOW instead of waiting for GC: * CrewLog.release_ownership() runs its lease finalizer explicitly (idempotent, atomic via weakref.finalize) and detaches it. * MemberLog.close() releases its cached CrewLog and unloads. * MemberEventLogService.close() closes every cached log, clears the caches, and severs the registry -> bound-method -> service cycle. * set_service() closes the outgoing service when it is replaced; get_service() closes the previous service on a home-change rebuild. Neither happens while an append is in flight on the same instance (the home moves only at a test boundary), so nothing races a writer that still needs the lease. Tests (whole-file guard, POSIX-provable). TestEventlogServiceRetirementReleasesHandles pins the CAUSE rather than the Windows-only symptom: after set_service(None) the retired service holds no cached logs and its registry cycle is severed; a home-change rebuild retires the previous service; close() is idempotent and reads re-open on demand. Verified to FAIL without the set_service close wiring and pass with it. Verification: full test_members_dm_thread.py + eventlog/test_eventlog.py + test_members.py + test_members_eventlog_wiring.py + test_eventlog_hooks.py + test_crew_log_member_unit_reclaim.py + test_members_roster_recency.py = 576 passed / 1 skipped (-n0). test_members_dm_thread.py stressed at -n4 x8 = 182 passed each. black (py312) / isort / flake8 / mypy clean on the changed modules.
…dows (#15633) * fix(acp): orphan alias-lock sweep deletes under its own handle on Windows The orphan-lock sweep removes an empty <alias>.lock only while holding its own exclusive lock on it: the held lock is the proof no launcher owns the inode, so the unlink happens WITHOUT first releasing (releasing before the unlink reopens the race the proof closes). On POSIX an open fd never blocks an unlink, so this is correct and the two sweep tests pass. On Windows a CRT descriptor (os.open) opens with FILE_SHARE_READ | FILE_SHARE_WRITE and OMITS FILE_SHARE_DELETE, so while the sweep's own verification handle lives, os.unlink of that same name fails with a sharing violation (PermissionError / WinError 32). The sweep then declines to remove genuine residue -- its own handle is what blocks the delete -- so test_leftover_alias_lock_files_are_swept_only_when_provably_residue (the residue file never unlinks) and test_a_lock_file_a_launcher_still_holds_ is_never_swept (the free sibling never unlinks, removed == 0 != 1) fail Backend Tests (Windows) shard 2. main does not run Windows shards on push, so this landed on main (e3309cd, #15150) and only surfaced on PRs rebased onto it. Fix at the root with a pin on both platforms: a new platform_compat.open_lock_file_for_sweep opens the lock file RDWR, and on Windows uses CreateFileW with FILE_SHARE_READ_WRITE_DELETE so the unlink lands while the handle (and its msvcrt byte-range lock) is still held -- preserving the hold-across-unlink guarantee identically on both platforms. OPEN_EXISTING never creates (the sweep only ever removes names already present); no OPEN_REPARSE_POINT (the caller already refuses a reparse point at the name and re-checks identity under the lock). POSIX keeps O_RDWR | O_NOFOLLOW, exactly the open it was doing, named. Tests + gates: - TestOpenLockFileForSweep in test_platform_compat.py pins the POSIX unlink-while-open path and the POSIX symlink refusal (both skipped off POSIX, where their real os.unlink-while-open / os.symlink semantics do not hold), and -- via a faked WinDLL that runs everywhere -- that the Windows CreateFileW requests delete-sharing + GENERIC_READ|WRITE and that a wrap failure closes the native handle. The two shard-2 tests exercise the real sweep on POSIX and continue to pass. - The extraction moved the sweep's by-name open behind open_lock_file_for_sweep, one hop past the link-screen gate's one-hop resolver reach -- which would silently drop _sweep_orphan_alias_locks from the ratchet (the hazard uncured, merely unseen). open_lock_file_for_sweep is added to the gate's PRIMITIVES (exactly as open_lock_file already is for the same reason), and test/link_screen_sites.py is regenerated so the site stays declared. * fix(eventlog): release member log handles deterministically on service retirement test/test_members_dm_thread.py flakes on shard 8 across multiple PR boards after #15534 merged, on both Linux and Windows. The CI traceback anchors it: test_returns_recorded_entries_newest_first_with_allowlist_fields assert record_activity(CREW, 'dashboard_chat-1', 'persistent', via='chat') AssertionError: assert False The write side returns False on the FIRST call in a fresh test, after earlier tests ran on the same xdist worker. Root cause. get_service() memoises one MemberEventLogService per process and rebuilds it only when the crew-log root moves (which every test does and production never does). The service sits in a REFERENCE CYCLE: its projection registry holds set_on_change(service._on_change), a bound method back to the service. So set_service(None) -- which the autouse _reset_member_eventlog_singleton floor calls at each boundary -- drops the last external reference but does not free the graph; the cycle keeps it alive until the cyclic collector runs. Each cached MemberLog's CrewLog releases its write lease through a weakref.finalize that fires only then, and holds its file descriptor until then. On POSIX that deferral is invisible (an advisory lock on a torn-down directory harms nothing, and the next acquire against a fresh path just works), which is why the leak could not be reproduced on Linux by running the file, targeted interleaves, or the full real shard-8 selection. On Windows the still-open descriptor keeps a mandatory lock that pins the (torn-down) home directory, so the directory cannot be removed and the next writer on the inheriting worker fails -- record_activity returns False. #15534 reset the singleton REFERENCE at both ends, which was necessary but not sufficient: the reference-cycle keeps the handles alive regardless. Fix (root, deterministic). Retirement now releases the handles NOW instead of waiting for GC: * CrewLog.release_ownership() runs its lease finalizer explicitly (idempotent, atomic via weakref.finalize) and detaches it. * MemberLog.close() releases its cached CrewLog and unloads. * MemberEventLogService.close() closes every cached log, clears the caches, and severs the registry -> bound-method -> service cycle. * set_service() closes the outgoing service when it is replaced; get_service() closes the previous service on a home-change rebuild. Neither happens while an append is in flight on the same instance (the home moves only at a test boundary), so nothing races a writer that still needs the lease. Tests (whole-file guard, POSIX-provable). TestEventlogServiceRetirementReleasesHandles pins the CAUSE rather than the Windows-only symptom: after set_service(None) the retired service holds no cached logs and its registry cycle is severed; a home-change rebuild retires the previous service; close() is idempotent and reads re-open on demand. Verified to FAIL without the set_service close wiring and pass with it. Verification: full test_members_dm_thread.py + eventlog/test_eventlog.py + test_members.py + test_members_eventlog_wiring.py + test_eventlog_hooks.py + test_crew_log_member_unit_reclaim.py + test_members_roster_recency.py = 576 passed / 1 skipped (-n0). test_members_dm_thread.py stressed at -n4 x8 = 182 passed each. black (py312) / isort / flake8 / mypy clean on the changed modules. --------- Co-authored-by: kirocrew-agent <agent@kirocrew.local>
…dows (#15633) * fix(acp): orphan alias-lock sweep deletes under its own handle on Windows The orphan-lock sweep removes an empty <alias>.lock only while holding its own exclusive lock on it: the held lock is the proof no launcher owns the inode, so the unlink happens WITHOUT first releasing (releasing before the unlink reopens the race the proof closes). On POSIX an open fd never blocks an unlink, so this is correct and the two sweep tests pass. On Windows a CRT descriptor (os.open) opens with FILE_SHARE_READ | FILE_SHARE_WRITE and OMITS FILE_SHARE_DELETE, so while the sweep's own verification handle lives, os.unlink of that same name fails with a sharing violation (PermissionError / WinError 32). The sweep then declines to remove genuine residue -- its own handle is what blocks the delete -- so test_leftover_alias_lock_files_are_swept_only_when_provably_residue (the residue file never unlinks) and test_a_lock_file_a_launcher_still_holds_ is_never_swept (the free sibling never unlinks, removed == 0 != 1) fail Backend Tests (Windows) shard 2. main does not run Windows shards on push, so this landed on main (e3309cd, #15150) and only surfaced on PRs rebased onto it. Fix at the root with a pin on both platforms: a new platform_compat.open_lock_file_for_sweep opens the lock file RDWR, and on Windows uses CreateFileW with FILE_SHARE_READ_WRITE_DELETE so the unlink lands while the handle (and its msvcrt byte-range lock) is still held -- preserving the hold-across-unlink guarantee identically on both platforms. OPEN_EXISTING never creates (the sweep only ever removes names already present); no OPEN_REPARSE_POINT (the caller already refuses a reparse point at the name and re-checks identity under the lock). POSIX keeps O_RDWR | O_NOFOLLOW, exactly the open it was doing, named. Tests + gates: - TestOpenLockFileForSweep in test_platform_compat.py pins the POSIX unlink-while-open path and the POSIX symlink refusal (both skipped off POSIX, where their real os.unlink-while-open / os.symlink semantics do not hold), and -- via a faked WinDLL that runs everywhere -- that the Windows CreateFileW requests delete-sharing + GENERIC_READ|WRITE and that a wrap failure closes the native handle. The two shard-2 tests exercise the real sweep on POSIX and continue to pass. - The extraction moved the sweep's by-name open behind open_lock_file_for_sweep, one hop past the link-screen gate's one-hop resolver reach -- which would silently drop _sweep_orphan_alias_locks from the ratchet (the hazard uncured, merely unseen). open_lock_file_for_sweep is added to the gate's PRIMITIVES (exactly as open_lock_file already is for the same reason), and test/link_screen_sites.py is regenerated so the site stays declared. * fix(eventlog): release member log handles deterministically on service retirement test/test_members_dm_thread.py flakes on shard 8 across multiple PR boards after #15534 merged, on both Linux and Windows. The CI traceback anchors it: test_returns_recorded_entries_newest_first_with_allowlist_fields assert record_activity(CREW, 'dashboard_chat-1', 'persistent', via='chat') AssertionError: assert False The write side returns False on the FIRST call in a fresh test, after earlier tests ran on the same xdist worker. Root cause. get_service() memoises one MemberEventLogService per process and rebuilds it only when the crew-log root moves (which every test does and production never does). The service sits in a REFERENCE CYCLE: its projection registry holds set_on_change(service._on_change), a bound method back to the service. So set_service(None) -- which the autouse _reset_member_eventlog_singleton floor calls at each boundary -- drops the last external reference but does not free the graph; the cycle keeps it alive until the cyclic collector runs. Each cached MemberLog's CrewLog releases its write lease through a weakref.finalize that fires only then, and holds its file descriptor until then. On POSIX that deferral is invisible (an advisory lock on a torn-down directory harms nothing, and the next acquire against a fresh path just works), which is why the leak could not be reproduced on Linux by running the file, targeted interleaves, or the full real shard-8 selection. On Windows the still-open descriptor keeps a mandatory lock that pins the (torn-down) home directory, so the directory cannot be removed and the next writer on the inheriting worker fails -- record_activity returns False. #15534 reset the singleton REFERENCE at both ends, which was necessary but not sufficient: the reference-cycle keeps the handles alive regardless. Fix (root, deterministic). Retirement now releases the handles NOW instead of waiting for GC: * CrewLog.release_ownership() runs its lease finalizer explicitly (idempotent, atomic via weakref.finalize) and detaches it. * MemberLog.close() releases its cached CrewLog and unloads. * MemberEventLogService.close() closes every cached log, clears the caches, and severs the registry -> bound-method -> service cycle. * set_service() closes the outgoing service when it is replaced; get_service() closes the previous service on a home-change rebuild. Neither happens while an append is in flight on the same instance (the home moves only at a test boundary), so nothing races a writer that still needs the lease. Tests (whole-file guard, POSIX-provable). TestEventlogServiceRetirementReleasesHandles pins the CAUSE rather than the Windows-only symptom: after set_service(None) the retired service holds no cached logs and its registry cycle is severed; a home-change rebuild retires the previous service; close() is idempotent and reads re-open on demand. Verified to FAIL without the set_service close wiring and pass with it. Verification: full test_members_dm_thread.py + eventlog/test_eventlog.py + test_members.py + test_members_eventlog_wiring.py + test_eventlog_hooks.py + test_crew_log_member_unit_reclaim.py + test_members_roster_recency.py = 576 passed / 1 skipped (-n0). test_members_dm_thread.py stressed at -n4 x8 = 182 passed each. black (py312) / isort / flake8 / mypy clean on the changed modules. --------- Co-authored-by: kirocrew-agent <agent@kirocrew.local> (cherry picked from commit 7460284)
…dows (#15633) (#15699) * fix(acp): orphan alias-lock sweep deletes under its own handle on Windows The orphan-lock sweep removes an empty <alias>.lock only while holding its own exclusive lock on it: the held lock is the proof no launcher owns the inode, so the unlink happens WITHOUT first releasing (releasing before the unlink reopens the race the proof closes). On POSIX an open fd never blocks an unlink, so this is correct and the two sweep tests pass. On Windows a CRT descriptor (os.open) opens with FILE_SHARE_READ | FILE_SHARE_WRITE and OMITS FILE_SHARE_DELETE, so while the sweep's own verification handle lives, os.unlink of that same name fails with a sharing violation (PermissionError / WinError 32). The sweep then declines to remove genuine residue -- its own handle is what blocks the delete -- so test_leftover_alias_lock_files_are_swept_only_when_provably_residue (the residue file never unlinks) and test_a_lock_file_a_launcher_still_holds_ is_never_swept (the free sibling never unlinks, removed == 0 != 1) fail Backend Tests (Windows) shard 2. main does not run Windows shards on push, so this landed on main (e3309cd, #15150) and only surfaced on PRs rebased onto it. Fix at the root with a pin on both platforms: a new platform_compat.open_lock_file_for_sweep opens the lock file RDWR, and on Windows uses CreateFileW with FILE_SHARE_READ_WRITE_DELETE so the unlink lands while the handle (and its msvcrt byte-range lock) is still held -- preserving the hold-across-unlink guarantee identically on both platforms. OPEN_EXISTING never creates (the sweep only ever removes names already present); no OPEN_REPARSE_POINT (the caller already refuses a reparse point at the name and re-checks identity under the lock). POSIX keeps O_RDWR | O_NOFOLLOW, exactly the open it was doing, named. Tests + gates: - TestOpenLockFileForSweep in test_platform_compat.py pins the POSIX unlink-while-open path and the POSIX symlink refusal (both skipped off POSIX, where their real os.unlink-while-open / os.symlink semantics do not hold), and -- via a faked WinDLL that runs everywhere -- that the Windows CreateFileW requests delete-sharing + GENERIC_READ|WRITE and that a wrap failure closes the native handle. The two shard-2 tests exercise the real sweep on POSIX and continue to pass. - The extraction moved the sweep's by-name open behind open_lock_file_for_sweep, one hop past the link-screen gate's one-hop resolver reach -- which would silently drop _sweep_orphan_alias_locks from the ratchet (the hazard uncured, merely unseen). open_lock_file_for_sweep is added to the gate's PRIMITIVES (exactly as open_lock_file already is for the same reason), and test/link_screen_sites.py is regenerated so the site stays declared. * fix(eventlog): release member log handles deterministically on service retirement test/test_members_dm_thread.py flakes on shard 8 across multiple PR boards after #15534 merged, on both Linux and Windows. The CI traceback anchors it: test_returns_recorded_entries_newest_first_with_allowlist_fields assert record_activity(CREW, 'dashboard_chat-1', 'persistent', via='chat') AssertionError: assert False The write side returns False on the FIRST call in a fresh test, after earlier tests ran on the same xdist worker. Root cause. get_service() memoises one MemberEventLogService per process and rebuilds it only when the crew-log root moves (which every test does and production never does). The service sits in a REFERENCE CYCLE: its projection registry holds set_on_change(service._on_change), a bound method back to the service. So set_service(None) -- which the autouse _reset_member_eventlog_singleton floor calls at each boundary -- drops the last external reference but does not free the graph; the cycle keeps it alive until the cyclic collector runs. Each cached MemberLog's CrewLog releases its write lease through a weakref.finalize that fires only then, and holds its file descriptor until then. On POSIX that deferral is invisible (an advisory lock on a torn-down directory harms nothing, and the next acquire against a fresh path just works), which is why the leak could not be reproduced on Linux by running the file, targeted interleaves, or the full real shard-8 selection. On Windows the still-open descriptor keeps a mandatory lock that pins the (torn-down) home directory, so the directory cannot be removed and the next writer on the inheriting worker fails -- record_activity returns False. #15534 reset the singleton REFERENCE at both ends, which was necessary but not sufficient: the reference-cycle keeps the handles alive regardless. Fix (root, deterministic). Retirement now releases the handles NOW instead of waiting for GC: * CrewLog.release_ownership() runs its lease finalizer explicitly (idempotent, atomic via weakref.finalize) and detaches it. * MemberLog.close() releases its cached CrewLog and unloads. * MemberEventLogService.close() closes every cached log, clears the caches, and severs the registry -> bound-method -> service cycle. * set_service() closes the outgoing service when it is replaced; get_service() closes the previous service on a home-change rebuild. Neither happens while an append is in flight on the same instance (the home moves only at a test boundary), so nothing races a writer that still needs the lease. Tests (whole-file guard, POSIX-provable). TestEventlogServiceRetirementReleasesHandles pins the CAUSE rather than the Windows-only symptom: after set_service(None) the retired service holds no cached logs and its registry cycle is severed; a home-change rebuild retires the previous service; close() is idempotent and reads re-open on demand. Verified to FAIL without the set_service close wiring and pass with it. Verification: full test_members_dm_thread.py + eventlog/test_eventlog.py + test_members.py + test_members_eventlog_wiring.py + test_eventlog_hooks.py + test_crew_log_member_unit_reclaim.py + test_members_roster_recency.py = 576 passed / 1 skipped (-n0). test_members_dm_thread.py stressed at -n4 x8 = 182 passed each. black (py312) / isort / flake8 / mypy clean on the changed modules. --------- (cherry picked from commit 7460284) Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com> Co-authored-by: kirocrew-agent <agent@kirocrew.local>
Problem / Motivation
Goal: Stop the member eventlog service singleton from leaking across tests, which makes
Backend Tests (Windows)shard 8 fail intermittently on unrelated PRs.Backend Tests (Windows) (8)fails on rebased PRs (observed on #15316 headf0fbd50baband #15476 head54e672fc50) at:test/test_members_dm_thread.py::TestMemberActivityRoute::test_the_read_never_asks_the_log_for_every_eventtest/test_members_dm_thread.py::TestMemberActivityRoute::test_colliding_slugs_do_not_mix_historiesBoth fail on the test's first line —
assert record_activity(CREW, ...)returnsFalse— not in the read logic the tests are about.maindoes not run Windows shards on push, so the breakage is only visible on PR boards.Why it matters
Any PR rebased onto current
maininherits a red Windows shard that has nothing to do with its own change, blocking otherwise-green PRs and burning reviewer/CI time chasing a phantom regression. The underlying isolation hole is shared by seven test files that useget_service(), so it can resurface on any shard-ordering change.Not a goal
eventlog.service,members.record_activity, and the roster fold are correct; this is purely test isolation.What changed (motivation → approach → change)
record_activityinTestMemberActivityRoutereturnsFalseon Windows shard 8 only; the same tests pass on Linux CI and locally.eventlog.service.get_service()memoises oneMemberEventLogServiceper process and rebuilds it only when the crew-log root moves. The root followsKIROCREW_HOME, which the autouse_isolate_kirocrew_homefixture repoints at a fresh tmp dir per test. A test that touches the service leaves a live singleton bound to its own home; the next test on the same xdist worker inherits it after that home is torn down. On POSIXget_service()rebuilds against the new home and nothing is observed; on Windows the leakedMemberLogholds open OS handles under the dead directory, blocking tmp-dir teardown and making the inheriting test's first write fail —record_activitycatches theOSErrorand returnsFalse.fix(members): order the Recent roster by the crew log (#15277)addedtest/test_members_roster_recency.py, whoseTestRosterReadTakesTheFoldedRecencytests callget_service()/ensure/appendwithout the module'sset_service(None)reset, shifting pytest-split shard-8 ordering so the leaked service lands just beforeTestMemberActivityRouteon the same Windows worker._reset_member_eventlog_singletonfixture intest/conftest.pythat clears the singleton at both ends of every test (set_service(None)on setup and teardown), matching the existing_restore_autonudge_singleton/ reasoning-effort singleton floors. Each test now starts on a clean singleton bound to its own home, so the outcome is deterministic on both platforms.The leak was verified directly: with the leaking predecessor running first, the inheriting test starts with
get_service()._singleton.rootpointing at the previous test's torn-down home (.../i0/1-kirocrew-home/...) while its ownKIROCREW_HOMEis.../i0/2-kirocrew-home— the exact cross-boundary bind this fixture removes.Backwards compatibility
Compatible: test-only change. No production code, public API, or on-disk format is touched; the fixture only resets a process-global test singleton that production legitimately publishes and every test already isolates its home from.
Tests
TestEventlogSingletonDoesNotLeakAcrossTests(two ordered tests, no local reset fixture) pins the cause on both platforms: the first builds a service bound to its own home and leaves it live; the second assertsservice._singleton is Noneat its start (the conftest floor cleared it) and that a fresh read binds to its own home, not the leaked one. Verified it fails without the fixture (eventlog service leaked across the test boundary) and passes with it.test/test_members_dm_thread.py,test_members_roster_recency.py,test_members_eventlog_wiring.py,test_members.py,test_eventlog_hooks.py,eventlog/test_eventlog.py,test_members_preview_speech_only.py— 561 passed together locally with the fixture in place.Manual verification
N/A — unit coverage sufficient. The Windows-specific handle behaviour cannot be reproduced on the Linux dev box, so the pin asserts the platform-independent cause (a singleton crossing the test boundary) rather than the Windows-only symptom; the Windows shard confirms the symptom is gone.
Related Issues
Unblocks Windows shard 8 on PRs rebased onto main after #15277.
Pattern harvest
Rule candidate: review-prompt
Pattern: a process-global singleton memoised on a path/root that tests repoint per-test must be reset at the test boundary (autouse fixture), or it leaks the first test's binding into later tests on the same xdist worker — silent on POSIX, a torn-handle failure on Windows.
Checklist