Skip to content

validate_no_field_redeclaration always blames the immediate extends parent, not the true declaring ancestor #2871

Closed

Description

@mstomar125

Context

Surfaced during review of PR #2866 (core#2829 — ADR-078 extends-chain shadowing enforcement).

Problem

validate_no_field_redeclaration (packages/core/src/schema/mod.rs) resolves the full effective field set via resolve_effective_fields, which returns only a flat Vec<SchemaField> with no per-field ownership tracking. When a field collision is found, the error unconditionally names parent_id (the immediate extends parent passed into the function) as the schema that "already declared" the field — even when the actual declaring schema is a grandparent or further ancestor.

Example: Task declares status. Mid extends Task (no own fields). Leaf extends Mid and tries to declare status. The error says "already declared by 'mid'" when Mid doesn't declare it at all — it's declared two levels up, on Task.

This is the same defect class that was just fixed on the relationship side in PR #2866 (validate_no_relationship_redeclaration, which now uses NodeService::resolve_relationships's owner map to name the true declaring schema).

Suggested approach

NodeService::resolve_field_owners (packages/core/src/services/node_service/schema.rs) already exists and returns (effective_fields, field_name -> owning_schema_id, chain) — the field-side analog of resolve_relationships's owner map. validate_no_field_redeclaration currently goes through the package-local resolve_effective_fields (which discards ownership) instead. Switching it to use resolve_field_owners's owner map, mirroring the relationship-side fix, would close this gap.

Impact

Cosmetic/diagnostic only — the redeclaration is still correctly rejected either way, just with a misleading "which schema owns this" detail in the error message. Not a correctness or security issue.

Activity

  1. mstomar125 commented on Sep 23, 2026

    @mstomar125
    ContributorAuthor

    Frontend: 5264 passed

  2. self-assigned this
    on Sep 23, 2026
  3. added a commit that references this issue on Sep 23, 2026
    294794a
  4. added a commit that references this issue on Sep 23, 2026
    58e4bb4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions