Repository navigation
fix(dashboard): count a thread switch as away for the warm task brief - #21750
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ human override accepted@iamwhatever overrode this lane for |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The PR rewrites the trigger of a maintainer-accepted RFC through an amendment the author wrote, and no maintainer has signed off on it. Watch
[DESIGN-REVIEWED] 243cca1 Description read[DESCRIPTION-READ] ab75d1224d742170b3c332850fe2ec0099e44b1d598f38ad04a48c6390e77459 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 6.1 Review — ✅ no blocking findingsGPT 6.1 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.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings block the merge; one advisory finding on split-view pane focus. FINDING — src/kiro_crew/dashboard/warm_task_brief.py:209 — in split view, [OPUS-REVIEWED] 243cca1 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
bolichen97
left a comment
There was a problem hiding this comment.
Not ready. The new defer-until-the-turn-ends path does not survive the turn it waits for.
Head reviewed: 60c8c92.
Rules 1 and 2 (a thread switch arms the thread left; only a frame for the same thread ends its episode) read correctly, and the 256-episode cap evicts the generation row too. The [work-ledger wake] prefix addition is correct.
One must-fix: _wait_for_idle_turn and the publish-time _settled wait run while _warm_task_brief_model_active does not hold the slot. The turn they wait for ends by appending a broadcast assistant row, and _ChatSlot.append calls cancel_warm_task_brief, which cancels the task. A newly admitted turn in chat_runner cancels it the same way. So rule 3 (defer a return during a turn) and the "a turn running at publication defers the result" clause of rule 4 drop the brief in the cases they were written for. The new tests use _BusySlot, which has no cancel hook, so they pass without exercising this path. Details inline.
Design call for the maintainer: First Principles is BLOCK on this head because the trigger amendment reverses accepted rows of rfc-delayed-task-brief.md (the "Switch chats" and "Hide on X, return on Y" rows, and the "worker/task change" staleness rule). As the maintainer who accepted that RFC, please record the decision on the amendment, through the override or a separate merged amendment. Design Review also asks for the expected brief rate on a conductor thread with periodic patrols. I did not post an override.
Not repeated: the split-view pane-focus false arm (Opus advisory) stands as written there.
| return current | ||
|
|
||
|
|
||
| async def _wait_for_idle_turn( |
There was a problem hiding this comment.
🔴 The deferral waits for a turn whose own reply cancels the deferral
_wait_for_idle_turn polls slot.running while the brief task is not marked model-active. The running turn ends with slot.append("assistant", ...) (broadcast), and _ChatSlot.append calls cancel_warm_task_brief(owner, slot.key). That function cancels any task not in _warm_task_brief_model_active. The asyncio.sleep here then raises CancelledError and the brief is gone. The publish-time wait in _settled has the same gap: model_active is discarded before it runs, so a patrol turn that starts at publication (admitted turns call cancel_warm_task_brief in chat_runner) or that ends with an assistant row also cancels it.
while slot.running:
if (
...
):
return False
await asyncio.sleep(_IDLE_POLL_SECS)
return TrueWhy it matters: Rule 3 and the publication deferral in rule 4 are the fixes for conductor and patrol threads. In production they drop the brief in exactly those cases, with no skip log line. The new tests use _BusySlot, which has no append cancel hook, so test_return_during_a_turn_defers_until_the_turn_ends and test_patrol_activity_during_the_model_call_still_publishes pass without the real cancellation path.
Suggestion: Keep the task protected from non-user cancellation for both waits (for example, hold the slot in a "deferring" set that cancel_warm_task_brief respects for assistant rows and non-user admitted turns, with finally cleanup), and keep the existing user_fingerprint and generation checks as the staleness gate. Add a test that drives a real assistant append through the cancel hook during the deferral. If the running turn's reply in fact reaches the slot with broadcast=False, I will withdraw this.
Rule: SAGE correctness; testing-conventions (test the claimed path)
There was a problem hiding this comment.
Fixed in 243cca1.
You were right. The awaited turn's own broadcast assistant row, and turn admission in chat_runner, both cancelled the deferring brief.
slot_transcript.appendnow cancels only on a broadcast role-userrow, throughcancel_for_live_user_row. That helper skips automation text such as[work-ledger wake]and[auto-nudge cycle.- Assistant rows and turn admission no longer cancel a brief. A typed turn still cancels through its own user row:
chat_send.py:1051, the steer atchat_delivery.py:895, and the queued drain atresponsive_chat.py:784. - Reset, stop, close and leave still cancel.
- The claim re-check now goes through
_settledas well, so a patrol turn admitted before the opener defers it instead of dropping it. - Every real cancel logs
warm task brief skipped for <key>: cancelled.
The tests now run on the real paths:
test_return_during_a_turn_survives_that_turns_own_replyandtest_patrol_turn_at_publication_defers_and_still_publishesuse a real_ChatSlot. The awaited turn ends with a real broadcastappend("assistant", ...).test_an_admitted_patrol_turn_does_not_cancel_a_briefandtest_a_typed_turn_cancels_a_briefdrive a real_run_chatthroughturn_harness.run_turn.
Against the old head, four of these fail. Mutation check: 16 of 16 hand mutants fail the suite, including re-adding the assistant-row cancel and the admission cancel.
|
|
Human judgment recorded@iamwhatever marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
60c8c92 to
243cca1
Compare
|
On the Opus advisory, split-view pane focus can arm a pane that is still on screen. Rebutted: it cannot reach a brief, so no code change.
|
|
|
bolichen97
left a comment
There was a problem hiding this comment.
The must-fix from my previous review is fixed on this head. The PR now waits only on a maintainer decision about the RFC amendment.
Head reviewed: 243cca1.
What changed my mind on the cancellation finding:
_ChatSlot.appendnow cancels only for a broadcastuserrow, throughcancel_for_live_user_row, and only when the text is not automation ([work-ledger wake],[auto-nudge cycle, and the other injected prefixes). The running turn's own assistant reply no longer cancels the deferred brief._run_chatno longer callscancel_warm_task_briefon admission. A typed turn still cancels through its user row. Reset, stop, close and leave still cancel.- The claim re-check now defers through
_settled, so a turn admitted after the snapshot also defers the opener. - The new tests use a real
_ChatSlotwhoseappendroutes back through the cancel hook, and a real_run_chatthroughturn_harness.run_turn. If the role check went back to{"user", "assistant"},test_return_during_a_turn_survives_that_turns_own_replywould raiseCancelledError. If admission cancelled again,test_an_admitted_patrol_turn_does_not_cancel_a_briefwould fail. I read these tests; I did not run them locally.
One behaviour to note, inside the amendment as written: a regenerate or continue during the brief no longer supersedes it, because it adds no typed user row and leaves user_fingerprint unchanged. The brief then posts after that reply. This matches rule (5), "only a live row the person typed cancels", so I do not ask for a change.
Remaining decision: First Principles is BLOCK on 243cca1. The override recorded earlier applies only to 60c8c92, and the author's own disposition on this head says the amendment still waits on the owner's ruling. A maintainer needs to record that decision on this head, through the override or a separate merged amendment on main. The same decision answers the Design Review item on the expected brief rate, which the amendment now states (about four a day on a busy conductor thread, ceiling 48). I did not post an override.
The one red backend shard, Backend Tests (Windows) (2), fails in test/test_history_consolidation_idle_seed.py with a Windows PermissionError on a temp rename. That file is outside this diff.
Withdrawn: the push at 243cca1 fixes the cancellation gap (a waiting brief is now cancelled only by a row the person typed) and the new tests use a real slot and run loop. What remains is the maintainer decision on the First Principles check.
|
/ai-review override first-principles 243cca1: Maintainer decision. I accept the trigger amendment: switch-as-away, defer-on-running and user-only staleness, with the RFC amendment shipping alongside the code. The shipped trigger never fired (0 claim rows since #20422). I also accept the brief rate in the Design reply: about 4 a day measured on a conductor thread, ceiling 48. bolichen97's must-fix is resolved on this head. |
Human judgment recorded@iamwhatever marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
Bring the delayed-task-brief RFC and its directory index into agreement with the document's amendments and with what shipped on main. The warm task brief shipped in #20422 and its 2026-10-18, 2026-10-22 and 2026-10-24 amendments shipped in #21750, #22828, #22839 and #23847, but the RFC still read `accepted` ("nothing built yet") with implementation-prs [] and a 2026-10-14 audit stamp. The front matter now records status implemented, those five PRs, and last-audited 2026-10-26 at 1cf77b5; the section 1 status and "Audited on" lines match it; and the snapshot's third field is renamed "Suggested actions" to match the section 3.5 output it feeds. The README index row no longer describes the superseded preparing-status design or says implementation waits for the RFC. It reads implemented, names the shipped PRs, and summarises the shipped trigger and card. The audit paragraph gains a dated re-audit sentence for the row. Closes #20887
Bring the delayed-task-brief RFC and its directory index into agreement with the document's amendments and with what shipped on main. The warm task brief shipped in #20422 and its amendments shipped in #21750, #22828, #22839, #23847, #24512 and #24307, but the RFC still read `accepted` ("nothing built yet") with implementation-prs [] and a 2026-10-14 audit stamp. The front matter now records status implemented, those seven PRs, and last-audited 2026-10-28 at 7cbf872; the section 1 status and "Audited on" lines match it; and the snapshot's third field is renamed "Suggested actions" to match the section 3.5 output it feeds. The README index row no longer describes the superseded preparing-status design or says implementation waits for the RFC. It reads implemented, names the shipped PRs, and summarises the shipped trigger, the free-form brief card and the leave-after-opener rule. The audit paragraph gains a dated re-audit sentence for the row. Closes #20887
Bring the delayed-task-brief RFC and its directory index into agreement with the document's amendments and with what shipped on main. The warm task brief shipped in #20422 and its amendments shipped in #21750, #22828, #22839, #23847, #24512 and #24307, but the RFC still read `accepted` ("nothing built yet") with implementation-prs [] and a 2026-10-14 audit stamp. The 2026-10-28 writer amendment (section 3.8, #25433) is design only: main has no wake turn and no `dashboard.warm_brief_wake` setting. So the front matter now records status partial, those seven PRs, and last-audited 2026-10-29 at 4d36177; the section 1 status line names what shipped and that section 3.8 is not built; the "Audited on" line matches; and the snapshot's third field is renamed "Suggested actions" to match the section 3.5 output it feeds. The README index row no longer describes the superseded preparing-status design or says implementation waits for the RFC. It reads partial, names the shipped PRs, summarises the shipped trigger, the free-form brief card and the leave-after-opener rule, and names the unbuilt writer amendment. The audit paragraph gains a dated re-audit sentence for the row. Closes #20887
…21712) Bring the delayed-task-brief RFC and its directory index into agreement with the document's amendments and with what shipped on main. The warm task brief shipped in #20422 and its amendments shipped in #21750, #22828, #22839, #23847, #24512, #24307, #25881 (Crew Mode scope), #26500 (fixed progress orb) and #26652 (first part of the 2026-10-31 redesign), yet the front matter and README row still read `accepted` ("nothing built yet") with implementation-prs [] and a 2026-10-14 audit stamp. Not built on main: the 2026-10-28 writer amendment (section 3.8; main has no wake turn and no `dashboard.warm_brief_wake` setting), the 2026-11-01 trigger amendment (#26938 is open), and the live checks, links and copied option buttons of section 3.9.3. So the front matter now records status partial, those ten PRs, and last-audited 2026-11-01 at fed53fc; the section 1 status line names what shipped and what is not built; the "Audited on" line matches; and the snapshot's third field is renamed "Suggested actions" to match the section 3.5 output it feeds. The README index row no longer describes the superseded preparing-status design or says implementation waits for the RFC. It reads partial, names the shipped PRs, summarises the shipped trigger, the one-message brief with its fixed card and quiet return, and names the unbuilt parts. The audit paragraph gains a dated re-audit sentence for the row. Closes #20887
Problem / Motivation
Goal: The warm task brief appears when the owner returns to a crewmate thread after leaving it for another chat, or after a patrol turn ends.
Since #20422 merged, no transcript holds a single
warm_task_brief_claimrow, so every return was dropped before the claim. The owner's real return left the conductor thread for another chat at 17:10Z and opened it again at 04:59Z. The thread was idle and the gateway had not restarted, yet no brief appeared. The full skip-path audit is in #21749.Why it matters
The feature is shipped but never fires for the people it was built for. People who move between chats in one dashboard window never get a brief. Conductor and patrol chats lose most of the remaining returns, because they are often mid-turn or post patrol rows during the 60-second model call.
Not a goal
slot_focusedframe on every thread switch.What changed (motivation → approach → change)
The symptom is that no brief ever appears. Four activation rules in
src/kiro_crew/dashboard/warm_task_brief.pycause it:Only a hidden page starts an away episode. Switching threads never counted. Now a frame naming another thread starts an episode for the thread being left, under the same last-owner-view rule as a hidden page.
Any owner frame ends every episode. A frame for another thread, window, or device wiped the episode. Now an episode ends only when an owner frame names its own thread again. A cap of 256 episodes evicts the oldest, together with its generation row.
A return while
slot.runningis skipped and never retried. Now the brief waits for the turn to end, polling every 2 s for at most 30 minutes, and only while the owner stays on the thread and no new leave happens. If the owner typed after returning, the brief is skipped.Any fingerprint change at publication drops the result. Patrol turns, worker reports, and ledger writes all count as changes. Now a prepared result goes stale only on a new genuine user turn, a new away episode, a reset or replaced slot, or a finished task. A turn running at publication defers the result until it ends. The full fingerprint still drives dedup.
The awaited turn cancels its own deferred brief. Its broadcast assistant row and turn admission both called
cancel_warm_task_brief. Now only a live user row the person typed cancels a brief in preparation, throughcancel_for_live_user_row, which skips automation text. Reset, stop, close and leave still cancel. The claim re-check also defers through_settled, and every real cancel logs a skip reason.Two smaller changes:
session_summary._INJECTED_PREFIXESgains[work-ledger wake]. Without it, the conductor's wake rows count as typed requests, and the brief can quote one as the original request.Design RFC: rfc-delayed-task-brief.md, status
acceptedon main. This PR adds a dated trigger amendment and updates the spec indocs/system-specs/modules/session.mdin the same commit. Spend is unchanged: at most one tool-free background call per claimed fingerprint, and only on a return.Backwards compatibility
Compatible: no route, frame shape, field, or stored format changes. The in-memory away map now holds one entry per left thread instead of at most one entry, capped at 256.
Removes nothing: the change only widens when an episode starts and narrows when a prepared result counts as stale; no path, row, key or function is removed.
Tests
test/test_warm_task_brief.py:_ChatSlot, a return during a turn survives that turn's own broadcast assistant reply and then posts. A patrol turn admitted during the model call defers publication until its reply lands.[work-ledger wake]row does not.turn_harness.run_turn, a real_run_chat: an admitted patrol turn does not cancel a pending brief, and a typed turn does.user_fingerprintignores assistant rows, wake rows, and ledger changes, and moves on a typed turn.[work-ledger wake]rows are injected, not user turns.These cases were changed to the new rules: unreasoned null never arms; the opener test expects two flushes; the stale-result test now uses a user send.
test/test_slot_running_readers.pylists the two newrunningreaders.local-gate.pybackend related tests ran 21878 passed with 1 failure, a source-pin budget breach from a first test draft; the final tests replace that draft withrun_turn, andtest_source_pin_budget.pypasses.Mutation check: 16 hand mutants, one per new rule, and every one fails
test/test_warm_task_brief.py. A probe file showed each skip path on main before the fix.Manual verification
Local gates were green: flake8, mypy, isort, black, comment-history, brand, docs-lint, file line cap, sync-io, loop-bound locks, harness parity, feature map, and the flake-pattern ratchet.
local-gate.pybackend related tests ran 6832 passed with 1 failure,test_session_token_identity.py::test_native_settings_sources_repeated_permissive_reads_do_not_hide_a_restriction. That test passes in isolation and is outside this diff. Semgrep could not install on this host, so CI's SAST job is the check for it.A local GPT review found nothing. A local Opus review raised one advisory (a user turn during a deferral) and one low finding (the generation row was not evicted with the cap). Both are fixed. A verifier confirmed them closed on the first head, and confirmed the reviewer's cancellation must-fix closed on
243cca148f.No harness screenshot.
kirocrew podneedssystemd --user, which this host lacks, and the worker sandbox cannot start a dev gateway or run kiro-cli. The diff has no frontend change, and the backend rules are covered by the focused tests above.Related Issues
Fixes #21749. Follows #20422 and the RFC from #20157.
Pattern harvest
Rule candidate: review-prompt
Pattern: a presence or trigger rule that only one test fixture ever exercises. When the shipped trigger has zero production hits, such as zero claim rows, read real transcripts for one before designing the next rule.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.