AI 程式開發/軟體測試
gpt-oss-20b Finds 13 Classes of Defects in Rope Refactoring Diffs, 12 Accepted by Maintainers
Researchers had a local model inspect only before-and-after Python refactoring diffs and identify 13 classes of behavioral changes across 217 Rope transformations. Maintainers accepted 12 as defects, but the model’s precision was only 0.67—too low to replace testing or static analysis.

A new study used a foundation model as a post-refactoring “behavior-preservation oracle.” Rather than providing the full repository or test results, the researchers supplied a git unified diff and asked the model to determine whether the transformation changed program behavior. The team reused 217 successful transformations generated by Rope 1.3.0 on TextBlob 0.17.1, covering seven types of operations, including renaming, extracting, inlining, and moving fields or methods. They ran a local gpt-oss-20b model three times in a zero-shot setting and took the majority vote.
Compared with annotations from a Python engineer with ten years of experience, the model achieved 0.91 recall, 0.67 precision, 0.84 accuracy, and an F1 score of 0.77. The human benchmark classified 64 of the 217 transformations as behavior-changing. After consolidating them by refactoring type, primary symptom, and minimal reproducible example, the researchers identified 13 distinct classes of defects. These included methods being defined outside their classes because of misplaced indentation after method extraction, method inlining failing to update attributes or incorrectly deleting imports, incorrect arguments being used when rewriting formatted strings, transformations being allowed on `__new__` or comparison methods, and cyclic dependencies arising after fields were moved.
The researchers submitted all 13 cases to the Rope issue tracker. Based on maintainer comments, labels, and issue status, 12 are still considered accepted bugs. The sole exception was inlining `__new__`, which maintainers classified as an unsupported enhancement request. However, “accepted” does not mean fixed: for example, #825, in which method extraction causes a `NameError`, remains open with no linked branch or pull request.
From an engineering perspective, the model could complement refactoring validation that checks only syntax or relies on inadequate test coverage, making it particularly suitable as a high-recall filter in CI. However, a precision of 0.67 means that roughly one in every three alerts may be a false positive. The study also evaluated only one project and an old version of Rope, relied on a single expert to establish ground truth, and used a diff-only approach that can misread Python indentation or hallucinate external calls not shown in the diff. Future work will require cross-validation across multiple projects, multiple reviewers, and executable tests, as well as verification of whether the defects still exist in newer Rope releases.