mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 16:14:40 +00:00
deleteNote() removed the target from its parents, gatherers, and the cache map, but never cleared its own child collections nor dropped itself from its children's replyTo. That left a partial deletion: every child kept the removed shell alive through replyTo (a leak), and a reply resolved later via computeReplyTo would getOrCreateNote a *second* Note for the same id — breaking the one-Note-per-id invariant. Adds Note.detachFromChildren(), which clears the note's forward child collections (via removeAllChildNotes) and severs this note from each child's replyTo (keeping any other parents). deleteNote() now calls it before notes.remove(), so once the note leaves the map nothing points at the dead shell. Orphaned replies become roots, which is correct once their parent is hard-deleted from the cache. Adds detachFromChildren coverage to NotePruningReferenceTest. https://claude.ai/code/session_01RqJPYzmjb1pR3NBeH2yY3s