Repository navigation
fix: clear a removed crewmate's thread session record - #32924
Conversation
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com>
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The change adds a missing step to the existing removal teardown, it runs on all three gateway removal paths, and it deletes only the removed crewmate's own thread entries. Notes
[DESIGN-REVIEWED] 4848ee4 Description read[DESCRIPTION-READ] 5d280d0ffc5b8c1a760eb28b7211fe8b9bbb9816b654afc3058bad768d840691 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the change adds the one missing removal step to the teardown every gateway removal already runs, and the defect has a linked issue (#22486) plus a test that fails on base. Inventory (8 items) — 8 justifiedIntent: when a person deletes a crewmate, its broken thread's saved session record goes with it, so the bad record can't come back after a restart. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 4848ee4 Description read[DESCRIPTION-READ] fee20f016380d09302eca73a48f05a66fcb2da8be593e35b27f51ff59b2d042c That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.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: |
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: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
The review checked head 4848ee4. All three gateway removal paths (the dashboard DELETE, the sync prune and the startup prune) now pass the session manager into the shared teardown, and the CLI path passes none, as crew-mode.md says. The fail-closed claimed-slug check runs before any key is derived. The .memory- boundary cannot match a sibling slug. SessionManager.destroy removes a sid-less entry. Mutations on the slug guard, the boundary, the has_hint filter and both prune call sites each turn the tests red.
Done well: the step reuses SessionManager.destroy instead of editing session_map.json directly, so only the process that owns the map rewrites it.
Optional: add a test that seeds mate with a private V2 memory_store and a sid-less current-store key. Today, deleting lines 228-229 of crew_removal.py leaves all 9 tests green, and the failed-destroy failed report row is not asserted either.
Optional: build the store key only for a V2 store record, or build each key in its own try. A legacy store name the validator rejects then no longer aborts the step and leaves the V1 key behind.
Optional: when this lands, close #28613 as superseded. Also decide whether #22486 needs a follow-up issue for resetting a live crewmate's thread, or whether "Part of" fits better than "Fixes".
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com> (cherry picked from commit bed3c8a) Original author: @bolichen97
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com> (cherry picked from commit bed3c8a) Original author: @bolichen97
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com> (cherry picked from commit bed3c8a) Original author: @bolichen97
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com> (cherry picked from commit bed3c8a) Original author: @bolichen97
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com> (cherry picked from commit bed3c8a) Original author: @bolichen97
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com> (cherry picked from commit bed3c8a) Original author: @bolichen97
Deleting a crewmate tore down its config row, crew log, avatar, goal check-ins, worktrees and private template copy, but never its pinned thread's session_map.json entry. A bad dashboard:member-<slug> record then outlived the crewmate, and nothing else could clear it. The shared removal teardown now destroys the thread's keys through the gateway's session manager, which also ends a live process for the thread: the V1 key, the current store's key and earlier store generations on the exact .memory- boundary. A slug another live crew still derives keeps its entries, and a failure never fails the delete. The dashboard delete and both prunes pass the manager; the CLI delete has none and leaves the map alone. Builds on #28613 by @cruisercohen. Co-authored-by: Matt Cohen <1832296+cruisercohen@users.noreply.github.com> (cherry picked from commit bed3c8a) Original author: @bolichen97
Problem / Motivation
Goal: Deleting a crewmate also clears its thread's saved session record, so a bad record no longer outlives the crewmate.
A crewmate's standing thread is saved in
session_map.jsonunderdashboard:member-<slug>, ordashboard:member-<slug>.memory-<store>on a private store. When that record goes bad (in #22486 the thread mounted only one of its MCP servers), nothing clears it: deleting the crewmate leaves the entry in the file, a restart restores it, Fresh start keeps the key, and member threads are not listed where a session can be deleted.Why it matters
Delete reads like the reset, and it is not. A person whose crewmate thread breaks has no supported way out except building a second crewmate, and the dead entry stays in
session_map.jsonfor good.Not a goal
kirocrew agent delete: it runs without the gateway's session manager, so it leaves the map alone.What changed (motivation → approach → change)
Deleting a crewmate left its thread's
session_map.jsonentry behind. The removal teardown every gateway removal runs (crew_removal._remove_member_leftovers) had a step for each other leftover (avatar, goal check-ins, worktrees, private template copy) but none for the thread's session.It gets one,
_destroy_member_thread_sessions, which hands each of the thread's keys to the gateway's session manager.destroyends a live process for the key and deletes its entry, the same permanent removal a destroyed session gets anywhere else..memory-boundary, which a sibling slug likemate-0a2620b15f41cannot sharefailedrow in the teardown report; the committed delete still answers 200DELETE /api/agents/{name}, thePOST /api/agents/syncprune (installed_agents.py) and the startup prune (crewmate_prune.py), each passingstate.sessions;handlers/agents.pyexposes the step to the composed facadecrew-mode.mdrecords the step and why the CLI delete skips it.Builds on #28613 by @cruisercohen.
Backwards compatibility
Compatible: nothing a live crewmate uses changes; only a removed crewmate's own thread entries are deleted, and a slug a live crew still derives keeps them.
Reader: src/kiro_crew/dashboard/handlers/members_thread.py:api_member_thread -- crew page -- a thread opens only for a crewmate in the roster, and a slug a live crew still derives keeps its entries (test_crew_delete_forgets_member_thread_session.py::test_a_slug_another_live_crew_still_derives_keeps_its_entries)
Reader: src/kiro_crew/dashboard/handlers/session_storage.py:_build_index -- crew page -- the removed thread's session ID is no longer counted as resumable, the outcome every destroyed session already has; a sibling crewmate's entry stays (test_crew_delete_forgets_member_thread_session.py::test_delete_destroys_the_departed_crewmates_thread_entries)
Reader: src/kiro_crew/cli_commands_agent.py:_remove_deleted_agent_leftovers -- release -- the CLI passes no session manager, so the map file is untouched (test_crew_delete_forgets_member_thread_session.py::test_leftovers_without_a_session_manager_touch_no_session)
Tests
test/test_crew_delete_forgets_member_thread_session.py(new) drives the realDELETE /api/agents/{name}route over a realSessionMap: the deleted crewmate's V1 and private-store keys go, its siblingmate-0a2620b15f41and an unrelated chat stay; an entry Fresh start left without a session ID goes; a claimed slug keeps every entry; a failingdestroystill answers 200; the teardown with no manager leaves the file byte-identical.test/test_pruned_crewmate_leftovers.py: the sync prune and the startup prune each destroy the pruned crewmate's thread key and no other.Proof: PROVEN test/test_crew_delete_forgets_member_thread_session.py::test_delete_destroys_the_departed_crewmates_thread_entries, test/test_crew_delete_forgets_member_thread_session.py::test_an_entry_a_fresh_start_left_without_a_sid_goes_too, test/test_pruned_crewmate_leftovers.py::test_agent_sync_prune_removes_the_pruned_crews_leftovers, test/test_pruned_crewmate_leftovers.py::test_startup_prune_removes_the_removed_crewmates_leftovers (head 4848ee4)
Determinism (testing-conventions D12), every new or changed test: 20/20 green at
-n0; 10/10 green at-n 4 --dist loadgroup --max-worker-restart=2besidetest_crew_delete_dashboard_lock.pyandtest_agent_delete_prunes_private_copy.py; all 9 ids of both files green in a shuffled order (seed 11164).Manual verification
N/A — unit coverage sufficient: the tests run the real delete route and both prunes against a real
session_map.json; the session manager'sdestroy(process teardown plus map delete) is unchanged and covered by its own tests.Screenshots / video
N/A — no user-visible surface changes: the diff is backend-only and removes a server-side record.
Related Issues
Fixes #22486
Sibling sweep
Swept: git grep -n "_remove_member_leftovers(" -- src/
Sibling: src/kiro_crew/dashboard/agent_admin/installed_agents.py:367 -- changed here
Sibling: src/kiro_crew/dashboard/server_runtime/crewmate_prune.py:182 -- changed here
Sibling: src/kiro_crew/cli_commands_agent.py:519 -- not affected -- runs without the gateway, whose live session manager owns the map
Pattern harvest
Not generalizable: each removal step in this teardown names its own resource, and the missing one was a store keyed by a derived alias that no generic check could see.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)