Inspiration
A problem developers often face: a test fails, and the stack trace points at code nobody touched in weeks. The real cause is usually a helper that changed recently and already returned before the crash so it never appears in the trace. . The question behind it is "what changed recently that is connected to this error, and which function produced the bad value?". That is a question about relationships between code, history and what actually ran, which is exactly what a graph answers.
What it does
Relate Bug Finder is a VS Code extension that keeps a live graph of your codebase in an embedded Neo4j Relate database: files, functions, imports, calls, and git history down to the individual function.
- Error → root cause. When a terminal command fails with a stack trace, a notification names the top suspect, and a panel ranks the likely culprits by recency of change × distance in the call graph, with plain-language reasons for each. In the demo, a crash in
Cart.totalis really caused bylookupCoupon, a helper changed 3 hours ago that isn't on the stack. Relate Bug Finder reads the crash line (coupon.pct), tracescouponback toconst coupon = lookupCoupon(couponCode), and ranks it #1. - Deep trace (one click, opt-in). It re-runs the failing command with a recorder attached, after showing the exact command. It records which functions ran, which lines ran, and what each function returned, and stores it in the graph as a
(:Run). When the error names a value (negative total: -10.000000000000014), the function that returned it first moves up. In the demo,bulk_discountgoes from #3 to #1 this way, even though it is long off the stack. - Compare with passing tests. The call graph picks related tests, which run the same way. Functions that also run in passing tests rank lower, and each suspect shows the lines that ran only in the failing test, highlighted in the editor.
- Blast radius before a refactor. CodeLens above every function shows its callers and recent changes. One click shows every transitive caller, the importing files, and exactly which tests to run.
- For AI assistants. "Ask AI to fix" hands the chat the suspects, reasons, the bad value, the lines and the code. MCP tools (
trace_error_suspects,get_blast_radius,find_recent_suspects,find_circular_dependencies, read-onlyquery_codegraph) give Copilot, Claude Code and Cursor the same graph, answering in milliseconds.
How I built it
- One graph for code, history and runs:
(:File)-[:IMPORTS]->(:File),(:File)-[:DEFINES]->(:Function),(:Function)-[:CALLS]->(:Function),(:Commit)-[:TOUCHED]->(:Function),(:Function)-[:READS|WRITES]->(:Field)and(:Run)-[:EXECUTED {count, since, lines, rets}]->(:Function). "Which method sets the field this crash read?" and "which functions ran in the failing test but not in the passing ones?" are each a single Cypher query. - Function-level git history:
git log -U0diff hunks are intersected with function line ranges, so a commit links to the exact function it changed, not just the file. - Relate embedded in the editor: everything lives in one
.vscode/codegraph.rlfile, with no server. Ranking, blast radius, related-test selection, spectrum scores and cycle detection are Cypher. On save, only that file and its importers are re-indexed (~300 ms). - Parsing: the TypeScript compiler API for JS/TS, Python's
astfor Python. - Deep trace recorder: a small stdlib-only Python hook (
sys.monitoringon 3.12+,sys.setprofile/settracebefore), limited to project code; Node uses its built-in V8 coverage. Nothing to install. - MCP: the MCP server forwards to a token-protected localhost bridge inside the extension, so agents always query the live graph. Agent Cypher runs in a transaction that is always rolled back, and writes are rejected.
- AI-assisted development: built with heavy use of Claude (claude.ai, then Claude Code with Claude Opus 5.5), which wrote most of the code, tests and documentation under my direction. I chose the idea, set the scope and priorities, guided and reviewed every step, decided what to build, and tested it myself. The full statement is in the README.
Challenges I ran into
- Relate's single-writer lock: a second process can't open the graph file while the extension holds it, and the lock is only released when the process exits. My first MCP server opened the file and silently stopped the extension from starting. It now talks to the extension through a local bridge and, when VS Code is closed, builds its own in-memory graph.
- A git flag that silently drops history:
git log --sincestops at the first out-of-order commit date, which hid almost all recent changes in the benchmark (143 of 144 bugs saw zero commits). The fix was--since-as-filter. - Recording without getting in the way: the first recorder slowed some test files 11× and was switched off by
pytest --cov. It now reports each line once and then disables that location. Median cost: 1.6× a test's normal run time. - Textbook fault localization didn't transfer: plain Ochiai (spectrum-based localization) made the ranking worse on real bugs. Only a softened version, chosen on the dev half, helps a little, and I report it as such.
Accomplishments that I'm proud of
Measured on BugsInPy, 114 reproduced real bugs from 12 Python projects. Weights were tuned on one half; these numbers are from the other half, never used for tuning (n = 59):
| Method | Right function #1 | In top 3 |
|---|---|---|
| Reading the stack top-down | 20% | 27% |
| Sentry-style (stack frames, newest change first) | 22% | 27% |
| Relate Bug Finder, instant | 31% | 39% |
| + Deep trace | 44% | 54% |
| + related passing tests | 46% | 56% |
- On failing assertions, where the stack ends in the test, reading the stack gets the right function first in 6% of bugs; Relate Bug Finder with Deep trace gets 46%.
- On crashes fixed somewhere off the stack, every baseline gets 0; Relate Bug Finder gets 5 of 18 into the top 3.
- The highlighted lines (about 9 of a function's 29) include a line the real fix changed in 94% of bugs.
- 10 automated test suites, including the built extension driven through the full UI flow and real re-runs.
What I learned
- Recency alone is noise; recency × graph distance is signal. The graph is what turns "recently changed" into "recently changed and connected to this error".
- Putting static structure, git history and recorded executions in one graph made questions that span all three into single queries.
- Measure honestly. A benchmark with a held-out half caught a git bug, killed two ideas that looked good on paper, and is the reason the numbers above can be trusted.
What's next for Relate Bug Finder
Return values and call order for Node's Deep trace, Go and Java support via tree-sitter, source maps, test-explorer integration, blast-radius comments on pull requests in CI, and vector search over function bodies in the same Relate graph.
Built With
- claude
- cypher
- git
- github-copilot
- mcp
- neo4j
- neo4j-relate
- node.js
- python
- typescript
- vscode