Skip to content

Exclude and re-root a descendant whose access differs from its embedding root's (#2895) - #2903

Merged
malibio merged 4 commits into
mainfrom
issue-2895-access-boundary-reroot
Sep 23, 2026
Merged

malibio merged 4 commits into
mainfrom
issue-2895-access-boundary-reroot

Conversation

@malibio

@malibio malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Closes #2895

Summary

Implements ADR-059 §7's defect path. Root-only membership still keeps access boundaries out of embedding aggregates by construction. When that is bypassed, three things happen:

  • Exclude. The aggregation walk leaves the boundary descendant and its subtree out of the root's vector.
  • Surface. It logs tracing::error! naming the root and the descendant.
  • Re-root. The descendant becomes its own embedding root.

How "access differs" is decided locally

SqliteStore::access_boundary(node) is the set of nearest restricted collections reached from the node's own classification. The walk starts at the node itself if it is a restricted collection, otherwise at its member_of edges, and then follows ADR-059 §1/§3. A descendant is a boundary when its set is non-empty and differs from its embedding root's. Candidates are found with one cheap subtree query: member_of holders (excluding person, whose edges are RBAC grants) and restricted collections. When the invariant holds there are none, and no walk runs.

Changes

  • New db/sqlite_store/embedding_roots.rs: access_boundary, access_boundaries_under, embedding_root_id.
  • NodeAccessor::access_boundaries_under drives the exclusion in aggregate_children_content. If the boundaries can't be read, it aggregates nothing rather than risk a leak.
  • get_embedding_root_id, the spawned-task walk, NodeEmbeddingService::find_embedding_root_id (replaces find_root_id), and the bulk-create and delete queueing all resolve through embedding_root_id.
  • refresh_for_rootness keeps a re-rooted descendant's embedding.
  • embed_root_node queues any boundary descendant that has no embedding yet. The edge that created the boundary edited no content, so nothing else would queue it.

Tests

  • access_boundary_descendant_is_excluded_and_rerooted_adr059 writes the member_of edge directly, bypassing assert_may_gain_parent. It asserts:
    • the root's aggregate excludes the descendant and grandchild text, but keeps a sibling and a node filed into an open collection;
    • an error-level defect log names both ids;
    • the descendant and grandchild resolve to the descendant;
    • the rootness refresh keeps the descendant's embedding and still drops an ordinary child's.
  • Mutation-checked: removing the exclusion, the re-rooting, or the refresh guard each fails the test.
  • embedding_aggregation_never_spans_an_access_boundary_adr059 still passes.

Docs

Companion edits are in nodespace-docs f3c13e3: ADR-059 §6 is reconciled with §2/§7, and the tree-root-only statements in data-layer.md and ADR-029 now carry the exception. data-layer.md also documents the local access comparison.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CbMVLf7z8mBEgn2xPsNLcB

…ing root's (closes #2895)

ADR-059 §7's defect path. Root-only membership keeps access boundaries out
of embedding aggregates by construction; when that is bypassed, aggregation
now leaves the boundary descendant and its subtree out of the root's vector,
logs the violation at error level naming both ids, and the descendant becomes
its own embedding root.

- SqliteStore::access_boundary / access_boundaries_under / embedding_root_id
  (new embedding_roots module): the nearest restricted collections reached from
  a node's own classification, compared against its embedding root's
- NodeAccessor::access_boundaries_under drives the exclusion in the shared
  aggregation walk
- get_embedding_root_id, the spawned-task walk, NodeEmbeddingService queueing,
  bulk create and delete all resolve through embedding_root_id
- refresh_for_rootness keeps a re-rooted descendant's embedding
- embed_root_node queues boundary descendants that have no embedding yet

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01CbMVLf7z8mBEgn2xPsNLcB
@malibio

malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #2903

Review Type: Initial Review (the PR has no earlier reviews or comments)

Summary

This PR adds the ADR-059 §7 defect path. It is a clear improvement. The access check lives in one place, the new SqliteStore::embedding_roots module, and all four embedding-root callers now go through it: get_embedding_root_id, the spawned-task walk, NodeEmbeddingService queueing, and bulk/delete. That replaces three hand-rolled parent-chain loops, so it also fixes a DRY problem. Aggregation fails closed when boundaries cannot be read.

I checked the boundary logic hardest, since this is an access-leak defense:

  • The two boundary functions agree. access_boundaries_under walks top-down and stops at each boundary. embedding_root_id walks top-down and each boundary it meets becomes the new comparison root. I traced four cases through both: a nested boundary, a same-access candidate with a boundary below it, an empty own-access candidate, and a restricted root with a same-restriction descendant. They give the same answer every time.
  • The depth caps do not leak. The CTE stops at depth 100, deeper than aggregation's MAX_AGGREGATION_DEPTH = 20. Anything the CTE misses is never aggregated.
  • The property path is correct. Reading $.collection.restrictedToMembers matches cloud-sync.md's nested-namespace statement.
  • Search finds a re-rooted descendant. Vector search (search_embeddings) has no parentless filter, so a re-rooted descendant's vector can be returned.

No blockers. There is one important gap in how quickly the defect path takes effect, plus some test-coverage gaps.

Requirements Check (issue #2895)

Acceptance criterion Status Notes
The boundary descendant and its subtree contribute nothing to the root's embedding ✅ aggregate_children_content skips boundaries and never pushes their subtree. The test checks both DESC and GRANDCHILD.
The defect is surfaced at error level, naming both ids ✅ tracing::error! with root_id and descendant_id. The test captures it and checks the ERROR level and both ids.
get_embedding_root_id and the spawned-task walk resolve to the descendant; it is embedded if embeddable ✅ Both use SqliteStore::embedding_root_id. queue_access_boundaries queues boundaries that have no embedding (see finding 1 for timing).
refresh_for_rootness keeps the re-rooted descendant's embedding ✅ The test tells kept from dropped by content hash, which is a good way to avoid a false pass from a stale marker.
A test writes the violating edge directly, bypassing assert_may_gain_parent, with the three assertions and a mutation check ✅ Raw INSERT INTO relationship. Removing the continue breaks the !contains("RESTRICTED_…") assertions by construction.
embedding_aggregation_never_spans_an_access_boundary_adr059 still passes ✅ Untouched; the pre-push gate passed.
Companion docs: ADR-059 §6 reconciled with §2/§7; data-layer.md and ADR-029 carry the exception ✅ nodespace-docs f3c13e3: the §6 table row, consequences and the membership paragraph are rewritten; data-layer.md gains a "How the defect path works" section; ADR-029's revision note gains the exception.
quality:fix ✅ Per the author; no lint suppression found.
Tests pass (test:all) ✅ The pre-push gate (full pyramid) passed.

Standards: no backward-compatibility code. find_root_id and MAX_PARENT_CHAIN_DEPTH are deleted, not deprecated, and have no remaining callers. No #[allow], no issue numbers in comments. References are by ADR.

Code Review Findings

1. 🟡 Important: a root vector already leaking stays leaked until something re-embeds the root

📁 packages/core/src/services/embedding_service.rs:369-372, 451-479; nodespace-docs architecture/data-layer.md (defect-path section)

The exclusion only takes effect when the root is next re-embedded. The bypassing member_of write edits no content, so:

  • The root keeps the restricted text. Its existing vector still holds the descendant's text, and stays searchable by meaning, until some unrelated content edit re-queues the root.
  • The descendant is not embedded yet. It is queued only from inside embed_root_node(root).
  • Some descendants are never queued. If the tree root is not embeddable (a date page or task), queue_for_embedding skips it and embed_root_node never runs. A text descendant restricted there is not embedded until its own content changes.

The docs say root-only membership is what makes an access-change trigger unnecessary. On the defect path that constraint has, by definition, been bypassed. Timeliness is outside the ACs, so this is not a blocker. The data-layer.md section still suggests the handling happens immediately, which overstates it.

Recommendation: add one sentence to data-layer.md's defect-path section: the exclusion applies at the root's next re-embed, and the write that creates the boundary does not trigger one. Also file a follow-up. The most likely bypass paths (sync apply, bulk import) could queue embedding_root_id(in_node) and its tree root whenever they write a member_of edge on a node that has a parent. That is a trigger, not a data migration, so CLAUDE.md allows it.

Principle: defense in depth, and docs that match behavior. A defense that runs only on an unrelated later event should say so.

2. 🟡 Important: the boundary logic is tested through one shape only

📁 packages/core/src/services/node_service/mod.rs:3067-3238; packages/core/src/db/sqlite_store/embedding_roots.rs

The one integration test covers an open root with a restricted descendant and a descendant filed into an open collection. The rest of the comparison logic in access_boundary and access_boundaries_under is untested:

  • Nested boundary. A boundary inside a boundary should resolve to the inner one in both embedding_root_id and access_boundaries_under(outer).
  • Restricted root. A descendant filed into the same collection should not be a boundary. One filed into a different or additional collection should be (the tie rule).
  • Restricted collection in the subtree. A has_child restricted collection should count itself at depth 0.
  • Persons. A person descendant with a member_of edge should not be a candidate.
  • Transitive restriction. A descendant filed into an open collection that is member_of a restricted one should be found via the member_of-out-of-a-collection step.
  • Queueing. queue_access_boundaries should create a stale marker for an unembedded boundary.

These are exactly the branches a later refactor of the set-equality or seed-depth rules would silently break. For example, changing access != root_access to !access.is_subset(..) would pass the current test.

Recommendation: add a small table-driven store-level test in embedding_roots.rs covering these six shapes. Assert on both access_boundaries_under and embedding_root_id for each, so the agreement between them is pinned (assert the invariant, not just the outcome).

Principle: test coverage should match how critical the code is. This is security logic with several branches.

3. 🟢 Suggestion: the subtree CTE runs twice on every embed

📁 packages/core/src/services/embedding_service.rs:372 and packages/core/src/behaviors/mod.rs:380

embed_root_node calls store.access_boundaries_under(root_id) through queue_access_boundaries. extract_content_for_embedding then calls it again through NodeAccessor::access_boundaries_under inside the aggregation. Each call is a recursive CTE over the whole subtree with two correlated EXISTS per row. The subqueries are indexed (idx_rel_in (in_node, relationship_type) plus the node primary key), and json_type is short-circuited behind node_type = 'collection'. The cost is small next to generating the embedding, but it is paid twice for every large document.

Recommendation: leave it for now. If embed latency on large trees ever matters, compute the set once in embed_root_node and pass it into both uses. The common path through embedding_root_id (one extra candidate query per queue call; access_boundary only runs when a candidate exists) is well optimized.

Principle: DRY, and avoiding repeated I/O.

4. 🟢 Suggestion: bulk create assumes every node shares one embedding root

📁 packages/core/src/services/node_service/bulk.rs:168-171, 427-430

The comment says all nodes in a bulk import share one root, so only first_parent's embedding root is queued. That was true for tree roots. Now a node in the batch can sit inside a boundary descendant while the first one does not, and then the wrong root gets queued. Bulk create does not write member_of edges and boundaries are defect-only, so this is minor.

Recommendation: reword the comment to "share the same tree; the embedding root of the first parent is assumed to cover the batch", or collect distinct embedding roots per parent (cheap, since parents are few).

Principle: comments should state an assumption accurately when the change affects it.

5. 🟢 Nit: the new doc paragraph is attached to the constant, not the function

📁 packages/core/src/behaviors/mod.rs:361-373

The doc block above const MAX_AGGREGATION_DEPTH, which you extended, rustdoc applies to the constant, not to aggregate_children_content. The misplacement was already there, but the new "never spans an access boundary / fails closed" contract belongs to the function. Move the constant above the doc block.

6. 🟢 Nit: inconsistent chunking of IN-lists

📁 packages/core/src/db/sqlite_store/embedding_roots.rs:165-190, 273-282

restricted_among splits its list into chunks of 900. embedding_root_id builds one IN-list of up to 999 ids without chunking. Both are well under libsql's variable limit, so this is not a bug. Either chunk both or drop the 900 chunking in restricted_among (a BFS frontier on a tree is small).

7. 🟢 Nit: this defect's log carries no error field

📁 packages/core/src/services/embedding_service.rs:440, 449, 453

queue_access_boundaries uses positional-format tracing::warn!, while the new error logs in behaviors/mod.rs use structured fields (root_id = %…). Structured fields would make these warnings searchable the same way.

Security notes (verified, no action)

  • Fails closed. If boundaries cannot be read, the root embeds its own content only. Failures of embedding_root_id in the queueing paths are logged and skipped, and cannot widen a vector.
  • Own-classification seeding is stricter than the cloud walk. It counts a node that is itself a restricted collection, and it compares multi-parent ties by set equality. Both only err toward excluding more content, which is the safe direction.
  • The person exemption is sound. A person's member_of edges are RBAC grants, and person behavior contributes nothing to a parent's vector.

Recommendation: APPROVE

The change meets every acceptance criterion, is architecturally cohesive and fails safe. Findings 1 (document the "next re-embed" timing, and file a follow-up) and 2 (table-driven boundary-shape tests) are strongly recommended. Neither blocks the merge.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

malibio and others added 2 commits September 23, 2026 11:03
- Add access_boundary_shapes_agree_across_exclusion_and_rerooting_adr059:
  nested boundaries, restricted root with same/different collection, the
  ties rule, a restricted collection in the subtree, the person exemption,
  an open collection nested in a restricted one, and a same-access candidate
  with a boundary below it. Each shape asserts both access_boundaries_under
  and embedding_root_id. Mutation-checked (subset-for-equality, person
  exemption, restricted-collection self-check).
- Move MAX_AGGREGATION_DEPTH above aggregate_children_content's doc block so
  rustdoc attaches it to the function.
- Structured tracing fields in queue_access_boundaries.
- Bulk-create comment states why one embedding root covers the whole import.
- Exclusion timing documented in nodespace-docs data-layer.md (8b353d4).

Skipped: computing the boundary CTE once per embed (the walk fetching its own
boundaries keeps the exclusion unbypassable; cost is small next to embedding
generation), and chunking embedding_root_id's IN-list (the chain is capped at
1000, far below SQLite's 32766 variables).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01CbMVLf7z8mBEgn2xPsNLcB
…from member_of only

Collections nest through member_of, never has_child. A collection may have
has_child children but never a parent, and a node with a parent cannot become
a collection (ADR-059 §2).

- Schema triggers collection_is_root_edge / collection_is_root_type refuse a
  has_child edge onto a collection and a type switch to collection on a
  child. has_child is written from about a dozen places, so the DDL is the one
  enforcement point that covers all of them, including sync and raw writes.
- Readable collection_not_root errors on the create, reparent
  (assert_may_gain_parent) and create_relationship paths.
- The collection exemption in both root-only membership guards is gone:
  collections never have parents, so it guarded nothing.
- Access boundaries: a collection is never a boundary or an embedding root.
  Candidates are member_of holders only, and the access walk follows
  member_of through collection nesting, without the restricted-collection
  self-check or the has_child step out of a collection.
- Tests: collection_is_always_a_root_adr059 covers create, move, relationship
  create, a raw edge insert and a type switch (mutation-checked: each trigger
  and each Rust check fails the test when removed). The boundary-shapes test
  drops its nested-collection shape, and the root-only membership store test
  now files a root collection and refuses an interior one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01CbMVLf7z8mBEgn2xPsNLcB
@malibio

malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary

Addressed (c43dad07):

Skipped:

Folded in after discussion (4580f30f): a collection is always a root (ADR-059 §2, nodespace-docs 864ee1a).

  • Collections nest through member_of. A collection may have has_child children but never a parent.
  • Enforcement:
    • schema triggers refuse a has_child edge onto a collection, and refuse switching a node that has a parent to collection;
    • the create, reparent and relationship-create paths also return a readable collection_not_root error.
  • A collection is no longer an access boundary or an embedding root. Boundaries come only from member_of. The collection exemption in both root-only membership guards is removed.
  • New test collection_is_always_a_root_adr059 covers create, move, relationship create, a raw edge insert and a type switch. It is mutation-checked against each trigger and each Rust check.

The pre-push gate passed, including e2e.

Re-Review Decision

RE-REVIEW NEEDED. 4580f30f adds a new invariant, schema triggers, and new write-path checks, and it changes the boundary logic.

@malibio

malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #2903 (Re-Review)

Review Type: Re-Review. Covers c43dad07 (review fixes) and 4580f30f (the new collection-is-root invariant). The initial review was on 06812f29.

Previous Review Summary: 7 recommendations. 5 addressed, 2 skipped with sound reasons, 0 open. The new work raises 1 minor issue (🟡) plus a few 🟢 notes.

# Finding Status
1 🟡 Exclusion only takes effect at the root's next re-embed ✅ data-layer.md has a "When it takes effect" bullet (docs 8b353d4). It is accurate and names root-only membership as the actual guarantee.
2 🟡 Boundary logic tested through one shape only ✅ Added the table-driven access_boundary_shapes_agree_across_exclusion_and_rerooting_adr059. It asserts both access_boundaries_under and embedding_root_id for each shape, so the two are held to agree. It is mutation-checked against subset-for-equality, the person exemption and the self-check. Shape (c) was correctly retired after 4580f30f, since that shape can no longer be built.
3 🟢 The boundary CTE runs twice per embed Skipped, with a good reason. Having the aggregation fetch its own boundaries is what makes the exclusion impossible to bypass.
4 🟢 Bulk-create comment ✅ Reworded
5 🟢 Doc attached to the constant ✅ Constant moved above the doc block
6 🟢 IN-list chunking is inconsistent Skipped, with a good reason. The chain is capped at 1000, far below the variable limit.
7 🟢 Unstructured warn logs ✅ Now structured fields

Requirements Check (issue #2895)

All criteria are still met.

  • Exclusion and re-rooting. Still in place. The boundary logic is simpler, and the table test covers it.
  • Error-level surfacing. Unchanged.
  • Rootness refresh. Unchanged.
  • Direct-edge test. Unchanged.
  • The ADR-059 aggregation test. Still passes; the gate passed.
  • Companion docs. Extended in 864ee1a:
    • ADR-059 §2 gains a "collection is always a root" paragraph, and the §6 table and restriction paragraph are updated;
    • ADR-037 gains a line on nesting;
    • data-layer.md adds the second structural constraint and describes the new walk.

The docs match the code.

Review of the new invariant (4580f30f)

Trigger correctness: verified.

  • Edge direction. The edge trigger checks new.out_node. For has_child, in_node is the parent and out_node the child; bulk_create_has_child, move_node and the old access walk all use this direction. So the trigger refuses a collection as a child and still allows a collection as a parent.
  • Type trigger. BEFORE UPDATE OF node_type fires on every UPDATE ... SET node_type = ?, including content updates that rewrite the type unchanged (nodes.rs:762/774/893/906/1062/1157). The WHEN new.node_type = 'collection' short-circuit makes the non-collection case almost free. For a collection, the EXISTS check is always false, because collections never have parents. So an unchanged-type update of an existing collection is never refused by mistake.
  • No bypass through REPLACE or UPSERT on node. No node insert uses INSERT OR REPLACE or ON CONFLICT DO UPDATE; the only upsert is on conflict. With immediate FKs, a node row always exists before its edge, so creating a collection row after its edge is impossible.
  • INSERT OR IGNORE does not skip it. RAISE(ABORT) aborts regardless of the statement's conflict clause.

Write-path sweep. No production path creates a collection under a parent:

  • Rust. collection_ops::create_collection passes parent_id: None, and CollectionService::create_collection uses create_node with no parent. The agent and CLI create collections through these paths or through path-to-id resolution.
  • Frontend. createNode in add-synced-database-dialog.svelte is parentless. The collection-node-viewer.svelte and collection-service.ts hits are placeholder or mock objects, not writes.
  • Type switch. No slash command switches to collection (core-plugins.ts:597).
  • Sync. The sync cold sweep (bulk_create_has_child) goes through assert_may_gain_parent, so it now refuses a batch that contains a collection child. This matches how that path already handles a member_of violation.

The guards and the access walk are simplified correctly.

  • Removing the collection exemption in assert_root_only_membership and assert_may_gain_parent is sound: the exemption now protected nothing, and deleting it follows YAGNI and the no-dead-code rule.
  • access_boundary is now a pure member_of walk, checking restrictions from depth 1 onward. It matches ADR-059 §1 once has_child cannot lead out of a collection.

Standards.

  • schema.rs. The change is pure DDL (CREATE TRIGGER IF NOT EXISTS) with no backfill or data migration, as the CLAUDE.md schema.rs rule requires.
  • References. Comments cite ADRs, not issue numbers.
  • No leftovers. No lint suppression, no #[allow], and no dead helpers: restricted_collection_sql is still used by access_boundary.
  • Error readability. Good. The shared collection_not_root prefix makes the Rust checks and the trigger RAISE messages read the same.

Code Review Findings

1. 🟡 assert_may_gain_parent now makes an extra round trip that loads full nodes, and its doc comment claims one

📁 packages/core/src/db/sqlite_store/nodes.rs:2626-2650

The new collection check calls get_nodes_by_ids (SELECT * FROM node), and then the existing chunked membership query runs.

  • Cost. On the cold-sweep path (bulk_create_has_child), that loads every child's full content and properties just to read node_type. A directory-sized batch pulls all its text into memory for a one-column check.
  • Stale doc. The comment above still says "A single chunked query keeps the bulk/cold-sweep path a single round trip", which is now false.

Recommendation: fold the check into the existing chunked query, for example SELECT n.id, n.node_type FROM node n WHERE n.id IN (...) AND (n.node_type = 'collection' OR (n.node_type != 'person' AND EXISTS(... member_of ...))). Then pick the error by node_type. That restores the single round trip and makes the comment true again. Principle: efficiency on a bulk path (fetch only what you need), and docs that match behavior. It is not a blocker, since the trigger is the real enforcement and correctness is unaffected.

2. 🟢 access_boundary no longer counts the node itself

📁 packages/core/src/db/sqlite_store/embedding_roots.rs:60-95

Removing the depth-0 restricted_among check is right for every node that can be a boundary candidate. One edge remains: the tree root is a restricted collection C, and a defect descendant is member_of C. Then root_access is computed without C, the descendant's access is {C}, and the descendant becomes a boundary. That errs toward excluding more, which is the safe direction. Because collections are never embedded, it also gives that descendant a vector it would otherwise lack. No change needed. A one-line note in the doc comment would save a later reader from re-deriving this.

3. 🟢 The in-transaction relationship path relies on the trigger alone

📁 packages/core/src/services/node_service/relationship.rs:580-590

The readable collection_not_root check is on create_relationship, and the nearby comment says the single-parent check is "Mirrored in create_relationship_in_tx". The collection check is not mirrored there, so that path gets the trigger's message. That message has the same prefix and is readable, so this is acceptable. Mention it only if someone expects the two paths to be the same.

4. 🟢 Nit: the placeholder id 'new' in the create-path error

📁 packages/core/src/services/node_service/crud.rs:469-473

When no id is supplied, the message reads collection 'new' cannot have a parent. Consider a dedicated wording such as "a collection cannot be created under a parent", or pass the parent id.

5. 🟢 Nit: a placeholder comment for the retired shape (c)

📁 packages/core/src/services/node_service/mod.rs (the boundary-shapes test)

The comment "(c) … cannot be built at all; see collection_is_always_a_root_adr059" explains why the letter is skipped, which is useful. You could just as well relabel the shapes. Optional.

Tests

collection_is_always_a_root_adr059 covers all five entry points: create, move, relationship create, a raw edge insert and a type switch. It also checks the positive case (a collection may have a has_child child) and the negative end state (no parent on the collection, no row for the refused node). The author reports each trigger and each Rust check was mutation-checked. The raw-insert case pins the trigger on its own, independent of the Rust guards. The updated store test in sqlite_store/mod.rs refuses an interior collection and still allows root-collection nesting.

Recommendation: APPROVE

Every previous finding was either addressed or skipped with a sound reason. The collection-is-root invariant is enforced at the right layer: DDL triggers cover all dozen has_child writers plus type switches, and Rust checks add readable errors. It removes a whole class of boundary shapes and simplifies the access walk to match. Finding 1 (fold the collection check into the existing query and fix the stale "single round trip" comment) is a quick fix and worth doing, but it does not block the merge.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

- assert_may_gain_parent finds collections and member_of holders in its
  existing chunked query, instead of a separate full-row fetch; the doc
  comment's single-round-trip claim holds again.
- access_boundary documents that a node never counts itself.
- collection_not_root takes an optional id, so a create without one reads
  "a new collection cannot have a parent" rather than "collection 'new'".

Skipped: a readable check in create_relationship_in_tx (the trigger's
collection_not_root message already names the rule), and relabelling the
boundary-shapes test (the shape (c) comment points to its replacement test).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01CbMVLf7z8mBEgn2xPsNLcB
@malibio

malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary (re-review)

Addressed (dbf68f94):

Skipped:

The pre-push gate passed.

Re-Review Decision

NO RE-REVIEW NEEDED. The changes are a query consolidation covered by the invariant test, a doc comment, and error wording.

@malibio
malibio merged commit be5a7d2 into main Sep 23, 2026
@malibio
malibio deleted the issue-2895-access-boundary-reroot branch September 23, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude and re-root a descendant whose access differs from its embedding root's

1 participant