Skip to content

fix: resolve bare-name TESTED_BY sources and run resolution in postprocess#601

Open
SHudici wants to merge 1 commit into
tirth8205:mainfrom
SHudici:fix/tested-by-bare-sources
Open

fix: resolve bare-name TESTED_BY sources and run resolution in postprocess#601
SHudici wants to merge 1 commit into
tirth8205:mainfrom
SHudici:fix/tested-by-bare-sources

Conversation

@SHudici

@SHudici SHudici commented Jul 3, 2026

Copy link
Copy Markdown

Problem

TESTED_BY edges are derived from test→production CALLS edges at parse time, so their production endpoint inherits the bare name of any call the parser couldn't resolve cross-file. That is the dominant case in practice — tests almost always import the code they test. On a mid-size production repo we measured 79% of TESTED_BY edges (6.8k of 8.5k) carrying bare sources, so every qualified-name consumer (tests_for, review context, transitive test lookup) returned 0 results for most functions.

Compounding this: GraphStore.resolve_bare_call_targets — the existing post-hoc resolver for bare CALLS targets — is defined but never called from any pipeline, so bare endpoints survived every build untouched.

Fix

  • GraphStore.resolve_bare_tested_by_sources(): resolves bare TESTED_BY sources with the same strategy as the CALLS resolver (unique node name → resolve; multiple candidates → prefer the one whose file the test file imports; otherwise stay bare rather than guess). Both methods now share one private helper; CALLS behavior is unchanged and pinned by a regression test.
  • Wire resolution into all three postprocess paths (_run_postprocess for the MCP build tool, run_postprocess for the re-run tool, shared run_post_processing for watch mode), ahead of the derived steps so flows and communities see qualified edges too. It runs at the minimal level as well — it's a cheap correctness pass over an indexed subset, not an enrichment. Failures degrade to build warnings per the existing step-isolation contract.

Measured effect (same production repo, 4.7k nodes / 39k edges)

  • 4,117 bare CALLS targets + 2,588 bare TESTED_BY sources resolved in one postprocess pass (the rest are genuinely ambiguous and deliberately left bare)
  • qualified TESTED_BY edges: 1,756 → 4,344
  • tests_for on a well-tested function: 0 results → 15 results
  • communities consolidated 228 → 103 as cross-file edges finally connected at clustering time

Testing

New tests: resolver units (unique name, ambiguous-stays-bare, import disambiguation via the test file, unknown name untouched, CALLS regression), shared-pipeline wiring (resolves + reports bare_edges_resolved, failure isolated to a warning), and build-tool level gating (minimal resolves, none skips). Full suite passes.

Composes with #598 (TESTED_BY read direction) but does not require it; this PR is cut independently from main.

🤖 Generated with Claude Code

…ocess

TESTED_BY edges are derived from test-to-production CALLS edges at parse
time, so their production endpoint inherits the bare name of any call the
parser couldn't resolve cross-file. That is the dominant case in practice
(tests almost always import the code they test): on a mid-size production
repo, 79% of TESTED_BY edges (6.8k of 8.5k) carried bare sources, so
qualified-name consumers (tests_for, review context, transitive test
lookup) returned nothing for most functions.

Two changes:

- GraphStore.resolve_bare_tested_by_sources() resolves bare TESTED_BY
  sources with the same strategy as resolve_bare_call_targets (unique
  node name, else IMPORTS_FROM disambiguation - here via the test file's
  imports). Both methods now share one private helper; the CALLS
  behavior is unchanged and covered by a regression test.

- The resolution pair now actually runs: resolve_bare_call_targets was
  defined but never called from any pipeline, so bare endpoints survived
  every build. Resolution is wired into all three postprocess paths
  (_run_postprocess for the MCP build tool, run_postprocess for the
  re-run tool, and the shared run_post_processing) ahead of the derived
  steps, so flows and communities see qualified edges too. It runs at
  the "minimal" level as well - it is a cheap correctness step (one
  indexed pass over bare edges), not an enrichment.

Failures are isolated as build warnings, matching the existing
step-isolation contract. Ambiguous names without import evidence stay
bare rather than guessing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant