fix(reset,stop): warn before a reset purges, skip and prune stale registries, refuse a guessed purge

reset.sh without --yes says the conversations are deleted for good before it
asks; without a terminal the refusal says so too. A registry that cannot be
created is skipped, since nothing can be registered there, and the directories
the fence created are removed on exit when still empty. stop --purge-conversation
refuses a conversation the row does not record instead of deleting the folder's
newest one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-31 07:56:07 +09:00
1 parent 12e140322d
commit 022c656052
9 files changed
+201 -28

No files matched your search

+29
View File
@@ -622,6 +622,35 @@ def test_rev2_claude_unpinned_sibling_row_skips_creator_claimed_id(mam_sandbox,
# --------------------------------------------------------------------------- Done Criterion 6 (id_order & create/resume wait)
@pytest.mark.parametrize("recorded", [None, UB])
def test_purge_refuses_a_conversation_the_row_does_not_record(mam_sandbox, mock_herdr, mock_agents, recorded):
"""A pre-assigned row with no usable id: the folder's newest conversation may be
anyone's, so a purge refuses and changes nothing. A plain stop records it, and
the purge after that (a deliberate second step) deletes it."""
ws = mam_sandbox / "claude-guess-ws"
ws.mkdir(parents=True, exist_ok=True)
epoch = int(time.time()) - 100
transcript = _claude_transcript(mam_sandbox / ".claude" / "projects", ws, UA)
name = "claude-guess-ws-creator-claude"
_mock_herdr_agent(mock_herdr, name, ws, 5001, epoch, agent="claude")
_write_rows(mam_sandbox, [_row(name, "claude", ws, epoch, pid=5001, claude_session_id_own=recorded)])
res = _run_stop(mam_sandbox, name, "claude", purge=True)
assert res.returncode == 1, res.stdout + res.stderr
assert "refusing to purge" in res.stderr and UA in res.stderr
assert transcript.exists()
row = _read_rows(mam_sandbox)[name]
assert row["status"] == "running" and row["claude_session_id_own"] == recorded
assert name in json.loads(Path(mock_herdr).read_text())["agents"]
if recorded is None:
assert _run_stop(mam_sandbox, name, "claude").returncode == 0
assert _read_rows(mam_sandbox)[name]["claude_session_id_own"] == UA
purge = _run_stop(mam_sandbox, name, "claude", purge=True)
assert purge.returncode == 0, purge.stdout + purge.stderr
assert not transcript.exists()
def test_c6_create_waits_or_refuses_while_same_cwd_post_discovered_row_has_no_id(
mam_sandbox, mock_herdr, mock_agents
):