Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eval/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/provasign/astkit v0.16.9 // indirect
github.com/provasign/astkit v0.16.10 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 // indirect
github.com/sourcegraph/beaut v0.0.0-20240611013027-627e4c25335a // indirect
Expand Down
4 changes: 2 additions & 2 deletions eval/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOF
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/provasign/astkit v0.16.9 h1:R8QeXlGhnahkyfxMKTfqfijth29BxP6dTBhar4036Mw=
github.com/provasign/astkit v0.16.9/go.mod h1:uSQxIxw3dVpK/6KmHvqIE8+DK/nhxDuPklKv7g96Jr4=
github.com/provasign/astkit v0.16.10 h1:KqLxccJByRASIBm+wOHTnd3F9Xs0+qnbUfJns37xqUE=
github.com/provasign/astkit v0.16.10/go.mod h1:uSQxIxw3dVpK/6KmHvqIE8+DK/nhxDuPklKv7g96Jr4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/scip-code/scip/bindings/go/scip v0.8.1 h1:ZkyT9RDgkbd6ffvMbi9nYdwh7+gLoz8Z9ftFMxgUiVs=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.26
require modernc.org/sqlite v1.51.0

require (
github.com/provasign/astkit v0.16.9
github.com/provasign/astkit v0.16.10
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
golang.org/x/sys v0.46.0
google.golang.org/protobuf v1.36.11
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOF
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/provasign/astkit v0.16.9 h1:R8QeXlGhnahkyfxMKTfqfijth29BxP6dTBhar4036Mw=
github.com/provasign/astkit v0.16.9/go.mod h1:uSQxIxw3dVpK/6KmHvqIE8+DK/nhxDuPklKv7g96Jr4=
github.com/provasign/astkit v0.16.10 h1:KqLxccJByRASIBm+wOHTnd3F9Xs0+qnbUfJns37xqUE=
github.com/provasign/astkit v0.16.10/go.mod h1:uSQxIxw3dVpK/6KmHvqIE8+DK/nhxDuPklKv7g96Jr4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=
Expand Down
5 changes: 5 additions & 0 deletions internal/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ const (
// MetaNativeComplete: JSON list of native analyzers that have completed
// a full pass on this index (later passes may be incremental).
MetaNativeComplete = "native-complete"
// MetaNativeLastGood: JSON object analyzer -> the diagnostic lines of
// its last pass that produced edges. A run that carries an analyzer's
// stored edges forward reports these lines once, followed by the
// current attempt's lines (see index.carryForwardVerdict).
MetaNativeLastGood = "native-last-good"
)

type IndexResult struct {
Expand Down
147 changes: 147 additions & 0 deletions internal/index/compilerinputs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package index

import (
"context"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"

"github.com/provasign/grove/internal/core"
"github.com/provasign/grove/internal/native"
"github.com/provasign/grove/internal/parser"
"github.com/provasign/grove/internal/store"
)

func writeFiles(t *testing.T, root string, files map[string]string) {
t.Helper()
for rel, body := range files {
p := filepath.Join(root, filepath.FromSlash(rel))
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(p, []byte(body), 0o644); err != nil {
t.Fatal(err)
}
}
}

// Stack audit 2026-10-20 #2: editing only tsconfig.json after a completed
// TypeScript pass skipped the analyzer ("no changed files in its
// languages"): config files are plaintext and native scope used only the
// changed source languages.
func TestConfigOnlyChangeInvalidatesNative(t *testing.T) {
root := t.TempDir()
ctx := context.Background()
writeFiles(t, root, map[string]string{
"a.ts": "export function target() {}\nexport function caller() { target(); }\n",
"tsconfig.json": `{"compilerOptions":{"strict":false},"include":["*.ts"]}`,
})
st, err := store.Open(root)
if err != nil {
t.Fatal(err)
}
defer st.Close()
idx := NewWithNativeConfig(parser.NewEngine(), st, native.Config{Enabled: false})
if _, initial, err := idx.Index(ctx, root); err != nil || initial.EdgeCount == 0 {
t.Fatalf("seed: %v %#v", err, initial)
}
if err := st.SetMeta(ctx, core.MetaNativeComplete, `["go","js-ts"]`); err != nil {
t.Fatal(err)
}
writeFiles(t, root, map[string]string{"tsconfig.json": `{"compilerOptions":{"strict":true},"include":["*.ts"]}`})
idx.SetNativeConfig(native.Config{Enabled: true})
_, r, err := idx.Index(ctx, root)
if err != nil {
t.Fatal(err)
}
joined := strings.Join(r.Native, "\n")
if strings.Contains(joined, "js-ts: skipped: no changed files") {
t.Fatalf("tsconfig changed but TypeScript analysis was skipped: %v", r.Native)
}
if !strings.Contains(joined, "js-ts: compiler inputs changed (tsconfig.json)") {
t.Fatalf("invalidation not reported: %v", r.Native)
}
raw, _, _ := st.GetMeta(ctx, core.MetaNativeComplete)
if strings.Contains(raw, "js-ts") || !strings.Contains(raw, "go") {
t.Fatalf("native-complete = %s, want js-ts dropped and go kept", raw)
}
}

// go.mod is not even an indexed file: a module-only edit was a no-op index
// that kept the old go list/type-check results.
func TestGoModOnlyChangeRerunsGoAnalyzer(t *testing.T) {
if _, err := exec.LookPath("go"); err != nil {
t.Skip("go not found")
}
root := t.TempDir()
ctx := context.Background()
writeFiles(t, root, map[string]string{
"go.mod": "module inputs\n\ngo 1.22\n",
"main.go": "package main\n\nfunc main() { run() }\n\nfunc run() {}\n",
})
st, err := store.Open(root)
if err != nil {
t.Fatal(err)
}
defer st.Close()
idx := New(parser.NewEngine(), st)
_, first, err := idx.Index(ctx, root)
if err != nil {
t.Fatal(err)
}
skipUnless(t, first.Native, "go: resolved ")

// Touched, identical content: still a no-op.
later := time.Now().Add(time.Minute)
if err := os.Chtimes(filepath.Join(root, "go.mod"), later, later); err != nil {
t.Fatal(err)
}
_, touched, err := idx.Index(ctx, root)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(strings.Join(touched.Native, "\n"), "no file changes") {
t.Fatalf("touch-only go.mod should stay a no-op: %v", touched.Native)
}

writeFiles(t, root, map[string]string{"go.mod": "module inputs\n\ngo 1.23\n"})
_, r, err := idx.Index(ctx, root)
if err != nil {
t.Fatal(err)
}
joined := strings.Join(r.Native, "\n")
if strings.Contains(joined, "no file changes") || !strings.Contains(joined, "go: compiler inputs changed (go.mod)") ||
!strings.Contains(joined, "go: full pass") {
t.Fatalf("go.mod change did not re-run the Go analyzer: %v", r.Native)
}
if r.EdgeCount == 0 {
t.Fatalf("graph lost its edges: %#v", r)
}
// Settled: the next plain index is a no-op again.
_, again, err := idx.Index(ctx, root)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(strings.Join(again.Native, "\n"), "no file changes") {
t.Fatalf("after the re-run the index should settle: %v", again.Native)
}
}

func TestCompilerInputAnalyzers(t *testing.T) {
cases := map[string]string{
"go.mod": "go", "sub/go.sum": "go", "go.work": "go",
"tsconfig.json": "js-ts", "packages/x/tsconfig.build.json": "js-ts", "jsconfig.json": "js-ts", "web/package.json": "js-ts",
"pom.xml": "java", "app/build.gradle.kts": "java", "Cargo.toml": "rust", "compile_commands.json": "cfamily",
"src/App.csproj": "csharp", "composer.json": "php", "pyproject.toml": "python",
"README.md": "", "config.json": "", "main.go": "",
}
for rel, want := range cases {
got := strings.Join(native.CompilerInputAnalyzers(rel), ",")
if got != want {
t.Errorf("%s: got %q want %q", rel, got, want)
}
}
}
Loading
Loading