A data transaction software defect repair method, system, device and storage medium fusing context and program-specific components

CN122985503APending Publication Date: 2026-10-27GUANGXI POWER GRID CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611018791.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-09
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0005]因此,本发明解决的技术问题是:现有缺陷修复方法仅依赖单一粒度上下文,难以利用距离待修复点较远的代码行信息,导致复杂缺陷修复效果差的问题

Benefits of technology

[0016]本发明的有益效果:本发明通过为神经机器翻译模型提供结合缺陷代码行、邻近代码行和缺陷函数的多粒度缺陷上下文输入,缓解了现有方法仅采用单一粒度上下文难以修复多类型缺陷的问题,且捕获程序重要特定成分,即代码结构特征,并应用修复模板,提升了现有方法对需要远距离程序特定成分的缺陷修复效果,提高正确修复的缺陷数量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985503A_ABST
    Figure CN122985503A_ABST
Patent Text Reader

Abstract

The application discloses a data transaction software defect repairing method, system and device fusing context and program specific components and a storage medium, relates to the field of computer software and data security, and comprises the following steps: acquiring defect codes to be repaired, extracting three kinds of context of defect code lines, adjacent code lines and defect functions, inputting a fine-tuned model to generate first repair candidate codes; meanwhile, performing syntax analysis on the defect codes, extracting code structure features and matching preset repair modes to generate second repair candidate codes; and finally, removing redundancies and performing syntax checking to output a final candidate repair code list; the application can alleviate the problem that a single granularity context is difficult to repair multiple types of defects, improve the repair effect of long-distance program specific components, and increase the number of correctly repaired defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer software and data security, and in particular to a method, system, device, and storage medium for repairing defects in data transaction software that integrates context and program-specific components. Background Technology

[0002] Data trading software defect repair involves generating repair code corresponding to defects in the software source code during software development and version iteration. By utilizing technologies such as deep learning, end-to-end automatic repair is achieved, reducing the manual cost of defect repair in the software development process.

[0003] Pattern-based and neural machine translation-based defect repair methods are currently hot research topics in the field of automated software defect repair. Pattern-based methods can generate high-quality patches using domain knowledge, but the manual cost of defining templates is high and their applicability is limited. Neural machine translation-based methods can capture the complex mapping relationship from defective code to repair code and are applicable to various defect types and programming languages. However, existing neural machine translation-based methods have the following problems: they only use a single defect context granularity, easily copying a large number of similar components in neighboring code lines or defective functions to generate simple replacement repairs, making it difficult to use relatively context-independent components to repair complex defects; when a large number of code lines are input, neural machine translation-based methods cannot accurately analyze the dependencies between code lines, making it difficult to use information from code lines far from the point to be repaired to repair defects. Summary of the Invention

[0004] In view of the above-mentioned problems, the present invention provides a method, system, device and storage medium for repairing defects in data transaction software that integrates context and program-specific components.

[0005] Therefore, the technical problem solved by the present invention is that existing defect repair methods rely only on a single granular context, making it difficult to utilize code line information that is far from the point to be repaired, resulting in poor repair performance for complex defects.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for repairing defects in data transaction software that integrates context and program-specific components, comprising: Obtain the defective code to be repaired, and extract multi-granular context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function; The defective line of code, adjacent lines of code, and defective function are input into a preset defect repair model to generate first repair candidate code that depends on different context components; The code with defects to be fixed is parsed, code structure features are extracted, a preset repair pattern is matched based on the code structure features, a preset repair template is filled in, and a second repair candidate code is generated. The first and second candidate repair codes are deduplicated and filtered by syntax validation to obtain the final list of candidate repair codes.

[0007] As a preferred approach to fixing defects in data transaction software that integrates context and program-specific components, wherein: The process of obtaining the defective code to be repaired and extracting multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function includes: The defective code line set is determined based on the code line in the program file as the basic unit. The defective code line set is determined according to the defect location and the repair type: in response to the repair type being an additive repair, the defective code line set is an empty set; in response to the repair type being a replacement repair, the defective code line set contains one or more code lines at the defect location.

[0008] As a preferred approach to fixing defects in data transaction software that integrates context and program-specific components, wherein: The step of obtaining the defective code to be repaired and extracting multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function also includes: Based on the set of defective code lines, a set of defective locations is determined, and the complete function body where the defective location is located is extracted as the defective function. Based on the defect location, extract the lines of code within a preset range before and after the defect location as adjacent lines of code. By connecting defective lines of code with empty contexts, adjacent lines of code contexts, and defective function contexts using preset keywords, three granularities of model input data are constructed: defective line of code granularity input data, adjacent line of code granularity input data, and defective function granularity input data.

[0009] As a preferred approach to fixing defects in data transaction software that integrates context and program-specific components, wherein: The step of inputting the defective code line, adjacent code lines, and defective function into a preset defect repair model to generate first repair candidate code that depends on different contextual components includes: Obtain historical defect code lines, historical defect functions, and corresponding historical fix code from historical defect code, and construct a historical code fix dataset; By fine-tuning a pre-trained code language model using a historical code repair dataset, a defect repair model is obtained. During the fine-tuning process, historical defective code lines and functions are used as model inputs, and the corresponding historical repair code is used as the target output.

[0010] As a preferred approach to fixing defects in data transaction software that integrates context and program-specific components, wherein: The step of inputting the defective code line, adjacent code lines, and defective function into a preset defect repair model to generate first repair candidate code that depends on different contextual components also includes: A word segmenter is used to segment the input data and target data separately, splitting the text sequence into several sub-tags; Add special tags to the vocabulary of the word segmenter to distinguish defect codes from context information; Each sub-tag obtained after word segmentation is mapped to the corresponding integer number in the vocabulary, resulting in the tag number sequence of the input data and the tag number sequence of the target data, and an attention mask is generated to identify the effective tag positions; Based on the label number sequence and attention mask, an autoregressive training method is used to fine-tune the code language model; The input data of the three granularities of the constructed model are respectively input into the fine-tuned defect repair model. The input data of the three granularities consists of two parts: defect code lines and context code. The empty context, the adjacent code line context, and the defective function context are used as supplementary information for the defective code line, respectively. After filtering out irrelevant format symbols, the two parts are connected by special tags to construct model inputs of three granularities. Input each granularity of input into the model, and generate corresponding repair code for each granularity. Merge the repair code generated at all granularities to obtain the first repair candidate code.

[0011] As a preferred approach to fixing defects in data transaction software that integrates context and program-specific components, wherein: The process involves parsing the defective code to be repaired, extracting code structure features, matching preset repair patterns based on these features, filling preset repair templates, and generating a second repair candidate code, including: Traverse the defective code lines and the abstract syntax tree of the defective functions to extract the function return type, parameter list, local variable information, as well as the names and types of member functions and member variables in the defective class; Extract code structure features from defective program files, including high-frequency code lines and simple expressions; Among them, code lines whose frequency of high-frequency code behavior reaches a preset threshold; simple expressions are obtained by traversing and decomposing parenthesis expressions.

[0012] As a preferred approach to fixing defects in data transaction software that integrates context and program-specific components, wherein: The process involves parsing the defective code to be repaired, extracting code structure features, matching preset repair patterns based on these features, filling preset repair templates, and generating a second repair candidate code, including: Based on the extracted code structure features, a preset repair mode is matched, and the repair template is filled according to the matched repair mode to generate repair code. The preset repair modes include the mode of inserting return statement, the mode of inserting null value check condition block, the mode of expanding expression condition, and the mode of inserting high frequency code line. Each mode has a repair template, and the position identifier in the template is filled according to the extracted code structure features. Perform availability checks on the extracted simple expressions: in response to identifier child nodes that are unavailable at defective locations, replace them with locally available information of the same type, while maintaining consistency in child node type during replacement.

[0013] Secondly, the present invention provides a data transaction software defect repair system that integrates context and program-specific components, comprising: The multi-granularity information extraction module is used to obtain the defective code to be repaired and to extract multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function. The multi-granularity repair generation module is used to input defective code lines, adjacent code lines, and defective functions into a preset defect repair model to generate first repair candidate code that depends on different context components; The structural feature repair module is used to perform syntax parsing on the defective code to be repaired, extract code structural features, match preset repair patterns based on code structural features, fill preset repair templates, and generate second repair candidate code. The candidate code filtering module is used to perform deduplication and syntax validation filtering on the first and second candidate repair codes to obtain the final candidate repair code list.

[0014] Thirdly, the present invention provides a computer device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of a data transaction software defect repair method that integrates context and program-specific components.

[0015] Fourthly, the present invention provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of a data transaction software defect repair method that integrates context and program-specific components.

[0016] The beneficial effects of this invention are as follows: By providing neural machine translation models with multi-granularity defect context input that combines defective code lines, neighboring code lines, and defective functions, this invention alleviates the problem that existing methods, which only use a single granular context, cannot repair multiple types of defects. Furthermore, by capturing important specific components of the program, i.e. code structure features, and applying repair templates, this invention improves the repair effect of existing methods on defects that require long-distance repair of specific program components, and increases the number of defects that are correctly repaired. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is an overall flowchart of a data transaction software defect repair method that integrates context and program-specific components provided by the present invention.

[0019] Figure 2 This is a schematic diagram of a data transaction software defect repair method that integrates context and program-specific components provided by the present invention.

[0020] Figure 3 This is a flowchart of the preset repair mode matching and generation process for a data transaction software defect repair method that integrates context and program-specific components provided by the present invention. Detailed Implementation

[0021] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.

[0022] Example 1, referring to Figure 1 This is the first embodiment of the present invention, which provides a method for fixing defects in data transaction software that integrates context and program-specific components, including: S1: Obtain the defective code to be repaired, and extract multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function; S2: Input the defective line of code, adjacent lines of code, and defective function into the preset defect repair model to generate the first repair candidate code that depends on different context components; S3: Perform syntax parsing on the code with defects to be fixed, extract code structure features, match preset repair patterns based on code structure features, fill preset repair templates, and generate second repair candidate code; S4: Perform deduplication and syntax validation filtering on the first and second candidate repair codes to obtain the final candidate repair code list.

[0023] It should be noted that through steps S1-S4, the present invention achieves the fusion generation and precise screening of defect repair, effectively overcoming the limitations of insufficient single context information and missing long-distance code dependencies, significantly improving the diversity and correctness of repair code, and providing a reliable guarantee for the high-quality development of data trading software.

[0024] Example 2, refer to Figures 1-3 Tables 1-3 illustrate one embodiment of the present invention, providing a data transaction software defect repair method that integrates context and program-specific components based on the previous embodiment, comprising: In this embodiment, the defective code to be repaired obtained in step S1 above, and multi-granularity context information extraction is performed on the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function, including: Define a line of code in a program file: A line of code is a line of code in a program file that ends with a newline character. It means that, among them This represents the total number of lines in the program file.

[0025] Let the set of defective code lines be The set of defective lines of code may be an empty set. A collection of individual lines of code Or a collection containing multiple lines of code The defect code line number Indicates the location of the defect.

[0026] Defect Location Set according to Different situations are determined: In When it is an empty set, This indicates the location in the program file where the fix code should be added. ;when When it consists of a single line of code, Indicates the location where the code to be fixed will be replaced. ;when When it contains multiple lines of code, Indicates the position to be replaced ; In summary, the set of defect locations Represented as: Defect function Set of defect locations The complete function definition, if If the defect is not in any function, then the defect function is empty; otherwise, let the start and end positions of the function be respectively... and The defect function is then expressed as: Repair code line collection For defective lines of code The corresponding repair might be an empty set. Single line or multiple lines .

[0027] When extracting multi-granularity information, it depends on the defect location. and repair type, from the defective program file Extracting context at three granularities: defective code lines Adjacent lines of code Defect function .

[0028] The repair types include add type and replace type. If a defect requires an add type repair, then the defect code line set... If a defect requires a replacement-type fix, meaning the line of code at the defect location needs to be replaced, then the set of defective lines of code is... for or .

[0029] Context at the level of adjacent lines of code Used to provide semantic information about the proximity of defects. Let there be a set of defect locations. The smallest defect line number is Then the adjacent line of code is defined as the line number in Lines of code within the specified range.

[0030] After testing, this embodiment selects... and This allows for the fixing of more defects. Context at the granularity of adjacent lines of code. Represented as: Extract the complete function body containing the defective line of code, and use it as the defective function. .

[0031] By using keywords to connect defective code lines and contexts of different granularities, three types of model input data can be constructed: data at the defective code line granularity and context "buggy: context: ", data of the granular context of adjacent lines of code" buggy: context: "and the data of the defect function granularity context "buggy: context: ".

[0032] It should be noted that the English keywords in the above format have specific meanings: "buggy" means "defective" and is used to mark the following lines of code as defective lines that need to be fixed. "context" means "context" or "contextual context," used to annotate the following code as surrounding code information that helps the model understand. Among these, This represents the actual set of defective code lines extracted. Represents the set of adjacent lines of code. This represents a set of defective functions, all three of which are replaced with their corresponding specific code content during input construction. These three inputs represent different contextual granularities: defective code lines provide the most direct target to be repaired, adjacent code lines supplement the local semantic environment, and defective functions provide more complete function-level logical dependencies. By feeding these three inputs into the defect repair model, the model can understand the causes and repair intentions of defects from multiple perspectives, generating diverse candidate repair codes. This effectively alleviates the information deficiency problem caused by a single-granularity context, laying a solid foundation for subsequent candidate code fusion and selection.

[0033] In this embodiment, step S2 above, which involves inputting the defective code line, adjacent code lines, and defective function into a preset defect repair model to generate first repair candidate code that depends on different contextual components, includes: We obtain historical defective code lines, historical defective functions, and corresponding historical fixes from historical defective code; these three elements together constitute a historical code fix dataset. We then use this historical code fix dataset to fine-tune the pre-trained StartCoder model, adapting it to the code fix task, thus obtaining a defect fix model.

[0034] The specific fine-tuning process is as follows: take the historical defective code lines and historical defective functions in the historical code repair dataset as the model input, and take the corresponding historical repair code as the target output.

[0035] In order to convert natural language and code text into numerical forms that the model can process, the word segmenter based on byte-level byte-pair encoding and its vocabulary in the StartCoder model are used to perform word segmentation on the input data and target data respectively.

[0036] The basic idea of ​​byte-level byte-pair encoding algorithms is to represent each character as a byte, and then continuously merge high-frequency co-occurring byte sequences to form new words, thereby improving the accuracy and efficiency of word segmentation. Meanwhile, to help the model distinguish between defective codes and contextual information in the input, two special markers—"buggy:" and "context:"—are added to the vocabulary so that the model can accurately identify different semantic parts.

[0037] After word segmentation, each sub-tag in the input data and target data is mapped to the corresponding integer number in the vocabulary, thereby obtaining the tag number of the input data, the corresponding attention mask, and the tag number of the target data.

[0038] The attention mask is used to identify which positions are valid markers and which are padding positions, ensuring that the model focuses only on the actual content during training. Numericalized data is used as input for model training.

[0039] During the training phase, the StartCoder model is fine-tuned using a teacher-forcing training method based on the label numbers of the input data, the attention mask, and the label numbers of the target data. This allows the model to learn the mapping relationship from defective code and its context to repair code. The core mechanism of teacher-forcing training is that at every moment in the training process... The input to the model decoder is the first real target data. The markers at each location, rather than the model itself. The marker for the predicted output at each moment.

[0040] It should be noted that this approach enables the model to obtain accurate historical information in a timely manner during training, thereby correcting prediction biases, avoiding the accumulation and amplification of errors that may occur during sequence generation, and effectively improving the stability and convergence speed of model training.

[0041] After the above fine-tuning, a defect repair model that can be used to generate candidate code for repair is finally obtained.

[0042] The defective line of code, adjacent lines of code, and defective function are input into the defect repair model to generate first repair candidate code that depends on different contextual components; Specifically, in step S1, three different granularities of model input data have been extracted and constructed: "buggy:" containing only defective code lines. context:" combined with "buggy:" in adjacent lines of code context: "and "buggy: " combined with the complete defect function context: ".

[0043] All three types of inputs follow the same construction rules: the model input consists of two parts: "defective code lines" and "context code". The context part provides the model with rich similar code components, which helps the model learn and draw on repair strategies from existing code patterns.

[0044] In the actual construction of the input, the defect function will be... As a collection of defective lines of code Context, filtering and The model's input data is constructed by connecting the two parts using the keywords "buggy:" and "context:" to remove unnecessary information such as newlines and tabs. For each type of input, the model's target output is the corresponding set of buggy code lines. .

[0045] The three different granularities of input data were fed into the fine-tuned StartCoder model, which then generated three sets of repair codes, denoted as follows: These correspond to the repair results under the contexts of defective code line granularity, adjacent code line granularity, and defective function granularity, respectively.

[0046] Finally, the union of these three sets of repair code is taken to obtain the first repair candidate code. .

[0047] It should be noted that by fusing candidate repairs generated from multi-granular contexts, the diversity of repair schemes is enriched, and a more comprehensive candidate set is provided for subsequent fusion and filtering with template repair results.

[0048] In this embodiment, step S3 above, which involves parsing the code to be repaired, extracting code structure features, matching a preset repair pattern based on the code structure features, filling a preset repair template, and generating a second repair candidate code, includes: The abstract syntax tree of the defective code and the defective function is traversed separately to extract their return type, function parameters and local variable information, so as to expand and generate new expressions or replace erroneous variable references.

[0049] Obtain information such as the names and types of class member functions and member variables from the defective class to facilitate calling and accessing the class's functions and attributes during the repair process.

[0050] The key program-specific components in defective program files are high-frequency code lines and simple expressions. Code lines that appear frequently in the program reflect program characteristics and are more likely to appear at defect locations. High-frequency code lines are defined as those with a length greater than [missing information]. And the frequency of occurrence is greater than The line of code. Select To filter out unimportant short codes, To obtain a larger number of rows.

[0051] Simple expressions are derived from parenthesized expressions that control program logic. Parenthesized expressions are expressions enclosed in parentheses on both sides, primarily appearing in the control conditions of switch expressions, do statements, if statements, and while statements. Their child nodes are "(", expressions, and ")". Table 1 shows the complete extraction scope and types of specific components in the program file, covering multiple component types at four levels: defective code lines, defective functions, defective classes, and defective files.

[0052] Table 1: Extraction Range and Type of Specific Components in the Program File

[0053] Common expression types are shown in Table 2, which includes basic expressions. Unary expression and binary expressions .

[0054] Basic expressions are components of complex expressions. Common basic expression types include five: literals, identifiers, field access, array access, and method invocation. These are represented using simple basic expressions. express.

[0055] A unary expression consists of one unary operator and one expression, such as "!a".

[0056] A binary expression consists of one operator. Connect left expression and right expression Composition, such as "a+b". Both left and right expressions are simple basic expressions ( A binary expression whose operators are not "&&" or "||" is defined as a simple binary expression. For binary expressions with operators "&&" or "||", both the left and right expressions can be represented independently. Therefore, the left and right expressions should be saved separately, rather than the complete binary expression. For example, "a+d", "a!=1", and "d!=0" are simple binary expressions, while "a!=1||d!=0" and "a&&b" are not.

[0057] Simple expression Defined as a simple basic expression Unary expression and simple binary expressions Union of: If the current node or or ,Right now It belongs to simple expression At that time, directly extract the node. .when If it belongs to a binary expression but not a simple binary expression, then iterate through it. The left and right expression nodes are used as parameters for recursive calls to decompose and obtain simple expressions.

[0058] Table 2: Common Expression Types

[0059] After extracting sufficient code structure features, a second repair candidate code is generated according to the preset repair mode.

[0060] The repair modes described in this embodiment include four types: insert return statement mode, insert null value check condition block mode, expand expression condition mode, and insert high-frequency code line mode.

[0061] The first three types are additive repairs, while the last is a replacement-type extension repair. All three are characterized by generating extended content based on the original code, complementing the replacement-type repair that neural machine translation models excel at. The common set of constant values ​​used is... The various repair modes and their required procedure-specific components are shown in Table 3.

[0062] Table 3: Repair Mode Details

[0063] like Figure 3As shown, after extracting code structure features, this invention matches four preset repair modes according to feature type: inserting return statement mode, inserting null value check condition block mode, expanding expression condition mode, and inserting high-frequency code line mode. The corresponding repair template is filled to generate repair code, and the generated repair code is subjected to simple expression usability verification. Finally, the second repair candidate code is output.

[0064] In insert return statements and insert null check condition block modes Common constant values ​​adapted to defect function return types (program file-specific components of type 2-1 in Table 1). For example, when the return type is integer, It can be 0 or 1. In the template, when fixing a defect lacking null value checks... There are four options for generating it: parameters of the defect function (2-2), local variables of the defect function (2-3), class member function calls (3-1, 3-2, 3-3), and class member variables (3-5). The template contains... To adapt to Common constant values. The high-frequency code line insertion mode directly inserts high-frequency code lines at the defect location (4-1).

[0065] If the defective line of code contains a conditional expression, then the condition of the original expression is expanded. Adding a new condition to the template. There are five options for generating the condition: the first four are null value checks, and the last one is a conditional expression obtained by replacing the unavailable defect location information in the simple expression with local defect location information of the same type. The unavailable defect location information refers to the function parameters and local variables in the class member function (3-3 and 3-4), and the local defect location information refers to the function parameters and local variables in the defect function (2-2 and 2-3). (The template contains...) This is the original expression in the defective code line (1-1). For example, when the defective code line is "if (a == b&&b == c){" or "if (a == b&&b == c")", Both can be represented as the expression "a == b && b == c".

[0066] It should be noted that since simple expressions extracted from the complete defect file may produce syntax errors when used directly at the defect location, it is necessary to replace the unusable information, namely the identifier type child nodes in the expressions. As shown in Table 2: the identifier expression node itself needs to be replaced; the child nodes to be replaced in field access and method call are located in the object field; the child nodes to be replaced in array access are located in the array field; the child nodes to be replaced in unary expression nodes are located in the operand field; and the child nodes to be replaced in binary expression nodes are located in the left and right expression fields. To ensure the correct syntax after replacement, the child nodes used for replacement must maintain the same type as the original child nodes.

[0067] In this embodiment, the first and second candidate repair codes are deduplicated and filtered using syntax validation in step S4 above to obtain the final candidate repair code list, which includes: For duplicate repair codes that are exactly the same as the defective code in the first and second repair candidate codes, only the first occurrence of the code is retained.

[0068] To detect generated code with syntax parsing errors, it is necessary to use a syntax analysis tool to parse the corresponding repair program file for each generated code, remove repair code containing syntax error nodes (ERROR), and retain syntactically correct and non-repeating repair code as the final candidate repair code list.

[0069] Example 3 illustrates a method for repairing defects in data trading software that integrates context and program-specific components. It should be noted that the technical solution of a data trading software defect repair system integrating context and program-specific components belongs to the same concept as the aforementioned method for repairing defects in data trading software that integrates context and program-specific components. Details not described in detail in the technical solution of the data trading software defect repair system integrating context and program-specific components in this embodiment can be found in the description of the aforementioned method for repairing defects in data trading software that integrates context and program-specific components.

[0070] This embodiment also provides a data transaction software defect repair system that integrates context and program-specific components, including: The multi-granularity information extraction module is used to obtain the defective code to be repaired and to extract multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function. The multi-granularity repair generation module is used to input defective code lines, adjacent code lines, and defective functions into a preset defect repair model to generate first repair candidate code that depends on different context components; The structural feature repair module is used to perform syntax parsing on the defective code to be repaired, extract code structural features, match preset repair patterns based on code structural features, fill preset repair templates, and generate second repair candidate code. The candidate code filtering module is used to perform deduplication and syntax validation filtering on the first and second candidate repair codes to obtain the final candidate repair code list.

[0071] This embodiment also provides a computer device applicable to a data transaction software defect repair method that integrates context and program-specific components, including: The system includes a memory and a processor. The memory stores computer-executable instructions, and the processor executes these instructions to implement a data transaction software defect repair method that integrates context and program-specific components, as proposed in the above embodiments.

[0072] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements a data transaction software defect repair method that integrates context and program-specific components as proposed in the above embodiments.

[0073] The storage medium proposed in this embodiment belongs to the same inventive concept as the data transaction software defect repair method that integrates context and program-specific components proposed in the above embodiments. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.

[0074] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for fixing defects in data transaction software that integrates context and program-specific components, characterized in that, include: Obtain the defective code to be repaired, and extract multi-granular context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function; The defective line of code, adjacent lines of code, and defective function are input into a preset defect repair model to generate first repair candidate code that depends on different context components; The code with defects to be fixed is parsed, code structure features are extracted, a preset repair pattern is matched based on the code structure features, a preset repair template is filled in, and a second repair candidate code is generated. The first and second candidate repair codes are deduplicated and filtered by syntax validation to obtain the final list of candidate repair codes.

2. The method for fixing defects in data transaction software that integrates context and program-specific components as described in claim 1, characterized in that, The process of obtaining the defective code to be repaired and extracting multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function includes: The defective code line set is determined based on the code line in the program file as the basic unit. The defective code line set is determined according to the defect location and the repair type: in response to the repair type being an additive repair, the defective code line set is an empty set; in response to the repair type being a replacement repair, the defective code line set contains one or more code lines at the defect location.

3. The method for repairing defects in data transaction software that integrates context and program-specific components as described in claim 2, characterized in that, The step of obtaining the defective code to be repaired and extracting multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function also includes: Based on the set of defective code lines, a set of defective locations is determined, and the complete function body where the defective location is located is extracted as the defective function. Based on the defect location, extract the lines of code within a preset range before and after the defect location as adjacent lines of code. By connecting defective lines of code with empty contexts, adjacent lines of code contexts, and defective function contexts using preset keywords, three granularities of model input data are constructed: defective line of code granularity input data, adjacent line of code granularity input data, and defective function granularity input data.

4. The method for fixing defects in data transaction software that integrates context and program-specific components as described in claim 3, characterized in that, The step of inputting the defective code line, adjacent code lines, and defective function into a preset defect repair model to generate first repair candidate code that depends on different contextual components includes: Obtain historical defect code lines, historical defect functions, and corresponding historical fix code from historical defect code, and construct a historical code fix dataset; By fine-tuning a pre-trained code language model using a historical code repair dataset, a defect repair model is obtained. During the fine-tuning process, historical defective code lines and functions are used as model inputs, and the corresponding historical repair code is used as the target output.

5. The data transaction software defect repair method as described in claim 4, characterized in that, The step of inputting the defective code line, adjacent code lines, and defective function into a preset defect repair model to generate first repair candidate code that depends on different contextual components also includes: A word segmenter is used to segment the input data and target data separately, splitting the text sequence into several sub-tags; Add special tags to the vocabulary of the word segmenter to distinguish defect codes from context information; Each sub-tag obtained after word segmentation is mapped to the corresponding integer number in the vocabulary, resulting in the tag number sequence of the input data and the tag number sequence of the target data, and an attention mask is generated to identify the effective tag positions; Based on the label number sequence and attention mask, an autoregressive training method is used to fine-tune the code language model; The input data of the three granularities of the constructed model are respectively input into the fine-tuned defect repair model. The input data of the three granularities consists of two parts: defect code lines and context code. The empty context, the adjacent code line context, and the defective function context are used as supplementary information for the defective code line, respectively. After filtering out irrelevant format symbols, the two parts are connected by special tags to construct model inputs of three granularities. Input each granularity of input into the model, and generate corresponding repair code for each granularity. Merge the repair code generated at all granularities to obtain the first repair candidate code.

6. The data transaction software defect repair method as described in claim 5, characterized in that, The process involves parsing the defective code to be repaired, extracting code structure features, matching preset repair patterns based on these features, filling preset repair templates, and generating a second repair candidate code, including: Traverse the defective code lines and the abstract syntax tree of the defective functions to extract the function return type, parameter list, local variable information, as well as the names and types of member functions and member variables in the defective class; Extract code structure features from defective program files, including high-frequency code lines and simple expressions; Among them, code lines whose frequency of high-frequency code behavior reaches a preset threshold; simple expressions are obtained by traversing and decomposing parenthesis expressions.

7. The method for repairing defects in data transaction software that integrates context and program-specific components as described in claim 6, characterized in that, The process involves parsing the defective code to be repaired, extracting code structure features, matching preset repair patterns based on these features, filling preset repair templates, and generating a second repair candidate code, including: Based on the extracted code structure features, a preset repair mode is matched, and the repair template is filled according to the matched repair mode to generate repair code. The preset repair modes include the mode of inserting return statement, the mode of inserting null value check condition block, the mode of expanding expression condition, and the mode of inserting high frequency code line. Each mode has a repair template, and the position identifier in the template is filled according to the extracted code structure features. Perform availability checks on the extracted simple expressions: in response to identifier child nodes that are unavailable at defective locations, replace them with locally available information of the same type, while maintaining consistency in child node type during replacement.

8. A data transaction software defect repair system that integrates context and program-specific components, employing the method described in any one of claims 1-7, characterized in that, include: The multi-granularity information extraction module is used to obtain the defective code to be repaired and to extract multi-granularity context information from the defective code to obtain the corresponding defective code line, adjacent code lines, and defective function. The multi-granularity repair generation module is used to input defective code lines, adjacent code lines, and defective functions into a preset defect repair model to generate first repair candidate code that depends on different context components; The structural feature repair module is used to perform syntax parsing on the defective code to be repaired, extract code structural features, match preset repair patterns based on code structural features, fill preset repair templates, and generate second repair candidate code. The candidate code filtering module is used to perform deduplication and syntax validation filtering on the first and second candidate repair codes to obtain the final candidate repair code list.

9. A computer device, characterized in that, include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It stores computer-executable instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 7.