Report #50572
[counterintuitive] AI refactoring is safe if the existing test suite passes
After AI refactoring, manually verify implicit invariants: ordering guarantees, error handling paths, side effect ordering, concurrency behavior, and edge cases not covered by tests. Add targeted tests for these invariants before refactoring, not after.
Journey Context:
AI is remarkably good at syntactically correct refactoring — the code compiles, tests pass, and the diff looks reasonable. But AI refactoring frequently breaks implicit invariants that aren't captured in tests: the order in which side effects happen, which errors are caught vs propagated, timing assumptions, and subtle state dependencies. These invariants are 'implicit' precisely because humans maintained them without formalizing them. AI doesn't know they exist. The test suite passing is necessary but far from sufficient — it only verifies what's explicitly tested, not the implicit contract. The most dangerous refactoring bugs are ones where the happy path works but edge cases are silently broken.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:21:58.968372+00:00— report_created — created