Specification-first convergence with an AI coding agent: a case study of dismantling a core architectural invariant across 189 files in a 717k-line codebase with no test oracle and no human code review

Joel Abenhaim

arXiv:2608.12440 · 2026-08-16 공개 · arXiv · PDF

specification-first ai-coding-agent architectural-refactoring typescript codebase-analysis no-human-review formal-specification verification-cycles

Abstract

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.

한국어 요약

한 줄 요약

AI 코드 에이전트가 71만 줄 TypeScript 코드베이스에서 핵심 아키텍처 불변식을 3일 동안 2,430달러 비용으로 성공적으로 해체.

핵심 기여도

핵심 아이디어

이 연구는 AI 코드 에이전트가 명세 기반 프로토콜을 통해 대규모 코드베이스의 핵심 아키텍처 불변식을 해체하는 사례를 제시한다. 기존의 점진적 리팩토링 방식으로는 불가능한 작업을, AI가 사양 정제, 구현, 검증의 반복을 통해 수행했다. 핵심 아이디어는 사양과 코드 간 일관성을 유지하면서도, 인간 검토 없이도 정확한 결과를 도출할 수 있다는 점이다. 특히, UI 패널이 AI 요청 동안 열려 있어야 하는 불변식을 해체하고, 스트리밍 생성이 패널 닫힘 후에도 지속되도록 변경하는 것이 핵심 목표였다.

기술적 접근법

주요 결과

의의 및 한계

이 연구는 AI 코드 에이전트가 대규모 아키텍처 변경을 인간 개입 없이 수행할 수 있음을 실증적으로 보여준다. 특히, 테스트 오라클 없이도 정확도를 유지하는 점이 학술적·실용적 가치를 지닌다. 그러나 사양 작성과 검증 과정이 모두 AI에 의존하기 때문에, 오류 발생 시 인간 개입이 어려울 수 있다. 또한, 사양이 명확히 정의되어 있어야 하며, 복잡한 논리적 관계를 처리하는 능력이 한계일 수 있다.

실용적 활용

이 접근법은 대규모 코드베이스에서 아키텍처 리팩토링, 불변식 해체, 또는 기존 시스템의 현대화에 적용 가능하다. 특히, 테스트 환경이 부족하거나, 인간 리뷰가 어려운 상황에서 유용할 수 있다. 소프트웨어 유지보수, 클라우드 마이그레이션, 또는 AI 기반 개발 도구의 자동화에 활용 가능.