Repository navigation
Emit RelationshipDeleted on move-to-root and reparent (move_node) - #1408
Conversation
move_node deletes the old has_child edge in the store, but only emitted a RelationshipUpdated for the NEW parent (gated on Some). A move-to-root (new_parent = None) therefore emitted no relationship event at all, so the detach never reached consumers (cloud sync left the node parented on other devices); a reparent left the old edge unannounced. Capture the old parent before the move and, when the parent actually changes (move-to-root OR reparent), emit a RelationshipDeleted for the old parent edge after the new-parent RelationshipUpdated — insert-before-delete order so a consumer never sees the node parentless mid-move. A same-parent position move emits nothing new. Needed by nodespace-sync's full-graph sync (epic #162): the daemon pushes this delete to remove the stale cloud has_child edge. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
REQUEST CHANGES ⏳ Initial review, top commit The fix itself is correct and nicely scoped. I traced each path:
Event shape is consistent with every sibling site: the One blocking gap: 🟡 No regression test for a sync-critical behaviour change. This PR alters the emit contract of
Please add a test (or three) asserting: (a) move-to-root emits a Two non-blocking notes: 🟢 🟢 Extra pre-move read. Net: correct, well-reasoned fix with consistent event shape — just needs the regression test that turns "I built the daemon and watched it push the delete" into something CI can keep enforcing for #162. |
) move_node deletes the old has_child edge in the store, but only emitted a RelationshipUpdated for the NEW parent (gated on Some). A move-to-root (new_parent = None) therefore emitted no relationship event at all, so the detach never reached consumers (cloud sync left the node parented on other devices); a reparent left the old edge unannounced. Capture the old parent before the move and, when the parent actually changes (move-to-root OR reparent), emit a RelationshipDeleted for the old parent edge after the new-parent RelationshipUpdated — insert-before-delete order so a consumer never sees the node parentless mid-move. A same-parent position move emits nothing new. Needed by nodespace-sync's full-graph sync (epic #162): the daemon pushes this delete to remove the stale cloud has_child edge. Co-authored-by: Mayank Tomar <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Problem
move_nodedeletes the oldhas_childedge in the store, but only emitted aRelationshipUpdatedfor the new parent (gated onSome(parent)). So:new_parent = None) emitted no relationship event — consumers never learned the node detached.For NodeSpace sync (epic NodeSpaceAI/nodespace-sync#162) this meant outdenting a node to the top level never propagated to other devices — the node stayed parented elsewhere.
Fix
Capture the old parent before the move; when the parent actually changes (move-to-root or reparent), emit a
RelationshipDeletedfor the old parent edge after the new-parentRelationshipUpdated(insert-before-delete order, so a consumer that inserts-then-deletes never sees the node parentless mid-move). A same-parent position move emits nothing new.Reuses the existing
RelationshipDeletedevent (no new variants),node_thing-normalized endpoints like the other emit sites.Verified
Built the sync daemon against this branch: the daemon now pushes the edge delete on move-to-root (
supabase push: has_child edge deleted parent=… child=…).cargo check -p nodespace-coreclean. (Full e2e propagation also needs the live tenant'srelationshipstable atREPLICA IDENTITY FULL— already in the tenant schema template — so the realtime DELETE carries the endpoints.)