Repository navigation
Reject reparenting a collection member into an interior position (ADR-059 §2) - #1772
Merged
Merged
Conversation
…-059 §2) The store guard from #1742 enforces root-only content membership at member_of write time; this adds the reparent side at the store's two has_child attach sites, symmetric with the forward guard: SqliteStore::move_node (the service move_node and upsert_node_with_parent reparent paths) and bulk_create_has_child (the sync-apply cold sweep, mirroring bulk_add_to_collections). A node that holds a member_of edge cannot gain a has_child parent — that would make it a forbidden interior member with no member_of write to catch it. The move is rejected rather than silently dropping the membership (a node can hold several member_of grants, each an independent access path), with an error naming the collections. The bulk check is one chunked query. Collection and person nodes are exempt; moving a member to root stays allowed. Closes #1765 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
|
APPROVE Store-level reparent guard verified through three independent adversarial reviews, each of which caught a real completeness gap and drove the enforcement to the correct layer:
980 lib + all integration + doctest targets green; clippy clean; pre-push gate (test:all + daemon build + e2e) green. Cold-sweep permanent-vs-transient handling tracked in nodespace-sync#378. Author=reviewer=mstomar125 self-approval per merge policy. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the reparent side of the root-only content-membership rule (ADR-059 §2). #1742 enforces it at
member_ofwrite time; this closes the reverse transition — a node that already holds amember_ofedge (a root member) being moved into an interior position, which would make it a forbidden interior member with nomember_ofwrite for the forward guard to catch.How
The guard is enforced at the store's two
has_childattach sites, symmetric with how #1742 enforced the forward direction at the store'smember_ofINSERT sites. Adversarial review confirmed these are the only two store paths that attach an existing node to a parent (the rest create fresh nodes or move already-interior ones), so gating both covers every reparent path by construction:SqliteStore::move_node— the serviceNodeService::move_node(outline drag/indent) andNodeService::upsert_node_with_parent(the gRPC upsert /save_node_with_parentTauri command; a distinct reparent path the first review caught bypassing a service-only guard).SqliteStore::bulk_create_has_child— the sync-apply cold sweep (apply_cold_rel_sweep_batched), mirroring Enforce root-only content membership for member_of edges as a store-aware relationship validation #1742's guard on its siblingbulk_add_to_collections.When a node's type is neither
collectionnorpersonand it holds one or moremember_ofedges, a move that would give it ahas_childparent is rejected with an error naming the collections (a single chunked query on the bulk path).member_ofgrants, each an independent access path; silently dropping them on an indent would revoke access with no record (Michael's decision on the issue's criterion 8).new_parent = None) — the guard only fires when the node would gain a parent.collection(nesting) andperson(grantee, ADR-037 §4) exempt — matching the forward guard.Adversarial review of the first (service-level) attempt found that
upsert_node_with_parentbypassed a service-only guard; moving the check to the store chokepoint closes that and any future reparent surface.Tests
test_reparent_guard_rejects_moving_a_member_under_a_parent:store.move_noderejects reparenting a member; non-member moves freely; move-to-root allowed; person exemption; andbulk_create_has_childrejects a member in a batch (cold-sweep parity).test_reparenting_a_collection_member_is_rejected: rejection via bothmove_nodeandupsert_node_with_parent, proof the membership is not dropped (second attempt still rejects), move-to-root still allowed.All core test targets green — 980 lib + integration + doctests, 0 failed. Reviewed adversarially three times: the passes caught the
upsert_node_with_parentbypass and thebulk_create_has_childcold-sweep gap in turn, both now closed and tested. The sync side of the cold-sweep rejection (permanent-vs-transient classification, so a bad incoming edge can't wedge the cursor) is tracked in nodespace-sync#378.Closes #1765