arXiv:2609.06272cs.SESep 2026

Manuscript Offprint

arXiv:2609.06272

KG-Commit: A Dynamic Knowledge Graph for Online Just-in-Time Software Defect Prediction

Mohsen Hesamolhokama, Mohammad Sina Beyrami Aghbash, Behnam Rohani, Mohammadamin Fazli, Jafar Habibi

Abstract

Just-in-time software defect prediction (JIT-SDP) aims to identify risky commits as they arrive and provide developers with timely feedback. This need for low latency has led most approaches to rely on commit-level information and overlook the broader project context in which a change occurs. Incorporating this context is challenging because it requires both efficient retrieval for incoming commits and continual maintenance as the repository evolves. We introduce KG-Commit, a dynamic knowledge graph that incrementally maintains repository history, within-file code structure, and commit semantics as the project evolves. It also uses an AST-delta mechanism to track structural changes between file edits and relies on lightweight graph inference running entirely on CPU. Our evaluation on 11 Apache software projects against six baselines shows that KG-Commit achieves the highest aggregate Macro-F1 (0.704), G-Mean (0.706), and AUC (0.809) using our selected inference pipeline. Under a realistic online protocol, it outperforms LR, HGB, RF, and DeepJIT on all 11 projects, LApredict on 10, and JITLine on 9 projects in Macro-F1, with the aggregate paired difference significant in every case. KG-Commit processes each commit in approximately 1.33 s, with a cost that remains stable as the graph grows and is compatible with commit rates observed in real-world projects. These findings show that rich project context can be efficiently maintained and exploited for online JIT-SDP.

Keywords: Online Defect Prediction, Knowledge Graph, Just-in-Time, Real-time Project Evolution

1. Introduction

Software underpins nearly every product and service that people rely on, and even a single defect can disrupt a critical system. Ensuring software quality is therefore a persistent concern for development teams, yet the time and resources available for testing and code review are limited. Software defect prediction (SDP) helps teams direct that effort to the right place by estimating which parts of a system are most likely to be faulty (Menzies et al., 2007; Lessmann et al., 2008; Hall et al., 2012). Traditional SDP approaches operate at the level of files, modules, or releases (Wang et al., 2016; Li et al., 2017; Zhou et al., 2022). At this granularity, predictions often arrive only after many changes have accumulated,

making it difficult to identify the particular change that introduced a defect and to recover the context in which it was made. Just-in-time defect prediction (JIT-SDP) was introduced to close this gap (Mockus and Weiss, 2000; Kamei et al., 2013). It evaluates each commit as soon as it is submitted, so a risky change can be reviewed while its author still remembers the context. Because of this immediate feedback, JIT-SDP has become a natural fit for continuous integration and an active research topic (Zhao et al., 2023).

For more than a decade, JIT-SDP has relied primarily on a compact set of hand-crafted metrics that summarize each commit. These metrics capture properties such as change size, code churn (Nagappan and Ball, 2005), the extent to which a change spans files and subsystems, and the experience of its author (Kamei et al., 2013; McIntosh and Kamei, 2018). Standard classifiers then use these summaries to estimate defect risk. As deep learning became more prominent, research gradually shifted from hand-crafted commit features to deep representation learning. Yang et al. (2015b) used

Email addresses: hokama@ce.sharif.edu (Mohsen Hesamolhokama), sina.beirami@sharif.edu (Mohammad Sina Beyrami Aghbash), behnam.rohani058@sharif.edu (Behnam Rohani), fazli@sharif.edu (Mohammadamin Fazli), jhabibi@sharif.edu (Jafar Habibi)

Preprint submitted to Elsevier

September 9, 2026 a deep belief network to transform conventional metrics into richer features, while DeepJIT and CC2Vec learned representations from commit messages and code diffs (Hoang et al., 2019, 2020). Later work extended this direction with line-level defect localization (Pornprasit and Tantithamthavorn, 2021, 2023), pre-trained code encoders such as CodeBERT (Ni et al., 2022; Jiang et al., 2025), and parameter-efficient adaptation of these models (Abu Talib et al., 2024).

What these models largely overlook is the broader project context in which the change occurs (Bryan and Moriano, 2023; Zhao et al., 2023). Knowledge graphs are well suited to representing such structure because they organize information as entities connected by typed relations (Hogan et al., 2021; Ji et al., 2022) and support reasoning and learning over these relations (Nickel et al., 2016). They have been applied successfully in areas such as recommendation, life sciences, and cybersecurity (Wang et al., 2019; MacLean, 2021; Zhao et al., 2024). Their use in software engineering, however, remains relatively limited and has focused mainly on organizing software artifacts such as APIs and libraries (Liu et al., 2023b). Knowledge graphs remain even less explored in software defect prediction and, to the best of our knowledge, have not been applied to JIT-SDP. This gap is particularly notable because a commit is inherently relational. It modifies specific files and functions, interacts with other parts of the system, is associated with an author, and carries an intent expressed through its message. Dynamic knowledge graphs provide a natural way to capture these evolving relationships (Zhang et al., 2024; Cai et al., 2024). By incorporating new events as they occur, they maintain an up-to-date representation of a changing domain (Trivedi et al., 2017; Goel et al., 2020). Since software evolves incrementally through a stream of commits, this representation is especially well aligned with the online nature of JIT-SDP.

In just-in-time prediction, however, accuracy is of little value if it arrives too late (Kamei et al., 2013), so richer context must be incorporated at a computational cost that remains practical for an incoming stream of commits. This creates a tension between contextual richness and per-commit processing cost. Project-level context, such as how a changed function is called elsewhere or how a file depends on others, is known to improve defect prediction (Zimmermann et al., 2009; Nam et al., 2013), but reconstructing this information from scratch for every incoming commit can be expensive. To remain efficient, many approaches mainly rely on information contained within the commit itself, such as its message and code diff (Hoang et al., 2019, 2020; Pornprasit and Tantithamthavorn, 2021). Others pursue efficiency more aggressively through a single inexpensive feature (Zeng et al., 2021) or lightweight retrieval over historical commits (Sahar et al., 2024). The open question is whether rich, project-specific context can be maintained at a cost compatible with the pace at which commits actually arrive.

Dynamic or real-time knowledge graphs offer a natural way to address this problem. Rather than reconstructing the project state from scratch, the graph is updated incrementally as each commit arrives, with each update affecting only the relevant portion of the graph (Zhao and Chen, 2023). The accumulated project context can then be queried through a graph query language such as Cypher (Francis et al., 2018; Angles et al., 2017). This replaces repeated reconstruction of project history with incremental per-commit work. Its practical suitability therefore depends on whether this processing cost remains stable as the project grows and is sufficiently small relative to the rate at which commits arrive.

Building on this idea, we introduce KG-Commit, a dynamic knowledge graph that evolves with the repository and provides project-specific context at inference time. KG-Commit is maintained incrementally in Neo4j and organizes information across three layers: (1) Core layer for repository entities and their relations, (2) AST layer for within-file program structure, and (3) Commit Semantic-Text Graph (CSTG) layer for the semantics of commit messages and code changes. We combine graph-based and feature-based inference over these representations to estimate defect risk and evaluate KG-Commit in terms of predictive performance, query and update cost, and suitability for online JIT-SDP.

References (100)

Couldn't load all references. Reload the page to try again.