Skip to content

fix(resolution): link imported Go and Dart values#1257

Draft
Adam0120 wants to merge 1 commit into
colbymchenry:mainfrom
Adam0120:fix/import-aware-value-references
Draft

fix(resolution): link imported Go and Dart values#1257
Adam0120 wants to merge 1 commit into
colbymchenry:mainfrom
Adam0120:fix/import-aware-value-references

Conversation

@Adam0120

Copy link
Copy Markdown

Summary

Link Go and Dart readers to imported top-level constants and variables so codegraph_node, callers, and impact analysis include value consumers outside the definition file.

This adds an internal value_ref reference kind that resolves only through explicit import/package mappings and persists as a normal references edge with metadata.valueRef. It does not change search ranking or add fuzzy matching.

Reproduction and root cause

Value-reference extraction currently builds edges only when the reader and file-scope value share one AST. Cross-file values produce no unresolved reference, so the resolver never sees them.

Two real examples:

  • Go: realtime.DefaultSessionStore is read from p2p/service.go and userapi/consumers/roomserver.go, but its impact radius previously contained only the definition.
  • Dart: agentBridgePresenceProvider is read by several pages and tests, but its impact radius previously contained only the provider declaration.

Precision boundary

  • Go candidates must be package-qualified, use an imported in-module package alias, name an exported top-level const/var, and not be shadowed by a parameter/local binding.
  • Dart candidates must resolve through an explicit relative import or this project's package:<pubspec name>/... URI. Prefixed imports are supported.
  • Dart targets must be public top-level const/final values and unique across the imported libraries.
  • Conditional and show/hide Dart imports are skipped conservatively.
  • Commented-out imports are stripped before mapping.
  • Both languages stop at the import resolver; value_ref never falls through to the name matcher.

Incremental sync

The original reference kind and name are stored in edge metadata. If the imported target disappears during sync, the edge is dropped; when the target returns, the unchanged reader is re-resolved and the edge is restored.

Validation

  • npm run build
  • __tests__/value-reference-edges.test.ts: 32/32 passed
  • __tests__/sync.test.ts: 31/31 passed
  • __tests__/extraction.test.ts: 579/579 passed
  • __tests__/resolution.test.ts: 165/169 passed; the four failures are the pre-existing Windows EBUSY cleanup failures in C/C++ and PHP end-to-end fixtures
  • Real Go index: DefaultSessionStore now reports both direct readers and a 7-symbol transitive impact radius
  • Real Dart index: agentBridgePresenceProvider now reports four production reader methods plus three test entry points and a 46-symbol transitive impact radius
  • Real prefixed Dart import: dirextalk_matrix_events.dirextalkAgentStatusEventType resolves to its source constant

Behavior boundary

This intentionally does not evaluate dynamic imports, Dart conditional/show/hide combinators, external packages, re-export barrels, or ambiguous imported names. Missing uncertain edges are preferred over incorrect ones.

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