An Iterative Test-and-Repair Framework for Competitive Code Generation

Lingxiao Tang 1 , Muyang Ye 1 , Zhaoyang Chu 2 , Xiaoxue Ren 1 , Zhongxin Liu 1 , Lingfeng Bao 1,* , He Ye 2 1 The State Key Laboratory of Blockchain and Data Security, Zhejiang University 2 University College London {lingxiaotang, yemuyang, xxren, liu_zx, lingfengbao}@zju.edu.cn {zhaoyang.chu.25, he.ye}@ucl.ac.uk · 2026

Read An Iterative Test-and-Repair Framework for Competitive Code Generation by Lingxiao Tang 1 , Muyang Ye 1 , Zhaoyang Chu 2 , Xiaoxue Ren 1 , Zhongxin Liu 1 , Lingfeng Bao 1,* , He Ye 2 1 The State Key Laboratory of Blockchain and Data Security, Zhejiang University 2 University College London {lingxiaotang, yemuyang, xxren, liu_zx, lingfengbao}@zju.edu.cn {zhaoyang.chu.25, he.ye}@ucl.ac.uk (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2604-05560.txt.

Introduction

Tang and six colleagues improve competitive code generation with FixAudit, which repairs one candidate instead of sampling many. A Fixer mends code against failing tests while an Auditor reads the code to craft tests that expose remaining bugs, cycling through four training stages. On a 7B model it tops the average of a larger 32B baseline and lifts Pass@1 by about 35 to 37 percent over same-size rivals.

Catalog record

CREATORLingxiao Tang 1 , Muyang Ye 1 , Zhaoyang Chu 2 , Xiaoxue Ren 1 , Zhongxin Liu 1 , Lingfeng Bao 1,* , He Ye 2 1 The State Key Laboratory of Blockchain and Data Security, Zhejiang University 2 University College London {lingxiaotang, yemuyang, xxren, liu_zx, lingfengbao}@zju.edu.cn {zhaoyang.chu.25, he.ye}@ucl.ac.uk
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE54075
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2604.05560

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

An Iterative Test-and-Repair Framework for Competitive Code Generation Lingxiao Tang 1 , Muyang Ye 1 , Zhaoyang Chu 2 , Xiaoxue Ren 1 , Zhongxin Liu 1 , Lingfeng Bao 1,* , He Ye 2 1 The State Key Laboratory of Blockchain and Data Security, Zhejiang University 2 University College London {lingxiaotang, yemuyang, xxren, liu_zx, lingfengbao}@zju.edu.cn {zhaoyang.chu.25, he.ye}@ucl.ac.uk Abstract . Large language models (LLMs) have made remarkable progress in code generation, but competitive programming remains a challenge. Recent training-based methods have improved code generation by using reinforcement learning (RL) with execution feedback. The more recent framework CURE further incorporates test generation into the training process, jointly training a Coder and a Tester within a single model. At inference time, the Coder generates many candidate programs, and the Tester generates tests from the problem description. The candidate who passes the most of the generated tests is selected as the final answer. However, CURE has two critical limitations. First, the Tester never reads any candidate code, so its tests often fail to expose implementation-specific bugs. Second, the Coder generates every candidate from scratch and never learns to fix a buggy program based on a failed test. To address these limitations, we propose FixAudit , which approaches competitive code generation from a new perspective: starting from a single initial candidate, it iteratively improves the candidate through a targeted test-and-repair debugging cycle. The framework trains one shared model with two specialized roles through four stages: the Fixer, which repairs the current candidate based on a failing test, and the Auditor, which reads the candidate code to generate new tests that expose its remaining bugs. We evaluate FixAudit on three benchmarks: APPS, CodeContests, and xCodeEval. Applied to a 7B model, the framework surpasses the average performance of the larger 32B baseline within the same model family under the zero-shot setting. Compared to strong baselines built on the same 7B base model, FixAudit improves average Pass@1 by 35.1% to 36.8% and average AvgPassRatio by 7.1% to 24.5%. Further analysis shows that FixAudit achieves stronger performance with fewer iterations, demonstrating both the effectiveness and efficiency of the approach. † † footnotetext: * Corresponding author. 1. Introduction Large language models (LLMs) have made remarkable progress in code generation ( 1 ; 5 ; 16 ; 20 ) . However, competitive programming remains a persistent challenge ( 18 ; 29 ; 24 ; 32 ) . These problems have strict logical constraints. A model can easily generate a program that passes some test examples, but still fails to pass all test sets that determine true correctness ( 18 ; 29 ; 32 ) . Reinforcement learning (RL) has emerged as a natural approach for improving code generation by using execution feedback as reward signals. Early methods such as CodeRL ( 25 ) , PPOCoder ( 45 ) , and RLTF ( 31 ) formulate code generation as policy optimization and use unit test results to guide training. StepCoder ( 11 ) and RLEF ( 13 ) further improve training stability through curriculum design and multi-turn feedback. However, these methods focus solely on training the code generation policy and do not train a test generation model. At inference time, they can only rely on the fixed public tests to evaluate candidates and cannot perform test-time scaling ( 35 ; 26 ) by generating additional tests to select among multiple solutions. The state-of-the-art training-based framework CURE ( 51 ) addresses this limitation by using RL to jointly train a single model to serve as both a Coder and a Tester. At inference time, the Coder generates a pool of candidate programs, and the Tester generates a set of test cases based solely on the problem description. The candidate who passes the most of the generated tests is selected as the final answer. This generate-and-select strategy realizes test-time scaling: generating more candidate programs and more tests together leads to a higher chance of producing and identifying a correct solution. However, CURE still suffers from two critical limitations. First, the Tester generates tests blindly without analyzing any candidate code. Because the Tester only receives the problem description as input and never sees the candidate programs, it produces generic tests that frequently fail to expose hidden, implementation-specific bugs in partially correct code. Second, CURE has no repair mechanism. The Coder generates new candidates from scratch each time and relies on the Tester to select the best one. It never learns to fix a buggy program based on a failed test case. If none of the candidates in the pool happen to be correct, no amount of test-based selection can produce the right answer. To overcome these limitations, we propose a different perspective. Rather than generating many candidates from scratch and selecting among them, we start from a single initial candidate produced by the base model and iteratively improve it through a continuous, targeted test-and-repair cycle. We introduce FixAudit , a new framework that jointly trains one shared model with two roles: the Fixer, which repairs the current candidate, and the Auditor, which generates tests to expose its remaining bugs. However, neither task is easy for LLMs. Targeted repair requires the model to trace program execution, pinpoint the exact fault, and modify only the faulty logic without breaking correct parts. Targeted test generation requires the model to simulate how the candidate code behaves on specific inputs and identify inputs that trigger its bugs. Both tasks demand strong execution reasoning ability, a capability that current LLMs lack ( 4 ; 14 ; 9 ) . We therefore design a four-stage training pipeline that progressively builds these capabilities: \raisebox{-0.9pt}{1}⃝ Stage A equips the model with the execution reasoning ability through supervised fine-tuning. It trains the model both to predict the output of a program on a given input and to derive the correct output from the problem specification alone. The first ability helps the Fixer understand why the current program fails, while the second helps the Auditor construct valid test cases. \raisebox{-0.9pt}{2}⃝ Stage B trains the Fixer via RL to repair initial buggy programs using provided failing tests, producing an improved candidate. However, this repaired candidate may still contain latent bugs that the existing tests do not cover. \raisebox{-0.9pt}{3}⃝ Stage C therefore trains the Auditor via RL to actively find these hidden bugs. Unlike CURE’s Tester, the Auditor reads the repaired candidate alongside the specification, allowing it to generate tests that specifically target the program’s remaining bugs. \raisebox{-0.9pt}{4}⃝ Stage D closes the loop by retraining the Fixer on these newly exposed failures, further refining the candidate. We evaluate our framework on three widely used competitive programming benchmarks: APPS, CodeContests, and xCodeEval. After training and test-time scaling, FixAudit built on Qwen2.5-Coder-7B-Instruct achieves 30.40% average Pass@1 and 56.77% average AvgPassRatio. Within the same model family, it improves average Pass@1 by 24.9% and average AvgPassRatio by 40.5% over the larger Qwen2.5-Coder-32B-Instruct used in the zero-shot setting. Compared with strong baselines built on the same 7B base model ( 49 ; 51 ) , FixAudit improves average Pass@1 by 35.1% to 36.8% and average AvgPassRatio by 7.1% to 24.5%. Moreover, FixAudit reaches stronger performance with fewer iterations, indicating that our approach is both effective and efficient. In summary, the main contributions

Read the complete text