Abstract
In this paper, we propose an assertion-based approach to capture software evolution, through the notion of commit-relevant specification. A commit-relevant specification summarises the program properties that have changed as a consequence of a commit (understood as a specific software modification), via two sets of assertions, the delta-added assertions, properties that did not hold in the pre-commit version but hold on the post-commit, and the delta-removed assertions, those that were valid in the pre-commit, but no longer hold after the code change. We also present DeltaSpec, an approach that combines test generation and dynamic specification inference to automatically compute commit-relevant specifications from given commits. We evaluate DeltaSpec on two datasets that include a total of 57 commits (63 classes and 797 methods). We show that commit-relevant assertions can precisely describe the semantic deltas of code changes, providing a useful mechanism for validating the behavioural evolution of software. We also show that DeltaSpec can infer 88% of the manually written commit-relevant assertions expressible in the language supported by the tool. Moreover, our experiments demonstrate that DeltaSpec's inferred assertions are effective to detect regression faults. More precisely, we show that commit-relevant assertions can detect, on average, 78.3% of the artificially seeded faults that interact with the code changes. We also show that assertions in the delta are 58.3% more effective in detecting commit-relevant mutants than assertions outside the delta, and that it takes on average 169% fewer assertions when these are commit-relevant, compared to using general valid assertions, to achieve a same commit-relevant mutation score.
Introduction
While version control systems like Git provide clear syntactic diffs—highlighting character-level changes—they offer little insight into the semantic impact of a commit. Understanding how a code change alters program behavior is critical for maintaining software quality. Traditional regression testing, while useful, is often scenario-specific and fails to provide a comprehensive description of behavioral shifts. This research addresses the challenge of automatically summarizing how program properties, expressed as formal assertions, evolve across software versions.
Methodology: The DeltaSpec Pipeline
The core contribution of this work is the concept of a commit-relevant specification. This specification is composed of two distinct sets: delta-added assertions (properties newly valid in the post-commit version) and delta-removed assertions (properties that no longer hold after the change).
To automate the discovery of these properties, the authors developed DeltaSpec. As illustrated in Figure 1, the tool follows a three-stage process:
- Test Generation: Utilizing Randoop, the system generates high-coverage test suites for both pre- and post-commit code versions.
- Specification Inference: Using SpecFuzzer, the tool proposes candidate assertions via grammar-based fuzzing and filters them using mutation analysis.
- Delta Spec Computation: A semantic "diff" is performed by comparing the sets of invariants from both versions to isolate the behavioral changes.
Experimental Evaluation
The effectiveness of DeltaSpec was evaluated using real-world Java projects from the Apache Commons ecosystem, including commons-collections, commons-lang, and commons-math. The evaluation utilized two primary datasets:
- Validation Set: Consisting of 18 commits, this set was used to compare inferred specifications against manually curated ground-truth assertions.
- Mutation Testing Set: Comprising 39 commits, this dataset was used to assess the tool's ability to detect "commit-relevant mutants"—faults specifically designed to interact with the modified code.
Key Results and Insights
The experimental results demonstrate that DeltaSpec provides a powerful mechanism for validating software evolution:
- Inference Precision: DeltaSpec successfully reproduced 88% of manually written commit-relevant assertions expressible in its grammar.
- Fault Detection: The inferred assertions detected an average of 78.3% of artificially seeded regression faults.
- Efficiency: Assertions within the semantic delta were found to be 58.3% more effective at detecting relevant mutants than general program invariants. Furthermore, achieving the same level of fault detection required 169% fewer assertions when focusing on the commit-relevant delta rather than a general pool of valid assertions.
These findings suggest that focusing on the "semantic diff" drastically reduces the noise developers face, allowing them to target the specific logic modified in a commit.
Conclusion and Future Work
DeltaSpec demonstrates that automated specification inference can effectively capture the behavioral evolution of software. However, limitations remain, particularly regarding the expressiveness of the underlying grammar and the inherent stochasticity of random test generation. Future work will focus on expanding the property grammar and exploring the direct mapping between delta assertions and the specific mutants they identify to further streamline the debugging process.
Summary updated