Skip to content

fix(members): seed crew recency from the human-turn marker - #17953

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/crew-recency-seed-marker
Oct 8, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/crew-recency-seed-marker

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The one-time crew recency seed counts only rows a person typed, read from the human-turn marker.

#17808's seed fills crew_recency.json from old Crewmates DM threads. It treated a user-role row as typed when its text did not open with [. That counts gateway rows that do not open with [, such as a 💓 Heartbeat prompt. It also skips a real human message like [1, 2, 3] is the list.

Why it matters

A wrong seed lists a crewmate the user never talked to, or hides one they did, on the first Crewmates visit after upgrade. The seed runs once, so a wrong answer stays until the user sends that crew a new message.

Not a goal

  • No change to the live recorder (POST /api/chat, POST /api/agents).
  • No re-run of the seed on data homes that already seeded.

What changed (motivation → approach → change)

Symptom: heartbeats count, typed […] messages do not. Cause: an exclusion rule on the text prefix. history.py documents that "a reader that wants human activity must require this marker rather than exclude the machine callers it happens to know about".

Change: _seed_from_dm_threads in src/kiro_crew/dashboard/handlers/members.py reads meta[HUMAN_TURN_META_KEY], the allowlist marker the human send paths set. In a thread where any row carries it, only marked rows count. A thread where no row carries it predates the marker (#11733, 2026-09-30; DM threads go back to 2026-08-27). There the old "does not open with [" rule still applies, so that history is not lost. docs/system-specs/modules/crew-mode.md states the new rule.

Answers the #17808 review spans GPT fdf96ec23d53 and First Principles 3c53b19d9965, which were held for a follow-up under the scope freeze.

Backwards compatibility

Compatible: only the one-time seed's row choice changes; the file format and every field on GET /api/members are unchanged.

Removes nothing: no field, route or record is taken away; an already-seeded data home is untouched.

Tests

  • test/test_crew_recency.py::test_seed_reads_only_what_the_user_typed_in_a_dm_thread: a human-marked row that opens with [ counts. A peer [sent by session …] delivery and assistant speech do not.
  • test_seed_reads_a_thread_from_before_the_marker_by_the_old_rule: an unmarked old thread still counts its typed row and skips the [ envelope. In a marked thread, a newer unmarked heartbeat is skipped; it is told apart by that thread's own row stamps (monotonic per thread), never across threads, so a coarse Windows clock cannot tie them. Mutations: forcing the "marked" branch, or dropping the marker filter, each turn this test red.
  • test_a_seed_that_could_not_read_a_thread_runs_again_later: its fixture row now carries the marker.

Manual verification

N/A — unit coverage sufficient: the seed is a pure read over ConversationLog rows, driven end to end through GET /api/members in the tests above.

Related Issues

Follow-up to #17808.

Pattern harvest

Rule candidate: review-prompt
Pattern: inferring "a person wrote this" by excluding known machine shapes (a text prefix) instead of requiring the HUMAN_TURN_META_KEY allowlist marker.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested a review from a team as a code owner October 8, 2026 02:13
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 42ebeacaa518af63afa890241baf042997001d03 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 42ebeacaa518af63afa890241baf042997001d03 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 42ebeac

Verdict parsed from the review's SHA-scoped output markers for commit 42ebeacaa518af63afa890241baf042997001d03.

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

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that a thread with one marked row but older typed rows from before the marker still ranks by its newest marked row. The seed ignores those older rows.

[DESIGN-REVIEWED] 42ebeac

Description read

[DESCRIPTION-READ] 9b0ad48a24818308215301247f21ea92e061c20830c5e09529fad797c681f7b2

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 42ebeacaa518af63afa890241baf042997001d03 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The fallback fires on any thread with no marked row, not just threads older than the marker, so a heartbeat-only thread still seeds a crewmate the user never talked to.

Not justified as shipped

  • Item 2 — symptom-level: marked = any(_is_human_row(...)) decides "predates the marker" by whether any row is marked, not by date. A thread written after fix(slack): rank the sessions list by the last human turn, not file mtime #11733 that carries only heartbeats has no marked row either, so it takes the old branch and 💓 Heartbeat counts. That is the case the Goal names: "lists a crewmate the user never talked to".
    Subtraction: delete the not marked fallback branch. Pre-marker threads then seed nothing, and that loss is bounded by the stated 2026-08-27→09-30 window. Or limit the fallback to rows timestamped before the marker shipped.
    Clears when: a heartbeat-only thread written after the marker seeds no recency, or the description accepts that leak as a residual.
  • Item 3 — one consumer, generalized: _is_human_row(msg, marker) has 2 call sites (members.py:922,928, grep _is_human_row(). Both pass HUMAN_TURN_META_KEY.
    Subtraction: drop the marker parameter and read HUMAN_TURN_META_KEY inside the helper.
    Clears when: the parameter is removed.

What this change ships

Inventory (4 items) — 2 justified

Intent: the first Crewmates visit after upgrade should list only crews the user actually messaged. FIX.

  1. The seed counts only marker-carrying user rows in threads that have any marked row — justified
  2. Threads with no marked row fall back to the "doesn't open with [" rule — symptom-level: also catches unmarked threads written after the marker
  3. New private helper _is_human_row(msg, marker) — one consumer, generalized
  4. The crew-mode spec states the new seed rule — justified

[FIRST-PRINCIPLES-REVIEWED] 42ebeac

Description read

[DESCRIPTION-READ] 3a8731648d0e007209dcce1640542658c45a3d6b5530b7c16f08fa610b72383c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 42ebeacaa518af63afa890241baf042997001d03 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 42ebeac

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

@iamwhatever
iamwhatever force-pushed the fix/crew-recency-seed-marker branch from 0d7c85c to 8276e17 Compare October 8, 2026 02:45
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
…refix

The one-time crew_recency seed decided a DM row was typed by the user
from content not opening with '[', which counted heartbeat prompts and
skipped human messages like '[1, 2, 3]'. Require meta[HUMAN_TURN_META_KEY],
the allowlist the human send paths set. Follow-up to #17808.
@iamwhatever
iamwhatever force-pushed the fix/crew-recency-seed-marker branch from 8276e17 to 42ebeac Compare October 8, 2026 03:16
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=621091c56cad Pin timestamps before asserting cross-thread recency order

Outcome: fixed in 42ebeacaa5. The test no longer compares two threads, whose stamps can tie on a coarse Windows clock (the Windows shard failure). It reads the marked thread's own row stamps, which are monotonic per thread, and asserts exact equality with the typed row's stamp. Two mutations each turn it red: dropping the marker filter, and forcing the marked branch.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=a08cad20dcae Item 2: a heartbeat-only thread written after the marker takes the old branch

Outcome: accepted as a bounded residual.
The seed runs once per data home, and only over Crewmates DM threads the user's roster already binds. A DM thread with no human-marked row and only heartbeat rows was never chatted with, so it is the narrow case. The only effect is that crew being listed after the upgrade until the user's next send moves the order. Dating the branch by the marker's release instead would need a per-thread first-row date read. It also lists the same thread wrongly in the other direction, for a user who chatted before 2026-09-30 and stopped.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=45c1878918a1 Item 3: drop the marker parameter from _is_human_row

Outcome: agreed, deferred. It is a cosmetic two-call-site change with no behaviour, and this head is otherwise green. Pushing it reruns the whole CI matrix, so it goes into the next change that touches this function.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE

Reviewed head 42ebeac. The one-time seed now counts only rows a person typed, read from HUMAN_TURN_META_KEY. The First Principles point is that the fallback still fires on a thread with no marked row, so a heartbeat-only thread can seed a crewmate. It is dispositioned on this head as an accepted boundary: it applies only to old threads before the marker existed, and it is a one-time seed. That is reasonable, but a maintainer should accept the residual.

@iamwhatever
iamwhatever enabled auto-merge (squash) October 8, 2026 05:15
@chenmingwei23
chenmingwei23 merged commit 852f339 into main Oct 8, 2026
147 of 148 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/crew-recency-seed-marker branch October 8, 2026 05:57
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 8, 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.

2 participants