Mining Two Decades of Repository History to Predict Software Complexity Accumulation: A Leakage-Aware Landmark Survival Analysis
This study leverages a leakage-aware landmark survival analysis on two decades of repository history to demonstrate that early development dynamics, rather than initial code structure, are the primary predictors of future software complexity accumulation, achieving reliable within-corpus forecasts but limited cross-project generalizability.
Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the author. For technical accuracy, refer to the original paper. Read full disclaimer
Software is built to last, but like any living thing, it changes over time. A piece of code that starts out simple and clean can, over months or years, become tangled and difficult to manage. This process is known as complexity accumulation. For decades, engineers have tried to spot these trouble spots early by measuring how complicated a file is at a single moment, much like taking a photograph of a building to judge its structural integrity. They use tools to count things like the number of decision points or the depth of nested logic. However, a photograph only shows the present; it cannot tell you if a building is about to develop a crack or if a quiet room is about to become a chaotic hub of activity. The real question is not how complex a file is today, but whether it is on a path to become a problem tomorrow.
To answer this, researchers turned to a method borrowed from medicine called survival analysis. In medical studies, this technique is used to predict how long a patient might survive before a specific event occurs, such as a relapse. It is uniquely suited for situations where some patients are still alive when the study ends, meaning their final outcome is unknown. In the world of software, this means looking at the entire history of a file, from its first line of code to its latest update, to see if and when it crosses a threshold into dangerous complexity. The challenge is that history is full of traps. If a researcher looks at the entire history of a file to predict its future, they might accidentally use information from the future to explain the past, a mistake that makes the prediction look perfect but is actually useless. The goal is to find signals that appear very early in a file's life that can reliably warn of future trouble, without peeking at the answer key.
A researcher named Moatasem M. Draz set out to solve this puzzle by mining twenty years of history from fourteen popular open-source software projects written in Python. Instead of looking at static snapshots, the study treated every file as a story with a beginning, a middle, and an end. The team tracked 1,291 files, watching them grow from their first few commits. They defined a "complexity event" not by an absolute number, but by a file's own growth. A file was considered to have hit a trouble spot if its internal complexity grew by a specific amount above where it started. This approach ensured that the model was predicting growth, not just identifying files that happened to start out complicated. To prevent the common error of using future information to predict the past, the researchers used a strict rule: they only looked at data from the first three commits of a file's life. Once that small window closed, they started a clock to see how long it took for that file to eventually become significantly more complex.
The results revealed a surprising truth about how software evolves. The study found that the initial structure of the code—the number of lines, the complexity of the logic, or how many other files it connected to—was a very poor predictor of future trouble. In fact, looking at the code's starting state was barely better than guessing at random. What mattered most were the early dynamics of how the file was being developed. Files that were edited quickly, touched by many different people, or saw rapid changes in their first few days were the ones most likely to spiral into complexity later on. The best model, which focused entirely on these early process signals, could predict which files would become complex with a level of accuracy that was significantly better than any previous method. It achieved a score of 0.663, a clear improvement over the best existing baselines, which hovered near the level of chance.
However, the study also discovered the limits of this approach. While the model worked well when tested on files from the same projects it learned from, it struggled when asked to predict the future of entirely new, unseen projects. When the researchers tested the model on a project it had never seen before, its accuracy dropped, suggesting that every organization or software ecosystem has its own unique rhythm that cannot be easily generalized. The study also tested whether adding more detailed structural data or using more advanced computer learning techniques would improve the results, but found that these additions did not help. The simple signal of early development activity was the strongest predictor, and adding more noise did not make the picture clearer.
This work offers a new way to think about software maintenance. Instead of waiting for a file to become a tangled mess and then trying to fix it, teams can now watch the early behavior of new files. If a file is being edited rapidly by a large group of people in its first few days, it is a candidate for a closer look, even if it looks simple right now. The study suggests that the path to a complex system is paved by the way the code is handled in its infancy, not by the code itself. By focusing on these early warning signs, developers can intervene while the cost of change is still low, preventing small files from becoming the heavy burdens that slow down entire projects. The findings confirm that in software, as in many other fields, the story of the future is often written in the first few chapters of the past.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.