go-incremental-scc-invalidation-frontier
I built and verified the solution. The complete, self-contained markdown is at ~/SOLUTION.md, and the working implementation/tests are in ~/incscc/ (graph.go, graph_test.go, go.mod). I verified that the code embedded in the markdown byte-for-byte matches the tested files.
A naive invalidator fails in five concrete ways:
{x : cv→*x} ∩ {x : x→*cu}; deletions run Tarjan only on the induced old component.Out/In as sets and drop only when hasCompEdge is false.topoDirty + lazy ensureTopo.compHash over the acyclic condensation, stopping propagation where the hash is unchanged.~/incscc)gofmt -l . # clean
go vet ./... # clean
go test -race ./... # ok incscc 5.2s
--- PASS: TestCycleMergeAndSplit
--- PASS: TestNoOpContentProducesNoFrontier
--- PASS: TestMergeSplitsAcrossManyComponents
--- PASS: TestDeterminismAcrossReplays
--- PASS: TestRandomizedAgainstBruteForce (40 seeds × 80 ops)
--- PASS: TestSparseDeletionIsLocal
--- PASS: TestSparseInsertionMergeIsLocal
--- PASS: ExampleGraph
The randomized differential test is the proof: after every edit it checks the SCC partition against from-scratch Tarjan, validates the topological build order, and asserts the emitted frontier equals the set of nodes whose semantic hash changed under an independent full recomputation. Locality is measured: a 500-node SCC inside a 5000-node graph touches exactly 500 nodes on deletion, and the benchmark stays ~180 µs per edit on a 400-node SCC inside a 40,000-node graph.
The markdown contains the full root-cause analysis, architecture/correctness argument, the complete graph.go/graph_test.go, and all reproduction commands.
# Evidence - Problem class: go-incremental-scc-invalidation-frontier - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-04T16:22:48.279Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Given a mutable module dependency graph with edge insertions and deletions, implement an incremental compiler invalidator that maintains strongly connected components and computes the minimal rebuild frontier, including cycles that split or merge after edits. Emit a deterministic topological build order and prove that cached artifacts are reused exactly when their transitive semantic inputs are unchanged, while avoiding full-graph recomputation on sparse edits.", "environment": "go1.26", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-incremental-scc-invalidation-frontier", "provider": "openrouter", "solved_at": "2026-10-04T16:22:48.280Z", "version": "1.26"}