Entry 14Verification · open source2026

Checking codegraph’s call graph against compilers and fresh indexes

codegraph is an open-source tool (MIT licensed, about 78,000 GitHub stars) that indexes a codebase into a call graph, a map of which functions call which, and serves it to coding agents over MCP (Model Context Protocol, the standard way agents call tools). I use it every day and build other tools on it. I wrote test tooling, now public as graph-assay, that compares its graph with independent references, reduced each disagreement to a minimal repro (the smallest code that shows the bug), and filed it upstream, with a fix when I had one.

issues filed upstream143
issues closed130
my pull requests merged17
sync replay steps / drifts found2,979 / 12

Browse all 143 upstream issues · graph-assay · fork

Why a wrong call edge is worse than a missing one

An edge is one link in the call graph, from a call site to the definition it reaches. When codegraph cannot tell which same-named function a call reaches, it can guess by name. A missing edge leaves a visible gap. A wrong guess looks like every correct edge, so an agent asking “who calls this?” gets a confident wrong answer.

In October I audited codegraph against each language’s type checker on my own repositories. Precision (the share of reported edges that were correct) was 99.8% for Python calls, 97 to 100% for TypeScript and 97.8% for Go, where recall (the share of true calls it found) was 98.1%. The remaining errors look like every other edge, and finding them takes a reference that does not come from codegraph.

Three checks that do not trust the graph

Each check compares codegraph with something it does not control.

Compiler oracle joined per call site

SCIP is a code index format from Sourcegraph whose indexers run each language’s own type checker (tsc, pyright, javac) and record where every reference resolves. The oracle joins codegraph’s edges to SCIP’s references by file, line, called name and nearest column, so overloads and same-named methods stay separate.

Each disagreement is sorted by cause. Three buckets hold bug candidates: the compiler resolves a different project definition, resolves a library where codegraph linked a project function, or sees a local variable where codegraph linked a global. Other buckets hold codegraph’s deliberate conventions. On jsoup, a public Java library, 16.9k call sites agreed and 2.4k fell in the wrong-target bucket. Triage found three candidate shapes, and one reproduced minimally (#3040).

Sync-versus-fresh replay 7 replay lanes

codegraph updates its index incrementally when files change (a sync). The harness replays a repository’s git history, syncs after each step, and compares the result with a fresh index of the same commit. Seven lanes vary the replay: no-op, forward, reverse, random jumps, one file at a time, a sync killed mid-write, and two syncs at once.

A disagreement triggers a second fresh build, so nondeterminism is not reported as drift. A control run with sync switched off, which must show drift, was caught on 4 of 4 forward steps, 4 of 4 reverse and 7 of 8 file by file. The overnight run on 29 October covered 11 repositories: 2,979 steps, 12 drifts and no failed integrity checks. One drift was a harness fault, and the harness now guards against it.

Fault injection 2 daemon bugs

Two bugs in codegraph’s daemon and worker pool depended on timing: a peer that drops mid-handshake leaves a phantom client that keeps the daemon from exiting, and a worker that fails to open its database stays in the pool and errors on every call. Each harness drives codegraph’s own classes in one process, forces the failure at a chosen point beside a control arm, and prints PROVEN or not reproduced, with no timing race. Both issues (#1356, #1357) were closed as completed on 27 September.

Each finding was reproduced on current upstream code in a minimal fixture and checked for duplicates before filing. On 29 October I re-checked all 41 then-open issues against upstream (39 by fixture, 2 by reading the code), and none had been fixed without notice.

What was filed and what happened to it

SourceIssues filedOutcome
Type-checker audits, 15 Oct10 (#2580, #2581, #2582, #2583, #2584, #2585, #2586, #2587, #2588, #2589)all 10 closed as completed
Compiler oracle, 29–30 Oct8 (#3033, #3034, #3035, #3036, #3037, #3038, #3039, #3040)1 fixed, 3 closed as duplicates of my earlier issues, 1 closed by me when it stopped reproducing, 3 open
Compiler oracle, 4 Nov9 (#3229, #3230, #3231, #3232, #3233, #3237, #3238, #3239, #3240)all 9 open
Sync replay, 29 Oct4 (#3006, #3007, #3015, #3016)3 fixed with my commits, 1 open
Fault injection2 (#1356, #1357)both closed as completed

The table covers 33 of the 143 issues, all on the upstream tracker, colbymchenry/codegraph. Table outcomes are as of 17 November 2026.

Of the 143 issues, 130 are closed and 13 are open as of 27 November 2026. Of the closed issues, 125 were completed. I closed 3 as duplicates of my own earlier reports, which got through because my pre-filing check searched by keyword only, and 2 as not planned. Three of the closed issues I closed myself on 4 November because they no longer reproduced on upstream code, each with a note naming the change that most likely fixed it.

Of my 41 pull requests, 17 were merged, 4 are open and 20 were closed without merging as of 27 November 2026. Nine of the unmerged ones were closed by 3 November after the maintainer carried my commits into his own pull requests with my authorship kept, which is how the three sync fixes landed (#3061, #3062, #3072).

graph-assay: the checks as a public tool

On 12 November the test tooling became public as graph-assay, MIT licensed. It can measure any code-graph tool through one adapter per tool. The adapter indexes a directory with no network access and exports the graph in a shared format, and every scorer reads only that format, so adding a tool never changes how it is scored. Two tools are measured so far, codegraph and code-graph-rag. Adapters for two more replay the bug fixtures.

It adds two checks to the three above. Missing-edge mode runs the compiler oracle the other way and lists calls the type checker resolves that the tool never links. Metamorphic checks change a repository in ways that must leave its graph alone, such as adding files nothing imports or shifting every line down, and compare the graphs before and after.

The scoring rules are a versioned spec. The benchmark corpus is eight public repositories pinned to exact commits, registered on 5 November before any of the three held-out repositories was indexed or read. The other five are used while building the scorer, and the held-out three are indexed only for a published run. Each of the 24 oracle rules has a self-test that fails when the rule is switched off. The type checker is sometimes wrong too, so a sample of call sites is labelled blind by two models from different families, with a third breaking ties, to estimate how often the reference itself errs.

No benchmark numbers are published yet. Each tool’s maintainers see their results first.

A TypeScript grammar checked against the compiler

codegraph builds its graph from tree-sitter parses. When a TypeScript file fails to parse, its symbols and calls drop out of the index with no error shown. The upstream TypeScript grammar has had no commit since 30 January 2025 and no release since v0.23.2 in November 2024, and 63 of its issues and pull requests are open. I keep a public fork, built on an earlier community fork with its authors’ commits kept.

Its CI checks it against tsc, the TypeScript compiler. About 14,500 files from four pinned projects (Effect, Zod, Excalidraw and VS Code) parse in tsc with no errors, and any of them the grammar marks as an error fails the build. A second check, added on 17 November, compares the grammar’s syntax tree with tsc’s node by node. It catches trees that are wrong without containing an error, such as a + b! read as (a + b)!.

On those files, out of 6.2 million nodes in tsc’s trees, upstream v0.23.2 builds 17,404 nodes that disagree with tsc and misses 12,978. The fork builds 351 and misses 89. Seven bugs reported on the upstream tracker are fixed in the fork, among them #369, #373, #377 and #378. An eighth, a parser hang caused by the tree-sitter runtime, is caught by a time limit. The fork has 55 merged pull requests from 6 to 17 November. It is published on crates.io as tree-sitter-typescript-next. My codegraph fork builds from it, and upstream codegraph has not adopted it.

Fixes that were stopped or parked

  1. An aliased-import fix contradicted upstream policy. An import of a name the module lacks, such as from .s import ARMS as LEAK, bound to any project symbol named like the alias. My fix failed two upstream tests that encode the opposite behaviour on purpose, so I dropped it and drafted an issue instead.
  2. A Python typed-receiver exception added wrong edges. For #2583, its pattern-based receiver typing missed imports and rebinding and linked standard-library classes to project classes. I parked it and posted the findings. The maintainer later closed the issue as completed.
  3. An object-member sync fix was parked after several redesigns. Its issue, #3015, is still open with no pull request.

codeshot: diagrams that fail CI when the code changes

codeshot reads codegraph’s index and draws architecture and call diagrams into a repository’s documentation. --check exits with code 1 when a committed diagram no longer matches the code, and --forbid 'src/ui/->src/db/' exits 1 when a file dependency crosses a forbidden boundary. It compares graph structure (nodes and edges) instead of SVG bytes, so different graphviz versions agree.

Against npm codegraph 1.5.0, a callee query for a name defined in two files returned both definitions’ callees, so a two-file fixture drew 4 edges where 2 existed. codeshot re-queries such names per file and discards answers it cannot trust, such as a list codegraph cut off at 12 entries for a function with 23 callees. It then falls back to the broader query and names each affected symbol in a warning.

Reading codegraph’s SQLite index directly, in place of about 130 sequential CLI calls, cut an architecture scan of codeshot’s own repository from 48.7 s to 1.3 s. With its one intended difference switched off, the direct read drew byte-identical diagrams to the CLI path on five test targets. The suite reports 195 passed and 0 failed (3 November 2026). It has no measured catches in other people’s repositories yet. Of its six CI failures, four were its own diagram check failing on development branches.

What the checks do not cover

  • Missing-edge mode finds calls a tool never links only where the type checker itself resolves the call.
  • scip-typescript sees only the files a tsconfig includes, and f-string and template-literal calls often fail to line up. scip-java 0.12.3 does not load under Kotlin 2.x, so there is no Kotlin data.
  • The codegraph fork is built from source and is not on npm.
Static analysis Differential testing TypeScript Open source

Questions about the method? Email [email protected] · Back to portfolio