fix(agents): only a canonical uuid reaches any claude path (Issue #31, review)
The user asked for no path at all from an id that is not a uuid. bd09c6a
still took `<id>.jsonl` for one (the pre-#31 reach), which has_artifacts and
the residual counted while in-use always said free: `purge claude notes`
deleted notes.jsonl. Now purge, has_artifacts and residual return nothing
for such an id, as in-use already did.
This makes test_a4_adapter_contract.py::test_purge_artifacts_composite fail:
it purges the claude id 'uuid-c' and expects uuid-c.jsonl gone. Editing an
existing test needs the user's approval; the one-line data change
(a canonical uuid in place of 'uuid-c') is kept outside the branch, in job
90efa4ce's report dir. Reverting this commit restores the jsonl-only reach.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dd292c12cb
commit
81b6c2ea6b
2 files changed
+25
-26
No files matched your search
@@ -420,27 +420,29 @@ def test_claude_roots_may_be_links(home, tmp_path, monkeypatch, conv):
|
||||
assert adapter.residual_artifacts(conv, ctx) == []
|
||||
|
||||
|
||||
def test_a_non_uuid_id_takes_only_its_transcript_file(home, tmp_path):
|
||||
"""The pre-#31 reach, kept for ids that are not uuids (test_a4 purges
|
||||
"uuid-c"): the `<id>.jsonl` file, never a directory of that name."""
|
||||
@pytest.mark.parametrize("name", ["uuid-c", "memory", "notes"])
|
||||
def test_a_non_uuid_id_reaches_nothing(home, tmp_path, name):
|
||||
"""Only a uuid names a claude session: no path is built for any other id,
|
||||
not even the `<id>.jsonl` the adapter took before #31."""
|
||||
ws = tmp_path / "ws"
|
||||
ws.mkdir()
|
||||
proj = home / ".claude" / "projects" / workspace_key(str(ws))
|
||||
proj.mkdir()
|
||||
jsonl = proj / "uuid-c.jsonl"
|
||||
jsonl.write_text("{}\n")
|
||||
kept = [proj / "uuid-c" / "a", home / ".claude" / "file-history" / "uuid-c" / "b"]
|
||||
for p in kept:
|
||||
jsonl = proj / f"{name}.jsonl"
|
||||
jsonl.write_text(json.dumps({"sessionId": name, "cwd": os.path.realpath(str(ws))}) + "\n")
|
||||
kept = [jsonl, proj / name / "a", home / ".claude" / "file-history" / name / "b"]
|
||||
for p in kept[1:]:
|
||||
p.parent.mkdir(parents=True)
|
||||
p.write_text("x")
|
||||
adapter = get_adapter("claude")
|
||||
ctx = _ctx(ws, home)
|
||||
|
||||
assert adapter.has_artifacts("uuid-c", ctx) is True
|
||||
assert adapter.residual_artifacts("uuid-c", ctx) == [str(jsonl)]
|
||||
assert adapter.purge_artifacts("uuid-c", ctx) == [str(jsonl)]
|
||||
assert not jsonl.exists() and all(p.exists() for p in kept)
|
||||
assert adapter.residual_artifacts("uuid-c", ctx) == []
|
||||
assert adapter.has_artifacts(name, ctx) is False
|
||||
assert adapter.residual_artifacts(name, ctx) == []
|
||||
assert adapter.purge_artifacts(name, ctx) == []
|
||||
res = _agents_cli(["purge", "claude", name, str(ws)], ws)
|
||||
assert json.loads(res.stdout)["purged"] == [], res.stdout + res.stderr
|
||||
assert all(p.exists() for p in kept)
|
||||
|
||||
|
||||
def test_purge_cli_resolves_claude_from_leftovers_only(home, tmp_path, conv):
|
||||
|
||||
Reference in new issue
Block a user