SemaDiff: Identifying Semantic-Changing Commits with Generated Code and Tests

📅 2026-07-14
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Accurately distinguishing between semantics-preserving and semantics-altering code commits remains an open challenge in software evolution, as existing approaches struggle to identify refactorings entangled with behavioral changes. This work proposes a behavior-comparison-based detection method that leverages large language models to automatically generate both invocation code and test cases for pre- and post-commit versions. By executing these artifacts and comparing cross-version behavioral consistency, the approach determines whether semantic changes have occurred. Notably, it is the first to employ large language models for the joint generation of invocations and tests, effectively disentangling refactoring from functional modifications. Evaluated on 183 manually annotated Java commits, the method achieves an overall accuracy of 76% and perfect precision (100%) in detecting semantic-altering changes.
📝 Abstract
Distinguishing semantic-preserving commits from changing ones remains an open challenge in software repository mining. While existing approaches detect refactoring commits accurately, they cannot ensure that a commit is purely semantic-preserving, without any interleaving behaviour-changing modification. This limitation can impact several tasks, such as debugging, fault localisation, bug dataset construction, rollback analysis, and bug fixes backporting. To fill this gap, we propose SemaDiff, a novel approach for identifying semantic-preserving commits through behaviour-based analysis; comparison of similar test execution on pre- and post-commit versions. As code impacted by the refactoring is often hard to test and different accross both versions, we propose generating additional calling methods to that code, which serve as testing target. Given a commit, SemaDiff analyses the diff to identify modified code and extracts unchanged dependent code that calls it. It then generates an additional dependent class using a large language model to exercise the changed code in both versions, and automatically generates tests for the dependent code. This way, we obtain the same tests for the different code versions, enabling the behavioural-difference detection. The commit is classified as semantic-preserving only if all generated tests produce identical outcomes across the two versions. To evaluate SemaDiff, we construct and annotate manually a dataset of 183 commits, gathered from well-known open-source Java projects. The obtained results show that SemaDiff distinguishes accurately semantic-preserving from -- changing commits in about 76% of the cases, with a 100% precision in semantic-changing commit detection.
Problem

Research questions and friction points this paper is trying to address.

semantic-preserving commits
semantic-changing commits
software repository mining
behavioral difference
code commits
Innovation

Methods, ideas, or system contributions that make the work stand out.

semantic-preserving commits
behavior-based analysis
test generation
large language models
code refactoring
🔎 Similar Papers
No similar papers found.