Repository navigation
Scope reverse-cardinality eviction by ownership equality (#2909) - #3282
Conversation
|
Review summary (pragmatic-code-reviewer, medium, static): CLEAN, no correctness findings. Checked both call sites (create_relationship_in_tx, merge re-point) and edge cases (self-owned type, non-shadowing subtype, missing/virtual types, extends exclusion); the only behaviour change is the intended shadowing case. Tests construct the shadow via set_schema_relationships and each was mutation-checked against type_satisfies. Nits, not addressed: (1) helper re-resolves the chain per existing reverse edge inside the write tx (typically 0-1 edges; a per-call cache would suffice for merge); (2) other type_satisfies uses scope by target type, not declaration ownership, so left as is; (3) optional comment pointer to the helper at the merge site. 🤖 Generated with Claude Code |
|
Merge queue: #3282 was taken out of the queue — the merge gate failed on it, rebased onto main. Reproduce with |
|
Removed the two issue references from doc comments (code-reference ratchet), rebased on origin/main; test:scripts, fmt and clippy pass. |
6e8cbe0 to
357b32a
Compare
… not chain membership create_relationship_in_tx and the merge re-point check decided whether an existing inbound edge belonged to the declaration being validated with type_satisfies (declaring type is somewhere in the source's chain). When a nearer schema shadows an inherited relationship of the same name, that misattributed the shadowing schema's edges to the ancestor's declaration. Both sites now compare the existing source's own nearest-first owner for the relationship name against the declaring type. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
357b32a to
ebaed45
Compare
Closes #2909
Root cause
Reverse-cardinality scoping decided whether an existing inbound edge belongs to the declaration being validated with
type_satisfies(existing_source_type, declaring_type), an ancestor-chain membership check. If a nearer schema shadows an inherited relationship of the same name (only possible via the low-levelset_schema_relationships, which skips cross-chain collision validation), the ancestor is still in the chain, so the shadowing schema's edges were misattributed to the ancestor's declaration and wrongly evicted/dropped.Fix
New
NodeService::source_resolves_relationship_to(relationship.rs) compares the existing source's own nearest-first owner (resolve_relationshipsowners map) for the relationship name against the declaring type: ownership equality. Used at both sites:create_relationship_in_txand the merge re-point collision check. Chose the equality patch over the persisted-declaring-schema column (no DDL change / DB reset needed).Tests
Not reachable today, so the state is constructed directly:
shadow_child extends shadow_base, both declaringowns(reverse cardinality one); the child's shadow is written withset_schema_relationshipsaftercreate_schema. Tests (relationship.rs,required_in_last_edge_tests):reverse_cardinality_scope_ignores_edges_owned_by_a_shadowing_declaration(create path; also asserts same-declaration edges are still replaced)merge_repoint_ignores_edges_owned_by_a_shadowing_declaration(merge path)Mutation check: reverting each call site to
type_satisfiesindividually makes its test fail (other passes).🤖 Generated with Claude Code