Repository navigation
Fix GraphResolver::is_declared_many_relationship to use merged extends-chain relationships - #2865
Conversation
…s-chain relationships (closes #2837) is_declared_many_relationship looked up cardinality via get_schema_node's own directly-declared relationships only, missing a "many" relationship declared on an ancestor schema and inherited (not redeclared) by a subtype. With zero or one currently-related rows this misclassified the relationship as not-many, falling through to count-based inference and resolving it as Missing or a bare Node instead of the required Collection. Switch the lookup to NodeService::resolve_relationships, the same extends-chain merge already used by workflow_state.rs and validation.rs for this exact bug class (core#2769/#2819). Adds a regression test covering an inherited many-relationship with zero current matches. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Review Type: Initial Review Requirements Check (issue #2837):
Code Review Findings: No Critical or Important findings. 🟢 Suggestion
Verified: Recommendation: APPROVE |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
…ny() Combines the find().is_some_and() pair into one any() predicate that checks name and cardinality together (Nit from PR#2865's pragmatic-code-review) -- no behavior change. Skipped the review's other suggestion (resolve_relationships re-walks the full extends chain on every 0/1-match cardinality check): inherent to resolve_relationships itself, already accepted for its two existing callers, and out of this issue's stated non-goals; a general GraphResolver caching pass is already tracked separately (issue-2830-resolver-caching). Co-Authored-By: Claude Sonnet 5 <[email protected]>
probe_inherited_relationship_with_real_attached_data was scratch/debug code (println! output, throwaway schema names) that ended up committed alongside the previous address-review commit -- not part of this PR's intended scope. Removed; the real regression coverage for this fix is inherited_many_relationship_with_zero_matches_resolves_to_empty_collection, already present. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Address-Review SummaryAddressed:
Skipped (with reasoning):
Incidental cleanup: a stray scratch/debug test ( Separately: reviewing this PR surfaced a real, deeper bug in Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The only change since the last review is a trivial, no-behavior-change style simplification (single-predicate |
Summary
GraphResolver::is_declared_many_relationship(packages/core/src/playbook/graph_resolver.rs) looked up a relationship's cardinality viaget_schema_node(node_type)— the type's own directly-declared relationships only, not merged across the ADR-078extendschain. A relationship declaredManyonly on an ancestor schema and inherited by a subtype node (not redeclared) was misclassified as not-many when the subtype node currently has 0 or 1 related rows: the lookup returnedfalse(nothing found on the bare subtype schema), so shape-inference fell through to count-based inference instead of forcingResolvedValue::Collection— resolving the relationship asMissingor a bareNodeinstead of the correctList.Same bug class as core#2769/core#2819, found in a third location during review of PR #2817.
Changes
is_declared_many_relationshipnow goes throughNodeService::resolve_relationships(the effective, extends-chain-merged relationship set, added in PR Merge inherited fields into get_workflow_state's candidate enumeration #2817 / core#2769) instead of a raw single-schemaget_schema_node+Schema::get_relationshiplookup — the same pattern already used byworkflow_state.rsandvalidation.rsfor this exact bug class.inherited_many_relationship_with_zero_matches_resolves_to_empty_collection) covering a many-relationship declared only on an ancestor schema and inherited (not redeclared) by a subtype instance with zero current matches — before the fix this resolved toMissing, after the fix it correctly resolves to an emptyCollection.Test plan
bun run test— 262 test files / 5264 tests passed (baseline, frontend)cargo test -p nodespace-core --lib playbook::graph_resolver— 39/39 passed, including the new regression testbun run quality:fix— clean (0 lint/format errors)bun run test:all+cargo build --bin nodespaced+bun run test:e2e) — all greenCloses #2837
🤖 Generated with Claude Code