Repository navigation
fix(members): order the Recent roster by the crew log, and record the user's own send - #15277
Conversation
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Monotone recency has no ceiling: one forward-skewed timestamp pins a member atop Recent for the store's life, and last-wins's self-healing is gone. WatchThe fold's premise — "time only ever moves forward, so a fold that moved it down could only ever be wrong" ( Suggestions
[DESIGN-REVIEWED] a164a95 Description read[DESCRIPTION-READ] 58142b9727e087edb228e9d1d5793a7dc60f4a6898978400bb0381c49353024a 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 detailsFINDING -- src/kiro_crew/dashboard/handlers/members.py:807 -- Function-local False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify event-log growth: What this change shipsInventory (8 items) — 6 justified, 2 harm-free ridersIntent: FIX — sorted by Recent, the crewmate the user just messaged now moves to the top of the roster, live; reproduced in the description and pinned by tests this PR adds that fail on base.
[FIRST-PRINCIPLES-REVIEWED] a164a95 Description read[DESCRIPTION-READ] e5567b7c2cedd1809be769e864fe1b0bf3a73c45e08320c992d84fabf2cc1e72 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS The GIF's first frame is blank white and the blind reader saw nothing in it — play shot-01.gif to confirm the row's travel was actually captured. [UX-REVIEWED] a164a95 Description read[DESCRIPTION-READ] 4dfe10ad4f59131d83a7b60a593f6d7adad07f06879500d2a8db81d280f96bae That sha256 names everything this verdict read: the PR description, plus the 6 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 |
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
15e1bc8 to
69ff7f0
Compare
e226190 to
276fa48
Compare
276fa48 to
32157b8
Compare
|
Attribution for this PR specifically:
Separately, Nothing here needs a change on this branch. The shard clears once #15361 lands on main. |
… user's own send Sorted by Recent, typing into a crewmate's DM left its row where it was. Four things held it still, and each alone was enough. The `member/message` event the roster's `last_active_ts` folds from was emitted at the tail of `_broadcast_chat_message`, which `Slot.append` calls only when a row still needs rendering -- never for a `user` row the composer already drew, nor on a slot with an HTTP stream reader. That gate answers whether anything needs to render the row, which says nothing about whether the row happened, so the one action the user expects to reorder the roster recorded nothing. The emit moves to `_record_member_row`, wired as a separate `Slot._on_row` hook that fires for every live appended row; a replay (`broadcast=False`) still records nothing. `GET /api/members` took the row's recency from the transcript's last SPEECH row, which answers when the member last SAID something rather than when it was last active. `_recency_for_row` now reads the response's own folded `roster` projection, floored by the transcript so a dropped best-effort append and a member with no log lose nothing. `RosterProjection.last_active_ts` becomes monotone. `reconcile_member_preview` appends its correction carrying the TRANSCRIPT's epoch, so a last-wins fold reset recency to the last thing said on every roster read. On the client, `last_active_ts` merges as the greater of row and pushed frame -- taking the row's value froze live frames out -- and `orderedMembers` re-sorts when the OPEN crewmate's recency advances. The order hold still stands for a background refetch, which is what must not move rows under the cursor. Closes #15276
32157b8 to
a164a95
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. No new handler; _recency_for_row reads the block already fetched for the row inside GET /api/members, MEMBER_MESSAGE shape unchanged so older readers are fine, v1->v2 fold bump costs one cold re-fold. The open-row lift only runs under the Recent sort after an advance, so it does not reorder the list. User rows pass through the same redaction chain.
Non-blocking: members_projections.py:139 makes one bad ts permanent; _parse_ts accepts True (1.0) and inf, and a future-dated ts from clock skew pins the fold. Rejecting bool/non-finite and clamping to now+epsilon would close it; no fold test for inf or a future ts.
`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. Co-authored-by: kirocrew-agent <agent@kirocrew.local>
Problem / Motivation
Goal: Sorted by Recent, the crewmate you just messaged moves to the top of the Crewmates roster, live.
It did not. Reproduced 2026-09-30: roster sorted by Recent, typed into a crewmate's DM, the row stayed in the middle of the list, in the alphabetical position it had before the send. The one crewmate the user is actually talking to was the hardest one to find.
Why it matters
Recent is the roster's default sort and the list is the only way into a crewmate's thread. A Recent sort that does not react to the user's own message is worse than no sort: the user has a mental model of "the one I am talking to is at the top", acts on it, and lands on someone else's durable pinned thread. The same staleness reaches
resolveDefaultMember, which opens the most recently used chat on a return visit, so a recency that never advanced sends the user back to the wrong conversation. A crewmate bound mid-session (its memory-store generation is minted at the moment of the first message) had no recorded activity at all and fell to the alphabetical tail.Not a goal
last_messagepreview comes from. The transcript stays its authority, for the reason the reconcile documents.member/messageappend reliable. It stays a best-effort hook; this PR makes a dropped append lose nothing rather than making it not drop.What changed (motivation -> approach -> change)
Four independent causes, each alone enough to hold the row still.
1. The user's own send recorded nothing. The
member/messageevent the roster'slast_active_tsfolds from was emitted at the tail ofDashboardState._broadcast_chat_message.Slot.appendcalls that hook only when(role != "user" or broadcast_user) and not self._has_reader, and the dashboard composer appends the user row withbroadcast_userdefaulting to False (chat_handlers.py) because the composer already drew its own bubble. That gate answers does anything still need to render this row, which says nothing about did this row happen -- so the single action the user most expects to reorder the roster emitted no event, and the_has_readerarm lost assistant rows the same way.The emit moves out to
DashboardState._record_member_row, wired as a newSlot._on_rowhook and called fromSlot.appendfor every live row. It shares only the two conditions that make a row not a row: the wire-only roles (chunk/done/streaming, none of which is persisted) andbroadcast, which is what separates a live append from a replay (channel_slots._rebuild_window,chat_fork,session_transfer). Recording a replay would stamp a member as active just now for a message sent hours ago and reorder the roster on a rotation recovery.2. The roster read did not consult the fold.
GET /api/memberssetrow["last_active_ts"]from the DM transcript's last SPEECH row, which answers when did this member last say something rather than when was it last active -- so a machinery turn was invisible to the ordering, and so was a row appended but not yet flushed._recency_for_rownow reads the response's own foldedrosterprojection and returnsmax(folded, transcript). The fold is the authority; the transcript is a FLOOR, because these events ride a best-effort hook a queue ceiling may drop and a member whose log cannot answer (no log yet, a slug shared by two members, a read the store will not prove -- each answers an emptyvalues) has only the transcript. Because the row and the projection block it ships now carry one value, the client's higher-seq-wins merge has one reading to reconcile rather than two.3. The preview reconcile walked recency backwards.
reconcile_member_previewcorrects a stale quote by appending amember/messagecarrying the TRANSCRIPT's epoch -- the last thing said, older than any machinery turn since -- andRosterProjectiontook each event'stslast-wins. So even a correct fold was reset to the last speech on every roster read, in an append-only log with no compaction and nothing to reopen it. This is why reading the fold in the handler was not sufficient on its own.last_active_tsbecomes the one monotone field in that fold: time only moves forward, so a fold that moved it down could only ever be wrong._parse_tsnormalises first, so an ISO string folds to epoch seconds and aNone, a bool or a non-number leaves the held value alone instead of becoming an ordering key.RosterProjection.state_versiongoes to 2 in the same step, because monotonicity is bookkeeping a savepoint written WITHOUT it can contradict: such a savepoint can hold a recency a preview correction walked backwards, and a resume applies only the events after it, so the regressed value would stand for the life of the store (or until the member next spoke) and the Recent order would still be wrong after the upgrade. Astate_versionmismatch discards the payload, after which the member's own log is re-folded from the start -- the events the bad savepoint consumed are the ones that hold the truth.4. The client could not let a live frame move a row.
MembersPagemerged the pushed projection'slast_active_tsonly when the row carried none (if (!r[key])), so a frame could never move a row that had any recency; andorderedMemberscommitted the order per membership + sort and never re-sorted on an advance. Recency now merges as the GREATER of row and pushed frame -- monotone, so a baseline frozen at its seed sequence cannot regress a row -- andorderedMembersreacts to one more event: the OPEN crewmate's recency advancing. That is not a background event; the open crewmate's recency can only move because of what the user just did in the thread in front of them. It lifts that one row out of the committed order and puts it first, rather than re-sorting -- a whole re-sort would publish every recency that arrived since the order was committed, so a background crewmate that advanced quietly during the visit would jump too, the hold would be spent, and rows WOULD move under the cursor. The other rows keep their positions relative to each other, which is also what the user's model says happened: I messaged this crewmate, so this crewmate is first. It settles after one move, since a row already first is not lifted again. Recency-ordered only: under the by-name sort a recency advance says nothing about where a row belongs, so the lift does not run. A row merely BECOMING the open one re-baselines the reading without moving anything, so opening a member still never shuffles the list.The spec (
docs/system-specs/modules/member-event-log.md) is updated in the same commit: themember/messageemitter, the monotone field, and the roster read's authority.Backwards compatibility
Compatible. No field is added, renamed, removed or narrowed, and no reader is given a value it could not already receive:
last_active_tswas already an optional number on the roster row and in therosterprojection view, and both changes only ever move it FORWARD in time.RosterProjection.state_versionmoves 1 -> 2, which RETIRES every existing roster savepoint: they are a cache of the member's own append-only log, so each is rebuilt by one cold fold on next read and nothing is lost. That is a deliberate one-time re-fold, not a compatibility break -- the savepoint kernel already treats a discarded payload as an ordinary outcome (projection/checkpoint.py), and no caller is served anything that depends on one existing. Themember/messageevent shape is unchanged; the only difference is that more of the rows that always existed now produce one.Two behaviours deliberately change, both in the direction of recording more:
userrow in a member DM, and any row on a slot with an HTTP stream reader, now produce amember/message. That is the fix._resolve_stop_event/_rearm_stop_eventcall_on_messagedirectly on an existing row) no longer produces a secondmember/message. It never was a new message, so it was a duplicate recency bump.Tests
test/test_members_roster_recency.py, 22 cases:TestRecencyForRow-- the fold wins over an older transcript; the transcript floors a lagging fold; an emptyvaluesfalls back to the transcript; aNone/ ISO string / bool / negative / NaN fold is not an ordering key (Truein particular must not rank a member one second after the epoch, sinceboolis anintsubclass).TestTheFoldNeverWalksRecencyBackwards-- a preview correction keeps the newer recency and still lands its quote; a newer event still advances; an event with notsleaves it alone; an ISOtsnormalises to a float. Plus the retirement itself:state_versionmust be at least 2, without which every pin above holds only for a store that has never saved.TestRosterReadTakesTheFoldedRecency-- end to end overGET /api/members: a machinery turn newer than the last speech orders the row, the preview still comes from the transcript, and the row agrees with the projection block it ships; a member with no log keeps the transcript reading.TestAppendRecordsTheRow-- auserrow from the composer IS recorded (the bug); an assistant row is recorded even with a stream reader; a replay is not; the wire-only roles are not; a failing recorder does not break the send.website/src/pages/members/MembersPage.test.tsx-- "the OPEN crewmate rising to the top is the one recency change that re-sorts": opening the coldest row does not re-sort, a background crewmate advancing QUIETLY to the greatest recency of the three moves nothing, a pushedmember_projectionframe for the open row then puts THAT row first with zeroapi.memberscalls -- not the higher-ranked background row, which is what a whole re-sort would have done -- and the other two keep their order relative to each other. A second case pins the by-name sort: there, the open crewmate's own advance moves nothing at all. The existing "a refresh-frame refetch never reorders the roster" case is unchanged and still passes, which is what holds cause 4's other half.website/scripts/record-members-recency-move.mjsdrives the isolated capture entry(
website/capture/members-page.html, which mounts the REAL MembersPage gateway-free) and asserts therecording's own claim before writing it: the cold row starts below the others, opening it reorders
nothing, a background crewmate's quiet advance to the top recency moves nothing, a pushed projection
frame then puts the OPEN row first and leaves the other two in their relative order, and
the roster-fetch count is unchanged across the move -- with a control asserting that counter observes a
real fetch at all, since a handler shadowed by the shared stub would otherwise read 0 forever.
Each fix is mutation-proved: nine mutations, one per decision, all nine caught by the case that claims to pin them, over a control run that was green first. Local runs: 22 pytest + 94 pytest across the three adjacent suites that touch the moved emit, 265 vitest across the three members files. flake8 / isort / black / mypy clean on the touched modules.
Manual verification
End to end in an isolated pod on this worktree (
kirocrew pod up kc-wt-roster-recency), driving the real endpoints and the real UI: three crewmates seeded so the Recent order is not alphabetical, then the coldest one opened and messaged.last_active_tslast_active_tsapi.membersrefetches driven by the moveThe row and the fold agree on both readings, and the move is carried by the projection push alone.
Screenshots / video
The move itself, recorded.
beta-leadis the open row (highlighted) and sits third under Recent; the user's own send arrives as a pushedmember_projectionframe and the row travels to the top, with framer'slayoutcarrying it so the eye can follow. Then a BACKGROUND crewmate's recency advances and nothing moves, which is the order hold still doing its job. Zero roster refetches drove any of it.Stills of the same behaviour end to end in a real pod (a gateway, a real DM, a real agent turn), where the numbers in Manual verification were read:
Pod stills, before and after the send
Related Issues
Closes #15276
Pattern harvest
Rule candidate:
review-promptPattern: a durable record written from inside a DELIVERY hook, so a row that needs no rendering is also never recorded. The two questions -- does anything still need to render this, and did this happen -- have no conditions in common beyond the row not existing, and hanging the second off the first silently drops exactly the rows some surface already drew optimistically.
Checklist