当LLM生成的重构产生连锁效应:对仓库采用就绪性的实证研究
When LLM-Generated Refactorings Ripple: An Empirical Study of Repository Adoption Readiness
AI总结:
该研究针对15个开源Java仓库的150个文件开展LLM重构实验,发现93.8%的重构候选存在高契约/依赖风险,建议从业者对LLM生成的重构进行仓库级分阶段验证。
摘要:
大型语言模型(LLM)越来越多地被用于重构源文件,但仅在文件层面的评估无法揭示影响仓库采用的契约、依赖或调用方假设的变化。为解决这一缺口,我们针对15个开源Java仓库的150个生产文件、5种LLM配置以及两种依赖感知生成条件(单提示重构和基于LangGraph的多智能体重构)开展了1500次生成尝试,其中1455次产生了可用于分析的完整候选方案。我们通过本地变更、面向仓库的结构指标、检测到的调用方影响、行为等价性指标以及可用的测试证据对这些候选方案进行评估,并将其分为低风险、需审查、高契约/依赖风险或无定论四类。结果显示,1365个候选方案(93.8%)被归类为高契约/依赖风险,106个(7.3%)存在至少一个检测到的下游调用方故障,290个(19.9%)存在错误的行为等价性指标,仅有8个满足低风险标准。在原因覆盖的子集内,随着更保守的依赖增量阈值的应用,高风险率有所降低;在65个具有明确目标测试结果的候选方案中,有60个通过了测试,其中包括50个被归类为高风险的候选方案。对705个完整配对的配对分析显示,在主要风险指标方面,不同生成条件之间无统计学显著差异,但模型配置在特定检测风险通道上存在差异。这些发现表明,从业者应将LLM生成的重构视为需要分阶段仓库级验证的候选方案,而未来研究应验证筛选和提取精度,并加强编译、行为以及协调多文件验证。
英文摘要:
Large Language Models (LLMs) are increasingly used to refactor source files, but file-local evaluations do not reveal changes to contracts, dependencies, or caller assumptions affecting repository adoption. To address this gap, we conduct 1,500 generation attempts across 150 production files from 15 open-source Java repositories, five LLM configurations, and two dependency-aware generation conditions: single-prompt refactoring and LangGraph-based multi-agent refactoring. Of these attempts, 1,455 yield complete candidates eligible for analysis. We evaluate these candidates using local changes, repository-facing structural indicators, detected caller impact, the behavioural-equivalence indicator, and available test evidence, and categorize them as Low-risk, Review-needed, High Contract/Dependency Risk, or Inconclusive. The results show that 1,365 candidates (93.8%) are classified as High Contract/Dependency Risk, whereas 106 (7.3%) have at least one detected broken downstream caller and 290 (19.9%) have a false behavioural-equivalence indicator; only eight satisfy the Low-risk criteria. Within the reason-covered subset, the High-risk rate decreases under more conservative dependency-delta thresholds, while 60 of the 65 candidates with conclusive targeted-test outcomes pass, including 50 classified as High risk. Paired analyses of 705 complete pairs identify no statistically significant generation-condition difference in the principal risk indicators, although model configurations differ in specific detected risk channels. These findings suggest that practitioners should treat LLM-generated refactorings as candidates requiring staged repository-level verification, while future research should validate screening and extraction precision and strengthen compilation, behavioural, and coordinated multi-file verification.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。