Hydrogen
testuser / hydrogen · #142

feat: add workspace-aware symbol resolution

open
t testuser · 14 files · 4 slices · opened 1 week ago · updated 4 days ago
main feat/workspace-symbol-resolution featureworkerbreaking-change passing alice bob
No staged comments
Description

This PR adds cross-package symbol resolution to the worker pipeline. Changes: - New `resolve` package under `pkg/analysis` - Updated ExtractSymbols job to emit edges - Migration for symbol_edges table - Integration tests covering multi-package repos

4 review slices

Changes are grouped into logical slices to make review easier. Work through them in order — higher-attention slices appear first.

Symbol Resolution Engine

Core Logic Focus HIGH
4 files · 12 symbols

Introduce workspace-aware symbol resolution that traces imports across Go packages.

Why this needs attention
  • New core analysis package
  • Cross-package dependency resolution
  • Affects downstream job chain
Verify cycle detection in resolve.Walk()
Check that edges are scoped to the PR diff, not the full repo
+ pkg/analysis/resolve/resolver.go +142
type Resolver
function New
method Walk
method resolveImport
+ pkg/analysis/resolve/edge.go +58
type Edge
type EdgeKind
method Validate
+ pkg/analysis/resolve/options.go +34
type Option
function WithMaxDepth
function WithWorkspaceRoot
M pkg/analysis/graph/builder.go +28 −6
function BuildGraph
function addEdgesFromResolver

Database Migration

Contract Must HIGH
2 files

Add symbol_edges table for storing resolved cross-file references.

Why this needs attention
  • New table with foreign keys
  • Must be backwards-compatible
Confirm DOWN migration drops in correct FK order
+ services/worker/migrations/000012_add_symbol_edges.up.sql +22
+ services/worker/migrations/000012_add_symbol_edges.down.sql +4

Worker Pipeline Updates

Integration Should MEDIUM
5 files · 8 symbols

Wire ResolveSymbolEdges into the worker job chain after ExtractSymbols.

Why this needs attention
  • Job chain ordering changed
  • New job registered
Ensure idempotency on replay
M services/worker/cmd/worker/main.go +8 −2
function main
M pkg/jobs/args.go +18
type ResolveSymbolEdgesArgs
method Kind
+ pkg/jobs/resolve_edges.go +87
type ResolveSymbolEdgesWorker
method Work
M pkg/jobs/extract_symbols.go +12 −4
method Work
+ pkg/store/symbol_edges.go +64
type SymbolEdgeStore
method InsertBatchTx

Tests

Tests LOW
3 files · 6 symbols

Integration tests for multi-package symbol resolution.

Why this needs attention
  • Test-only changes
  • No production impact
Check fixture coverage for circular imports
+ pkg/analysis/resolve/resolver_test.go +96
function TestWalk_SinglePackage
function TestWalk_CrossPackage
+ pkg/analysis/resolve/edge_test.go +42
function TestEdge_Validate
+ pkg/jobs/resolve_edges_test.go +68
function TestResolveSymbolEdgesWorker