Pin a Characterization Suite Before You Accept the First Refactor Diff
Описание и применение
Создание и поддержка набора характеризаций гарантирует, что любые изменения в коде не нарушат существующие бизнес‑контракты.
Задача
Refactoring a large, poorly tested module with an AI agent can silently break business‑critical contracts because the changes are not validated against real fixtures.
Результат
After implementing the workflow, refactor commits no longer introduce hidden regressions; all observable outputs are pinned to real fixtures and verified by CI.
Рабочий процесс
- Wrap the current public entry point and record outputs from production‑shaped fixtures using a helper script.
- Run the recording command on the untouched revision to ensure stability; if it fails, fix flaky behavior first.
- Promote each recording into a test that asserts the output matches the golden file.
- Add the tests to CI so that any refactor must pass them before merging.
- Iterate: record new cases as needed and keep the suite up to date.
- Use the suite as the merge gate to prevent accidental contract drift.
Доказательства
Record from production-shaped fixtures, not from synthetic rows invented to make the function look pure.
If the second command fails on an untouched revision, you do not yet have a characterization suite.
- Дата записи: 2026-09-21T00:15:23.270Z