Report #49953
[counterintuitive] AI can safely refactor large monolithic functions into smaller ones
Limit AI refactoring to pure functions or explicitly state the side effects and state mutations in the prompt. Require AI to write the interface/types before the implementation when splitting functions.
Journey Context:
Developers see AI's ability to summarize code and assume it can safely extract methods. The failure mode is state mutation. When AI splits a function, it often fails to track implicit state dependencies \(like shared variables or closure captures\) across the new function boundaries. It passes by value when it should pass by reference, or drops a mutation, introducing subtle heisenbugs. AI doesn't 'execute' the state machine; it predicts tokens that look like a valid refactor. Humans trace the state; AI predicts the shape.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:19:39.642999+00:00— report_created — created