StructFix: a structure-aware reasoning framework for automated program repair with code property graphs
Masked language models are increasingly used as the backbone of patch generation for automated program repair (APR). However, most Pre-trained Language Model (PLM)-based repair systems treat code as token sequences, underutilizing structural cues such as control and data dependencies. Consequently, they can produce test-passing patches that are not fully consistent with the intended behavior. We propose StructFix, a structure-aware APR framework that grounds masked patch generation in Code Property Graphs (CPGs). StructFix constructs method-level CPGs from the unmasked program context, encodes structural dependencies with a graph encoder, and integrates graph evidence into token representations through span-based token–node soft alignment and token-wise gated graph–text fusion. This design enables the model to use structural signals in a context-dependent manner while predicting masked tokens. StructFix correctly repairs 86 Defects4J v1.2 bugs, including 12 not repaired by any compared baseline, and repairs 30 Java and 28 Python defects on QuixBugs, which demonstrates cross-language robustness. Our experimental results show that explicitly coupling structural dependencies with masked generation improves repair effectiveness and enables transfer across datasets.