Skip to content

Three hand-rolled extends-chain walkers over two different edge sources — drift risk, not a single source of truth #2888

Closed

Description

@mstomar125

Context

Surfaced by a codebase scan focused on the extends-chain/ADR-078 bug class. Duplication/drift-risk finding, not a live bug.

Problem

Three separate code paths independently walk the schema extends chain, using two different underlying edge sources:

  • NodeService::resolve_type_chain (packages/core/src/services/node_service/schema.rs:499-513) reads store.get_extends_parent_map() — a direct SQL query over extends rows.
  • schema::resolve_effective_fields (packages/core/src/schema/mod.rs:764-790) instead uses load_parent_map (schema/mod.rs:650) = get_all_schemas() + a hydrated declared_parent field — a different, heavier query path.
  • resolve_declared_relationship (packages/core/src/services/node_service/relationship.rs:483-507) hand-walks the chain itself with per-scope get_schema_node + get_relationship calls, rather than calling the existing resolve_relationships helper.

Additionally, resolve_field_owners's and resolve_relationships's function bodies (schema.rs:533-576, 614-659) are near-identical to each other (already generalized once via flatten_chain_by_name per core#2830/PR#2862, but the two callers' chain-resolution setup remains separately written).

Having two independent sources of truth for "who is my parent" is the same class of risk as core#2870's cache-vs-live disagreement: a future hydration-filter change in get_all_schemas could silently make resolve_effective_fields diverge from every other resolver in the codebase, with no test currently guarding that the two stay in sync.

Suggested approach

Not prescribed — likely consolidating load_parent_map to use the same get_extends_parent_map() source as resolve_type_chain, and having resolve_declared_relationship call resolve_relationships directly instead of hand-walking. A larger, riskier follow-up than the other findings from this scan — worth scoping carefully rather than doing as a quick mechanical fix.

Activity

  1. self-assigned this
    on Sep 25, 2026
  2. mstomar125 commented on Sep 25, 2026

    @mstomar125
    ContributorAuthor

    Frontend baseline: 262 test files passed, 5269 tests passed (166.17s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions