Repository navigation
fix(crew): destroy a deleted crewmate's thread session entries - #28613
cruisercohen wants to merge 1 commit into
Conversation
778054b to
f3d6f3b
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Fixes a reported defect (#22486) at the teardown that skipped this step, and adds tests that fail on base. One note: the generation matcher re-implements an existing slot-key parser. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: when someone deletes a crewmate from the dashboard, its broken thread session record goes too, so recovering doesn't mean creating a new crewmate. FIX.
[FIRST-PRINCIPLES-REVIEWED] 2b2e431 Description read[DESCRIPTION-READ] 0372f40c2f96e398a373f5b261df2069980c90c6652c69ebe44ec1182f2f6579 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the missing teardown step goes into the shared crew-delete teardown, follows the same unclaimed-slug rule as the other steps, and goes through Notes
[DESIGN-REVIEWED] 2b2e431 Description read[DESCRIPTION-READ] 9fa33e17399ae5fb25c19bffa1c964f631d9560620b55221d221ed437c36a292 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 |
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: |
DELETE /api/agents/{name} left dashboard:member-<slug>[.memory-<store>]
in session_map.json with no supported way to clear it. The delete's shared
teardown now destroys those entries through the session manager when the
slug is unclaimed.
Fixes #22486
f3d6f3b to
2b2e431
Compare
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: |
|
Thanks for this PR. The CI run on this head never got runners, so its jobs were cancelled, and the branch is based on an older main. Could you update it onto the latest main (rebase or merge)? That starts a fresh CI run against current main, and we will review it once it is green. |
|
[operator: bolichen97] Continuing this in #32924; thanks for the start. |
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>
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 pinned thread's
session_map.jsonentries, so a bad slot record is not left behind with no way to remove it.The thread is keyed
dashboard:member-<slug>(V1) ordashboard:member-<slug>.memory-<store>(private store).DELETE /api/agents/{name}removes the config row, crew log, dashboard lock, avatar, goal check-ins, worktrees and private template copy, but never the session-map entry. Fresh start rotates the sid and keeps the key, a restart restores it, and member threads are not listed where a session can be deleted, so the entry outlives the crewmate.Why it matters
The issue reports a crewmate whose thread mounted only one MCP server because of a bad slot record. The only recovery was to make a new crewmate, leaving the dead record in place for good.
Not a goal
memory_stores._allocate_member_id); that is the companion issue, and fix(members): let a new crewmate start from a deleted one's memory #22947 builds on it.kirocrew agent delete. Only the gateway's in-memory map may rewritesession_map.json(it rewrites the whole file from memory), so the CLI path leaves the entries as before.What changed (motivation → approach → change)
dashboard:member-<slug>.memory-<store>is still insession_map.json.crew_removal._remove_member_leftovershas no step for the thread's session.dashboard/member_thread_teardown.destroy_member_thread_sessions, called from_remove_member_leftoverswhen the route passes the gateway's session manager. It resolves the slug from the config captured before the delete, skips everything when a live crew still derives the slug (_member_slug_is_claimed, the rule the other steps use), and callssessions.destroy(key)for each entry the map holds: the V1 key, the current store's key (named outright, so an entry a Fresh start left without a sid is reached), and earlier generations matched by the exact.memory-boundary frommapped_sids_by_key()(somember-mate-0a26…is not caught bymember-mate).destroyends a live process for the thread and deletes the map entry in one step. A failure is reported as afailedthread sessionrow and never fails the committed delete.crew-mode.mdsays what the delete does with the entries and why the CLI path does not.The new function lives outside
agent_admin/so the agents facade (at the 2,000-line cap) does not need another binding; it takes the claimed-slug predicate as an argument, so a patch of the facade's_member_slug_is_claimedstill reaches it.Backwards compatibility
Compatible: no request is refused and no response shape changes. The only new effect is that a deleted crewmate's thread session is destroyed. Its transcript file stays. Note for #22947 (adopting a deleted member's store): an adopted thread starts a new native session from the kept transcript instead of resuming the old sid.
Reader: src/kiro_crew/session.py:SessionManager.get_or_create -- dashboard -- a deleted crewmate's thread key no longer maps to a sid, so nothing resumes it; test_delete_destroys_the_departed_crewmates_thread_entries
Reader: src/kiro_crew/dashboard/server_runtime/crewmate_prune.py:_claimed_dashboard_slots -- dashboard boot -- the slot is no longer claimed as a dashboard session; same test
Tests
test/test_crew_delete_forgets_member_thread_session.py, through the real route with a realSessionMap:member-mate-0a2620b15f41…key and an unrelated chat stay (fails on main);destroythat raises still answers 200 with the row gone;_remove_member_leftoverswith no session manager (the CLI) leaves the map file byte-identical.Run locally (Linux, Python 3.12): the new file plus every test file naming the agents facade,
crew_removal,_remove_member_leftoversor a composition contract (81 files): 5375 passed, 9 skipped. black, isort, flake8 and mypy clean on the touched modules; file-line-cap, comment-history and docs_lint pass.Manual verification
N/A — unit coverage sufficient: the route test drives the real delete handler against a real session map file and asserts the entries left.
Related Issues
Fixes #22486
Sibling sweep
Swept:
git grep -n "_remove_member_leftovers(" -- src/Siblings:
kirocrew agent delete(left on purpose, see Not a goal); the sync and startup prunes call no teardown on main (#28052 adds one; the new parameter is optional, so it composes).Pattern harvest
Not generalizable: one teardown step missing from the crew delete; the existing steps already follow a shared unclaimed-slug rule, and this one now does too.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.