AI 程序员三天拆掉核心架构,零人工审查
一个 71 万行、3648 个文件的 TypeScript 生产系统,要拆掉一个核心架构约束:AI 请求期间 UI 面板必须保持打开。目标改成——流式生成在面板关闭后继续存活,重开面板时能无缝接回同一直播流,不丢不重。作者判断这活儿靠增量重构基本不可能,常规做法是推倒重写。但这次,AI 编程代理在「规范优先」协议下干完了:先让代理自己写正式规范,14 轮对照源码审计规范,然后原子化实施,编译/测试反馈循环,再 17 轮对照冻结规范审计代码。31 轮审计里,人类还没运行过程序,就修了 201 个缺陷。收敛标准是连续两轮验证零发现。改动涉及 189 个文件,加上提取阶段共 288 个文件、3.4 万行插入、1.6 万行删除。三天完成,成本 2430 美元,全程无人类代码审查,无测试预言机。作者把 1500 多页法语规范与原始会话日志全部公开,供人核查。这不是你明天能用的工具,但它指向一个反直觉的事实:在特定协议下,AI 能独立完成人类认为「只能重写」的架构级手术,而且过程可审计、可复现。
📄 原文摘要(英文)
This paper reports a single, fully instrumented case study of a large-scale architectural refactoring by an AI coding agent under a specification-first protocol, with no human review of the generated code and no pre-existing oracle to validate the target behaviour. The task, dismantling a central invariant across a large interdependent codebase, was assessed by the author as effectively infeasible through incremental refactoring, the kind of change that conventionally calls for a rewrite instead. Under the protocol described here, the agent completed it successfully. The system is a 717,725-line production TypeScript application across 3,648 files. The task required dismantling a core lifetime invariant: the guarantee that a UI panel remains open for the duration of an AI request. The target behaviour was that a streaming generation survives the closing of its panel and can be reattached, on reopening, to the same live stream with no loss or duplication. The protocol: formal specification by the agent, 14 refinement cycles auditing that specification against the source code, atomic implementation, a compile/test feedback loop, then 17 verification cycles auditing the code against the frozen specification. Across 31 audit passes, 201 defects were corrected before any human executed the program. The convergence criterion was empirical: two consecutive verification passes returning zero findings. The change touched 189 files (31 new); with the extraction phase, the two commits total 288 files, 34,770 insertions, 16,422 deletions. Across the first and roughly thirty later sessions, the software behaved as specified, no bug observed. Elapsed: three days; cost: USD 2,430. The full specification and raw session logs, 1,500+ pages in French, are published as evidence, allowing inspection of the process and submission to a language model for consistency checking.