You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enforce that schema nodes are always roots (no parent via move/create) #3102
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
Activity
malibio commentedon Sep 27, 2026
Frontend: 279 files / 5425 tests passed
Enforce that schema nodes are always roots and isCore is fixed (closes …
Enforce that schema nodes are always roots and isCore is fixed (closes …