Delete by id can leave the deleted episode in its cluster
Summary
Deleting an episode by id can leave it as a member of its profile cluster: after delete_by_ids returns, the deleted episode is gone from Markdown but find_cluster_for_member still returns its cluster. The memory-delete property test (tests/unit/test_properties/test_memory_delete_jitter.py, invariant J1a / J2 "a returned by-id deletion left its closure nowhere") finds it.
Reproduce
On main (c3228464), from the repository root:
uv run python - <<'PY'
from tests.unit.test_properties.test_memory_delete_jitter import (
test_deletions_and_writers_keep_their_invariants as t,
)
t.hypothesis.inner_test(
first=[("add", "s1", ("u1",)), ("add", "s1", ("u1",)),
("add", "s1", ("u1",)), ("add", "s1", ("u3",))],
second=[("cluster", "u3"), ("del_id", "u3")],
seed=0, crash=None, disk_full_at=None,
)
PY
It fails every time (3 of 3 runs):
AssertionError: ('by-id closure still clustered', 'u3', 'ep_<date>_00000001')
assert 'cl_…' is None
The same example fails on v1.6.0 (9cd1be60). The minimal sequence: one message for u3, a clustering pass for u3, then a by-id deletion of u3's episode.
Expected
After a by-id deletion returns, no cluster lists the deleted episode (or anything in its closure) as a member.
Notes
- CI does not see this: the property test runs derandomized there, and this example is not among the ones it draws. It was found by a local run with a persistent Hypothesis example database (2 of 20 local runs drew it).
- Found while testing #594 (purge), which does not touch the deletion or clustering code; the replay above is on
mainwithout that branch. - One other local run of the same test failed with a
FileNotFoundError(profile extraction reading auser.mdthat a deletion had just removed). Whether it shares this cause is not established.
i want to take it。