Repository navigation
Enforce that schema nodes are always roots and isCore is fixed (closes #3102) - #3126
Conversation
Pragmatic Code Review: PR #3126Review Type: Initial Review SummaryThis is a net improvement and ready to land. It gives schemas the same "always a root" enforcement that collections got in ADR-059:
The One real gap remains, and this PR makes it worse: a user schema can still be created with Requirements Check
Code Review Findings🟡 1. A user schema can be created with
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Review feedback addressed (cc5f3b9)✅ Fixed: 7/7
⏭️ Skipped: none. 🧪 Re-review needed: yes. #1 adds a new create-time refusal and #3 changes the transactional relationship path. |
Pragmatic Code Review — Re-Review (PR #3126, commit cc5f3b9)Review Type: Re-Review Requirements Check (issue #3102):
Verification of previous findings
Code Review Findings🟢 Tx has_child target lookup doesn't synthesize virtual dates 🟢 Nit: create refusal uses the Positive notes
Recommendation: APPROVE. All 7 prior findings are resolved correctly and no legitimate create path regresses. Both remaining items are optional. |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Re-review feedback addressed (5fb35cd)✅ Fixed (1/2)
⏭️ Skipped (1/2)
🧪 Re-review needed: no. This is a one-line parity change with no new behavior. |
5fb35cd to
fd3b07a
Compare
…#3102) - New tree invariant `schema_not_root`: create-with-parent, move, bulk reparent, generic has_child relationship create and merge refuse to give a schema a parent. `schema_is_root_edge` / `schema_is_root_type` triggers back it up on every write path, mirroring the collection-is-root enforcement. - Whether a schema is core is fixed at creation: the generic update paths (single, tx, versioned, bulk) refuse an `isCore` change or retyping a core schema, backed by the `schema_core_status_fixed` trigger. - Corrected the nodes.rs comments: descendants are never schemas by construction; the subtree scan in delete_subtree_atomic is defensive. - Subtree-delete tests now build their nested schema by dropping the trigger, simulating a broken invariant for the defensive scan. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… refusal - Service create paths (single, tx, bulk, bulk hierarchy) refuse a schema with isCore: true; core schemas are only seeded straight into the store. Now that core status is fixed, such a schema could never be undone. - schema_core_status_fixed uses json_type = 'true', matching the Rust as_bool() check and the delete refusal exactly. - The transactional has_child path (Play add_relationship) returns the typed collection/schema root refusal via a helper shared with the non-tx path. - Root-only refusals run before the date container auto-create, so a rejected create under a date leaves nothing behind. - create_child_node_atomic reports the normalized schema id. - Tests: create_child_node_atomic, merge with a schema survivor, create under a date, creating a core schema; assert_may_gain_parent doc reworded. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ookup Matches the non-tx twin and the source lookups in the same function. Skipped: switching the create-time core-schema refusal to ValidationFailed — it would bury the leading `schema_is_core:` code callers key on. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DVzwQZA6rU2wweT5gFN3iv
The rule joins the TreeInvariantRule union, so the exhaustive switch in describeMergeRefusal (added on main) needs a case for it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DVzwQZA6rU2wweT5gFN3iv
fd3b07a to
08bb342
Compare
Closes #3102
Summary
schema_not_roottree invariant (newTreeInvariantRule::SchemaNotRoot, wire nameschema_not_root). Schemas are refused a parent at the same sites that refuse collections: create-with-parent,create_child_node_atomic, move and bulk reparent (assert_may_gain_parent), generichas_childrelationship create, and merge. Theschema_is_root_edgeandschema_is_root_typetriggers enforce it on every write path. This mirrors ADR-059's collection-is-root enforcement.isCoreis fixed at creation. All five generic update paths reject a change to whether a node is a core schema. They returnInvalidUpdatewith the messageschema_is_core: …. Theschema_core_status_fixedtrigger also enforces this in the database, and it covers retyping a core schema away fromschema, which would otherwise get around the delete refusal.nodes.rscorrected.delete_children_subtree_uncheckedand its_in_txtwin now say that descendants are never schemas, which is guaranteed by construction. The subtree scan indelete_subtree_atomicis now described as defensive.TreeInvariantRuleunion and the dev-tools mapping doc now include the new rule.Tests
schema_is_always_a_root: the create, move, relationship create, raw edge insert, and type-switch paths are all refused.schema_core_status_cannot_change_through_generic_updates:update_node,bulk_update, rawisCoreclear, and raw retype are all refused.nodespace-coresuite passes (2271 tests), and the push check passes.🤖 Generated with Claude Code