When an AI coding agent fails to fix a real bug, the usual cause is that it never found the right code, not that it wrote a bad patch. On SWE-bench, handing Claude 2 the exact files to edit raised its resolve rate from 1.96% to 4.8% (SWE-bench). In the Linux kernel, keyword retrieval puts the buggy file in its top three results only about 10% of the time (kGym). Protein biology spent years on a structurally similar problem: cutting a long chain into "domains," the independent units that fold and function on their own. That field stopped labeling boundaries one position at a time. It now predicts, for every pair of residues, the probability that the two belong to the same unit, and then groups residues using that matrix (Chainsaw). A domain found this way can be scattered across distant parts of the sequence and still come out as one group.
We propose the same move for code. The pairwise signal we learn is the probability that two files are edited together when a bug is fixed. A trained model predicts this "co-fix affinity" from static repository features. A localizer then retrieves whole fault domains rather than ranked lists of individual files. The intended payoff is on bugs whose fix spans several files that a directory tree does not group together. These are the bugs current neural localizers handle worst (BugLab), and they are also where a flat ranked list wastes the most context.
Core Claim
Repositories contain functional units that cut across their directory layout, much as an evolutionary protein domain can be split across the sequence. Historical fix commits are the natural supervision for these units. Our claim is that a learned pairwise co-fix matrix, used to expand a seed localization into a bundle of jointly relevant files, recovers the complete set of edited files more often, and with less context, than three alternatives: ranked retrieval, dependency-graph neighborhoods, and directory or community-detection partitions.
The claim is falsifiable in a specific way. The gain should concentrate on multi-file fixes. It should vanish if the learned matrix is replaced by the directory structure or by raw co-change counts, and it should be largest on code with little edit history.
What the Protein Work Supplies, and What It Warns Against
The protein papers play three different roles in this proposal.
The first role is supplying the method. Chainsaw predicts residue-pair co-membership with a fully convolutional network and then assigns domains greedily to maximize likelihood. It reports 78% agreement with CATH annotations against 72% for the next method. DistDom shows that adding 2D pairwise maps to 1D features beats 1D features alone. DPAM-AI adds AlphaFold's pairwise confidence matrix and homology hits. We reuse two things from this line of work: the pairwise output with likelihood-maximizing grouping, and the idea of attaching a confidence to each pair.
The second role is a constraint. Chainsaw's human evaluation found that in 65% of cases where two methods disagreed, both segmentations were equally valid. Zhang et al. and Cong document disagreement between sequence-based and structure-based domain definitions. We take this as a warning that there is no single true repository segmentation to score against. We therefore never evaluate segmentation directly. We evaluate only whether it helps recover the gold edit set.
The third role is motivation. Wu et al. show that boundary errors propagate into failed structure prediction. The code analog is a hard partition that splits a bug's files across two domains. This motivates comparing soft propagation through the matrix against hard segmentation.
On the code side, RepoGraph builds a line-level definition-reference graph and retrieves small neighborhoods around keywords, a fixed number of hops out. Its edges are static dependencies, not learned co-fix probabilities. Co-PatcheR splits the work into file localization, then line localization, then generation, but its first stage is a model reading the repository, not a structural parse. BugLab localizes single-token bugs over code graphs and suffers false positives. None of these learns which units fail together.
Research Program
Code units and features. The unit of analysis is the file, with a second stage over functions inside the chosen domain. Files keep the pairwise matrix tractable for Python repositories, which have thousands of files. For the kernel we score only candidate pairs drawn from the dependency graph, shared subsystems, and nearest neighbors in an embedding of file contents, instead of the full dense matrix.
Each file pair gets the following features:
- dependency-graph distance and shared callers, built with the tree-sitter graph from the RepoGraph code;
- shared path prefix;
- identifier and docstring embedding similarity;
- optionally, co-change counts from commits strictly before the evaluation cutoff.
Files are ordered by path so that the matrix has the block-and-band structure a convolutional model can exploit, mirroring the role sequence order plays in Chainsaw.
Supervision. The training target is $y_{ij}=1$ if files $i$ and $j$ were both modified by at least one fix commit. Training data comes from SWE-bench's 19,000 training instances, drawn from 37 repositories, plus mined fix commits from the same repositories. We verify that these repositories are disjoint from the evaluation repositories. The model outputs $A_{ij}\in[0,1]$, the predicted co-fix affinity.
Localization. Given an issue or crash trace, any seed localizer produces scores $s_i$ over files. We use BM25, RepoGraph, or the agent's own first-stage guess. We then compute an expanded score
$$r_j = \max_i \; s_i \, A_{ij},$$
so that a file inherits relevance from the most likely co-fixed seed. The localizer returns the top bundle under a fixed token budget, and the function-level stage runs inside that bundle.
A hard variant replaces $A$ with a Chainsaw-style greedy partition and returns whole domains. Comparing the soft and hard variants tests whether boundary errors propagate here the way they do in protein structure prediction.
Baselines
Naive reference. The do-nothing reference is BM25 file retrieval, exactly as in SWE-bench and kGym. The reported numbers are a 1.96% resolve rate for Claude 2 in SWE-bench and roughly 10% top-3 file hit rate on the kernel in kGym.
Strongest localization competitor on Python. This is RepoGraph plugged into the Agentless pipeline. On SWE-bench-Lite it reports a 29.67% resolve rate and raises file-level localization accuracy from 47.3% to 51.7%. It is the closest competitor because it is also a structure-aware expansion of a seed set. We will rerun it from the released code with the same base model, the same seeds, and the same token budget as our method, and our expansion will be applied on top of its seeds. Beating it means:
- higher full-edit-set recall at equal tokens on Lite;
- a statistically significant gain on the multi-file stratum;
- a resolve rate above our own rerun of RepoGraph+Agentless.
Strongest end-to-end system. This is Co-PatcheR, which reports a 46% resolve rate on SWE-bench-Verified. We will substitute our localizer for its file-localization stage and keep its generation and validation models fixed. Any change in resolve rate is then attributable to localization alone.
Partition baselines and ablations. Three variants isolate where any gain comes from:
- a directory partition, which expands seeds to sibling files;
- Louvain community detection on the RepoGraph dependency graph;
- raw historical co-change counts used directly as $A$.
The first two isolate learning versus a fixed structure. The third isolates learned generalization versus memorized history.
On kGym, no reported result was found on Lacuna for any graph-based or learned localizer. The comparison there is against BM25 and the partition baselines only.
Why not just…?
Why not just use the directory tree as the domain partition? Directories are human-drawn modules, and for many single-file bugs they will be as good as anything learned. That makes this a real threat. The proposal survives only if, on fixes whose gold edits span more than one top-level directory, the learned matrix recovers the full edit set more often than sibling expansion does. We report this stratum separately. If the two tie there as well, we will conclude that repository domains are mostly the directories and drop the learning claim.
Why not just run community detection on the dependency graph? Static call and import edges are exactly what RepoGraph already exploits, and its gain over plain retrieval was modest: 47.3% to 51.7% file-level accuracy. Co-fixed files are often coupled through shared data formats, configuration, or protocol contracts that have no reference edge between them. The Louvain ablation measures directly how much of our gain is just graph clustering.
Why not just mine co-change rules from git history? Raw co-change is the strongest simple alternative. It may match the learned model on heavily edited core files. It is undefined for new or rarely touched files, however, and those are where localization most often fails. We stratify by each file's pre-cutoff commit count. The learned model must win on the low-history bins. If it does not, the contribution reduces to co-change-based bundling, which we would report as such.
Why not just use a bigger model with a longer context? The "sea of context" degradation reported in SWE-bench, and Co-PatcheR's 14B pipeline outperforming larger monolithic models, both suggest that more capacity does not substitute for choosing the right context. To check this, we will plot recall against context tokens: a long-context model reading BM25 top-$k$ versus our bundles.
Proposed Experiments
Python evaluation. We evaluate on SWE-bench-Lite and SWE-bench-Verified, split by the number of files in the gold patch. The primary metric is full-edit-set recall, meaning every gold-edited file falls inside the retrieved bundle, measured at fixed token budgets. Secondary metrics are top-$k$ file accuracy and resolve rate.
Linux kernel evaluation. On kBenchSyz (279 bugs), the seed is the crash stack trace. Here we report localization metrics only, because each build-and-test cycle takes 17–30 minutes (kGym). Patch runs are limited to the top configuration.
Generalization. Multi-SWE-bench tests whether a co-fix model trained on Python transfers to other languages using language-agnostic features alone.
Decisive checks. Four results decide the claim:
- the multi-file stratum gain over directory expansion;
- the low-history gain over raw co-change;
- soft propagation against hard partition, the code analog of Wu et al.'s boundary-error cascade;
- a calibration check that bins $A_{ij}$ and compares each bin to the observed co-fix frequency on held-out commits.
If the matrix is well calibrated and wins on multi-file and low-history bugs, the protein-style formulation earns its place. If it loses to directories or raw history, that negative result will tell us that repository modularity is already explicit in ways protein modularity is not.
References
- SWE-bench: Can Language Models Resolve Real-world Github Issues?
- kGym: A Platform and Dataset to Benchmark Large Language Models on Linux Kernel Crash Resolution
- Chainsaw: protein domain segmentation with fully convolutional neural networks
- Self-Supervised Bug Detection and Repair
- Multi-head attention-based U-Nets for predicting protein domain boundaries using 1D sequence features and 2D distance maps
- DPAM-AI: a domain parser for AlphaFold models powered by artificial intelligence
- Comparative mapping of sequence-based and structure-based protein domains
- Using evolutionary context to classify difficult protein folds
- Improving protein tertiary structure prediction by deep learning and distance prediction in <scp>CASP14</scp>
- RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph
- Co-PatcheR: Collaborative Software Patching with Component-specific Small Reasoning Models