feat: add workspace-aware symbol resolution
opent testuser · 14 files · 4 slices · opened 1 week ago · updated 4 days ago
main ← feat/workspace-symbol-resolution featureworkerbreaking-change passing alice bob
Review
#142
Files
+ edge.go pkg/analysis/resolve/ + options.go pkg/analysis/resolve/ M builder.go pkg/analysis/graph/
Slices
Symbol Resolution Engine 4Database Migration 2Worker Pipeline Updates 5Tests 3
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 symbolsIntroduce 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/jobs/resolve_edges.go Worker Pipeline Updates
↳ function New added
func New(opts ...Option) *Resolver↳ method Walk added
func (r *Resolver) Walk(root string) ([]Edge, error)↳ function WithMaxDepth added
func WithMaxDepth(n int) Option↳ type Edge added
type Edge structpkg/analysis/resolve/resolver_test.go Tests
↳ function New added
func New(opts ...Option) *Resolver↳ method Walk added
func (r *Resolver) Walk(root string) ([]Edge, error)↳ function WithWorkspaceRoot added
func WithWorkspaceRoot(root string) Optionpkg/analysis/resolve/edge_test.go Tests
↳ type Edge added
type Edge struct↳ method Validate added
func (e Edge) Validate() error+ pkg/analysis/resolve/resolver.go +142 Mark reviewed
type Resolver type Resolver struct
function New func New(opts ...Option) *Resolver
method Walk func (r *Resolver) Walk(root string) ([]Edge, error)
method resolveImport func (r *Resolver) resolveImport(pkg string) (string, error)
+ pkg/analysis/resolve/edge.go +58 Mark reviewed
type Edge type Edge struct
type EdgeKind type EdgeKind string
method Validate func (e Edge) Validate() error
+ pkg/analysis/resolve/options.go +34 Mark reviewed
type Option type Option func(*Resolver)
function WithMaxDepth func WithMaxDepth(n int) Option
function WithWorkspaceRoot func WithWorkspaceRoot(root string) Option
M pkg/analysis/graph/builder.go +28 −6 Mark reviewed
function BuildGraph func BuildGraph(units []Unit, edges []Edge) *Graph
function addEdgesFromResolver func addEdgesFromResolver(g *Graph, resolved []resolve.Edge) error
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 Mark reviewed
+ services/worker/migrations/000012_add_symbol_edges.down.sql +4 Mark reviewed
Worker Pipeline Updates
Integration Should MEDIUM
5 files · 8 symbolsWire ResolveSymbolEdges into the worker job chain after ExtractSymbols.
Why this needs attention
- • Job chain ordering changed
- • New job registered
Ensure idempotency on replay
pkg/jobs/resolve_edges_test.go Tests
↳ type ResolveSymbolEdgesArgs added
type ResolveSymbolEdgesArgs struct↳ method Kind added
func (ResolveSymbolEdgesArgs) Kind() stringM services/worker/cmd/worker/main.go +8 −2 Mark reviewed
function main func main()
M pkg/jobs/args.go +18 Mark reviewed
type ResolveSymbolEdgesArgs type ResolveSymbolEdgesArgs struct
method Kind func (ResolveSymbolEdgesArgs) Kind() string
+ pkg/jobs/resolve_edges.go +87 Mark reviewed
type ResolveSymbolEdgesWorker type ResolveSymbolEdgesWorker struct
method Work func (w *ResolveSymbolEdgesWorker) Work(ctx context.Context, job *river.Job[ResolveSymbolEdgesArgs]) error
M pkg/jobs/extract_symbols.go +12 −4 Mark reviewed
method Work func (w *ExtractSymbolsWorker) Work(ctx context.Context, job *river.Job[ExtractSymbolsArgs]) error
+ pkg/store/symbol_edges.go +64 Mark reviewed
type SymbolEdgeStore type SymbolEdgeStore struct
method InsertBatchTx func (s *SymbolEdgeStore) InsertBatchTx(ctx context.Context, tx pgx.Tx, edges []SymbolEdgeRow) ([]int64, error)
Tests
Tests LOW
3 files · 6 symbolsIntegration 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 Mark reviewed
function TestWalk_SinglePackage func TestWalk_SinglePackage(t *testing.T)
function TestWalk_CrossPackage func TestWalk_CrossPackage(t *testing.T)
+ pkg/analysis/resolve/edge_test.go +42 Mark reviewed
function TestEdge_Validate func TestEdge_Validate(t *testing.T)
+ pkg/jobs/resolve_edges_test.go +68 Mark reviewed
function TestResolveSymbolEdgesWorker func TestResolveSymbolEdgesWorker(t *testing.T)