Inspiration
CHECK24 asked a simple question: with AI-assisted development producing far more pull requests than before, is a codebase getting better or worse? Right now, nobody can tell. Linters produce hundreds of warnings, and asking an LLM to "review the repo" gives answers you can't verify. We wanted a tool that a developer can trust: it shows the architecture, picks the few problems worth fixing first, and proves every claim with the exact lines of code.
What it does
DriftGuard analyses a repository at a pinned commit and answers three questions:
- What does this codebase look like? An interactive module map: the main module groups (client and server kept apart), the dependencies between them, and the cycles. Every view has a list twin, and every state is a shareable link.
- What should we fix first? Not 500 warnings, but a Top 5, ranked by how often the code changes and how much depends on it. Each finding carries its evidence: the graph nodes, the file, the line range, the commit and an honest label (project rule violated, structural observation or maintenance hypothesis). Click a finding and you land on its place in the graph and on the exact lines of code.
- Is it getting better or worse? The bonus challenge: we compare the last commit before March 2025 with today, normalised per 1,000 lines so growth alone isn't punished, and classify every change as erosion, improvement or neutral.
On top of those facts, an LLM judge explains each Top-5 finding: which maintenance task gets harder, where to look first, what is uncertain, and one remedy from the modifiability-tactics catalogue (Bass, Clements & Kazman). Every judgement must cite the lines it talks about, or it is thrown away.
We analysed Artemis (the shared repo), Keycloak and n8n: 3 million lines today.
| Artemis | Keycloak | n8n | |
|---|---|---|---|
| Lines, Feb 2025 → today | 271k → 549k | 416k → 522k | 755k → 1.97M |
| Structure since March 2025 | unchanged | unchanged | worse: first module cycle, 3.5× the rate of oversized components |
| Change risk since March 2025 | worse: hotspots 0.42 → 0.53 per 1k lines | unchanged | worse: hotspots 0.19 → 0.25 per 1k lines |
How we built it
The pipeline follows CHECK24's seven stages, with a hard line between facts and opinion.
Stages 1–5 are deterministic (Python, typed with pyright strict):
- Repository: one pass over
git log --numstatfor the last 12 months, renames followed, bot and bulk commits excluded. - Parse: tree-sitter for Java and TypeScript (including Vue
<script>blocks), in parallel and cached by content hash. - Model: a resolver that follows imports, re-export barrels and
tsconfigpaths. It never guesses: ambiguous references stay ambiguous and unresolved ones are reported. Resolution is 99.8% for Java and 99.8–100% for TypeScript on our repos. - Visualise: module groups from
corpus.yaml, laid out deterministically in a React viewer (React Flow + ELK). - Analyse: four detectors (dependency cycles, maintenance hotspots, oversized components, documented project rules such as n8n's "no TypeORM outside the database layer"), with thresholds as repo-relative percentiles and a ranking with a variety rule, so the Top 5 isn't five versions of one problem.
Graphs run on rustworkx, tables on Polars, JSON on orjson. Every list is sorted, every float rounded, and three runs, including one with an empty cache and a different worker count, produce byte-identical output on every repo.
Stages 6–7 are the LLM on top. The judge gets one evidence packet per finding (facts, pinned code excerpts, resolved references, recent commit subjects and the allowed tactics) through CHECK24's LLM gateway. The output schema is enforced by the API, and our validator rejects any answer that cites code it wasn't given, skips a measured number or proposes a disallowed tactic. The LLM can never add, remove or reorder a finding. Every call is cached and listed in an AI ledger with tokens and cost.
A second, optional AI step lets a maintainer add context ("exams are high-stakes", "modules talk only through their api package"). It changes the judgements, never the findings.
Challenges we ran into
- Resolving TypeScript honestly. Barrel files, path aliases and type-only imports make "who depends on whom" hard. Guessing would have been easy and wrong, so we built a resolver that reports what it can't resolve.
- Determinism at scale. Parallel parsing, sets, floating-point noise and graph layout all try to make two runs differ. We hash every output and fail the build if three runs don't match.
- Comparing two snapshots of a moving codebase. Artemis renamed 1,135 files between the snapshots. Matching nodes across renames was essential for a fair before/after.
- Keeping the LLM honest. Left alone, an LLM sounds confident and cites nothing. Strict schemas, a citation validator and an explicit "insufficient evidence" answer make every judgement checkable, and sometimes humbler: when the excerpts don't prove a claim, the judge has to say what to inspect instead.
- Not drowning in findings. Artemis has 393 findings. Choosing five that are worth a maintainer's time took repo-relative percentiles, merging duplicate evidence and a variety rule.
Accomplishments that we're proud of
- Fast: a cold run analyses n8n's 1.97 million lines in 13 seconds, against a budget of about 6 minutes.
- Cheap: the LLM bill for all six snapshots was two cents (36 calls, every one in the ledger).
- Robust: 3 out of 3 byte-identical runs on every repo.
- Traceable: 1,916 of 1,916 findings point to a node, file, line range and commit.
- A real catch: in n8n, DriftGuard found a breach of the project's own documented persistence rule that the maintainers hadn't baselined.
What we learned
- The LLM is most useful with a narrow job: one finding, its evidence, and a rule to cite it. When the evidence is thin, a good judge says so.
- "Better or worse" only means something per unit of size, and change is not automatically bad: n8n also had 93 improvements.
- Honest labels matter. Calling a hotspot a maintenance hypothesis, not a defect, made the report more trustworthy.
What's next for DriftGuard
- Show the cheapest edges to cut in a big cycle, not only that the cycle exists.
- Give the judge a summary of the finding's neighbourhood in the graph and its before/after numbers, for more specific advice.
- Count complexity per nested function in TypeScript (as ESLint does), and count only product files when detecting bulk commits.
- Run on every pull request in CI, so drift shows up while it's still cheap to fix.
Built With
- cytoscrape.js
- git
- github-actions
- llm
- orjson
- playwright
- polars
- pydantic
- python
- react
- rustworkx
- shadcn-ui
- shiki
- tailwindcss
- tree-sitter
- typer
- typescript
- uv
- vite
- vitest
- zustand