When a language model fixes a bug by reading the output of a failing test, it has to reason backward: from the wrong value at the assertion, through the chain of statements that produced it, to the one statement that is actually wrong. Existing evidence says models are worst at exactly this direction. They predict a program's inputs from its outputs far less accurately than its outputs from its inputs, and their accuracy drops when a reasoning graph is described in reverse order. We propose to measure how iterative code repair degrades as the bug sits further upstream of the failure. We control that distance in freshly generated programs that no model can have memorized. We then test one targeted fix: before the model sees the trace, cut it down to the backward cone of the failure, meaning the recorded operations that actually fed the wrong value, and present each operation as a small forward check the model can verify locally.
In two sentences: repair loops probably stall because models cannot trace a failure backward through many steps of program execution, and static, possibly memorized benchmarks hide this. We build a contamination-proof program generator that dials the backward distance between bug and failure, show how repair collapses with that distance, and test whether handing the model only the failure's backward cone, as forward-checkable steps, flattens the collapse.
Core Claim
Think of an execution as a graph. Each node is one executed operation instance: a variable taking a value at a particular step. Each edge says that one value was computed from another. We call this the dynamic dependence graph. For a failing test, let $d$ be the number of dependence edges between the corrupted operation and the failing assertion. We model repair success at depth $d$ as roughly $p_0 r^d$, where $p_0$ is success when the bug is at the assertion and $r$ is the per-hop retention rate. This geometric form assumes each backward hop is an independent chance to lose the thread. The same form fits forward simulation accuracy at depth $d$, with retention $r_{\text{fwd}}$.
We make three claims. First, backward retention $r_{\text{back}}$ in repair is markedly lower than $r_{\text{fwd}}$ on the same programs. Second, this gap, not code generation ability, explains why feedback loops plateau. Third, restricting the feedback to the failure's backward cone, with each node rendered as a locally checkable step ("total became 17 from total=12 and x=5 at line 9"), raises $r_{\text{back}}$ toward $r_{\text{fwd}}$. The third claim is the intervention. The first two are the measurement that makes it interpretable.
Where This Sits
The motivating evidence comes from three places. The code-simulation literature documents the asymmetry directly. CRUXEval finds input prediction harder than output prediction, with GPT-4 at 81.9% versus 75.0% using chain-of-thought. CodeSense traces real GitHub code with debuggers and finds input prediction near 12% for Claude 3.5. DyVal generates reasoning problems from directed acyclic graphs and finds that describing them in reversed order costs GPT-4 13.6 points on reachability. None of these three studies repair. We carry their asymmetry into the repair loop, where backward reasoning is not optional.
The trace-repair literature supplies our baselines and one constraint. TraceFixer feeds a CodeT5 repair model buggy code, a partial trace and the "desired state" at the divergence point. Towards Effectively Leveraging Execution Traces shows that longer traces hurt repair and has GPT-4 summarize them first. Do Code Semantics Help? compares five text trace formats and finds concise traces help at test time. It also finds that fine-tuning on traces mostly hurts, degrading accuracy in 7 of 9 cases. That negative result is our constraint: the main intervention is applied at test time, not trained in.
These papers shorten or summarize the trace. None asks which part of the trace a backward reasoner needs, and none controls where the bug sits relative to the failure.
Graph task unification contributes the evaluation design, not a model. All in One and GraphPrompt recast node-, edge- and graph-level tasks as questions about an induced subgraph, meaning a node or node pair plus its local neighborhood, so that one model and one format serve all of them. We borrow that move to pose three kinds of question over the same execution graph:
- a node question: what value does this operation hold;
- an edge question: does this value influence that one;
- a subgraph question: which node in this backward cone is the root cause.
Posing all three on one graph lets us attribute a repair failure to a specific missing capability on the very instances being repaired.
PLUR is the closest graph-and-repair work. It unifies 16 program tasks over static syntax-tree and data-flow graphs with a graph-aware transformer. It uses no runtime information and treats repair as one-shot translation. We use runtime graphs inside an iterative loop, and we do not claim that a graph encoder is required.
Research Program
The first artifact is a program generator in the spirit of DyVal and DSR-Bench, but emitting executable Python rather than math or data-structure queries.
- Program construction. The generator samples a computation graph and compiles it into a function with loops, branches, lists and dicts, and deliberate aliasing. Aliasing matters because CodeSense shows models shortcut it from surface patterns.
- Bug injection. It plants a single mutation at an operation whose dependence distance $d$ to a failing assertion is chosen in advance, from 1 to 8. It also controls the width of the backward cone, meaning how many ancestor operations compete as suspects.
- Guarantees. The generator keeps the reference program, so it knows the root cause, the desired value at every node, and a hidden test suite for checking patches.
- Surface variants. Every instance comes in variants with renamed identifiers, reordered independent statements and flipped branch predicates. Following Hooda et al., these variants separate structural reasoning from memorized surface patterns.
The second artifact is the intervention. We instrument the run, build the dynamic dependence graph, and extract the backward cone of the failing assertion, which is the set of operations it transitively depends on. Each cone node is rendered as one line stating the operation, its inputs' recorded values and its output. The lines are ordered from the failure outward.
No desired values are shown, because they would be unavailable in real use. The model's job becomes scanning a short list of local computations for the one that contradicts the specification. Each such check is a forward, one-step judgment, which is the direction models handle better.
The repair loop is otherwise standard: propose a patch, rerun the tests, rebuild the cone on the new failure, and stop after a fixed number of rounds.
The third component is the unified probe. For each repair instance we also ask the node, edge and subgraph questions defined above, all over that instance's execution graph. We then regress repair success on probe accuracy to see which capability is the binding one.
Baselines
The naive reference point is repair with only the failing test's error message and no trace, run in the same loop with the same round budget. Towards Effectively Leveraging Execution Traces reports this error-only condition at a Correct Fix Accuracy of 0.511 for GPT-4 on HumanEval-Java. The intervention must beat it at every depth, and by a growing margin as $d$ increases.
The strongest existing text-trace method at test time is the Concise format from Do Code Semantics Help?, which improved GPT-4o on MBPP-R by up to 10.85%. The strongest summarization method is the LLM-optimized trace from Towards Effectively Leveraging Execution Traces, reported at 0.572 Correct Fix Accuracy on HumanEval-Java. These two are the most direct competitors, since each already attacks trace noise.
We rerun both ourselves on the same backbone models, instances, round budget and prompt-tuning budget. The summarizer's extra tokens count toward its cost. Beating them means higher repair success on the generated suite at depths of 4 and beyond, with equal or fewer input tokens, and at least matching their numbers on HumanEval-Java and MBPP-R when rerun.
We include TraceFixer's input format with desired states supplied, given as buggy code, partial trace and desired divergence state. It reports 63% top-1 on CodeNet. We treat it as an oracle-assisted upper reference, because it receives information our method withholds.
The key ablation replaces the backward cone with a random subset of trace lines of equal size, and separately with the most recent lines before the failure. This isolates whether dependence-based selection matters, rather than mere shortening.
A second ablation renders the cone as a graph adjacency list instead of forward-checkable lines. This tests whether graph formatting adds anything beyond selection.
No reported result was found on Lacuna for any method on our generated suite. All suite numbers will be produced by us.
Why not just…?
Why not just use the concise text trace, which already works? It may be close. The concise format helps at test time, but it trims lines by recency and verbosity, not by causal relevance. At large backward depth the root cause may sit far outside a recency window. The equal-length random and recent-lines ablations settle this. If concise traces match the cone at every depth, selection by dependence adds nothing and we will report that.
Why not just give the model an interpreter or debugger and let it inspect state itself? External execution clearly helps forward reasoning: Is Code Better Than Language for Algorithmic Reasoning? reports 48.84% with an interpreter versus 17.37% with internal simulation. But a debugger answers only the questions the model knows to ask. Choosing where to set a breakpoint is itself backward localization. This is a real threat, so we run an arm where the model can issue a matched number of variable-inspection queries per round. If that arm's retention with depth matches the cone arm, the cone is a convenience rather than a fix.
Why not just run more refinement rounds or add agent roles? MAGIS lifts SWE-bench resolution from 1.74% to 13.94% with specialized roles. It also identifies line localization as the dominant factor, and Yan et al. report that gains plateau after a few rounds. We run self-debugging with rounds scaled to match the cone arm's token budget. If extra rounds recover deep bugs, depth is not the bottleneck and our first claim fails.
Why not just evaluate on post-cutoff static benchmarks? They do not let us set $d$, which is the variable the whole study depends on. CodeSense also shows that even fresh code admits surface shortcuts. We still report results on static suites as a transfer check.
Proposed Experiments
Models are one frontier API model and two open code models of different sizes, all under a fixed round budget. Metrics are:
- repair success, meaning all hidden tests pass;
- root-cause localization accuracy;
- the fitted retention rates $r_{\text{back}}$ and $r_{\text{fwd}}$;
- input tokens.
Five checks decide the proposal.
- Is backward reasoning the bottleneck? On the error-only and concise-trace arms, $r_{\text{back}}$ should fall clearly below $r_{\text{fwd}}$, the forward retention measured by output-prediction questions at the same depths. If the two match, the bottleneck story is wrong.
- Does the cone fix it? The cone arm should raise $r_{\text{back}}$ above both text baselines and the random-subset ablation. If the random subset does as well, the gain is just shortening.
- Is it memorization? The gap between renamed or reordered variants and original instances should be negligible for the cone arm. A large gap would mean surface matching.
- Which capability binds? Accuracy on edge questions ("does this influence that") should predict repair success better than accuracy on node-value questions. That result would pin the failure on dependence tracking rather than arithmetic.
- Does it transfer? On HumanEval-Java and MBPP-R, rerun with our backbones, the cone arm should at least match the rerun optimized-trace and concise-trace baselines. As a correlational check, per-model $r_{\text{back}}$ on the generated suite should track CRUXEval input-prediction accuracy.
A secondary experiment tests whether the fine-tuning result from Do Code Semantics Help? is specific to its targets. We fine-tune one open model on generated edge questions only and ask whether repair improves without the overconfidence reported for trace fine-tuning. This is exploratory; the main claims do not depend on it.
References
- CRUXEval: A Benchmark for Code Reasoning, Understanding and Execution
- CodeSense: a Real-World Benchmark and Dataset for Code Semantic Reasoning
- DyVal: Dynamic Evaluation of Large Language Models for Reasoning Tasks
- TraceFixer: Execution Trace-Driven Program Repair
- Towards Effectively Leveraging Execution Traces for Program Repair with Code LLMs
- Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Models
- All in One: Multi-task Prompting for Graph Neural Networks
- GraphPrompt: Unifying Pre-Training and Downstream Tasks for Graph Neural Networks
- PLUR: A Unifying, Graph-Based View of Program Learning, Understanding, and Repair
- Can LLMs Reason Structurally? Benchmarking via the lens of Data Structures
- Do Large Code Models Understand Programming Concepts? Counterfactual Analysis for Code Predicates
- Is Code Better Than Language for Algorithmic Reasoning?
- MAGIS: LLM-Based Multi-Agent Framework for GitHub Issue Resolution
- CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translation