Abstract
Automated Program Repair (APR) and Commit Message Generation (CMG) are traditionally treated as independent tasks in software engineering. However, separate processing often leads to error propagation and a failure to capture the global relationship between buggy and fixed states. This paper introduces a joint learning framework that simultaneously repairs code and generates explanatory commit messages. By utilizing a Changes-aware Dynamic Attention Mechanism, the model achieves superior performance in message generation and demonstrates significant "multilingual synergy" across five programming languages.
Introduction
In modern software development, fixing a bug is only the first step; developers must also document the change with a clear commit message. While AI has advanced in both Automated Program Repair (APR) and Commit Message Generation (CMG), these tasks are rarely integrated. Existing "cascaded" systems—where one model fixes the code and another describes it—suffer from a significant gap: error propagation. If the repair model makes a mistake, the generation model produces a misleading description. Furthermore, these systems often fail to capture the semantic intent behind a change, leading to generic or unhelpful documentation.
Methodology: The Joint Learning Framework
The researchers propose a unified Transformer-based architecture designed to decode fixed code and commit messages in a single pass. The core innovation of this approach is the Changes-aware Dynamic Attention Mechanism.
Changes-aware Dynamic Attention
Unlike standard attention mechanisms that look at code as a static sequence, this mechanism explicitly calculates the relationship between the buggy and fixed states:
- The Delta ($\delta$): Represents the semantic difference (the "what changed") by subtracting the buggy code representation from the fixed code representation.
- The Sum ($\zeta$): Provides a semantic summarization of both versions to maintain context (e.g., function names and surrounding logic).
- Control Gates: These act as a traffic controller, dynamically balancing the model's focus between the specific delta and the broader context during message generation.
Enhanced Cascaded Baselines
To provide a rigorous comparison, the authors also developed enhanced cascaded models using three training strategies:
- Teacher-Student Method: Knowledge distillation from a "teacher" model (with access to ground-truth messages) to the "student" repair model.
- Multi-task Learning: Training the model to both locate the bug (classification) and fix it (generation).
- Back-translation: Generating synthetic buggy code from fixed code to augment the training data.
Data and Multilingual Synergy
The study utilizes a new Multilingual Triple Dataset comprising over 100,000 "triples" (buggy code, fixed code, and commit message) scraped from GitHub Archive (2018–2020). The dataset spans five major languages: Python, Java, JavaScript, C#, and C++.
A key finding was the presence of "multilingual synergy." The model performed significantly better when trained on all five languages simultaneously rather than on a single language. This was particularly beneficial for low-resource languages like C#, which "borrowed" knowledge from high-resource languages like Python to improve performance.
Results and Discussion
The experimental results highlight a trade-off between specialized repair and integrated generation:
- Code Repair: The Multi-task cascaded model achieved the highest "Exact Match" score (8.33% on Java), suggesting that explicit bug localization is highly effective for the repair task itself.
- Message Generation: The Joint Model was the clear leader, achieving a BLEU-4 score of 11.48—a 10.8% improvement over the best cascaded baseline. It also showed greater resilience when generating long commit messages (over 20 tokens), where cascaded models typically fail.
The qualitative analysis in Figure 6 demonstrates how the Joint Model accurately identifies the logic change (replacing * with +) and generates a corresponding message, whereas the Cascaded Model misinterprets the change as an access modifier update.
Limitations and Future Directions
Despite its successes, the model currently treats code as a flat sequence of text tokens, lacking an understanding of the Abstract Syntax Tree (AST) or hierarchical structures. Additionally, standard metrics like BLEU are not always representative of functional correctness in code. Future work will focus on incorporating tree-based structures (like Graph Neural Networks) and developing "code-aware" evaluation metrics to better capture the semantic and functional success of automated repairs.
Summary updated