Admissible Search Over Unfinished Refactors

When a language model edits a codebase, it often makes a change in one place, such as altering a function's arguments or replacing an array with a bitmask, and then fails to update every other place that depends on it. The result is a program that no longer compiles, or that breaks somewhere far from the edit. This proposal treats each of these leftover inconsistencies as an obligation: a specific code location that a static checker (a type checker or compiler front end) flags because something it depends on has changed. Counting obligations gives a cheap number that can never overestimate how many more edits are needed. Classical best-first search can use such a number to decide which partial patch to work on next and which to discard. The language model then has a narrow job: fix one obligation, shown with only its local neighborhood of code. Tracking what remains unfinished becomes the job of the search.

The motivation comes from two findings that point the same way. First, scaffolding around a language model rarely lifts it above its own reasoning ceiling. Refinement loops stall once the model cannot work out the root cause of a failure, and multi-agent wrappers help only in proportion to the strength of the underlying model. Second, stuffing more of the repository into the prompt makes localization worse, not better. Global bookkeeping across many files is exactly the part of repository editing that needs both deep reasoning and a lot of context. It is also the part that a symbolic tool can do exactly. The core claim is that moving that bookkeeping out of the model and into an admissible search lets a fixed base model finish multi-location changes it currently abandons halfway, while keeping each prompt small and roughly constant in size.

Core Claim

Define a search node as a working copy of the repository: the original code plus a cumulative diff. Let $g(n)$ be the number of location-level edits made so far, where a location is one function or class body. Let $O(n)$ be the set of obligations the static checker reports at node $n$ that trace back to edited symbols. The heuristic is

$$h(n) = \mathrm{LP}\Big(\min_{S} |S| \ \text{ s.t. every } o \in O(n) \text{ has } o \text{ or one of its dependency ancestors in } S\Big),$$

the linear-programming relaxation of the smallest set of locations whose editing could discharge every obligation. Any obligation must be fixed either where it occurs or at a definition it depends on, for example by restoring a default argument. So the minimum such set is a lower bound on the remaining edits needed to reach any statically consistent program. The relaxation is lower still. Every goal state, meaning a patch that passes the tests, must also be statically consistent. The heuristic is therefore admissible ($h(n) \le h^*(n)$, where $h^*$ is the true remaining edit distance) with respect to the real goal, not just a proxy. What the heuristic says nothing about is semantic correctness. That part stays with the model and the tests, and the proposal says so plainly.

This counts distance (number of edits) rather than a cost or a test-pass score. That choice follows Speedy versus Greedy Search, which shows that remaining-distance estimates guide search more smoothly and are less easily lured into dead ends than cost estimates. Test-pass signals in code repair are a deceptive local gradient of exactly that kind. Charging an edit's downstream consequences immediately, since a signature change instantly creates its call-site obligations, mirrors the cost-shifting idea in Revisiting Dominance Pruning in Decoupled Search. There, moving costs onto the main path makes plan costs visible to the search earlier. Here, a "cascading" edit that spawns forty obligations is immediately penalized relative to a contained one.

Relation to Prior Work

The closest work is Better Process Supervision with Bi-directional Rewarding Signals. It scores math reasoning steps with an A*-style sum of a step-validity model and a value model trained on Monte Carlo rollouts, and it reports that this avoids the decline that standard step verifiers show as Best-of-N grows. Its forward term is a learned expectation, not a bound, and it works on short math chains. This proposal differs in where the heuristic comes from: a static analysis that is admissible by construction. It also differs in the domain, which is multi-location code edits where the context problem actually bites. A learned value term in the BiRM style is kept only as an ablation and as a tie-breaker, never as the pruning criterion.

The method for building the bound is borrowed from Approximate Factoring for A* Search. That paper derives admissible heuristics for parsing by projecting a large structured search space onto simpler projections whose optimal completions sum to a lower bound. The obligation graph is such a projection. It discards everything about the program except "which locations disagree with which definitions," and solving that small covering problem exactly gives the bound. Their soft, slightly inadmissible variant, which traded under 1% search errors for large speedups, suggests a controlled relaxation to test later. Optimality arguments for A* from The Optimality of A* Revisited apply only to the edit-count objective. The claim is not optimal patches. The claim is that sound pruning and ordering beat unsound ones.

Three refinement systems motivate the gap. MAGIS splits GitHub issue repair across manager, custodian, developer, and quality-assurance agents with BM25 file retrieval, and it reports trouble when changes span many files. $A_2$DEPT evolves solver programs with a stochastic program tree and names the "partial migration trap": a data structure is changed in one function and its callers are never updated. MEIC rolls back regressions to the last stable state. None of them can tell, before running anything, that a partial patch is still at least $k$ edits from any consistent program. The search here supplies exactly that signal, and it generalizes MEIC's rollback into principled backtracking. TELPA supports the use of static analysis to choose context, but it restricts analysis to one file to avoid blowing up the context. The obligation frontier is a way to cross files without that blowup.

Two lines of work constrain the design. The first concerns the base-model ceiling. ReFoRCE observes that self-refinement stalls when feedback does not reveal the root cause. ReDel finds that recursive multi-agent gains grow only with base-model strength. Debating Truth shows debate among weak agents collapsing into shared mistakes. CodeTransOcean reports compiler-feedback gains plateauing after a few rounds. Together these rule out designs that ask the model to do more meta-reasoning, and they push the design toward giving the model less to reason about per call. The second concerns context. SWE-bench documents localization collapsing as more code is supplied. GraphLLM finds graph-reasoning accuracy falling with graph size even within the token limit. Compressing structure into soft prompts, as GraphLLM does, cannot work here, because compilers and tests need exact text. Instead, each prompt contains the issue, a compact rendering of the current diff, one obligation, and its few-hop dependency neighborhood serialized in depth-first order. Can Graph Descriptive Order Affect Solving Graph Problems with LLMs? found that traversal-ordered serialization improves accuracy by over 12% relative to random edge order.

Research Program

The system has three parts. The first is an obligation extractor. For Java it uses the compiler front end, which gives sound reports. For Python it combines a type checker with name-resolution and call-arity checks, which are less sound. The extractor maps each diagnostic to a location and to the edited definitions it depends on. The second part is a best-first search over diffs. Its open list is ordered by $g + h$, with ties broken by a learned value score and by test outcomes. It prunes any node whose $g + h$ exceeds the edit budget. It never accepts edits that delete or weaken tests or assertions, which closes the obvious way to make failures disappear. The third part is the expansion step. The base model receives one obligation, chosen as the one appearing in the most minimum covers, and proposes a small number of alternative hunks. Each hunk becomes a child node after re-running the extractor. When obligations reach zero, the tests run. If they fail, the search uses the failure trace to create a "semantic obligation" at the implicated location. This obligation adds nothing to $h$, which keeps $h$ admissible, but it gives the model a narrowly scoped repair target.

The analysis component asks whether admissibility actually holds on real patches. For every gold patch in the evaluation sets, we replay the patch edit by edit and check $h \le$ the true remaining edits at each prefix. Violations will occur where the location-granularity assumption breaks, for example when an import shadows a name. These are counted and characterized rather than assumed away. Two quantities are also measured as search proceeds: prompt length per call and number of model calls. This tests whether context stays flat.

Baselines

The do-nothing reference is a single-shot patch from the same base model given BM25-retrieved files, following the SWE-bench protocol. The SWE-bench paper reports 1.96% resolution for Claude 2 in this sparse-retrieval setting and 4.8% with oracle files. Those figures fix the scale of the floor; we rerun the floor with our own model.

The strongest existing system for repository repair in the file is MAGIS. On SWE-bench Lite, MAGIS reports 25.33% resolution, against 18.00% for SWE-Agent and 16.11% for AutoCodeRover (MAGIS). Those numbers come from different base models and budgets. We will therefore reimplement MAGIS's role structure on our base model with an identical cap on model calls, tokens, and test executions, and compare against that rerun. Quoting the reported 25.33% only for orientation is the fair choice. Beating MAGIS means a higher resolution rate at equal budget on the full Lite set. On the multi-location subset described below, the expected margin is larger and should hold across three seeds.

The baseline most likely to threaten the idea is a compiler-feedback refinement loop. It uses the same static checker and test harness as our system, pastes all current diagnostics and the cumulative diff into each prompt, has no search, and gets the same budget. It isolates whether gains come from the checker's information, which both systems share, or from how the search uses it. A second ablation, the obligation queue, feeds obligations one at a time with local context but greedily, with no backtracking or pruning. It separates the benefit of decomposition and bounded context from the benefit of the admissible search itself. A third ablation replaces $h$ with a BiRM-style value model trained on rollouts from SWE-bench-train repositories and uses it for both ordering and pruning. This tests whether soundness matters or whether any decent forward estimate does. The last baseline is Best-of-N sampling of full patches, filtered by tests, at matched model calls.

Why not just…?

Why not just feed every compiler error back into a normal refinement loop? This is the most serious alternative, because the checker already tells the model what is broken. The case against it is indirect. CodeTransOcean and ReFoRCE both see compiler-feedback loops plateau. A long error list plus a growing diff is precisely the kind of saturated context that SWE-bench shows hurts. A greedy loop also cannot back out of a cascading edit. The compiler-feedback-loop and obligation-queue baselines settle this directly. If the loop matches the full system on the multi-location subset, the contribution reduces to "use a type checker," and we would report that.

Why not just give a long-context model the whole repository? SWE-bench finds localization worsening as more code is supplied. GraphLLM finds accuracy on structured inputs falling with size even inside the token limit. We include a whole-relevant-files variant of the compiler-feedback-loop baseline, using as many files as fit in the window, and plot success against the number of locations the gold patch touches. The prediction is that it degrades with patch breadth while the search stays flatter.

Why not just sample many patches and keep one that passes the tests? At large budgets this can be strong. However, BiRM reports that unguided Best-of-N with step verifiers declines as N grows. Independent full-patch samples also each have to get every call site right at once, so the chance that all sites are correct shrinks with the number of locations. The matched-budget Best-of-N baseline, swept over N, shows where this argument holds and where it fails.

Why not just learn the forward estimate as BiRM does? A learned value can be more informative than a coverage bound, and it may win on ordering. The value-model ablation tests this. If it matches our system, admissibility buys nothing in practice. The hypothesis is that it fails specifically at pruning, where it discards the correct partial patch.

Proposed Experiments

The evaluation uses three sets. The first is SWE-bench Lite in full. The second is the subset of SWE-bench issues whose gold patches touch at least two locations or change a signature; this is the regime the method targets. On single-location issues we expect parity and will say so. The third is a constructed migration set, for which no reported result was found on Lacuna. We take the Java Defects4J projects used by TELPA (Chart, Lang, Math, Time) and a set of SWE-bench Python repositories. In each, we apply a seed refactor at one definition, such as an added parameter, a changed return type, or a container swapped for a different structure, and ask the system to complete it. The original tests serve as the oracle. The main metric is resolution rate. Secondary metrics are model calls and tokens per solved task, prompt length per call across search depth, and the rate of partial migrations in failed attempts, meaning outputs that still have obligations.

Three checks decide whether the idea holds. First, on the multi-location and migration sets, the full system must beat the compiler-feedback loop and the obligation queue at equal budget. If it does not, the search adds nothing. Second, the empirical admissibility audit must show violations on a small minority of gold-patch prefixes, and performance must not collapse when they occur. Third, we run the full system and the MAGIS rerun on a weaker and a stronger open model. ReDel predicts that scaffolding gains grow with model strength. Our hypothesis is the reverse for this particular scaffold: because it removes bookkeeping that weak models fail at, its margin over the compiler-feedback loop should be at least as large on the weaker model. Finding the opposite would show that the base-model ceiling binds even after bookkeeping is moved out of the model.