Repository navigation
Enforce root-only content membership for member_of edges (store-level, ADR-059 §2) - #1768
Merged
Merged
Conversation
…sites A content node may hold a member_of edge only when it is a root node (no has_child parent); collection and person nodes are exempt (collection nesting; grantee membership per ADR-037 §4). Add assert_root_only_membership to SqliteStore and call it at all three member_of write sites — add_to_collection, bulk_add_to_collections, and create_generic_relationship (which carries member_of when an explicit order is supplied) — so every write path is gated without a per-path check: CLI, graph import, playbook add_relationship, and the sync-apply cold-sweep. The bulk validation is one chunked query to keep the cold-sweep path a single round trip. Interior nodes are rejected with an actionable, node-naming error. Closes #1742 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
|
APPROVE Store-level enforcement verified through two independent adversarial reviews.
Full core lib suite 975/975; clippy clean; pre-push gate (test:all + daemon build + e2e) green. Author=reviewer=mstomar125 self-approval per merge policy. |
12 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
Enforces root-only content membership for
member_ofedges (ADR-059 §2): a content node may be a member of a collection only when it is a root node (nohas_childparent).collectionnodes (nesting) andpersonnodes (grantee membership, ADR-037 §4) are exempt.The rule is enforced at the store level so every write path is covered by construction — CLI, graph import, playbook
add_relationship, and the sync-apply cold-sweep — rather than by a per-path check that a future path could miss.How
A new
SqliteStore::assert_root_only_membership(member_ids)runs before all threemember_ofINSERT sites:add_to_collection(single, auto-order)bulk_add_to_collections(the path the sync-apply cold-sweep and daemon import call directly)create_generic_relationshipwhen itsrel_typeismember_of— reached when a caller supplies an explicitorder(NodeService::create_relationship's non-auto-order fork, playbookadd_relationship, CLIrelationship create --edge-data)The bulk check is a single chunked
IN (...)query (node type + parent presence in one round trip), so the performance-sensitive cold-sweep path stays one query, not 2×N point lookups. Interior nodes are rejected with an actionable, node-naming error (member_of_not_root: content node '<id>' …).Acceptance criteria (issue #1742)
member_ofwrite rejected; ✅ root content write succeedsbulk_add_to_collections), not only local writesTests
Two store-level tests:
test_root_only_content_membership_is_enforced(root ✓, interior ✗ via bothadd_to_collectionandcreate_generic_relationship, person/collection exemptions, restricted-task-in-open-project end-to-end) andtest_bulk_root_only_membership_is_enforced(all-root batch applies; a batch with one interior node is refused — cold-sweep parity). Full core lib suite: 975 passed / 0 failed.Review
Two independent adversarial reviews. The first caught a real High-severity bypass —
create_generic_relationshipwas an unguarded thirdmember_ofwriter reachable by adding oneorderkey — which is now fixed and covered by a test. A focused second pass confirmed the fix is complete (exactly threemember_ofwriters, all guarded) and introduces no false positives.Closes #1742