Skip to content

Make resolve_relationship_name's forward-name lookup extends-chain aware - #2894

Merged
mstomar125 merged 3 commits into
mainfrom
issue-2868-rel-ops-extends
Sep 23, 2026
Merged

mstomar125 merged 3 commits into
mainfrom
issue-2868-rel-ops-extends

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

rel_ops::resolve_relationship_name's forward-name check resolved a relationship name via node_service.get_schema_node(node_type) — the node's own schema only, never the ADR-078 extends-chain-merged set that NodeService::resolve_relationships already provides. A relationship declared Forward only on an ancestor schema and inherited (not redeclared) by a subtype was invisible to it.

The write path (create_relationship, via resolve_declared_relationship) is already chain-aware, so a subtype instance could carry a real, attached edge — but reading it back through this resolver fell through to OpsError::InvalidParams, which GraphResolver::fetch_related_nodes treats as "undeclared, not a failure" and silently returns an empty result for. Since this resolver is shared with the CLI's read path, the same silent-empty-result class likely reached CLI relationship reads too.

Changes

  • packages/core/src/ops/rel_ops.rs: resolve_relationship_name's forward-name lookup now goes through NodeService::resolve_relationships (the chain-merged set) instead of a direct get_schema_node lookup. The downstream error-path relationship listing (used when a name resolves in neither direction) now draws from the same chain-merged set for consistency.
  • packages/core/src/playbook/graph_resolver.rs: adds a regression test alongside the existing inherited_many_relationship_with_zero_matches_resolves_to_empty_collection test — this one attaches a REAL edge to a subtype instance via the extends chain and asserts resolve_path returns a populated Collection containing it, not an empty one.
  • packages/core/tests/rel_ops_forward_name_extends_chain_test.rs (new): regression coverage directly at the rel_ops layer — an inherited forward name resolves as Forward (not InvalidParams), a real edge attached to a subtype instance is actually readable back through get_related_nodes, and an undeclared name on a subtype still correctly errors.

Same fix pattern as the earlier fixes for this bug class in workflow_state.rs, validation.rs, and graph_resolver.rs's is_declared_many_relationship.

Test plan

  • New regression tests pass: cargo test -p nodespace-core --test rel_ops_forward_name_extends_chain_test (3 tests)
  • New graph_resolver regression test passes alongside its sibling
  • Existing rel_ops/relationship integration suites pass unchanged (relationship_reverse_name_traversal_test, relationship_editing_test, schema_relationship_declarations_test, core_task_link_relationships_test)
  • Full bun run test:all pre-push gate passes (frontend, scripts, skill, Rust unit + integration + Tauri-seam)

Closes #2868

🤖 Generated with Claude Code

mstomar125 and others added 3 commits September 23, 2026 09:47
rel_ops::resolve_relationship_name checked a relationship name against
node_type's own schema only (get_schema_node), never the ADR-078
extends-chain-merged set NodeService::resolve_relationships already
provides. A relationship declared Forward only on an ancestor schema and
inherited (not redeclared) by a subtype was invisible to it, so resolution
fell through to InvalidParams even though create_relationship's write path
is already chain-aware and had attached a real edge. GraphResolver::
fetch_related_nodes treats that error as "undeclared, not a failure" and
silently returns an empty result, so a subtype instance with genuine
attached data resolved as if nothing were there.

Same fix pattern as workflow_state.rs, validation.rs, and graph_resolver.rs's
is_declared_many_relationship: resolve via resolve_relationships instead of
a direct own-schema lookup. The error-path relationship listing further down
the function now draws from the same chain-merged set for consistency.

Adds regression coverage at both the fetch layer (graph_resolver.rs) and the
rel_ops layer directly: a real edge attached to a subtype instance via the
extends chain is now actually readable back, not just correctly classified.

Closes #2868

Co-Authored-By: Claude Sonnet 5 <[email protected]>
CLAUDE.md forbids embedding GitHub issue numbers in code comments; the
pre-push gate's check-code-references ratchet catches it. Describe the
regression directly instead.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…owing

Two more own-schema-only reads in the same file, same bug class as the
forward-name-check fix:

- get_node_relationships's outbound-group loop consulted get_schema_node
  directly, so a relationship declared only on an ancestor and inherited by
  a subtype rendered no outbound group at all in the relationship viewer --
  not empty, just absent -- even though the write path already accepted
  edges under it. Now resolved via resolve_relationships.

- get_related_nodes's Reverse-narrowing filter compared a related node's
  concrete node_type against the declaring schema's exact id, not its whole
  extends-chain descendant set. A subtype instance's edge (e.g. one issue
  blocking another, where "blocks" is declared only on the shared ancestor
  task type) was silently dropped by this exact-match filter -- reading as
  "nothing blocks this" rather than as an error. Fixed with the same
  resolve_type_chain + memoized verdict pattern graph_resolver.rs already
  uses for the identical problem in its own reverse-segment walk.

Also adds regression coverage proving the type-system extends name itself
keeps resolving (not erroring) now that the chain-merged forward check
excludes it, and that an inherited forward name still wins over a
same-spelled reverse name declared elsewhere -- the same precedence rule
that already applied to a subtype's own directly-declared relationships,
now correctly extended across the chain.

Three further sibling call sites with the identical own-schema-only pattern
(find_duplicate_for, detect_unique_field_collisions, check_node_completeness)
are filed separately (core#2898, core#2899) rather than fixed here -- each
touches a different subsystem (uniqueness/duplicate-detection,
completeness-checking) than this PR's relationship-resolution scope. A
systemic guard against this bug class recurring is filed as core#2900.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125
mstomar125 merged commit d9c59c7 into main Sep 23, 2026
@mstomar125
mstomar125 deleted the issue-2868-rel-ops-extends branch September 23, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rel_ops::resolve_relationship_name's forward-name lookup is not extends-chain aware

1 participant