Repository navigation
v0.18.0 - Peer divergence: find code out of step with its siblings
Everything scantool did until now described code — its structure, what changed, which functions are central. This release adds the first thing that makes a judgment about code: it points at functions that break a pattern the rest of the codebase follows. That break is often a regression, a half-finished implementation, or a copy that drifted from the original.
The new capability
If nine of the ten functions that call parse() also call validate(), the one that doesn't is worth a look — it may have skipped a step everything else treats as mandatory. scantool now finds these on its own, three ways:
find_divergence(new tool) audits a whole directory for them — point it at a codebase and it returns the functions that are out of step with their peers, or nothing if the code is consistent.scan_diffshows them only for the functions you changed. A function that, after your edit, now breaks a pattern its siblings keep is the most likely place you just introduced a bug.preview_directoryatdepth="deep"includes the same audit while you orient in an unfamiliar codebase.
What you get is a shortlist of "this looks out of step, go check it" — a missing validation, a handler that forgot a step its family shares, an implementation that drifted from its siblings. It is a review hint, not a bug detector: peers differ for legitimate reasons, so it points and you judge.
Why it is a shortlist and not noise
A detector like this is only useful if it stays quiet on healthy code. Three things keep it there, each measured rather than tuned:
- It flags only breaks that are statistically surprising and stand out against the codebase's own distribution — no fixed thresholds, so a consistent codebase produces nothing at all. The silence is the honest answer, not a failure.
- It compares a function only against peers in the same role. A base class delegates where its overrides construct; an alternative-parser path looks nothing like the main one — comparing across those manufactures false alarms, so it doesn't. On this repository that removed every false positive in the labelled set while keeping a planted real one.
- The role test is built so the missing call cannot fool it into thinking the function plays a different role — a near-circular trap that an adversarial test caught and the naive version failed.
The predictions, labelled cases and kill criterion behind this are in experiments/network_consensus/ and experiments/role_conditioning/. Two of the predictions came out wrong and are left as written.
Hot functions stopped depending on definition order
The divergence work needed a call graph that does not guess. Resolving a call by name is ambiguous when the name is defined in several places, and the old code took the first match — so centrality, and the hot-function ranking, shifted with definition order; about 43% of the edges in this project's own graph were that kind of arbitrary tie-break. Ambiguous calls now spread their weight across every candidate, so the ranking is stable, and search_structures leads list all candidates instead of one.
Also
- README setup snippets for Cursor, Windsurf, VS Code and Cline.