Repository navigation
fix(dashboard): remove a deleted crewmate's dashboard structure lock - #21660
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] b4a754c Description read[DESCRIPTION-READ] adcdeee26a1f030a0026d40ff0f590ff32198477290c70b03c5ffe55f12743bd 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 to check. What this change shipsInventory (6 items) — 6 justifiedIntent: when a person deletes a crewmate, its dashboard structure lock goes too, so a later crewmate with the same slug does not start out locked to the deleted one's page. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] b4a754c Description read[DESCRIPTION-READ] 765ad753a20ab5080604580ba61b4d1bf8fd7b0148d5e9ef8f71f4199936a893 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: |
dad080b to
fda8e03
Compare
The person's structure lock lives in crew-panels/<slug>.dashboard-lock, outside members/<slug>/, so no step of the crew delete teardown reached it. The file outlived the crewmate, and a later crewmate deriving the same slug started out locked to the old one's page snapshot. The delete route now removes it next to the crew-log reclaim and under the same authorization: the slug resolved from the config captured before the delete, the decision taken inside the memory-store namespace lock, and the removal only while no crew on disk still derives that slug. remove_structure_lock takes the lock's own guard, re-asks the roster under it, and unlinks only the lock file; a slug a live crewmate claims keeps its lock. Fixes #19365 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit de67cc2)
…atch The autouse home fixture now patches through _floor_monkeypatch, and the aliased-store case scopes its patch with monkeypatch.context() instead of undoing the shared instance, so neither can lift the other's patches (semgrep test-autouse-shared-monkeypatch and test-bare-monkeypatch-undo). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 225f2d1)
fda8e03 to
b4a754c
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Good to ship. No blocking issues and no should-fix notes.
Head reviewed: b4a754c.
What I checked on this head:
remove_structure_locktakes the same<slug>.dashboard-lock.guardthatset_structure_lockholds, and asks the claim predicate under it. A live or recreated namesake keeps its lock.- The slug comes from the config captured before the record was dropped, so a crewmate with an explicit
member_idloses the right file. This matches_reclaim_deleted_member_crew_log. - The call runs inside
_drop_from_team, undermemory_store_namespace_lock, and on a worker thread through_drained_to_thread. The bounded guard poll does not block the event loop. - A guard timeout or an aliased store raises inside the step, and the step logs it and returns. A delete never fails because of the lock.
- The fast path returns before the guard when no lock exists, so a crewmate that never locked leaves nothing in
crew-panels. instance.pystays at 1,999 lines. The spec and theset_structure_lockdocstring name the delete route as the second remover.- The 12 tests cover removal, the
member_idslug, a sibling, a namesake, an unreadable roster, the predicate under the guard, unsafe names, and the real DELETE route under the namespace lock. - The linked issue is tier T2. No path is on the security denylist. All required checks on this head are green.
Problem / Motivation
Goal: Deleting a crewmate removes its dashboard structure lock, so a later crewmate that derives the same slug does not start out locked to the deleted one's page.
Deferred finding from #18687. The person's structure lock is the file
crew-panels/<slug>.dashboard-lock. It sits outsidemembers/<slug>/on purpose, so the agent's shell cannot clear it, and for the same reason none of the existing delete teardown steps reach it.DELETE /api/agents/{name}removes the config record, the memory store, the crew log, the avatar and the private template copy, but it leaves the lock file on disk with no owner. Any later crewmate whose slug matches then opens withstructure_locked: trueand the old crewmate's snapshot served as its page.Why it matters
The issue rates this low-risk: slugs come from UUID-derived
member_ids, which are not reused. Still, a lock file with no owner is state that nothing ever collects. And if a slug does come back, for example a legacy crewmate whose slug derives from its name, the new crewmate cannot adopt, apply or roll back a page until the person finds the lock and clears it from the Profile card.Not a goal
crew-panelsfiles (the published panel record<slug>.jsonand the lock's.guardfile). The guard is deliberately kept, see below._commit'sInstanceLocked, the owner-gatedhuman_onlyroute).members/<slug>/or any other per-member tree.What changed (motivation → approach → change)
Symptom → cause → change:
crew-panels, which only the gateway writes. The delete route's teardown only ever touched the member's own tree and the crew-log store, so it never removed the lock._member_slug_is_claimed, the slug is resolved from the config captured while the record still existed, and the call runs insidememory_store_namespace_lock, the one seam every member-id allocator shares.dashboard_templates/structure_lock_removal.py(new module):remove_structure_lock(slug, *, still_unclaimed).crew-panels.<slug>.dashboard-lock.guardlock thatset_structure_lockholds, asksstill_unclaimed()under it, and only then unlinkslock_path(slug)and fsyncs the directory.FileNotFoundError.lock_path, which reusespanel_dir(), so a session key and an aliased (symlink/junction) store are still refused before any I/O.agent_admin/crew_removal.py: new_reclaim_deleted_member_dashboard_lock(name, cfg). It is best-effort and never raises, like every other step of the teardown._delete_membercalls it right after_reclaim_deleted_member_crew_log, inside the namespace-lock hold. It is re-exported fromhandlers/agents.pyso it runs on the facade globals, as the composition contract requires.crew-panels/<slug>.json(the published panel record), is left in place on purpose, and here is why it does no harm.agent_panel.publishasksowner_is_liveinside its lock and hands over a record whose owner the roster no longer holds (handlers/agent_panel.py:_owner_is_live).api_member_panel, refuses a record owned by a different exact crew name.member_id. That crewmate sees the old published panel until its first publish replaces it. The data is the same owner's, the route is owner-gated, and it is replaced rather than enforced.docs/system-specs/modules/dashboard-instances.md("The structure lock is the person's, and only theirs") now says the delete route is the lock's second remover, and under what conditions.Backwards compatibility
Compatible: no route, field, validator or API changes shape. The delete route answers exactly as before, and the new step is best-effort, so a lock that cannot be removed never fails a delete.
Reader: src/kiro_crew/dashboard_templates/instance.py:read / _lock_snapshot -- crew page -- reads per slug; only a slug no roster crewmate derives loses its file, and "missing" reads as unlocked, the intended state for a later crewmate (
test_delete_removes_the_departed_crewmates_lock)Reader: src/kiro_crew/dashboard_templates/instance.py:_commit / is_locked -- chat | subagent (dashboard MCP apply/rollback) -- same per-slug read; a live crewmate's lock is kept (
test_a_recreated_namesake_keeps_its_lock,test_other_crewmates_locks_are_untouched)Reader: src/kiro_crew/dashboard/handlers/member_dashboard.py:api_member_dashboard / api_member_dashboard_lock -- crew page --
_resolveanswersmember_not_foundfor a deleted crewmate before the lock is read, so nothing changes for itReader: src/kiro_crew/dashboard_agentic.py:LOCKED turn line -- chat -- built from
read()'sstructure_locked, so it follows the same per-slug answer as aboveTests
New
test/test_crew_delete_dashboard_lock.py(12 tests):test_delete_removes_the_departed_crewmates_lock: the delete teardown removes the lock andis_lockedreads false afterward.test_the_lock_is_found_by_the_persisted_member_id: a crewmate with an explicitmember_idloses the lock under that id, and the lock under its folded name (a different slug) is kept.test_other_crewmates_locks_are_untouched: a sibling's lock file is byte-identical afterward.test_a_crewmate_that_never_locked_creates_nothing: no lock and no.guardfile appear.test_a_repeated_cleanup_is_a_no_op: a second removal is safe and returns False.test_an_unreadable_lock_file_is_still_removed: a damaged lock, which reads LOCKED because the check fails closed, is still collected.test_a_recreated_namesake_keeps_its_lock: the roster re-read under the guard decides, not the captured snapshot.test_an_unreadable_roster_removes_nothing: a config that does not parse keeps the lock.test_the_predicate_is_asked_under_the_guard_and_claimed_keeps_the_lock: while the predicate runs, a second non-blocking take of the guard fails, and a "claimed" answer removes nothing.test_a_session_key_has_no_lock_to_remove,test_an_aliased_store_is_refused_and_the_lock_kept: the existing name refusals still hold.test_the_delete_route_removes_the_lock_under_the_namespace_lock: the realDELETEroute answers 200 and removes the departed crewmate's lock while holding the namespace lock. The live crewmate's lock is kept.The second commit isolates these tests from the shared
monkeypatch, to satisfy semgreptest-autouse-shared-monkeypatchandtest-bare-monkeypatch-undo(SAST failed on the first head). The autouse home fixture now uses_floor_monkeypatch, and the aliased-store case scopes its patch withmonkeypatch.context(). Semgrep 1.78 does not run natively on this Windows box, so that fix is verified by CI's SAST job, not locally.Negative controls, run locally on the patched tree:
assert [] == [True]).lambda: Trueturnstest_a_recreated_namesake_keeps_its_lockandtest_an_unreadable_roster_removes_nothingred.Local gates (Windows, Python 3.13):
test_dashboard_structure_lock,test_crew_log_member_unit_reclaim,test_dashboard_agents_composition_contract,test_agent_delete_prunes_private_copy,test_agent_avatar,test_change_cards_identity,test_crew_memory_store_binding,test_members_dm_thread): 631 passed, 9 skipped. 4 failed, allWinError 1314raised inside the tests' ownsymlink_tosetup: this host does not grant the symlink privilege, so none of them reaches the changed code.check_black_formatting,check_subprocess_encoding,check_comment_history,check_brand_nameandtest_flake_pattern_ratchetall clean.mypy --platform linux src/kiro_crew: Success, no issues found in 2301 source files.scripts/local-gate.pydid NOT complete locally.agents.pyis a hub, so its related set is 941 backend test files, and collecting them did not finish within a 40-minute bound on this Windows box (killed by my timeout, rc=143, no test result either way). That run is left to CI. The suites that exercise the changed code directly are listed above.Manual verification
N/A — unit coverage sufficient: the change is a backend teardown step with no UI, and the route test drives the real
DELETE /api/agents/{name}handler against a real data home, real config and real lock files.Related Issues
Fixes #19365
Deferred from #18687.
Pattern harvest
Not generalizable: the class this belongs to ("per-member state stored outside
members/<slug>/needs its own reclaim step") is already handled step by step in this teardown, through the crew log, avatar and private copy. Thepanel_dir()docstring already tells whoever adds a member-space reaper to clearcrew-panelstoo. A rule cannot list per-member stores that do not exist yet.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code