From ec48c5f01014935bf16c96612e646fb998180204 Mon Sep 17 00:00:00 2001 From: Patel230 Date: Tue, 2 Jun 2026 09:37:21 +0530 Subject: [PATCH 1/2] fix: resolve compat matrix collision and sync ecosystem submodules Rename root compatibility-matrix.json to platform-capabilities.json so compat-test reads testdata/compatibility-matrix.json. Fix noctx across codegraph, tools, and bench; use go work sync for tidy; bump external/* submodules to latest main. --- COMPATIBILITY.md | 25 +++--- Makefile | 10 +-- cmd/compat-test/main.go | 16 ++-- cmd/testfirst_workflow.go | 3 +- external/eyrie | 2 +- external/inspect | 2 +- external/sight | 2 +- external/tok | 2 +- external/trace | 2 +- external/yaad | 2 +- internal/bench/suite.go | 7 +- internal/codegraph/algorithms_cgo.go | 35 ++++---- internal/codegraph/codegraph_cgo.go | 81 ++++++++++--------- internal/codegraph/embeddings_cgo.go | 7 +- internal/tool/git_history.go | 26 +++--- internal/tool/impact.go | 14 ++-- ...-matrix.json => platform-capabilities.json | 0 testdata/compatibility-matrix.json | 2 +- 18 files changed, 123 insertions(+), 115 deletions(-) rename compatibility-matrix.json => platform-capabilities.json (100%) diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index cebd03ba..9c40adb7 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -4,7 +4,9 @@ This eco uses **independent SemVer per repo** (see [VERSIONING.md](./VERSIONING. That gives each component its own release cadence, but raises an obvious question: *which combinations of versions are actually tested together?* -The answer lives in [`compatibility-matrix.json`](./compatibility-matrix.json). +The answer lives in [`testdata/compatibility-matrix.json`](./testdata/compatibility-matrix.json). + +Platform/provider capability metadata is separate: [`platform-capabilities.json`](./platform-capabilities.json). ## What it records @@ -46,7 +48,7 @@ existing consumers. `.shared-templates/workflows/compatibility-test.yml.tmpl` is a reusable workflow that: -1. Reads `compatibility-matrix.json` from the eco repo. +1. Reads `testdata/compatibility-matrix.json` from the hawk repo. 2. Checks out each component at the version listed in the named matrix. 3. Builds + tests the cross-repo integration scenarios. @@ -68,21 +70,14 @@ It runs on: ## Validating the file -The file is validated against [`compatibility-matrix.schema.json`](./compatibility-matrix.schema.json) +The file is validated against [`testdata/compatibility-matrix.schema.json`](./testdata/compatibility-matrix.schema.json) in CI. To validate locally: ```bash -# Quick check using ajv (Node) +make compat-check # structural validation + version pins + +# Or with ajv (Node) npx ajv-cli validate \ - -s compatibility-matrix.schema.json \ - -d compatibility-matrix.json - -# Or with Python -python3 -c " -import json, jsonschema -schema = json.load(open('compatibility-matrix.schema.json')) -data = json.load(open('compatibility-matrix.json')) -jsonschema.validate(data, schema) -print('ok') -" + -s testdata/compatibility-matrix.schema.json \ + -d testdata/compatibility-matrix.json ``` diff --git a/Makefile b/Makefile index db8f6ef0..28cb63a8 100644 --- a/Makefile +++ b/Makefile @@ -106,8 +106,8 @@ security: ## Run govulncheck. @command -v $(GOVULNCHECK) >/dev/null 2>&1 || (echo "install: go install golang.org/x/vuln/cmd/govulncheck@latest" && exit 1) $(GOVULNCHECK) ./... -tidy: ## Tidy go.mod / go.sum. - go mod tidy +tidy: ## Sync workspace modules and verify checksums. + go work sync go mod verify # --------------------------------------------------------------------------- @@ -190,11 +190,11 @@ help: ## Show this help. # --------------------------------------------------------------------------- .PHONY: compat-test compat-check -compat-test: ## Validate compatibility-matrix.json and report the 'next' matrix. - @go run ./cmd/compat-test -matrix=next +compat-test: ## Validate testdata/compatibility-matrix.json and report the 'next' matrix. + @go run ./cmd/compat-test -matrix=next -file=testdata/compatibility-matrix.json compat-check: ## Strict validation — non-zero exit if any component lacks a version. - @go run ./cmd/compat-test -matrix=next -strict + @go run ./cmd/compat-test -matrix=next -strict -file=testdata/compatibility-matrix.json .PHONY: hooks hooks: diff --git a/cmd/compat-test/main.go b/cmd/compat-test/main.go index ce895b94..5a051266 100644 --- a/cmd/compat-test/main.go +++ b/cmd/compat-test/main.go @@ -160,17 +160,23 @@ func report(mf matrixFile, m matrix, strict bool) error { return nil } -// findMatrixFile looks for compatibility-matrix.json in the current dir, then -// walks up looking for one. Returns "" if not found within 6 levels. +// findMatrixFile locates the cross-repo compatibility matrix (testdata/compatibility-matrix.json). +// It must not pick hawk/platform-capabilities.json, which is a different document. func findMatrixFile() string { dir, err := os.Getwd() if err != nil { return "" } + candidates := []string{ + "testdata/compatibility-matrix.json", + "hawk/testdata/compatibility-matrix.json", + } for i := 0; i < 6; i++ { - p := filepath.Join(dir, "compatibility-matrix.json") - if _, err := os.Stat(p); err == nil { - return p + for _, rel := range candidates { + p := filepath.Join(dir, rel) + if _, err := os.Stat(p); err == nil { + return p + } } parent := filepath.Dir(dir) if parent == dir { diff --git a/cmd/testfirst_workflow.go b/cmd/testfirst_workflow.go index 0f94ffdb..fe39d2b7 100644 --- a/cmd/testfirst_workflow.go +++ b/cmd/testfirst_workflow.go @@ -1,6 +1,7 @@ package cmd import ( + "context" "fmt" "os" "os/exec" @@ -84,7 +85,7 @@ func RunTestFirstWorkflow(cfg TestFirstConfig, chatFn ReviewChatFn) TestFirstRes // runTests executes the test command and returns output + pass status. func runTests(testCmd string) (string, bool) { - cmd := exec.Command("sh", "-c", testCmd) + cmd := exec.CommandContext(context.Background(), "sh", "-c", testCmd) cmd.Dir, _ = os.Getwd() out, err := cmd.CombinedOutput() output := strings.TrimSpace(string(out)) diff --git a/external/eyrie b/external/eyrie index 5205d42c..d5c3b979 160000 --- a/external/eyrie +++ b/external/eyrie @@ -1 +1 @@ -Subproject commit 5205d42c657fe4c397bfb49563bd64e27be59887 +Subproject commit d5c3b979fd0840410e0b506593fb346ede99a6e3 diff --git a/external/inspect b/external/inspect index 086ceae6..426e7706 160000 --- a/external/inspect +++ b/external/inspect @@ -1 +1 @@ -Subproject commit 086ceae69c87bb46064607dc8347ca7f5c8f7f68 +Subproject commit 426e77065fb4e7c5c6c85d7bc1a9c4ff8816d245 diff --git a/external/sight b/external/sight index a552746c..6d3b83ab 160000 --- a/external/sight +++ b/external/sight @@ -1 +1 @@ -Subproject commit a552746c244583daefe68d84fe561ccea9013852 +Subproject commit 6d3b83ab628d552f3ae5794ccff412cc58c31cc3 diff --git a/external/tok b/external/tok index ad094a67..fe25344f 160000 --- a/external/tok +++ b/external/tok @@ -1 +1 @@ -Subproject commit ad094a67797d1e9ed9c0f860768fbb37fd3b7170 +Subproject commit fe25344fefec647fa93330e6b544d8d45a0e6366 diff --git a/external/trace b/external/trace index d7a722ba..997be1b2 160000 --- a/external/trace +++ b/external/trace @@ -1 +1 @@ -Subproject commit d7a722ba285fb663a3a0518fee5318919bdac4d0 +Subproject commit 997be1b2a501428adc81bc927cc4ba6996457115 diff --git a/external/yaad b/external/yaad index 03b6f005..abb30043 160000 --- a/external/yaad +++ b/external/yaad @@ -1 +1 @@ -Subproject commit 03b6f005ddab51eba7a456548aac627becdc2796 +Subproject commit abb30043435488b2c12bf05a52190e8087e37235 diff --git a/internal/bench/suite.go b/internal/bench/suite.go index 22bae9d2..802d9760 100644 --- a/internal/bench/suite.go +++ b/internal/bench/suite.go @@ -1,6 +1,7 @@ package bench import ( + "context" "encoding/json" "fmt" "os" @@ -54,7 +55,7 @@ func runYaadBench(projectDir string) ([]BenchmarkResult, error) { } start := time.Now() - cmd := exec.Command("go", "test", "-bench=.", "-benchmem", "-count=1", "-timeout=60s", "./engine/...") + cmd := exec.CommandContext(context.Background(), "go", "test", "-bench=.", "-benchmem", "-count=1", "-timeout=60s", "./engine/...") cmd.Dir = yaadDir output, err := cmd.CombinedOutput() duration := time.Since(start) @@ -81,7 +82,7 @@ func runTokBench(projectDir string) ([]BenchmarkResult, error) { } start := time.Now() - cmd := exec.Command("go", "test", "-bench=.", "-benchmem", "-count=1", "-timeout=60s", "./...") + cmd := exec.CommandContext(context.Background(), "go", "test", "-bench=.", "-benchmem", "-count=1", "-timeout=60s", "./...") cmd.Dir = tokDir output, err := cmd.CombinedOutput() duration := time.Since(start) @@ -108,7 +109,7 @@ func runHawkBuildBench(projectDir string) (BenchmarkResult, error) { } start := time.Now() - cmd := exec.Command("go", "build", "-o", "/dev/null", ".") + cmd := exec.CommandContext(context.Background(), "go", "build", "-o", "/dev/null", ".") cmd.Dir = hawkDir err := cmd.Run() duration := time.Since(start) diff --git a/internal/codegraph/algorithms_cgo.go b/internal/codegraph/algorithms_cgo.go index ec14bce6..850b3011 100644 --- a/internal/codegraph/algorithms_cgo.go +++ b/internal/codegraph/algorithms_cgo.go @@ -3,6 +3,7 @@ package codegraph import ( + "context" "fmt" "sort" "strings" @@ -38,7 +39,7 @@ func (cg *CodeGraph) BetweennessCentrality(topN int) (*BetweennessResult, error) // Build adjacency list from edges adj := make(map[string][]string) - rows, err := cg.db.Query("SELECT source, target FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements')") + rows, err := cg.db.QueryContext(context.Background(), "SELECT source, target FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements')") if err != nil { return nil, err } @@ -150,7 +151,7 @@ func (cg *CodeGraph) BetweennessCentrality(topN int) (*BetweennessResult, error) } // Try to get node name and file var name, filePath, kind string - err := cg.db.QueryRow("SELECT name, file_path, kind FROM nodes WHERE id = ?", s.id).Scan(&name, &filePath, &kind) + err := cg.db.QueryRowContext(context.Background(), "SELECT name, file_path, kind FROM nodes WHERE id = ?", s.id).Scan(&name, &filePath, &kind) if err == nil { nc.Name = name nc.FilePath = filePath @@ -194,7 +195,7 @@ func (cg *CodeGraph) CommunityDetection() (*CommunityDetectionResult, error) { adj := make(map[string]map[string]float64) var edges []edge - rows, err := cg.db.Query("SELECT source, target, kind FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements', 'contains')") + rows, err := cg.db.QueryContext(context.Background(), "SELECT source, target, kind FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements', 'contains')") if err != nil { return nil, err } @@ -349,7 +350,7 @@ func (cg *CodeGraph) ConnectedComponents() ([][]string, error) { // Build adjacency list adj := make(map[string][]string) - rows, err := cg.db.Query("SELECT source, target FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements')") + rows, err := cg.db.QueryContext(context.Background(), "SELECT source, target FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements')") if err != nil { return nil, err } @@ -426,7 +427,7 @@ func (cg *CodeGraph) DiffGraph(beforeNodes map[string]bool, beforeEdges map[stri // Get current nodes currentNodes := make(map[string]bool) - rows, _ := cg.db.Query("SELECT id, file_path FROM nodes") + rows, _ := cg.db.QueryContext(context.Background(), "SELECT id, file_path FROM nodes") if rows != nil { for rows.Next() { var id, filePath string @@ -450,7 +451,7 @@ func (cg *CodeGraph) DiffGraph(beforeNodes map[string]bool, beforeEdges map[stri // Get current edges currentEdges := make(map[string]bool) - rows, _ = cg.db.Query("SELECT source || '->' || target || ':' || kind FROM edges") + rows, _ = cg.db.QueryContext(context.Background(), "SELECT source || '->' || target || ':' || kind FROM edges") if rows != nil { for rows.Next() { var edgeKey string @@ -483,7 +484,7 @@ func (cg *CodeGraph) SnapshotGraph() (nodes map[string]bool, edges map[string]bo nodes = make(map[string]bool) edges = make(map[string]bool) - rows, err := cg.db.Query("SELECT id FROM nodes") + rows, err := cg.db.QueryContext(context.Background(), "SELECT id FROM nodes") if err != nil { return nil, nil, err } @@ -501,7 +502,7 @@ func (cg *CodeGraph) SnapshotGraph() (nodes map[string]bool, edges map[string]bo } rows.Close() - rows, err = cg.db.Query("SELECT source || '->' || target || ':' || kind FROM edges") + rows, err = cg.db.QueryContext(context.Background(), "SELECT source || '->' || target || ':' || kind FROM edges") if err != nil { return nil, nil, err } @@ -537,7 +538,7 @@ func (cg *CodeGraph) FindDeadCode() ([]DeadCodeEntry, error) { defer cg.mu.RUnlock() // Get all nodes - rows, err := cg.db.Query( + rows, err := cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`, @@ -551,7 +552,7 @@ func (cg *CodeGraph) FindDeadCode() ([]DeadCodeEntry, error) { // Get all referenced node IDs referenced := make(map[string]bool) - edgeRows, _ := cg.db.Query("SELECT DISTINCT target FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements')") + edgeRows, _ := cg.db.QueryContext(context.Background(), "SELECT DISTINCT target FROM edges WHERE kind IN ('calls', 'references', 'imports', 'extends', 'implements')") if edgeRows != nil { for edgeRows.Next() { var target string @@ -565,7 +566,7 @@ func (cg *CodeGraph) FindDeadCode() ([]DeadCodeEntry, error) { } // Also mark source nodes as referenced (they're being used) - edgeRows, _ = cg.db.Query("SELECT DISTINCT source FROM edges") + edgeRows, _ = cg.db.QueryContext(context.Background(), "SELECT DISTINCT source FROM edges") if edgeRows != nil { for edgeRows.Next() { var source string @@ -677,7 +678,7 @@ func (cg *CodeGraph) PageRank(iterations int, damping float64) (map[string]float inlinks := make(map[string][]string) nodes := make(map[string]bool) - rows, err := cg.db.Query("SELECT source, target FROM edges WHERE kind IN ('calls', 'references', 'imports')") + rows, err := cg.db.QueryContext(context.Background(), "SELECT source, target FROM edges WHERE kind IN ('calls', 'references', 'imports')") if err != nil { return nil, err } @@ -768,7 +769,7 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult, result.Impacted[s.id] = s.depth // Get all nodes that depend on this one - rows, _ := cg.db.Query( + rows, _ := cg.db.QueryContext(context.Background(), `SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.id, ) if rows != nil { @@ -789,7 +790,7 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult, // Load node details for id, depth := range result.Impacted { var n Node - err := cg.db.QueryRow( + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, @@ -840,7 +841,7 @@ func (cg *CodeGraph) AnalyzeCoupling(topN int) ([]CouplingMetric, error) { // Build file -> set of referenced symbols fileDeps := make(map[string]map[string]bool) - rows, err := cg.db.Query("SELECT file_path, target FROM edges e JOIN nodes n ON n.id = e.source WHERE e.kind IN ('calls', 'references', 'imports')") + rows, err := cg.db.QueryContext(context.Background(), "SELECT file_path, target FROM edges e JOIN nodes n ON n.id = e.source WHERE e.kind IN ('calls', 'references', 'imports')") if err != nil { return nil, err } @@ -975,7 +976,7 @@ func FindCrossRepoCalls(repos []string) ([]CrossRepoCall, error) { repoNodes[repoRoot] = make(map[string]bool) // Get all nodes - rows, err := cg.db.Query("SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes") + rows, err := cg.db.QueryContext(context.Background(), "SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes") if err != nil { cg.Close() continue @@ -1002,7 +1003,7 @@ func FindCrossRepoCalls(repos []string) ([]CrossRepoCall, error) { } // Get unresolved refs (calls to symbols not in this repo) - rows, err := cg.db.Query("SELECT from_node_id, reference_name, file_path, line FROM unresolved_refs") + rows, err := cg.db.QueryContext(context.Background(), "SELECT from_node_id, reference_name, file_path, line FROM unresolved_refs") if err != nil { cg.Close() continue diff --git a/internal/codegraph/codegraph_cgo.go b/internal/codegraph/codegraph_cgo.go index bcbc8612..bb3c63fa 100644 --- a/internal/codegraph/codegraph_cgo.go +++ b/internal/codegraph/codegraph_cgo.go @@ -3,6 +3,7 @@ package codegraph import ( + "context" "crypto/sha256" "database/sql" "fmt" @@ -193,7 +194,7 @@ func (cg *CodeGraph) createSchema() error { VALUES (new.rowid, new.id, new.name, new.qualified_name, new.docstring, new.signature); END; ` - _, err := cg.db.Exec(schema) + _, err := cg.db.ExecContext(context.Background(), schema) return err } @@ -297,8 +298,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error { // Delete old nodes for this file cg.mu.Lock() - _, _ = cg.db.Exec("DELETE FROM nodes WHERE file_path = ?", filePath) - _, _ = cg.db.Exec("DELETE FROM edges WHERE source IN (SELECT id FROM nodes WHERE file_path = ?)", filePath) + _, _ = cg.db.ExecContext(context.Background(), "DELETE FROM nodes WHERE file_path = ?", filePath) + _, _ = cg.db.ExecContext(context.Background(), "DELETE FROM edges WHERE source IN (SELECT id FROM nodes WHERE file_path = ?)", filePath) cg.mu.Unlock() // Walk AST and extract symbols @@ -364,7 +365,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { defer cg.mu.Unlock() for _, n := range nodes { - _, err := cg.db.Exec( + _, err := cg.db.ExecContext(context.Background(), `INSERT OR REPLACE INTO nodes (id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, n.ID, n.Kind, n.Name, n.QualifiedName, n.FilePath, n.Language, @@ -377,7 +378,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { } for _, e := range edges { - _, err := cg.db.Exec( + _, err := cg.db.ExecContext(context.Background(), `INSERT INTO edges (source, target, kind, line, metadata) VALUES (?, ?, ?, ?, ?)`, e.Source, e.Target, e.Kind, e.Line, e.Metadata, ) @@ -387,7 +388,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { } for _, ref := range unresolvedRefs { - _, err := cg.db.Exec( + _, err := cg.db.ExecContext(context.Background(), `INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, file_path, language) VALUES (?, ?, ?, ?, ?, ?)`, ref.FromNodeID, ref.ReferenceName, ref.ReferenceKind, ref.Line, ref.FilePath, ref.Language, @@ -399,7 +400,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { // Update file record hash := sha256Sum(source) - _, _ = cg.db.Exec( + _, _ = cg.db.ExecContext(context.Background(), `INSERT OR REPLACE INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count) VALUES (?, ?, ?, ?, ?, ?, ?)`, filePath, hash, ext, len(source), time.Now().Unix(), time.Now().Unix(), len(nodes), @@ -438,7 +439,7 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) { cg.mu.RLock() defer cg.mu.RUnlock() - rows, err := cg.db.Query( + rows, err := cg.db.QueryContext(context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM nodes_fts fts @@ -449,7 +450,7 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) { ) if err != nil { // Fallback to LIKE search - rows, err = cg.db.Query( + rows, err = cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE name LIKE ? ORDER BY name LIMIT ?`, @@ -490,7 +491,7 @@ func (cg *CodeGraph) GetCallers(nodeID string, maxDepth int) ([]Node, error) { } visited[current.id] = true - rows, err := cg.db.Query( + rows, err := cg.db.QueryContext(context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM edges e JOIN nodes n ON n.id = e.source @@ -541,7 +542,7 @@ func (cg *CodeGraph) GetCallees(nodeID string, maxDepth int) ([]Node, error) { } visited[current.id] = true - rows, err := cg.db.Query( + rows, err := cg.db.QueryContext(context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM edges e JOIN nodes n ON n.id = e.target @@ -577,7 +578,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // Get the focal node var focalNode Node - err := cg.db.QueryRow( + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, nodeID, @@ -614,7 +615,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // Get node var n Node - err := cg.db.QueryRow( + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, s.nodeID, @@ -629,7 +630,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // If container, expand children at same depth if containerKinds[n.Kind] { - childRows, _ := cg.db.Query( + childRows, _ := cg.db.QueryContext(context.Background(), `SELECT target FROM edges WHERE source = ? AND kind = 'contains'`, s.nodeID, ) if childRows != nil { @@ -645,7 +646,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error } // Traverse incoming edges (things that depend on this node) - depRows, _ := cg.db.Query( + depRows, _ := cg.db.QueryContext(context.Background(), `SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.nodeID, ) if depRows != nil { @@ -735,7 +736,7 @@ func (cg *CodeGraph) ResolveRefs() error { cg.mu.Lock() defer cg.mu.Unlock() - rows, err := cg.db.Query(`SELECT id, from_node_id, reference_name, reference_kind, line, file_path, language FROM unresolved_refs`) + rows, err := cg.db.QueryContext(context.Background(), `SELECT id, from_node_id, reference_name, reference_kind, line, file_path, language FROM unresolved_refs`) if err != nil { return err } @@ -762,7 +763,7 @@ func (cg *CodeGraph) ResolveRefs() error { for _, r := range refs { // Try to find target by name var targetID string - err := cg.db.QueryRow( + err := cg.db.QueryRowContext(context.Background(), `SELECT id FROM nodes WHERE name = ? OR qualified_name LIKE ? LIMIT 1`, r.name, "%"+r.name, ).Scan(&targetID) @@ -771,7 +772,7 @@ func (cg *CodeGraph) ResolveRefs() error { } // Create edge - _, err = cg.db.Exec( + _, err = cg.db.ExecContext(context.Background(), `INSERT INTO edges (source, target, kind, line) VALUES (?, ?, ?, ?)`, r.fromID, targetID, r.kind, r.line, ) @@ -781,7 +782,7 @@ func (cg *CodeGraph) ResolveRefs() error { } // Clean up resolved refs - _, _ = cg.db.Exec(`DELETE FROM unresolved_refs`) + _, _ = cg.db.ExecContext(context.Background(), `DELETE FROM unresolved_refs`) return nil } @@ -794,16 +795,16 @@ func (cg *CodeGraph) Stats() (map[string]interface{}, error) { stats := make(map[string]interface{}) var nodeCount, edgeCount, fileCount int - cg.db.QueryRow("SELECT COUNT(*) FROM nodes").Scan(&nodeCount) - cg.db.QueryRow("SELECT COUNT(*) FROM edges").Scan(&edgeCount) - cg.db.QueryRow("SELECT COUNT(*) FROM files").Scan(&fileCount) + cg.db.QueryRowContext(context.Background(), "SELECT COUNT(*) FROM nodes").Scan(&nodeCount) + cg.db.QueryRowContext(context.Background(), "SELECT COUNT(*) FROM edges").Scan(&edgeCount) + cg.db.QueryRowContext(context.Background(), "SELECT COUNT(*) FROM files").Scan(&fileCount) stats["nodes"] = nodeCount stats["edges"] = edgeCount stats["files"] = fileCount // Nodes by kind - rows, _ := cg.db.Query("SELECT kind, COUNT(*) FROM nodes GROUP BY kind ORDER BY COUNT(*) DESC") + rows, _ := cg.db.QueryContext(context.Background(), "SELECT kind, COUNT(*) FROM nodes GROUP BY kind ORDER BY COUNT(*) DESC") if rows != nil { byKind := make(map[string]int) for rows.Next() { @@ -1075,7 +1076,7 @@ func (cg *CodeGraph) Sync() (*SyncResult, error) { // Get currently tracked files trackedFiles := make(map[string]string) // path -> content_hash - rows, err := cg.db.Query("SELECT path, content_hash FROM files") + rows, err := cg.db.QueryContext(context.Background(), "SELECT path, content_hash FROM files") if err != nil { return nil, err } @@ -1140,9 +1141,9 @@ func (cg *CodeGraph) Sync() (*SyncResult, error) { if !currentFiles[trackedPath] { absPath := filepath.Join(cg.root, trackedPath) relForDelete := trackedPath - cg.db.Exec("DELETE FROM nodes WHERE file_path = ?", absPath) - cg.db.Exec("DELETE FROM edges WHERE source IN (SELECT id FROM nodes WHERE file_path = ?)", absPath) - cg.db.Exec("DELETE FROM files WHERE path = ?", relForDelete) + cg.db.ExecContext(context.Background(), "DELETE FROM nodes WHERE file_path = ?", absPath) + cg.db.ExecContext(context.Background(), "DELETE FROM edges WHERE source IN (SELECT id FROM nodes WHERE file_path = ?)", absPath) + cg.db.ExecContext(context.Background(), "DELETE FROM files WHERE path = ?", relForDelete) result.FilesRemoved++ } } @@ -1199,7 +1200,7 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) { var path []Node for _, id := range current.path { var n Node - err := cg.db.QueryRow( + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, @@ -1215,7 +1216,7 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) { } // Expand via call edges - edgeRows, _ := cg.db.Query( + edgeRows, _ := cg.db.QueryContext(context.Background(), `SELECT target FROM edges WHERE source = ? AND kind IN ('calls', 'references') LIMIT 20`, current.nodeID, ) if edgeRows != nil { @@ -1331,7 +1332,7 @@ func (cg *CodeGraph) Files(dirFilter string) ([]FileEntry, error) { } query += " ORDER BY path" - rows, err := cg.db.Query(query, args...) + rows, err := cg.db.QueryContext(context.Background(), query, args...) if err != nil { return nil, err } @@ -1379,13 +1380,13 @@ func (cg *CodeGraph) Status() (*StatusResult, error) { } // Counts - cg.db.QueryRow("SELECT COUNT(*) FROM nodes").Scan(&status.Nodes) - cg.db.QueryRow("SELECT COUNT(*) FROM edges").Scan(&status.Edges) - cg.db.QueryRow("SELECT COUNT(*) FROM files").Scan(&status.Files) - cg.db.QueryRow("SELECT COUNT(*) FROM unresolved_refs").Scan(&status.Unresolved) + cg.db.QueryRowContext(context.Background(), "SELECT COUNT(*) FROM nodes").Scan(&status.Nodes) + cg.db.QueryRowContext(context.Background(), "SELECT COUNT(*) FROM edges").Scan(&status.Edges) + cg.db.QueryRowContext(context.Background(), "SELECT COUNT(*) FROM files").Scan(&status.Files) + cg.db.QueryRowContext(context.Background(), "SELECT COUNT(*) FROM unresolved_refs").Scan(&status.Unresolved) // Nodes by kind - rows, _ := cg.db.Query("SELECT kind, COUNT(*) FROM nodes GROUP BY kind ORDER BY COUNT(*) DESC") + rows, _ := cg.db.QueryContext(context.Background(), "SELECT kind, COUNT(*) FROM nodes GROUP BY kind ORDER BY COUNT(*) DESC") if rows != nil { for rows.Next() { var kind string @@ -1397,7 +1398,7 @@ func (cg *CodeGraph) Status() (*StatusResult, error) { } // Files by language - rows, _ = cg.db.Query("SELECT language, COUNT(*) FROM files GROUP BY language ORDER BY COUNT(*) DESC") + rows, _ = cg.db.QueryContext(context.Background(), "SELECT language, COUNT(*) FROM files GROUP BY language ORDER BY COUNT(*) DESC") if rows != nil { for rows.Next() { var lang string @@ -1409,11 +1410,11 @@ func (cg *CodeGraph) Status() (*StatusResult, error) { } // Journal mode - cg.db.QueryRow("PRAGMA journal_mode").Scan(&status.JournalMode) + cg.db.QueryRowContext(context.Background(), "PRAGMA journal_mode").Scan(&status.JournalMode) // Check if up to date (no pending changes) status.UpToDate = true - fileRows, _ := cg.db.Query("SELECT path, content_hash FROM files") + fileRows, _ := cg.db.QueryContext(context.Background(), "SELECT path, content_hash FROM files") if fileRows != nil { for fileRows.Next() { var path, hash string @@ -1437,7 +1438,7 @@ func (cg *CodeGraph) Status() (*StatusResult, error) { // searchByName is an internal search that returns nodes matching a name. func (cg *CodeGraph) searchByName(name string, limit int) ([]Node, error) { - rows, err := cg.db.Query( + rows, err := cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE name = ? OR name LIKE ? LIMIT ?`, @@ -1456,7 +1457,7 @@ func (cg *CodeGraph) GetNode(id string) (Node, error) { defer cg.mu.RUnlock() var n Node - err := cg.db.QueryRow( + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, diff --git a/internal/codegraph/embeddings_cgo.go b/internal/codegraph/embeddings_cgo.go index 37182cd0..3304fb3f 100644 --- a/internal/codegraph/embeddings_cgo.go +++ b/internal/codegraph/embeddings_cgo.go @@ -2,7 +2,10 @@ package codegraph -import "sort" +import ( + "context" + "sort" +) // SemanticSearch performs embedding-based semantic search. // It generates embeddings for all nodes and finds the most similar @@ -25,7 +28,7 @@ func (cg *CodeGraph) SemanticSearch(query string, limit int) ([]Node, error) { queryVec := GenerateEmbedding(queryNode) // Get all nodes - rows, err := cg.db.Query( + rows, err := cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`, diff --git a/internal/tool/git_history.go b/internal/tool/git_history.go index 3f288d44..9b0abe5b 100644 --- a/internal/tool/git_history.go +++ b/internal/tool/git_history.go @@ -70,24 +70,24 @@ func (GitHistoryTool) Execute(ctx context.Context, input json.RawMessage) (strin switch p.Action { case "history": - return gitFileHistory(root, p.File, p.Limit) + return gitFileHistory(ctx, root, p.File, p.Limit) case "cochange": - return gitCoChange(root, p.File, p.Limit) + return gitCoChange(ctx, root, p.File, p.Limit) case "owners": - return gitFileOwners(root, p.File, p.Limit) + return gitFileOwners(ctx, root, p.File, p.Limit) case "blame": - return gitBlame(root, p.File) + return gitBlame(ctx, root, p.File) default: return "", fmt.Errorf("unknown action: %s (use: history, cochange, owners, blame)", p.Action) } } -func gitFileHistory(root, file string, limit int) (string, error) { +func gitFileHistory(ctx context.Context, root, file string, limit int) (string, error) { if file == "" { return "", fmt.Errorf("file is required for history action") } - cmd := exec.Command("git", "log", "--oneline", "--follow", fmt.Sprintf("-%d", limit), "--", file) + cmd := exec.CommandContext(ctx, "git", "log", "--oneline", "--follow", fmt.Sprintf("-%d", limit), "--", file) cmd.Dir = root out, err := cmd.Output() if err != nil { @@ -107,13 +107,13 @@ func gitFileHistory(root, file string, limit int) (string, error) { return b.String(), nil } -func gitCoChange(root, file string, limit int) (string, error) { +func gitCoChange(ctx context.Context, root, file string, limit int) (string, error) { if file == "" { return "", fmt.Errorf("file is required for cochange action") } // Get commits that touched this file - cmd := exec.Command("git", "log", "--format=%H", "--follow", fmt.Sprintf("-%d", limit*5), "--", file) + cmd := exec.CommandContext(ctx, "git", "log", "--format=%H", "--follow", fmt.Sprintf("-%d", limit*5), "--", file) cmd.Dir = root out, err := cmd.Output() if err != nil { @@ -131,7 +131,7 @@ func gitCoChange(root, file string, limit int) (string, error) { if commit == "" { continue } - cmd := exec.Command("git", "diff-tree", "--no-commit-id", "--name-only", "-r", commit) + cmd := exec.CommandContext(ctx, "git", "diff-tree", "--no-commit-id", "--name-only", "-r", commit) cmd.Dir = root out, err := cmd.Output() if err != nil { @@ -177,13 +177,13 @@ func gitCoChange(root, file string, limit int) (string, error) { return b.String(), nil } -func gitFileOwners(root, file string, limit int) (string, error) { +func gitFileOwners(ctx context.Context, root, file string, limit int) (string, error) { args := []string{"log", "--format=%an", "--follow", fmt.Sprintf("-%d", limit*10)} if file != "" { args = append(args, "--", file) } - cmd := exec.Command("git", args...) + cmd := exec.CommandContext(ctx, "git", args...) cmd.Dir = root out, err := cmd.Output() if err != nil { @@ -236,12 +236,12 @@ func gitFileOwners(root, file string, limit int) (string, error) { return b.String(), nil } -func gitBlame(root, file string) (string, error) { +func gitBlame(ctx context.Context, root, file string) (string, error) { if file == "" { return "", fmt.Errorf("file is required for blame action") } - cmd := exec.Command("git", "blame", "--line-porcelain", file) + cmd := exec.CommandContext(ctx, "git", "blame", "--line-porcelain", file) cmd.Dir = root out, err := cmd.Output() if err != nil { diff --git a/internal/tool/impact.go b/internal/tool/impact.go index ff78ad3c..cb74b3bd 100644 --- a/internal/tool/impact.go +++ b/internal/tool/impact.go @@ -66,7 +66,7 @@ func (ImpactTool) Execute(ctx context.Context, input json.RawMessage) (string, e // If no files specified, get from git diff if len(p.Files) == 0 { - files, err := gitDiffFiles(root) + files, err := gitDiffFiles(ctx, root) if err != nil { return "", fmt.Errorf("impact: failed to get git diff: %w", err) } @@ -85,7 +85,7 @@ func (ImpactTool) Execute(ctx context.Context, input json.RawMessage) (string, e } // Build co-change analysis - coChange, err := buildCoChangeAnalysis(root, 100) + coChange, err := buildCoChangeAnalysis(ctx, root, 100) if err != nil { coChange = &simpleCoChange{pairs: make(map[string]map[string]int)} } @@ -386,14 +386,14 @@ func formatImpactReport(analysis *ImpactAnalysis) string { // ── Helpers ── -func gitDiffFiles(root string) ([]string, error) { +func gitDiffFiles(ctx context.Context, root string) ([]string, error) { // Try staged + unstaged - cmd := exec.Command("git", "diff", "--name-only", "HEAD") + cmd := exec.CommandContext(ctx, "git", "diff", "--name-only", "HEAD") cmd.Dir = root out, err := cmd.Output() if err != nil { // Try initial commit - cmd = exec.Command("git", "diff", "--name-only", "--cached") + cmd = exec.CommandContext(ctx, "git", "diff", "--name-only", "--cached") cmd.Dir = root out, err = cmd.Output() if err != nil { @@ -575,8 +575,8 @@ func resolveImport(imp, ext, dir, root string) string { return "" } -func buildCoChangeAnalysis(root string, commitLimit int) (*simpleCoChange, error) { - cmd := exec.Command("git", "log", "--name-only", "--pretty=format:", fmt.Sprintf("-%d", commitLimit)) +func buildCoChangeAnalysis(ctx context.Context, root string, commitLimit int) (*simpleCoChange, error) { + cmd := exec.CommandContext(ctx, "git", "log", "--name-only", "--pretty=format:", fmt.Sprintf("-%d", commitLimit)) cmd.Dir = root out, err := cmd.Output() if err != nil { diff --git a/compatibility-matrix.json b/platform-capabilities.json similarity index 100% rename from compatibility-matrix.json rename to platform-capabilities.json diff --git a/testdata/compatibility-matrix.json b/testdata/compatibility-matrix.json index 4556aac3..45e2afd5 100644 --- a/testdata/compatibility-matrix.json +++ b/testdata/compatibility-matrix.json @@ -2,7 +2,7 @@ "$schema": "./compatibility-matrix.schema.json", "description": "Cross-repo compatibility tracking for GrayCodeAI repositories. Each `matrix` entry records a combination of component versions that have been tested together. CI runs the matrix on a schedule and on PR to ensure released components stay compatible.", "version": "1", - "updated": "2026-05-18", + "updated": "2026-06-02", "components": [ "hawk", "hawk-sdk-go", From ccb5e14ee407595c02380dad8f5e3ec57dad4b9d Mon Sep 17 00:00:00 2001 From: Patel230 Date: Tue, 2 Jun 2026 09:58:38 +0530 Subject: [PATCH 2/2] style: gofumpt codegraph cgo files for CI format gate --- internal/codegraph/algorithms_cgo.go | 6 ++--- internal/codegraph/codegraph_cgo.go | 36 ++++++++++++++-------------- internal/codegraph/embeddings_cgo.go | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/internal/codegraph/algorithms_cgo.go b/internal/codegraph/algorithms_cgo.go index 850b3011..384ce9c7 100644 --- a/internal/codegraph/algorithms_cgo.go +++ b/internal/codegraph/algorithms_cgo.go @@ -538,7 +538,7 @@ func (cg *CodeGraph) FindDeadCode() ([]DeadCodeEntry, error) { defer cg.mu.RUnlock() // Get all nodes - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`, @@ -769,7 +769,7 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult, result.Impacted[s.id] = s.depth // Get all nodes that depend on this one - rows, _ := cg.db.QueryContext(context.Background(), + rows, _ := cg.db.QueryContext(context.Background(), `SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.id, ) if rows != nil { @@ -790,7 +790,7 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult, // Load node details for id, depth := range result.Impacted { var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, diff --git a/internal/codegraph/codegraph_cgo.go b/internal/codegraph/codegraph_cgo.go index bb3c63fa..e468c609 100644 --- a/internal/codegraph/codegraph_cgo.go +++ b/internal/codegraph/codegraph_cgo.go @@ -365,7 +365,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { defer cg.mu.Unlock() for _, n := range nodes { - _, err := cg.db.ExecContext(context.Background(), + _, err := cg.db.ExecContext(context.Background(), `INSERT OR REPLACE INTO nodes (id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, n.ID, n.Kind, n.Name, n.QualifiedName, n.FilePath, n.Language, @@ -378,7 +378,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { } for _, e := range edges { - _, err := cg.db.ExecContext(context.Background(), + _, err := cg.db.ExecContext(context.Background(), `INSERT INTO edges (source, target, kind, line, metadata) VALUES (?, ?, ?, ?, ?)`, e.Source, e.Target, e.Kind, e.Line, e.Metadata, ) @@ -388,7 +388,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { } for _, ref := range unresolvedRefs { - _, err := cg.db.ExecContext(context.Background(), + _, err := cg.db.ExecContext(context.Background(), `INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, file_path, language) VALUES (?, ?, ?, ?, ?, ?)`, ref.FromNodeID, ref.ReferenceName, ref.ReferenceKind, ref.Line, ref.FilePath, ref.Language, @@ -400,7 +400,7 @@ func (cg *CodeGraph) IndexFile(filePath string) error { // Update file record hash := sha256Sum(source) - _, _ = cg.db.ExecContext(context.Background(), + _, _ = cg.db.ExecContext(context.Background(), `INSERT OR REPLACE INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count) VALUES (?, ?, ?, ?, ?, ?, ?)`, filePath, hash, ext, len(source), time.Now().Unix(), time.Now().Unix(), len(nodes), @@ -439,7 +439,7 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) { cg.mu.RLock() defer cg.mu.RUnlock() - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext(context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM nodes_fts fts @@ -450,7 +450,7 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) { ) if err != nil { // Fallback to LIKE search - rows, err = cg.db.QueryContext(context.Background(), + rows, err = cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE name LIKE ? ORDER BY name LIMIT ?`, @@ -491,7 +491,7 @@ func (cg *CodeGraph) GetCallers(nodeID string, maxDepth int) ([]Node, error) { } visited[current.id] = true - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext(context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM edges e JOIN nodes n ON n.id = e.source @@ -542,7 +542,7 @@ func (cg *CodeGraph) GetCallees(nodeID string, maxDepth int) ([]Node, error) { } visited[current.id] = true - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext(context.Background(), `SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language, n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported FROM edges e JOIN nodes n ON n.id = e.target @@ -578,7 +578,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // Get the focal node var focalNode Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, nodeID, @@ -615,7 +615,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // Get node var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, s.nodeID, @@ -630,7 +630,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error // If container, expand children at same depth if containerKinds[n.Kind] { - childRows, _ := cg.db.QueryContext(context.Background(), + childRows, _ := cg.db.QueryContext(context.Background(), `SELECT target FROM edges WHERE source = ? AND kind = 'contains'`, s.nodeID, ) if childRows != nil { @@ -646,7 +646,7 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error } // Traverse incoming edges (things that depend on this node) - depRows, _ := cg.db.QueryContext(context.Background(), + depRows, _ := cg.db.QueryContext(context.Background(), `SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.nodeID, ) if depRows != nil { @@ -763,7 +763,7 @@ func (cg *CodeGraph) ResolveRefs() error { for _, r := range refs { // Try to find target by name var targetID string - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext(context.Background(), `SELECT id FROM nodes WHERE name = ? OR qualified_name LIKE ? LIMIT 1`, r.name, "%"+r.name, ).Scan(&targetID) @@ -772,7 +772,7 @@ func (cg *CodeGraph) ResolveRefs() error { } // Create edge - _, err = cg.db.ExecContext(context.Background(), + _, err = cg.db.ExecContext(context.Background(), `INSERT INTO edges (source, target, kind, line) VALUES (?, ?, ?, ?)`, r.fromID, targetID, r.kind, r.line, ) @@ -1200,7 +1200,7 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) { var path []Node for _, id := range current.path { var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, @@ -1216,7 +1216,7 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) { } // Expand via call edges - edgeRows, _ := cg.db.QueryContext(context.Background(), + edgeRows, _ := cg.db.QueryContext(context.Background(), `SELECT target FROM edges WHERE source = ? AND kind IN ('calls', 'references') LIMIT 20`, current.nodeID, ) if edgeRows != nil { @@ -1438,7 +1438,7 @@ func (cg *CodeGraph) Status() (*StatusResult, error) { // searchByName is an internal search that returns nodes matching a name. func (cg *CodeGraph) searchByName(name string, limit int) ([]Node, error) { - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE name = ? OR name LIKE ? LIMIT ?`, @@ -1457,7 +1457,7 @@ func (cg *CodeGraph) GetNode(id string) (Node, error) { defer cg.mu.RUnlock() var n Node - err := cg.db.QueryRowContext(context.Background(), + err := cg.db.QueryRowContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE id = ?`, id, diff --git a/internal/codegraph/embeddings_cgo.go b/internal/codegraph/embeddings_cgo.go index 3304fb3f..0f47d80b 100644 --- a/internal/codegraph/embeddings_cgo.go +++ b/internal/codegraph/embeddings_cgo.go @@ -28,7 +28,7 @@ func (cg *CodeGraph) SemanticSearch(query string, limit int) ([]Node, error) { queryVec := GenerateEmbedding(queryNode) // Get all nodes - rows, err := cg.db.QueryContext(context.Background(), + rows, err := cg.db.QueryContext(context.Background(), `SELECT id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`,