Software Engineering Empirical Research Radar
从 FL/TCP 到 AI-Native Program Repair
一个面向中文快速阅读的 repair 专题教程:如何从 fault localization、test prioritization 和 trace 经验进入现代 LLM 程序修复。
定位。 你不需要从零变成 repair 学者。你已经有 FL、TCP、trace 和 CI 直觉;repair 只是把问题推进一步:不仅问哪里错、跑哪些测试,还问如何生成补丁、验证补丁、避免假修。
主张。 AI repair 时代最有价值的不是泛泛代码生成,而是诊断证据如何改变模型的修复行为。
分层阅读路线
Repair Pipeline:先看流程,不先看数字
收集 failing tests、stack trace、错误输出、相关文件/函数、依赖片段和已有测试。
决定模型应该看 statement、method、function、file 还是多文件上下文。
LLM 或 repair system 生成候选补丁;可以一次生成,也可以多轮 agentic 生成。
编译、运行 triggering/relevant/all tests,并记录 plausible、失败日志和成本。
把编译错误、测试失败、运行时状态或诊断证据反馈给模型,再试下一轮。
区分 plausible patch 和 correct patch,检查 overfitting、语义偏差和补丁大小。
近年代表工作怎么读
| 工作 | 设置 | 你该学什么 | 链接 |
|---|---|---|---|
| SRepair | function-level LLM repair; Defects4J 1.2/2.0 | 不要默认 statement-level FL 是唯一入口;function-level repair 已经是强 practical baseline。 | source |
| RepairAgent | autonomous LLM-based agent for program repair | 现代 baseline 不只是 prompt,而是查文件、找上下文、生成补丁、跑测试、迭代。 | source |
| DebugRepair | self-directed debugging + runtime evidence for LLM APR | 运行时证据正在成为强线;我们的 trace/value-route 必须压缩成公平、patch-free advice。 | source |
| NIST/IEEE Computer survey | LLM-based APR overview | 用 survey 快速建立术语和系统分类,但不要只停在综述。 | source |
| Defects4J | Java real-bug benchmark | 所有 repair 数字先问版本、active/deprecated、bug universe、validation scope。 | source |
今年工作的演化
| 时间线 | 主流形态 | 关键技术 | 对我们的启发 |
|---|---|---|---|
| 2023--2024 | LLM repair 从 direct prompting 走向 FL/context-guided repair;研究重点是给模型多少上下文、用 statement 还是 function scope。 | buggy function retrieval、suspicious statement、few-shot prompt、multi-sample patch generation、generate-and-validate。 | 这阶段的核心问题是 context selection;你的 FL 能力可以直接变成 repair scope/advice。 |
| 2024--2025 | Repair 开始明显 agent 化:模型不只输出补丁,还会查文件、定位、修改、运行测试并根据失败继续迭代。 | tool use、file navigation、test feedback loop、patch queue、budgeted attempts、agent trace logging。 | 强 baseline 不能只用一次性 LLM;至少要有反馈循环或 agentic baseline。 |
| 2025--2026 | 研究重心转向 runtime evidence、自主 debugging、评价可信度和更严格的 correct patch 判定。 | stack/value evidence、trace compression、failing/passing contrast、generated tests、overfitting detection、semantic review。 | 这正好连接 00 的 trace 采集和 06/07/08 的诊断证据;关键是 patch-free、statement-level、tie-worst 的公平证据。 |
现在大概能修到什么水平
| 口径 | 直观数字 | 怎么解读 | 链接 |
|---|---|---|---|
| Defects4J official universe | 854 active bugs + 10 deprecated bugs | 先确认分母;不同论文用 395、835、854 或子集时不能直接横比。 | source |
| RepairAgent | 164 / 835 correct bugs, about 19.6% | agentic repair 是合理 baseline,但不是天花板;它展示了 tool loop 的必要性。 | source |
| SRepair | reported 300 single-function bugs plus 32 multi-function bugs | function-level context 能很强;只给 statement 可能会限制 LLM。 | source |
| DebugRepair | reported 295 correct bugs with DeepSeek-V3 in its setting | runtime evidence/self-debugging 已经是强线;我们的新证据要证明比普通 FL/Ochiai 更有用。 | source |
| Strict leaderboard style | often reports much smaller cross-tool comparable numbers | leaderboard 口径更保守;适合提醒自己 plausible/correct/benchmark split 不能混。 | source |
读法。 Defects4J 上现代 LLM/APR 的强结果大致已经进入 20%--35% correct 的区间;但不同论文的 bug universe、模型、预算、validation scope 和 correct 判定不同,不能把数字当成一个排行榜。我们的实验必须用同一组 bugs、同一预算、同一模型、同一 validation protocol 做 paired comparison。
关键技术层
| 技术层 | 核心问题 | 常见做法 | 我们的切入 |
|---|---|---|---|
| Context retrieval | 模型该看哪些代码? | file/function retrieval、call graph、dependency slice、test-to-code links。 | 把 Ochiai statement 映射到 method/function neighborhood,比较不同 scope。 |
| Diagnostic evidence | 模型该知道什么失败事实? | stack trace、assert diff、value trace、failing/passing contrast、state invariant hint。 | 把 00/06/07/08 的结果压缩成 patch-free diagnostic card。 |
| Patch generation | 一次生成还是多候选? | single-shot、multi-sample、self-refine、agent proposal queue。 | 控制 token/attempt 数,避免我们的 arm 只是预算更多。 |
| Validation scheduling | 每个 patch 后先跑哪些测试? | compile first、triggering tests、relevant tests、full suite、history-aware prioritization。 | 把 TCP 迁移成 repair-loop test scheduling。 |
| Feedback summarization | 失败信息怎么回传给 LLM? | compiler error summary、failed assertion diff、top stack frames、changed-line receipt。 | 反馈必须短、固定格式、不能泄漏 developer patch。 |
| Correctness defense | 过测试是否真的修对? | human review、developer patch comparison、independent/generated tests、overfitting taxonomy。 | 最终 claim 分 plausible/correct,负例单独分析。 |
你的旧能力怎么迁移
FL / TCP / Trace 到 Repair 的翻译表
| 旧能力 | Repair 中的新问题 | 可能贡献 |
|---|---|---|
| Fault localization | 给模型哪个 scope 和 suspicious evidence? | repair advice、statement-neighborhood evidence、scope selection。 |
| Test prioritization | 每轮候选补丁之后先跑哪些 tests? | agentic repair 的 validation scheduling。 |
| Trace / value route | 失败与通过行为在哪里分叉? | runtime evidence compression、diagnostic card。 |
| CI / regression testing | 修复循环如何低成本、可靠、可回滚? | repair loop protocol、cost-aware validation、flaky-aware repair。 |
Benchmark 和工具集
| Benchmark / Tool | 适合做什么 | 风险 |
|---|---|---|
| Defects4J | 主战场;适合 FL/repair/testing 的可复现实验。 | 版本和 bug universe 容易混;correct patch 仍需判定。 |
| QuixBugs | 小算法 bug;适合快速 smoke test。 | 太小,不能代表真实工程 repair。 |
| ManyBugs / IntroClass | 经典 C repair benchmark。 | 生态较旧,和 LLM/Java pipeline 距离较远。 |
| SWE-bench | 真实 GitHub issue 级 agentic repair。 | 太重,短期不适合作为第一篇主实验。 |
| Bugs.jar / Bears / BugSwarm | Java/CI 相关真实 bug 或 failure。 | 搭建和可复现成本更高,适合作后续扩展。 |
常见坑
- 只报 plausible:通过测试不等于语义正确;first-tier repair paper 会追问 correct patch。
- baseline 太弱:只比 vanilla LLM 不够,至少要有 Ochiai-guided 和 feedback-loop baseline。
- oracle leakage:不能把真实 fault line、bug type、fixed diff 或开发者 patch 泄漏给模型。
- 预算不公平:不同 arm 的 token、候选补丁数、测试轮数、上下文长度必须可解释。
- prompt engineering 化:如果贡献只是更会写 prompt,论文会弱;需要可复现的 evidence/advice schema。
- 忽略负例:repair advice 误导模型的 case 很重要,它能让论文更可信。
第一篇实验建议
Diagnostic advice for LLM repair
最小公平实验不是“我们的 advice vs 什么都不给”,而是三组 paired comparison:
- vanilla LLM repair;
- Ochiai-guided LLM repair;
- diagnostic-advice-guided LLM repair。
核心指标:fixed/plausible/correct、attempts、compile fail、test fail、patch size、test cost、overfitting risk。
两到四周冲刺计划
| 时间 | 目标 | 产出 |
|---|---|---|
| Day 1--2 | 搭 smoke runner | 能对 1 个 Defects4J bug 生成 patch、apply、compile、run tests、保存 receipt。 |
| Day 3--4 | 写三套 prompt | vanilla、Ochiai-guided、diagnostic-advice-guided,固定预算。 |
| Day 5--7 | 跑 3-bug smoke | 看是否出现 unique plausible/correct、attempt 减少或 overfitting 降低。 |
| Week 2 | Csv-1..16 pilot | paired result table、patch inspection、go/no-go。 |
| Week 3--4 | 扩到 50 bugs | 若 pilot 有信号,形成 SANER/ASE 级别的最小结果。 |
读论文时的检查清单
每篇 repair 论文都先问这些
- 它给模型/工具看了哪些信息?有没有 oracle?
- bug universe 是什么?Defects4J 哪个版本?active 还是 deprecated?
- reported result 是 plausible 还是 correct?correct 如何判定?
- baseline 是不是足够强?有没有 agentic feedback 或 FL-guided baseline?
- token、候选补丁数、测试预算、上下文长度是否公平?
- 失败案例是否分析?它告诉我们下一篇 paper 可以做什么?