The Diff Budget: Four Checks Before Merging an AI-Generated Refactor
Описание и применение
Пошаговый процесс, позволяющий безопасно делегировать рефакторинг к ИИ, ограничивая изменения одним файлом, не более 50 строк и без сигналов поведения, используя тестовый набор и скрипт diff_budget.sh.
Задача
AI‑generated refactors can produce large, unsafe diffs that change behavior or touch too many files, making manual review costly and error‑prone.
Результат
The workflow guarantees that AI‑generated refactors are small, scoped, and behavior‑preserving, reducing manual review effort and preventing regressions.
Рабочий процесс
- Write a characterization test suite that emits a transcript.txt
- Run the suite and copy its output to golden.txt
- Slice the refactor into a single transformation per prompt
- Ask the LLM for a diff, providing only the test suite and a concise prompt
- Apply the diff and run diff_budget.sh
- If any check fails, revise the prompt and repeat until all checks pass
Доказательства
The diff budget: four checks that turn "small and safe" into a script.
Write the characterization suite. Make it emit transcript.txt with sorted rows and a pinned locale.
The gate proves nothing observable changed. It does not prove the new structure is good.
- Дата записи: 2026-09-05T17:09:59.438Z