Skip to content

fix: resume a bot thread that a planned restart cut off - #35691

Open
jingchaodev wants to merge 1 commit into
kirodotdev:mainfrom
jingchaodev:crew/kirocrew-developer/fix-restart-member-resume
Open

jingchaodev wants to merge 1 commit into
kirodotdev:mainfrom
jingchaodev:crew/kirocrew-developer/fix-restart-member-resume

Conversation

@jingchaodev

@jingchaodev jingchaodev commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A Bot thread whose turn a planned restart cut resumes after the restart, as the chat page's sessions do.

After a planned restart (the dashboard Restart, an update apply, or /kirocrew restart in Slack), a Bot thread (a Bot's own chat, slot mode member) keeps its interruption row and its Resume button. The chat page's sessions and the Bot's own workers cut by the same restart are resumed.

Why it matters

A Bot that is working when its owner restarts the gateway stops until someone opens the Bot's page and presses Resume. A planned restart is the app's own choice, so nothing should be left for the person to do. The reporter lost two cut Bot turns this way on 2026-11-11 (21:02 and 21:25 UTC).

Not a goal

  • A crash or force-quit: it writes no record, so its chats keep the manual Resume.
  • The Resume-all button: its count, its candidates and the owner's origin on the turns it resumes stay as they are.
  • An app's worker slot (a slot mode an app registers, e.g. design-critique): its app's page drives its turns, so the boot resume still leaves it out.
  • A Bot thread whose boot restore is deferred (member_slot_retry, about 120 s after boot): the resume pass has already run by then.
  • Automatic resume of crash-cut chats, which feat(chat): resume interrupted turns on their own, within a budget #20750 proposes behind a setting.

What changed (motivation → approach → change)

record_running_slots records every slot with a turn in flight, of any mode. The next boot resumes them through chat_resume_all.start_resume_all, so the Resume-all run's bound and refusals apply. But that run's collect_interrupted_idle keeps only CHAT_PAGE_MODES ("" and the retired "orchestrator"), the filter the button needs so its count matches the chat page's sidebar. The restart inherited the button's filter, so a recorded Bot thread was dropped.

collect_interrupted_idle and start_resume_all take a modes argument whose default is CHAT_PAGE_MODES. The button route passes nothing, so its candidates are the same. resume_after_restart passes CHAT_PAGE_MODES | {DM_SLOT_MODE}. The set of listed roots, whose Crew Mode workers stay with their conductor, is still built from the chat page's rows. A Bot's workers carry mate_root, never crew_root, so they keep resuming beside the Bot thread.

Slot mode in the record Boot resume on main With this PR
"" chat (Crew Mode roots, a Bot's workers, cron and task chats) resumed resumed
a Crew Mode worker whose root is listed left to its conductor left to its conductor
"orchestrator" (retired, restored as "") resumed resumed
"member" Bot thread dropped resumed
an app's worker mode left out left out

The run also gave every turn it resumed the press's user origin, which a press earns because the owner made it. The boot is the gateway acting: the cut turn may have been a Bot's check-in, a cron or a loop wake, and the record is a data-home file that sandboxed code can write. So start_resume_all takes user_origin, the press keeps True, and resume_after_restart passes False, as session control's Continue does. A restart-resumed turn, a Bot thread's or a chat page session's, then cannot run an operation that only a person's turn may run.

Sub-agents run outside the dashboard's slots, so the record never names one. learn-cron-dashboard.md names the modes the boot resumes and the origin its turns carry.

Open PR #20750 edits restart_resume.py too: whichever PR lands second passes modes=CHAT_PAGE_MODES | {DM_SLOT_MODE} where _planned_candidates calls collect_interrupted_idle.

Backwards compatibility

Breaking: a turn the planned-restart boot resumes no longer counts as one the person sent, for a chat page session as for a Bot thread, so an operation only a person's turn may run refuses inside it until the person sends again. Writer sweep on origin/main @ b6091e4: start_resume_all has two callers. The Resume-all route keeps user_origin=True, and resume_after_restart passes False (changed here).

Reader: src/kiro_crew/dashboard/handlers/guide.py:_resolve_agent_caller -- chat -- a user-only operation refuses in a restart-resumed turn as in a loop wake; a Bot thread's own goal, milestones and check-ins cards stay admitted (test_a_planned_restart_resumes_no_chat_as_a_turn_the_person_sent pins the flag)
Reader: src/kiro_crew/directive_origin.py:user_origin_gate_admits -- chat -- set_project, reset_conversation, chat_tag and suggest_followup refuse in a restart-resumed turn, as in a loop wake
Reader: src/kiro_crew/dashboard/session_directive_apply_slot.py:_nothing_to_do -- chat -- a restart-resumed turn may end quietly, as a loop wake may; the transcript keeps the inspectable tool step
Reader: src/kiro_crew/dashboard/crew_dispatch_notice.py:maybe_write_dispatch_notice -- chat -- a restart-resumed conductor turn writes no dispatch notice, as its other automated turns do not
Reader: src/kiro_crew/dashboard/session_directive_apply_slot.py:_apply_chat_rename -- chat -- the agent's own chat rename refuses in a restart-resumed turn, as in a loop wake
Reader: src/kiro_crew/dashboard/chat_turn/turn_admission.py:_is_person_turn -- cron tab -- a restart-resumed turn in a cron tab starts its KAS session without the folder agent's hooks, as the cron's own runs do
Reader: src/kiro_crew/dashboard/handlers_instances_crew_reads.py:_slot_refusal -- crew page -- unchanged: a crew read needs _turn_owner_sent, which no Continue sets, so a restart-resumed turn was refused before too

Tests

  • test_a_planned_restart_resumes_a_bot_thread_it_recorded_once: a recorded, interrupted Bot thread resumes with a chat page session, once (a second boot dispatches nothing), while the button's candidates for the same slots stay the chat page session alone.
  • test_a_planned_restart_resumes_no_chat_as_a_turn_the_person_sent: neither the chat page session nor the Bot thread the boot resumes carries the person's origin on its queue entry. test_resumes_every_candidate_with_the_pick_up_body still pins the owner's origin on a press.
  • test_a_planned_restart_resumes_a_bot_threads_workers_but_not_a_listed_roots: a session the Bot thread dispatched still resumes, and a listed Crew Mode root's worker is still left to its conductor.
  • test_a_recorded_bot_thread_is_refused_as_any_chat_is (approval, queue, sub-agents): a pending approval and a card queued in this process refuse the Bot thread with the button's codes, and running sub-agents keep it out of the run.
  • test_a_boot_with_no_record_resumes_nothing (chat, bot-thread): a crash boot resumes neither.

Proof: PROVEN test/test_chat_resume_all.py::test_a_planned_restart_resumes_a_bot_thread_it_recorded_once, test/test_chat_resume_all.py::test_a_planned_restart_resumes_no_chat_as_a_turn_the_person_sent, test/test_chat_resume_all.py::test_a_planned_restart_resumes_a_bot_threads_workers_but_not_a_listed_roots (head 6e1f160)

Determinism: the new and changed tests passed 20 of 20 runs at -n0 and 10 of 10 at -n 4 --dist loadgroup --max-worker-restart=2 beside test/test_inapp_restart_keeps_turn_marker.py and test/test_restart_waits_for_cut_turns.py; the whole file passed in a shuffled order (seed 8542, 65 tests).

Manual verification

N/A — unit coverage sufficient: the change is the candidate filter and the origin of the boot pass, and the tests drive resume_after_restart from a written record over real slots, with only the turn dispatcher stubbed.

Related Issues

Closes #35630

Related: #20750

Related: #13838

Sibling sweep

Swept: git grep -nE "collect_interrupted_idle|start_resume_all|CHAT_PAGE_MODES|continue_slot_turn(" -- src/
Sibling: src/kiro_crew/dashboard/restart_resume.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_resume_all.py -- not affected -- the Resume-all press keeps the chat page's rows and the owner's origin
Sibling: src/kiro_crew/dashboard/chat_api/continue_turn.py -- not affected -- the per-row Resume is the person's own press
Sibling: src/kiro_crew/dashboard/chat_api/slot_repair.py -- not affected -- the image repair route is the person's own press
Sibling: src/kiro_crew/dashboard/handlers/crew_pause.py -- not affected -- the Board's Resume is the person's own press
Sibling: src/kiro_crew/dashboard/session_control_parts/turn_control.py -- not affected -- an agent's Continue already passes no user origin
Sibling: src/kiro_crew/dashboard/limit_continue.py -- not affected -- the continue after a usage-limit reset is the person's own press, armed ahead of time
Sibling: src/kiro_crew/dashboard/slot_projection.py -- not affected -- a comment on the week-old interruption filter, which collect_interrupted_idle applies for every modes
Sibling: src/kiro_crew/slack/code_channels/resume.py -- not affected -- the code-channel restart resume has its own path and store, and already passes no user origin

Pattern harvest

Rule candidate: review-prompt
Pattern: an automatic path that reuses a UI control's run inherits that control's display scope and the person's origin as its own

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@jingchaodev
jingchaodev requested review from a team and KiroCrewCaptain as code owners November 12, 2026 00:31
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The planned-restart boot resume now includes Bot threads (modes=CHAT_PAGE_MODES | {DM_SLOT_MODE}) and resumes every turn without the person's origin (user_origin=False). The Resume-all button keeps its default candidates and the person's origin. The Crew Mode listed-roots set is still built from chat page rows only, so a wider filter only adds candidates. Approval, queue and sub-agent refusals all run through the shared continue_slot_turn and collect checks. The record is still taken once per boot, and a crash boot still resumes nothing. The origin change is declared as breaking and hardens trust: the record is a data-home file that sandboxed code can write. The new tests would fail on main: a Bot thread dropped, and the person's origin set on restart-resumed turns.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 79948b541f · 216 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@jingchaodev

Copy link
Copy Markdown
Contributor Author

Gentle ping: could a maintainer approve the workflow runs for this fork PR when there is time? It merges cleanly with current main. Thanks!

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 20, 2026
A planned restart records every chat with a turn in flight, and the
next boot resumes them through the Resume-all run. That run keeps only
the chat page's slot modes, the filter the Resume-all button needs for
its count, so a Bot thread (slot mode member) was dropped and its work
stopped until someone pressed Resume.

collect_interrupted_idle and start_resume_all take a modes set that
defaults to the chat page's. The restart passes the chat page's modes
plus the member mode, so the button's count and candidates stay as
they are. The Crew Mode roots whose workers stay with their conductor
are still the chat page's rows, so a Bot's workers keep resuming.

The run also took the press's user origin for every turn it resumed.
A press is the owner's, but the boot is the gateway's: the cut turn
may have been a check-in, a cron or a loop wake, and the record is a
data-home file sandboxed code can write. start_resume_all takes a
user_origin flag, the press keeps it, and the restart passes False,
so no resumed turn can run an operation only a person's turn may run.

Closes kirodotdev#35630
@jingchaodev
jingchaodev force-pushed the crew/kirocrew-developer/fix-restart-member-resume branch from 79948b5 to 6e1f160 Compare November 20, 2026 19:32
@jingchaodev

Copy link
Copy Markdown
Contributor Author

Rebased: main conflicted with docs/system-specs/modules/learn-cron-dashboard.md (c08661a -> 394cb9f). #40010 rewrote the restart-resume paragraph this PR extends. The spec now keeps #40010's wording plus this PR's lines. The code and tests are unchanged.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Planned restart does not resume a Bot thread's cut turn

2 participants