arXiv · 2606.04993
Code Lifespan Survival Analysis (CLSA): Predicting the Survival of Source Code Lines Using AST-Aware Mining
Abstract
Context: Predicting which source lines will be deleted - and when - matters for maintenance, technical debt, and review prioritization. Existing MSR approaches work at file or method granularity, masking individual-statement risk. Objective: We introduce Code Lifespan Survival Analysis (CLSA), the first framework to model individual-line deletion risk from covariates - where prior line-granularity work estimated lifespans but found no significant predictors. CLSA treats each line as a right-censored subject and estimates deletion risk from structural, contextual, and temporal covariates; its strongest predictors are computable statically from one file (AST structure plus line token count), without version history or bug data. Method: We mine 32.5 million line birth events from 120 open-source TypeScript repositories. A 5-stage matching pipeline separates true deletions from refactoring noise, preventing 8.3 million false deaths. We fit a Cox Proportional Hazards model with 15 covariates and check robustness via Weibull/Log-Logistic AFT, gamma frailty, and time-stratified landmark models. Results: Over half of all lines are never deleted (Kaplan-Meier median not reached); among deleted lines the median lifespan is 95.7 days. Covariate effects are strongly time-varying, forming three regimes. Line token count is a steady protective factor (HR=0.80) that strengthens gently with age (HR 0.87 to 0.77 across regimes). Lines in conditional branches reverse: protective at birth (HR=0.98, 0-90 days), a risk factor after 90 days (HR=1.21). Repository identity is the largest factor: a gamma frailty model (variance theta=1.208) raises concordance from 0.593 to 0.667, outweighing every structural covariate. Conclusion: Line-level survival modeling is tractable, yielding interpretable, mostly static risk signals and a calibration recipe for time-conditional risk scoring in IDEs and code review.
Explore related subjects
Keep this discovery
Pavel Gurov. 2026-06-03. Code Lifespan Survival Analysis (CLSA): Predicting the Survival of Source Code Lines Using AST-Aware Mining. https://doi.org/10.5281/zenodo.20714794
Cite the original work for its findings. Save a collection to share your selection of sources.