Repository navigation
Re-queue the old embedding root when a node leaves its tree - #2936
Conversation
…2907) refresh_for_rootness now takes the former has_child parent. After the edge write it queues that parent's embedding root when it differs from the node's new root, so the tree a node left is re-embedded instead of keeping the departed subtree's text (stale search, and an ADR-059 §7 leak after an outdent-then-file into a restricted collection). Covered paths: move_node, move_node_unchecked, create_parent_edge (its store move replaces an existing parent), delete_relationship and remove_relationship_in_tx for has_child. The tx path now records the embedding half on NodeServiceTx and with_transaction runs it after commit, so a rolled-back transaction queues nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Pragmatic Code Review: PR #2936 (closes #2907)Review Type: Initial Review (the PR had no reviews or comments before this one) SummaryThis is a clean, well-targeted fix.
The
A side benefit: the tx paths ( Ran Requirements Check
Code Review Findings🟡 Important1. The issue lists this path under "Paths to cover" and asks to "audit every call site; each one that can change the parent must queue the old root". In practice, split targets are fresh siblings in the same tree, so today's real-world impact is probably zero. That is why this is 🟡 and not 🔴. Recommendation: pick one:
Either way, the audit result should be explicit. 🟢 Suggestions2.
This is rare and user-initiated, so a follow-up issue is fine. Also add a one-line comment at the call site explaining why 3. let rebuilt = TextNodeBehavior.get_aggregated_content(&root_a, &svc).await.unwrap_or_default();
assert!(!rebuilt.contains("LINE_TEXT"), ...);
4. The current root is resolved twice per detach
Nits
CLAUDE.md adherence✅ No backward-compat code, no lint suppression, no issue numbers in code comments (only ADR references). Comments explain why. The call-site signature change was applied everywhere in the same PR, with no dual API kept. Recommendation: APPROVEThe change is a clear net improvement and is correct on every path it touches. The deferred-after-commit mechanism is well built and tested for both commit and rollback. Address finding 1 before merge, either by covering |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
…ile test - move_children_to_parent: the new parent need not be in the children's tree, so capture each child's parent during pre-validation (this also replaces the separate root check) and refresh with it after the edge swap. New cross-tree batch test, mutation-checked. - Outdent-then-file test: the aggregate was None after the outdent and unwrap_or_default made the exclusion assertion vacuous. Keep a child in the old tree so the rebuilt aggregate is real text, assert it before and after, and expect() rather than default. - merge_nodes: comment why the survivor has no former parent. Skipped: the double root lookup per detach (negligible for interactive moves) and the unused parameter in a non-nlp build (that build does not exist). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Review addressed (96b7858)✅ 🟡 1. ✅ 🟢 2. ✅ 🟢 3. The aggregate assertion couldn't fail: confirmed and fixed. After the outdent ✅ Nit, repeated ⏭️ 🟢 4. Double root lookup: skipped. The cost is negligible for interactive moves; worth revisiting only if a bulk detach path appears. Tests: Re-review needed: yes. #1 adds new behavior on a public API path. |
Pragmatic Code Review (Re-Review): PR #2936 (closes #2907)Review Type: Re-Review. Scope is the new commit only: Previous Review Summary
Requirements Check
Code Review Findings🟢 Verified correct (answers to the specific checks)1. The refresh ordering matches
2.
3. The rewritten outdent-then-file test can now fail.
4. The It records the deliberate 5. The It reads "the parent the write took away: Nits
CLAUDE.md adherence✅ No lint suppression, no backward-compat shims, and no issue numbers in comments (only ADR refs). Comments explain why ("The new parent need not be in the children's tree, so each child may have left one"). Recommendation: APPROVEEvery prior recommendation was addressed or skipped with a sound reason. The |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Re-review addressed⏭️ Nit, one refresh per child in No code changes. No re-review needed. The PR is ready for merge at the maintainer's discretion. |
Closes #2907
Problem
When a node left a tree (outdent to root, reparent across trees,
has_childedge delete), only its new embedding root was queued. The old root's vector kept the departed subtree's text. That caused stale search results, and an ADR-059 §7 leak after an outdent followed by filing the line into a restricted collection.Fix
refresh_for_rootnesstakes aformer_parent. After the edge write,queue_former_embedding_rootqueues that parent's embedding root when it differs from the node's current root, so a move within one tree adds nothing. Every call site now has to say whether it detached.move_node,move_node_unchecked,create_parent_edge(its storemove_nodereplaces an existing parent),delete_relationshipandremove_relationship_in_txforhas_child. Audited sites that never replace a parent passNone: append/generichas_childcreate, bulk cold-sweep attach, merge survivor.refresh_for_rootness_in_txrecords the embedding half onNodeServiceTx.with_transactionruns it only after a successful commit, and a rollback queues nothing. Side effect: tx edge writes now also queue the gained tree, which they never did.refresh_for_rootnessis split into a title half and an embedding half (refresh_embedding_for_rootness) so the tx path can reuse the embedding half.Tests
New
former_embedding_root_testsmodule (9 tests): outdent (checked and unchecked), cross-tree reparent (both roots queued),create_parent_edgereparent, relationship-API edge delete, tx edge delete after commit, rollback queues nothing, move within one tree queues only that tree, and outdent then file into a restricted collection (old root queued, rebuilt aggregate excludes the line).Mutation check: disabling the former-root queue fails all 7 tests that expect a queue. The within-tree and rollback tests are negative guards. The "queued once" part of the within-tree criterion can't be observed at the stale-marker level, because marking a root stale is idempotent.
nodespace-corelib: 1726 passed. Pre-push gate green.Out of scope / follow-up
merge_nodesdeletes the loser without queuing the loser's tree. That's the same stale-aggregate class, but it isn't a node leaving its tree.🤖 Generated with Claude Code