Skip to content

Reject reparenting a node that holds a member_of edge into a non-root position (ADR-059 §2 criterion 8) #1765

Closed

Description

@mstomar125

Overview

Follow-up split out of #1742. The store-level guard from #1742 enforces root-only content membership at member_of write time. It does not cover the reverse transition: a node that is already a valid root member of a collection can be made interior by an outline move (move_node), which gives it a has_child parent while it still holds its member_of edge. No member_of write happens, so no guard fires, and the invariant (ADR-059 §2: a content node may be a member of a collection only when it is a root) is silently violated through ordinary UX.

Where

packages/core/src/services/node_service/hierarchy.rs — move_node (the indent/reparent path) never re-checks membership after assigning a new has_child parent.

Decision (per #1742, criterion 8)

Reject the move, do not silently drop the membership. A node can hold multiple member_of grants, each an independent access path; dropping them on an indent would silently revoke access with no record. Promotion is also wrong (it moves classification to a node the user didn't file).

Acceptance

  • move_node that would give a node a has_child parent while it holds one or more member_of edges is rejected with an actionable error naming the node and the collection(s) it is a member of
  • Moving a node that holds no membership is unaffected
  • Person/collection nodes are unaffected (they are exempt from the root-only rule)
  • Test: file a root content node into a collection, then attempt to indent it under another node → rejected, membership intact
  • bun run test:all green

Related

Activity

  1. self-assigned this
    on Jul 28, 2026
  2. mstomar125 commented on Jul 28, 2026

    @mstomar125
    ContributorAuthor

    Resolved by #1772 (squash-merged fd5b417c).

    The reparent side of ADR-059 §2 (issue #1742's criterion 8) is now enforced at the store's two has_child attach-an-existing-node sites — SqliteStore::move_node (covers the service move_node outline-edit path and the upsert_node_with_parent gRPC / save_node_with_parent path) and SqliteStore::bulk_create_has_child (the sync-apply cold sweep) — symmetric with #1742's forward guard on member_of inserts. A node holding a member_of edge cannot be given a has_child parent; the move is rejected (not silently dropped — a node may hold several grants, each an independent access path) with an error naming the collections. Collection and person nodes are exempt; moving a member to root stays allowed.

    Adversarial review was decisive here — three passes caught, in turn, the upsert_node_with_parent bypass and the bulk_create_has_child cold-sweep bypass that a service-only guard would have shipped. 980 lib + integration + doctests green.

    Follow-up: the cold-sweep now produces permanent root-only rejections on the has_child batch as well as member_of; nodespace-sync#378 is updated to classify both as permanent (skip + advance the cursor) so a contradicting incoming edge can't wedge the sweep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions