Skip to content

ADR-078 shadowing/collision not enforced for relationships, or for add-fields-only schema updates #2829

Closed

Description

@mstomar125

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:

  1. 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 rule flatten_chain_fields applies to fields — but no write path actually checks for a relationship-name collision across an extends chain the way validate_no_field_redeclaration does 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.
  2. 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 with extends (handle_create_schema, mod.rs:1172) and from re-targeting extends on update (mod.rs:1951). The add_fields handling in handle_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 no extends re-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

  1. added
    bug
    on Sep 22, 2026
  2. mstomar125 commented on Sep 23, 2026

    @mstomar125
    ContributorAuthor

    Frontend: 5264 passed

  3. self-assigned this
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions