When a coding agent changes one function in a multi-file repository, it rarely knows which other functions that change has broken. Current systems handle this in one of two ways. Some re-generate and re-test broadly, which multiplies the number of model calls and the wall-clock time. Others look only at a fixed neighborhood in a dependency graph, which misses breakage further away and drags in irrelevant code. We propose to treat "is this function now broken?" as a probabilistic question over the repository's call, containment and inheritance graph, and to answer it with linearized belief propagation. That is a version of the classic message-passing inference algorithm that becomes a single sparse linear solve, so it runs in milliseconds on graphs with millions of edges. The agent then re-verifies or re-generates only the functions whose estimated probability of breakage is high.
The part we think is new is that the parameters controlling how breakage spreads along each kind of edge are not hand-set. They are learned from mutation experiments in which an upstream function is edited, the tests are run, and we record which downstream functions failed. Learning these parameters is possible because the linear solve is differentiable. It also addresses an open problem the linearization literature names explicitly: compatibility matrices are assumed to be known and fixed. The convergence criterion of linearized belief propagation tells us when the learned spreading is too strong for the linear approximation to be trusted. In that case the agent falls back to exhaustive re-verification instead of trusting a bad estimate.
Core Claim
During repository-scale iterative refinement, a learned, multi-state linearized belief propagation model over the code dependency graph can rank downstream functions by their probability of breaking after an edit. Using that ranking, the system re-verifies a small fraction of nodes while keeping the final test accuracy of exhaustive re-verification. It also beats graph-distance heuristics and random-walk propagation at the same verification budget, and the gap with random walks should come specifically from distinguishing kinds of breakage.
Background and What This Builds On
The inference machinery comes from three papers. The Linearization of Belief Propagation on Pairwise Markov Random Fields centers beliefs and edge potentials around a uniform baseline. The multiplicative message updates then become a linear system with an "echo cancellation" term that stops a node's own evidence from bouncing back to it around cycles. Linearized and Single-Pass Belief Propagation gives exact convergence conditions based on the spectral radius of the coupling and adjacency matrices. It reports more than 99.9% agreement with standard loopy BP at speedups of up to 600×. ZooBP extends this to graphs with several node and edge types, which is the shape of a code graph. We reuse all three as method. We depart from them in one way: they assume compatibility matrices are given and constant, and we learn one per relation type from outcomes.
The application side is motivated by three strands of code-generation work. RPG builds a repository planning graph and generates code in dependency order with test-driven validation at every node. It reaches 81.5% functional coverage and 69.7% test accuracy on RepoCraft, but it pays for this with LLM calls and test runs at each node. It has no cheap way to estimate whether an upstream interface change destabilizes downstream nodes. RepoGraph builds a line-level definition/reference graph with tree-sitter and feeds fixed k-hop neighborhoods to the model, raising Agentless to 29.67% on SWE-bench Lite. Its graph is static and the neighborhood rule is a distance cutoff, not an inference. Repoformer shows that most retrieved cross-file context (up to 80%) is unhelpful or harmful, and that skipping retrieval when it is unnecessary gives up to a 70% speedup. Its gate, however, is a local token decision that is blind to multi-hop structure. Together these say that targeted, structure-aware decisions about what to revisit are where latency is won.
Two negative results constrain the design. The linearization paper reports that when coupling is strong, linearized BP loses accuracy relative to loopy BP. Code dependencies can be strongly coupled; a renamed parameter breaks every caller. That is why the convergence check and fallback are part of the method rather than an afterthought. Second, VERINA finds that up to 64 rounds of compiler feedback plateau at roughly 20% proof success. More undirected refinement is therefore not a substitute for knowing where to look.
The Model
Nodes are functions, methods and classes, extracted with tree-sitter as in RepoGraph. Edges carry one of a few relation types: invokes, contains, inherits/overrides, and imports. Each node holds a belief over three states: intact, interface-broken (signature, arity or return type no longer matches what its users expect), and behavior-broken (the interface matches but semantics changed). An edit produces a prior residual at the edited node, computed from cheap diff features such as whether the signature, return statements or raised exceptions changed.
Following ZooBP, the centered beliefs $\mathbf{b}$ solve
$$\Big(\mathbf{I} - \sum_{r} \mathbf{A}_r \otimes \mathbf{H}_r + \sum_{r} \mathbf{D}_r \otimes \mathbf{H}_r^2\Big)\,\mathbf{b} = \mathbf{e}.$$
Here $\mathbf{A}_r$ is the adjacency matrix for relation $r$, $\mathbf{D}_r$ its degree matrix (the echo-cancellation term), $\mathbf{H}_r$ a small $3\times 3$ centered compatibility matrix for relation $r$, and $\mathbf{e}$ the stacked prior residuals from the edit.
The three-state structure is what separates this from plain graph diffusion. An interface break in a callee should push its callers toward interface-broken. A behavior break should push callers toward behavior-broken more weakly. An override edge may absorb a parent's behavior change entirely. These are distinct off-diagonal patterns in $\mathbf{H}_r$, and a scalar random walk cannot represent them.
We fit the entries of each $\mathbf{H}_r$ by minimizing cross-entropy between the solved beliefs and observed downstream test failures. Gradients flow through the sparse solve by implicit differentiation, which needs one extra solve with the transposed system. During fitting we penalize the spectral radius bound from Linearized and Single-Pass Belief Propagation so that the learned couplings stay in the regime where the linear system converges. At deployment, if a particular edit's subgraph violates the bound, the agent re-verifies the full dependent closure.
Research Program
The work has three parts.
The first is a training and evaluation corpus of edit-impact labels. We take Python repositories from the SWE-bench task pool and repositories generated by ZeroRepo using microsoft/RPG-ZeroRepo. We apply both synthetic mutations (signature changes, return-value changes, exception changes) and real historical edits from gold patches. We run the test suites and record which functions' covering tests fail. Repositories are split by repository, so test-time graphs are unseen.
The second is the propagation model itself, its learned compatibility matrices, and the convergence-gated fallback.
The third is integration into two refinement loops. In ZeroRepo's topological generation loop, after a node is revised, only downstream nodes whose belief of being broken exceeds a threshold are re-tested and, if they fail, repaired. In Agentless with RepoGraph, the belief ranking replaces the k-hop rule for choosing which neighboring code goes into the model's context.
We will also inspect the learned $\mathbf{H}_r$ matrices. Recovering interpretable patterns, such as near-zero behavior propagation across override edges, would be evidence that the model captures real structure. Uniform couplings would suggest it is merely smoothing over the graph.
Baselines
The naive reference points bracket the problem. "Re-verify everything" re-runs every downstream node in the dependency closure after each edit. This is essentially ZeroRepo's default behavior and is the accuracy ceiling for our method. "Re-verify nothing beyond the edited node" is the latency floor. Both run on the same generated repositories with the same LLM, the same test budget per node, and the same random seeds. ZeroRepo's reported RepoCraft numbers (RPG) are 81.5% functional coverage and 69.7% test accuracy, and we treat re-verify-everything under our reproduction as the target to match. We found no reported result on Lacuna for ZeroRepo's number of LLM calls, test executions or wall-clock time per repository, so we will measure these ourselves for all arms.
The strongest structural competitor is graph-distance selection in the style of RepoGraph: re-verify all nodes within k hops of the edit, with k tuned on the validation repositories. It is strong because most breakage really is local, and it costs nothing to compute.
The strongest propagation competitor is personalized PageRank from the edited node with one learned weight per edge type. It is trained on the same impact labels with the same tuning budget. We regard it as the most dangerous baseline, because a two-state linearized BP with homophilous coupling is mathematically close to a random walk with restart.
We add a learned local classifier: a small code model fine-tuned on the same labels to predict, from the diff and a candidate caller's source, whether that caller breaks. This is the neural-critic route, analogous in spirit to the revision reward model of Let's Revise Step-by-Step, and it is evaluated on every candidate pair. Standard loopy BP with the same learned potentials serves as an accuracy reference for the linearization.
Three ablations isolate the key ingredients: two states instead of three, which tests whether the multi-state compatibility matters beyond PageRank; fixed rather than learned $\mathbf{H}_r$; and removal of the echo-cancellation term.
The comparison is made at a fixed verification budget, meaning the same fraction of dependent nodes re-tested. Beating a baseline means one of two things. Either higher recall of truly broken nodes at that budget, or, inside the ZeroRepo loop, test accuracy within one point of re-verify-everything while using at least 40% fewer re-verification calls and fewer calls than the best competitor at matched accuracy.
Why not just…?
Why not just run the test suite after every edit? When tests are fast and complete, this is the right answer, and our method adds nothing at the test-execution level. The cost in refinement loops is mostly elsewhere. In ZeroRepo-style generation, a failing downstream node triggers LLM repair. Tests are themselves generated per node and may not yet exist for downstream code. SWE-bench repositories often have slow suites. Our in-loop metric therefore counts LLM repair calls and wall-clock time, not just test runs. We will also report the fraction of edits for which full re-testing is cheaper than our solve plus the targeted tests, so the regime where the method helps is stated explicitly.
Why not just re-verify the k-hop neighborhood? This is the honest default, and if breakage is overwhelmingly one hop away it will match us. The impact corpus measures the hop distribution of real breakage directly. If more than about 90% of failures sit within one hop and k-hop matches our recall at equal budget, the claim fails for this domain. The expected advantage comes from two cases. Hub functions have many callers, most of them unaffected, where k-hop wastes budget. Inheritance chains carry breakage several hops, where a small k misses it.
Why not just use personalized PageRank with learned edge weights? This is the closest real threat. The two-state ablation should roughly reproduce it, so any advantage must come from the three-state compatibility matrices. If three-state linearized BP does not beat tuned PageRank on recall at fixed budget, we will report that the belief-propagation framing adds nothing over random walks here and fall back to PageRank. A partial win would remain: the convergence check would still give a principled fallback rule.
Why not just fine-tune a small model to judge each caller? A neural critic sees code semantics that our diff features do not, and may be more accurate pair by pair. It costs a forward pass per candidate, however. Neural critique loops roughly double response time in Volcano (2.7s to 5.8s), and pairwise judging ignores multi-hop chains. We compare at matched wall-clock time as well as matched budget. We also test a hybrid in which belief propagation proposes candidates and the critic re-ranks only the top few, which may turn out to be the best system.
Proposed Experiments
The first check is offline impact prediction on held-out repositories. We report AUROC and recall of broken nodes at budgets of 5%, 10% and 20% of the dependent closure, broken down by mutation type and by hop distance. Here the three-state model must beat two-state PageRank on interface-versus-behavior breakage.
The second check is the ZeroRepo loop on RepoCraft. We report functional coverage, test accuracy, LLM calls and wall-clock time against re-verify-everything and k-hop selection.
The third check, secondary, is Agentless on SWE-bench Lite with belief-ranked context in place of RepoGraph's k-hop context, measured against the reported 29.67% resolve rate at equal context length.
Across all experiments we log how often the convergence bound triggers fallback, and compare linearized against loopy BP accuracy on those edits. This directly tests whether the strong-coupling weakness reported in The Linearization of Belief Propagation on Pairwise Markov Random Fields shows up in code graphs, and whether the gate catches it.
The decisive result is the second check. If matched accuracy with far fewer repair calls does not appear there, the method is a better impact predictor but not a latency win.
References
- The Linearization of Belief Propagation on Pairwise Markov Random Fields
- Linearized and Single-Pass Belief Propagation
- ZooBP: Belief Propagation for Heterogeneous Networks
- RPG: A Repository Planning Graph for Unified and Scalable Codebase Generation
- RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph
- Repoformer: Selective Retrieval for Repository-Level Code Completion
- VERINA: Benchmarking Verifiable Code Generation
- Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs
- Volcano: Mitigating Multimodal Hallucination through Self-Feedback Guided Revision