Repository navigation
Add one-hop related-schema traversal to the context block - #1849
Conversation
Renders a RELATED (via relationship, not directly matched) section in format_for_prompt, listing schemas reachable one hop from the directly-retrieved set via SchemaNode::relationships. Traversal is bidirectional (outgoing target_type declarations and incoming declarations from other schemas), name-only, and non-recursive. Measured in #1817/#1834: node-type selection on type-unnamed queries improved 0% -> 27.8-33% with this enrichment, for ~5% prompt tokens. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis is a clean, well-scoped, single-file change that does what issue #1837 asked for: a pure, testable one-hop bidirectional schema-relationship traversal, wired into The one substantive architectural finding is that the new code re-scans the full schema corpus on every The one acceptance criterion that's genuinely unaddressed is the regression check called out explicitly in the issue body (existing correctly-handled scenarios must not regress). The PR is silent on it. This is a measurement concern, not something enforceable by unit tests, and the issue itself frames it as importable follow-up rather than a hard gate — but it should at minimum be acknowledged in the PR description or as a tracked follow-up, not silently dropped. Net: this is a net-positive, low-risk change. Nothing here blocks merge on architecture, correctness, or security grounds. Requirements Check
FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Verification Notes
Recommendation: COMMENTNot a blocker on any Critical or Improvement finding — the change is correct, well-tested, atomic, and consistent with surrounding code conventions. I'm not recommending outright APPROVE only because one acceptance criterion from the issue (the regression check) appears genuinely unaddressed and un-acknowledged, and the bidirectional-convergence test gap is worth closing before calling this criterion fully satisfied. Both are cheap to close in a quick follow-up round; neither requires re-architecting anything in this PR. |
malibio
left a comment
There was a problem hiding this comment.
COMMENT (not blocking): clean, well-tested, atomic single-file change implementing bidirectional one-hop schema traversal correctly. No Critical issues. Two open items worth closing before calling this fully done: (1) the issue's regression-check acceptance criterion is unaddressed/unacknowledged in the PR, (2) no test exercises true bidirectional convergence within a single traversal call (current tests isolate outgoing vs incoming separately). Also flagged: the new code re-scans the full schema corpus per call instead of using the existing InboundRelationshipCache — investigated and found that cache is currently orphaned/unused elsewhere too, so this isn't a new anti-pattern, just an existing architectural loose end worth a follow-up. Full report in PR comment above.
Code Review SummaryNet positive, ready to merge with minor follow-ups. This is a small, atomic, well-tested change that implements issue #1837 as specified: one-hop, bidirectional, name-only related-schema traversal added to Only FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Requirements Validation (issue #1837 acceptance criteria)
Correctness Deep-Dive
Performance AssessmentThe O(n·m) full-corpus scan (n = corpus size, m = average relationships per retrieved schema) on every context build when schemas are relevant is a reasonable tradeoff for this codebase's actual scale. Testing AssessmentThe dozen-plus new unit tests are substantive, not superficial — they test actual acceptance-criteria behaviors (incoming-only reachability, no-op, non-duplication, non-recursion, name-only rendering) rather than just "function doesn't panic." Test naming is clear and each test's comment explains the scenario's intent. The one gap (convergent multi-path dedup) is noted above as an Improvement, not a blocker, since the implementation is visibly correct on inspection. RecommendationApprove. The two "Suggested Improvements" above are worth a fast-follow issue (reuse |
malibio
left a comment
There was a problem hiding this comment.
Review verdict: APPROVE (recommended) — GitHub blocks self-approval since this PR is authored under the same account as this review. See the full review comment above for details. Net positive, atomic, correct, well-tested; two non-blocking Improvements noted for a fast-follow.
…ument invariants Both PR #1849 reviews independently flagged the same test gap: existing traversal tests exercise outgoing-only and incoming-only reachability as separate fixtures, never both directions firing in a single call, and never a schema reachable via two different paths at once. Adds two tests closing that gap: - related_schemas_both_directions_fire_in_one_call: two retrieved schemas, each reaching a different related schema via a different direction, in one traversal call. - related_schemas_convergent_paths_dedupe_to_one: a schema reachable via both an outgoing edge from one retrieved schema and an incoming edge from a third schema, asserting it surfaces exactly once. Also documents two previously-implicit invariants raised in review: WorkspaceContext::related_schemas is only ever populated when relevant_schemas is non-empty, and a dangling target_type (pointing at a schema no longer in the corpus) is silently dropped by design, not by omission. Not addressed, by design: - Reusing InboundRelationshipCache/get_relationship_graph instead of related_one_hop_schemas's own corpus scan: both reviews called this a fast-follow, not a blocker. The cache is already orphaned elsewhere in the codebase (relationship.rs's own inbound-relationship lookup bypasses it too) — wiring it in is a real architectural change that deserves its own issue, not a quiet addition during review triage. - HashMap-based lookups in place of the linear scans: both reviews explicitly judged this over-engineering at the documented schema-corpus scale (tens to low hundreds). - The issue's regression-check acceptance criterion is a measurement/ eval concern, not something a unit test can verify; noted in the PR thread rather than faked with a test. Co-Authored-By: Claude <[email protected]>
Addressed review feedbackBoth reviews converged on the same test gap, plus a couple of documentation nits. Here's what changed in 12d269b: ✅ Addressed:
⏭️ Skipped, with reasoning:
All 27 Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The changes are two additive unit tests (no production logic touched) and two doc comments. No behavior changed, no new code paths introduced, nothing architectural. Both reviewers' substantive concerns (test coverage gap) are directly closed by tests that exercise exactly the scenario they described; the two explicitly-skipped items were both reviews' own "fast-follow, not blocking" characterization, not new judgment calls that need verification. |
Closes #1837