AI Refactoring Degrades Code Integrity

AI Refactoring Degrades Code Integrity

dev.to and Machine Learning documented early work by Belady and Lehman on the IBM OS/360 Operating System over 12 years, which established foundational concepts of software system entropy and increasing complexity. A preprint published on arXiv.org, dev.to, and MindStudio defines "passive drift" as the gradual erosion of structural constraints through untracked state transitions that preserve core logic. According to the same preprint, this phenomenon arises as autonomous agent actions and subsequent manual hand-patches accumulate over time, diverging from the original architectural intent. MindStudio observed that these manual edits are often only present in the diff and not recorded as enforceable rules, creating contradictions that accumulate as technical debt. A preprint published on arXiv.org, dev.to, and MindStudio explains that the generated code remains functionally correct and passes unit tests, creating an "illusion of progress" while masking underlying architectural degradation. MindStudio found that this compounding of silent, unverified edits systematically degrades structural constraints more reliably than explicit architectural refactoring. A preprint published on arXiv.org warns that the erosion of semantic stability occurs when agents refactor legacy logic without understanding its historical rationale, introducing fragility that passes unit tests but fails in production under specific edge cases. A preprint published on arXiv.org describes the "reviewer's paradox," where the high volume of AI-generated output overwhelms human verification capacity, shifting auditors from strategic supervision to passive approval. The preprint further indicates that this leads to higher rates of code churn and duplicated logic, accelerating system entropy and degrading structural integrity. A preprint published on arXiv.org found a strong Pearson correlation coefficient of 0.89 between the application of design patterns and software maintainability across over 300 system revisions. The preprint also observed that untracked state transitions and dynamic requirement changes, simulating passive drift, cause existing code generation methods to experience significantly increased modification effort compared to structured approaches.

Active Overwrite and Passive Drift Compound

A preprint published on arXiv.org, dev.to, MindStudio, Medium, and JFrog explains that active overwrite and passive drift do not operate as independent failure modes; instead, immediate pattern substitution actively accelerates gradual constraint erosion by establishing new, unverified baselines that subsequent AI agents and human engineers inherit and compound. A preprint published on arXiv.org explained that active overwrite acts as the initial injection mechanism, introducing redundant or misaligned logic that fragments the codebase's intended structure and directly accelerates "agentic entropy." Medium, Ranjan Kumar, and JFrog pointed out that without cryptographic provenance, these changes lack a verifiable audit trail, establishing new, unverified baselines. A preprint published on arXiv.org and MindStudio reported that passive drift then functions as the cumulative erosion of structural constraints, accumulating these inherited deviations. A preprint published on arXiv.org found this compounding effect amplified in multi-agent environments, where agents may copy each other's reasoning to reduce compute, reinforcing errors with mutual confidence and solidifying new, incorrect shared baselines. A preprint published on arXiv.org, dev.to, MindStudio, Medium, and JFrog argues that while the binary distinction between active overwrite and passive drift accurately captures their distinct mechanisms, it obscures their deeply intertwined nature as a continuous spectrum of compounding semantic deviations.

Median Code Lifespan and Cyclomatic Complexity

PeerJ Computer Science reported that the median lifespan of code lines and tokens is approximately 2.4 years, with young lines frequently modified. Empirical documentation of the transition from active modification to gradual degradation spans various software projects and engineering teams. These include the ESS Telephone Switching System, as reported by a Virginia Tech publication; numerous open-source repositories like github.com/droolsjbpm/drools and the Unix operating system, which PeerJ Computer Science found; and specific GitHub Java projects, documented in an Oregon State University technical report. To distinguish these phases, researchers have employed several quantitative metrics. Code change and lifetime metrics, for example, include lines of code modified per unit of time and the number of files changed, as a Virginia Tech publication and Software Engineering Stack Exchange observed. An Oregon State University technical report found that software entropy metrics include week-wise total entropy based on token changes. Toptal explained that these metrics also encompass proposed formulas to quantify disorder, where values above 0.5 indicate high entropy drift. Code quality and maintenance indicators are also crucial. Future Processing and a Simula Research Laboratory publication cited Cyclomatic complexity. AugmentCode, a University of Alabama in Huntsville thesis, and Medium reported on the technical debt ratio. Furthermore, AugmentCode and Paul M. Duvall identified test coverage, bug rate, and code duplication as key indicators. The Valuable Dev stated that developer perception of difficulty in scaling applications also serves as an indicator of increasing software entropy.

AI-Driven Refactoring Lacks Provenance

A preprint published on arXiv.org, MindStudio, and another preprint published on arXiv.org assert that the immediate substitution of architectural priors by AI agents (active overwrite) and the subsequent gradual erosion of structural constraints through untracked changes (passive drift) constitute a continuous process of degradation, rather than isolated issues. This continuous process poses a significant risk to software architectural integrity, particularly without cryptographic provenance. The preprints warn that this leads to increased technical debt, higher modification effort, and reduced maintainability, ultimately slowing future development and increasing regression frequency. A preprint published on arXiv.org, Medium, and JFrog emphasized that the absence of cryptographic provenance critically enables this decay by removing the verifiable audit trail necessary to detect and prevent architectural misalignments and their cumulative effects. Without verifiable audit trails, the architectural intent of software projects risks being lost entirely, as AI agents continue to establish new, unverified baselines.


Download the full research report (PDF)