When LLM-Generated Refactorings Ripple: An Empirical Study of Repository Adoption Readiness
Organizations: Tampere University, Finland. · the School of Computing and Engineering, University of Derby, UK.
Abstract
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.
Figures & tables
| # | Project | Java files | Classes | Methods | KLOC |
|---|---|---|---|---|---|
| 1 | Ant | 993 | 1,365 | 10,184 | 239 |
| 2 | ArgoUML | 1,687 | 2,017 | 11,846 | 332 |
| 3 | Checkstyle | 2,273 | 2,839 | 7,215 | 188 |
| 4 | Eclipse Collections | 997 | 1,360 | 16,502 | 214 |
| 5 | GanttProject | 570 | 837 | 4,727 | 86 |
| 6 | Guava | 1,995 | 4,139 | 21,018 | 475 |
| Stage group | Nodes | Responsibility |
|---|---|---|
| Preparation | load , analyze , dependency_context | Load the fixed baseline file, detect PMD smells, and construct dependency context. |
| Planning | plan , llm_plan , feasibility | Map smells to refactoring techniques, produce a structured plan, and check size or feasibility constraints. |
| Generation | refactor | Generate the candidate Java file. |
| Verification | verify , ripple_verify , llm_verify | Run static quality checks, apply ripple-risk verification, and record an LLM-based assessment. |
| Reporting | report | Persist metrics, traces, and reports. |
| Model | Configured model identifier |
|---|---|
| Gemini | google/gemini-3.1-pro-preview |
| GPT | openai/gpt-5.5 |
| Claude | anthropic/claude-opus-4.8 |
| DeepSeek | deepseek/deepseek-v4-pro |
| Qwen | qwen/qwen3.6-plus |
| Category | Setting | Value |
| Temperature | Refactoring call | 0.4 for B0-V2 and the MA refactoring agent |
| MA planning call | 0.2 | |
| MA verification call | 0.1 | |
| Output budget | Refactoring output | LOC-scaled, with a default maximum of 2,500 tokens |
| MA planning / verification | 4,096 / 2,048 tokens | |
| Timeout | Refactoring call | LOC-banded, typically 480–3,600 seconds |
| Project | Files | LOC | Smells | Fan-in | Fan-out | APIs | Caller APIs | Callers | Dep. risk | Structural | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Tot. | Med. | Tot. | Med. | Tot. | Med. | Tot. | Med. | Tot. | Med. | Tot. | Med. | Tot. | Med. | Tot. | Med. | Inh. | Iface | ||
| Ant | 10 | 3258 | 254.0 | 48 | 3.0 | 108 | 1.5 | 156 | 15.0 | 145 | 10.5 | 44 | 1.0 | 108 | 1.5 | 37.7 | 2.65 | 7 | 4 |
| ArgoUML | 10 | 4709 | 460.5 | 53 | 5.0 | 206 | 0.0 | 325 | 16.0 | 89 | 4.5 | 24 | 0.0 | 206 | 0.0 | 22.3 | 0.98 | 8 | 4 |
| Checkstyle | 10 | 3849 | 369.0 | 12 | 1.0 | 93 | 1.5 | 160 | 17.0 | 137 | 5.5 | 12 | 1.0 | 93 | 1.5 | 25.2 | 1.05 | 7 | 2 |
| Eclipse Collections | 10 | 5793 | 261.5 | 95 | 2.5 | 44 | 1.0 | 345 | 29.5 | 383 | 17.0 | 198 | 2.0 | 44 | 1.0 | 127.0 | 3.30 | 0 | 5 |
| GanttProject | 10 | 2353 | 200.0 | 41 | 2.0 | 91 | 2.0 | 148 | 7.5 | 119 | 7.5 | 59 | 1.5 | 91 | 2.0 | 38.9 | 1.73 | 4 | 4 |
| Metric | Min | Q1 | Med. | Mean | Q3 | Max | % |
|---|---|---|---|---|---|---|---|
| LOC | 18 | 88.5 | 212.5 | 342.7 | 375.5 | 3182 | 100.0 |
| Smells | 1 | 1.0 | 3.0 | 8.7 | 11.8 | 60 | 100.0 |
| Fan-in | 0 | 0.0 | 1.0 | 8.3 | 5.8 | 181 | 68.7 |
| Fan-out | 0 | 4.0 | 10.0 | 16.7 | 21.8 | 119 | 98.0 |
| APIs | 0 | 2.0 | 7.0 | 14.5 | 18.0 | 135 | 92.7 |
| Caller APIs | 0 | 0.0 | 1.5 | 5.7 | 6.0 | 86 | 68.7 |
| Metric | Raw | Holm-adjusted | |
|---|---|---|---|
| LOC | 23.50 | 0.0526 | 0.1863 |
| Baseline smells | 41.91 | 0.0001 | 0.0010 |
| Fan-in | 25.21 | 0.0325 | 0.1863 |
| Fan-out | 28.56 | 0.0120 | 0.0839 |
| Public/protected APIs | 15.30 | 0.3578 | 0.3578 |
| Caller-used APIs | 25.40 | 0.0308 | 0.1863 |
| Detected outcome | Count | Rate | Wilson 95% CI | Single-prompt | Multi-agent | |
|---|---|---|---|---|---|---|
| High contract/dependency risk | 1,365 | 1,455 | 93.8% | 92.5–94.9% | 661/706 (93.6%) | 704/749 (94.0%) |
| Medium contract/dependency risk | 90 | 1,455 | 6.2% | 5.1–7.5% | 45/706 (6.4%) | 45/749 (6.0%) |
| At least one broken caller | 106 | 1,455 | 7.3% | 6.1–8.7% | 57/706 (8.1%) | 49/749 (6.5%) |
| Behavioural-equivalence indicator false | 290 | 1,455 | 19.9% | 18.0–22.1% | 138/706 (19.5%) | 152/749 (20.3%) |
| Category | Detected mechanism | Count | Rate | Single-prompt | Multi-agent |
|---|---|---|---|---|---|
| Dependency | Any dependency change | 716 | 82.9% | 94/115 (81.7%) | 622/749 (83.0%) |
| Large dependency delta | 662 | 76.6% | 85/115 (73.9%) | 577/749 (77.0%) | |
| Internal import/dependency change | 54 | 6.3% | 9/115 (7.8%) | 45/749 (6.0%) | |
| Caller/API | Caller-used API changed or removed | 597 | 69.1% | 83/115 (72.2%) | 514/749 (68.6%) |
| Contract/API | Any contract/API change | 333 | 38.5% | 40/115 (34.8%) | 293/749 (39.1%) |
| Public/protected signature changed | 231 | 26.7% | 27/115 (23.5%) | 204/749 (27.2%) |
| Threshold | High | Rate | |
|---|---|---|---|
| 5 | 810 | 864 | 93.8% |
| 7 | 790 | 864 | 91.4% |
| 10 | 765 | 864 | 88.5% |
| 15 | 745 | 864 | 86.2% |
| 20 | 714 | 864 | 82.6% |
| Outcome | Paired | Single-prompt | Multi-agent | MA–SP | Discordant pairs | Test | |
|---|---|---|---|---|---|---|---|
| High contract/dependency risk | 705 | 660 (93.6%) | 660 (93.6%) | 0.0 pp | 2 / 2 | 1.000 | Exact McNemar |
| Broken caller detected | 705 | 57 (8.1%) | 49 (7.0%) | pp | 23 / 15 | 0.256 | Exact McNemar |
| Behavioural-equivalence indicator false | 705 | 138 (19.6%) | 152 (21.6%) | pp | 55 / 69 | 0.243 | Exact McNemar |
| Broken-caller count | 705 | 0 [0, 0] | 0 [0, 0] | 0 | 47 non-zero differences | 1.000 | Wilcoxon signed-rank |
| Detected mechanism | Single-prompt | Multi-agent | MA–SP | Raw | Holm | Adjusted result |
|---|---|---|---|---|---|---|
| Caller-used API affected | 83 (72.2%) | 83 (72.2%) | 0.0 pp | – | 1.000 | Not significant |
| Public/protected signature changed | 27 (23.5%) | 25 (21.7%) | pp | 0.500 | 1.000 | Not significant |
| Public API removed | 6 (5.2%) | 2 (1.7%) | pp | 0.289 | 1.000 | Not significant |
| Constructor signature changed | 19 (16.5%) | 18 (15.7%) | pp | 1.000 | 1.000 | Not significant |
| Package declaration changed | 0 (0.0%) | 0 (0.0%) | 0.0 pp | – | 1.000 | Not significant |
| Large dependency delta | 85 (73.9%) | 77 (67.0%) | pp | 0.0078 | 0.0859 | Not significant |
| LLM configuration | Pair | High risk | Broken caller | Behavioural-equivalence indicator false | |||
|---|---|---|---|---|---|---|---|
| SP | MA | SP | MA | SP | MA | ||
| Claude Opus 4.8 | 150 | 94.0% | 94.0% | 8.7% | 8.0% | 26.0% | 30.0% |
| DeepSeek v4 Pro | 148 | 93.9% | 93.9% | 6.8% | 8.1% | 18.9% | 21.6% |
| Gemini 3.1 Pro Preview | 149 | 94.0% | 94.6% | 12.1% | 9.4% | 25.5% | 23.5% |
| GPT-5.5 | 149 | 94.0% | 94.6% | 8.1% | 7.4% | 15.4% | 26.8% |
| Qwen 3.6 Plus | 109 | 91.7% | 89.9% | 3.7% | 0.0% | 9.2% | 0.0% |
| Condition | Outcome | Complete blocks | Statistic | Post-hoc status | |
|---|---|---|---|---|---|
| Single-prompt | High contract/dependency risk | 108 | Not defined | – | No within-block variation |
| Broken-caller occurrence | 108 | Exact McNemar with Holm | |||
| Behavioural-equivalence indicator false | 108 | Exact McNemar with Holm | |||
| Broken-caller count | 108 | Pairwise tests not executed | |||
| Multi-agent | High contract/dependency risk | 149 | 0.073 | Not applied | |
| Broken-caller occurrence | 149 | Exact McNemar with Holm |
| Reporting category | Count | Rate | Wilson 95% CI | Single-prompt | Multi-agent |
|---|---|---|---|---|---|
| Low-risk | 8 | 0.5% | 0.3–1.1% | 0/706 (0.0%) | 8/749 (1.1%) |
| Review-needed | 55 | 3.8% | 2.9–4.9% | 43/706 (6.1%) | 12/749 (1.6%) |
| High Contract/Dependency Risk | 1,365 | 93.8% | 92.5–94.9% | 661/706 (93.6%) | 704/749 (94.0%) |
| Inconclusive | 27 | 1.9% | 1.3–2.7% | 2/706 (0.3%) | 25/749 (3.3%) |
| Evidence item | Count | Rate |
| Structural and behavioural evidence ( eligible candidates) | ||
| High contract risk | 1,365 | 93.8% |
| Medium contract risk | 90 | 6.2% |
| Broken caller detected | 106 | 7.3% |
| Behavioural-equivalence indicator: true | 1,165 | 80.1% |
| Behavioural-equivalence indicator: false | 290 | 19.9% |
| LLM configuration | Eligible | Low-risk | Review-needed | High risk | Inconclusive |
|---|---|---|---|---|---|
| Claude Opus 4.8 | 300 | 1 (0.3%) | 9 (3.0%) | 282 (94.0%) | 8 (2.7%) |
| DeepSeek v4 Pro | 298 | 2 (0.7%) | 11 (3.7%) | 280 (94.0%) | 5 (1.7%) |
| Gemini 3.1 Pro Preview | 299 | 2 (0.7%) | 11 (3.7%) | 282 (94.3%) | 4 (1.3%) |
| GPT-5.5 | 299 | 1 (0.3%) | 11 (3.7%) | 282 (94.3%) | 5 (1.7%) |
| Qwen 3.6 Plus | 259 | 2 (0.8%) | 13 (5.0%) | 239 (92.3%) | 5 (1.9%) |
| Source-file characteristic | High-risk share | Broken-caller share | False behavioural-equivalence share |
|---|---|---|---|
| LOC | , | , | , |
| Baseline smell count | , | , | , |
| Fan-in | , | , | , |
| Fan-out | , | , | , |
| Public/protected API count | , | , | , |
| Caller-used API count | , | , | , |
| Risk-rule mechanism | High-risk candidates | Share of 810 High-risk candidates | Sole High-producing mechanism |
|---|---|---|---|
| Caller-used API affected | 597 | 73.7% | 114 |
| Public/protected signature changed | 231 | 28.5% | 0 |
| Public API removed | 82 | 10.1% | 0 |
| Constructor signature changed | 138 | 17.0% | 6 |
| Package changed | 0 | 0.0% | 0 |
| Large dependency delta ( ) | 662 | 81.7% | 150 |