Repository navigation
Description
Context
Surfaced during review of PR #2817 (core#2769 — added NodeService::resolve_relationships, the relationship counterpart to resolve_field_owners, both in packages/core/src/services/node_service/schema.rs).
Problem
ADR-078 defines extends as additive-only: an extending schema's effective set is its own declarations plus every ancestor's, with no override and no narrowing. Two write paths don't fully enforce this:
- Relationships have no collision check across the extends chain.
NodeService::resolve_relationships(packages/core/src/services/node_service/schema.rs)'s own doc comment claims "nearest-first, first-declared wins on a name collision" — the same shadowing ruleflatten_chain_fieldsapplies to fields — but no write path actually checks for a relationship-name collision across anextendschain the wayvalidate_no_field_redeclarationdoes for fields. A subtype schema can currently declare a relationship with the same name as one an ancestor already declares, and the read-time merge will silently pick one (nearest-first) rather than rejecting the redeclaration at write time the way a field redeclaration is rejected. handle_update_schema's add-fields-only path never checks against the parent chain.validate_no_field_redeclaration(packages/core/src/schema/mod.rs:731) is only called from schema creation withextends(handle_create_schema,mod.rs:1172) and from re-targetingextendson update (mod.rs:1951). Theadd_fieldshandling inhandle_update_schema(mod.rs:1770) merges new fields straight into the schema's own field list with no equivalent check, so a field can be added later — to an already-extending schema, with noextendsre-target involved — that collides with (shadows) a field the chain already inherits from an ancestor, with no write-time rejection. Only the read-time "nearer scope wins" fallback (flatten_chain_fields's doc calls it "a backstop, not a feature") catches it.
Impact
Both are latent-defect classes rather than confirmed live bugs — narrow, administrative-operation edge cases (schema authoring), not on any hot or user-facing runtime path. Worth closing so ADR-078's "well-formed chains have no collisions" assumption (which several other places, including this PR's own resolve_field_owners/resolve_relationships fallback comments, rely on) is actually enforced rather than merely documented.
Suggested approach
Not prescribed. Likely needs: (a) a relationship-name-collision check across the extends chain, run wherever a relationship is declared (schema creation and set_schema_relationships), mirroring validate_no_field_redeclaration's field check; (b) re-running (or generalizing) that same field check from update_schema's add-fields path, not just the extends-declaration path.
Non-goals
No change to flatten_chain_fields's or resolve_relationships's existing read-time shadowing/merge behavior (nearest-first, first-declared wins) — that backstop should stay regardless, per its own doc comment. Scoped to adding the missing write-time rejection.
Activity
mstomar125 commentedon Sep 23, 2026
Frontend: 5264 passed
Address review: fix stale-parent and wrong-blame bugs in the ADR-078 …