Skip to content

Enforce that schema nodes are always roots (no parent via move/create) #3102

Closed

Description

@malibio

Context

Found while reviewing PR #3095, which made the store's schema delete guard (assert_schema_deletable) run on every schema in a deleted has_child subtree, not just the target.

Problem

Several places assume a schema node always sits at the root, but nothing enforces it:

  • validate_move (packages/core/src/services/node_service/hierarchy.rs) only restricts date nodes. A schema, including a core schema, can be moved under any container, including another schema's description.
  • delete_children_subtree_unchecked and its _in_tx twin (packages/core/src/db/sqlite_store/nodes.rs) document that the descendants are "never schema nodes" and skip the guard. Suppose a schema is moved under another schema's description. An update_schema description change then runs replace_description_subtree, which cascades the nested schema away without any check. That removes a core schema, or strands the schemas that extend it.

PR #3095 closed the delete_subtree_atomic path defensively. The invariant itself is still unenforced.

Suggested approach

Enforce it at the source. Refuse any move that gives a schema node a parent, and refuse parent_id when a schema is created. Every "a schema sits at the root" assumption then holds by construction. After that:

  • in delete_subtree_atomic, reword "A schema normally sits at the root" to say the subtree scan is defensive,
  • make the delete_children_subtree_unchecked comment true.

Related (separate gap)

assert_schema_deletable reads isCore from the properties JSON. So the core-schema delete refusal is only as strong as the protection on that property against a generic update_node that sets isCore: false. Check whether isCore can be changed through the generic update path, and reject it if so.

Acceptance criteria

  • Moving a schema node under any parent is rejected
  • Creating a schema node with a parent_id is rejected
  • isCore cannot be changed through generic node updates
  • Stale comments in nodes.rs are corrected

Activity

  1. malibio commented on Sep 27, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 279 files / 5425 tests passed

  2. self-assigned this
    on Sep 27, 2026
  3. added 2 commits that reference this issue on Sep 27, 2026
    1ae4061
    6d7a097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions