Project code generation methods, devices, computer equipment, and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-25
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]本发明提供一种人工智能的项目代码生成方法、装置、计算机设备及介质,以解决依赖代码编辑器本身的基础校验功能,基于静态规则进行代码检测,再由开发人员根据代码编辑器给出的提示人工复核的方式,开发效率较低,迭代周期长的技术问题
[0009]上述项目代码生成方法、装置、计算机设备及存储介质所实现的方案中,服务端可获取软件开发项目的项目代码,以及软件开发项目的新增需求对应的新增代码;利用预设项目语义模型,解析项目代码和新增代码的代码语义,基于代码语义和新增需求整合新增代码与项目代码,生成软件开发项目对应的目标代码,目标代码为针对新增需求进行项目版本更新后的项目代码;对目标代码进行发布风险评估,确定目标代码对应的发布风险等级;按照发布风险等级,确定目标代码的发布门禁策略,可按照发布门禁策略将目标代码部署于客户端,为客户端提供相应的软件服务。本发明可利用预设项目语义模型,解析软件开发项目的项目代码和该项目新增需求的新增代码的代码语义,以理解软件开发项目的功能及架构,再基于解析得到的代码语义和新增需求,校验项目代码与新增代码的适配性,以及能否解决新增需求,最后整合得到更新后的目标代码,并对其进行发布风险评估,自动确定目标代码的发布门禁策略,减少人工复核代码和评估发布风险的工作量,有效提高项目代码的开发效率,进而减少项目代码的迭代周期。
Smart Images

Figure CN122569898A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence technology, financial technology and medical health technology, and in particular to a project code generation method, apparatus, computer equipment and storage medium. Background Technology
[0002] When new requirements arise in a software development project, writing, verifying, and modifying code are the core steps in realizing requirement iteration. For example, in the development of electronic medical record systems, medical image analysis platforms, remote diagnosis and treatment backend systems, and supporting software for patient health monitoring equipment in the healthcare field, when new requirements arise, such as adding patient medical record entry templates, adding medical test indicator analysis functions, or adding encrypted transmission functions for patient privacy data, developers first manually write the new code in commonly used code editors such as VS Code and PyCharm. These editors can only provide hints for surface-level syntax errors and cannot identify problems related to medical business logic within the code. Developers then correct the syntax errors based on the editor's hints, and professional developers and healthcare IT personnel then manually review the code until it passes review, completing the project iteration.
[0003] Related technologies rely on the basic verification functions of the code editor itself, perform code inspection based on static rules, and then have developers manually review the code according to the prompts provided by the code editor. This approach has low development efficiency and long iteration cycles. Summary of the Invention
[0004] This invention provides a method, apparatus, computer device, and medium for generating project code for artificial intelligence, in order to solve the technical problem of low development efficiency and long iteration cycle caused by relying on the basic verification function of the code editor itself, performing code detection based on static rules, and then having developers manually review the code according to the prompts given by the code editor.
[0005] Firstly, a project code generation method is provided, including: Obtain the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; Using a pre-defined project semantic model, the code semantics of the project code and the newly added code are analyzed. Based on the code semantics and the new requirements, the new code and the project code are integrated to generate the target code corresponding to the software development project. The target code is the project code after the project version is updated to meet the new requirements. Conduct a release risk assessment of the target code to determine the corresponding release risk level of the target code; Determine the access control policy for the release of target code based on the risk level of the release.
[0006] Secondly, a project code generation device is provided, including: The acquisition module is used to acquire the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; The generation module is used to parse the code semantics of the project code and the newly added code using a preset project semantic model. Based on the code semantics and the new requirements, the new code and the project code are integrated to generate the target code corresponding to the software development project. The target code is the project code after the project version is updated to meet the new requirements. The assessment module is used to assess the release risk of the target code and determine the corresponding release risk level of the target code; The determination module is used to determine the release access control policy for target code based on the release risk level.
[0007] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described project code generation method.
[0008] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described project code generation method.
[0009] In the solution implemented by the above-mentioned project code generation method, apparatus, computer equipment, and storage medium, the server can obtain the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; using a preset project semantic model, it parses the code semantics of the project code and the new code, integrates the new code and the project code based on the code semantics and the new requirements, and generates the target code corresponding to the software development project. The target code is the project code after updating the project version for the new requirements; it performs a release risk assessment on the target code to determine the release risk level of the target code; according to the release risk level, it determines the release access control policy of the target code, and can deploy the target code on the client according to the release access control policy to provide the client with corresponding software services. This invention utilizes a pre-defined project semantic model to parse the code semantics of the project code and the code for new requirements in a software development project. This allows for an understanding of the project's functionality and architecture. Based on the parsed code semantics and new requirements, the compatibility between the project code and the new code is verified, as well as whether the new requirements can be addressed. Finally, the updated target code is integrated, and a release risk assessment is performed on it. The release access control strategy for the target code is automatically determined, reducing the workload of manual code review and release risk assessment. This effectively improves the development efficiency of the project code and reduces the iteration cycle of the project code. Attached Figure Description
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. 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.
[0011] Figure 1 This is a schematic diagram of an application environment for a project code generation method according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating a project code generation method in one embodiment of the present invention; Figure 3 yes Figure 2 A schematic diagram of a specific implementation method for step S20; Figure 4 This is a schematic diagram of a project code generation device in one embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 6 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described 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 are within the scope of protection of the present invention.
[0013] The project code generation method provided in this embodiment of the invention can be applied to, for example, Figure 1In this application environment, the client can communicate with the server via the network. The server can obtain the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; using a preset project semantic model, it parses the code semantics of the project code and the new code, integrates the new code and the project code based on the code semantics and the new requirements, and generates the target code corresponding to the software development project. The target code is the project code after updating the project version for the new requirements; it performs a release risk assessment on the target code to determine the corresponding release risk level; according to the release risk level, it determines the release access control policy for the target code, and can deploy the target code to the client according to the release access control policy to provide the client with the corresponding software services. This embodiment utilizes a preset project semantic model to parse the code semantics of the project code and the code of the newly added requirements of the software development project, in order to understand the functions and architecture of the software development project. Based on the parsed code semantics and the new requirements, it verifies the compatibility between the project code and the new code, and whether it can solve the new requirements. Finally, it integrates to obtain the updated target code, and performs a release risk assessment on it, automatically determining the release access control strategy for the target code. This reduces the workload of manually reviewing code and assessing release risks, effectively improving the development efficiency of the project code, and thus reducing the iteration cycle of the project code.
[0014] The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will now be described in detail through specific embodiments.
[0015] Please see Figure 2 As shown, Figure 2 A flowchart illustrating the project code generation method provided in this embodiment of the invention includes the following steps: S10: Obtain the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project.
[0016] In some embodiments, a software development project may be software developed according to specific business needs, and may include front-end development projects and back-end development projects. Its project code may be source code that needs to be updated based on new requirements, and may include business code, common components, utility classes, configuration files, script files, third-party dependency reference code, commented documentation, branch version code, and obsolete code snippets from previous iterations. To improve project performance and user experience, new requirements may be proposed for the software development project based on new features, changes in business rules, and interface optimizations, and corresponding new code may be developed. AI tools can be used to generate new code based on these new requirements, or developers can develop new code based on these new requirements. The new code may include new classes, functions, interfaces, and configuration items. The new code is then integrated with the project code to generate updated target code, thereby completing the functional iteration of the software development project.
[0017] S20: Utilize a pre-defined project semantic model to parse the code semantics of the project code and newly added code, integrate the newly added code with the project code based on the code semantics and new requirements, and generate the target code corresponding to the software development project.
[0018] The target code is the project code updated to meet the new requirements. A pre-defined project semantic model can be used to parse the semantics of both the project code and the newly added code, and based on the new requirements and code development standards, verify and integrate the new code with the project code to generate the updated target code.
[0019] In specific application scenarios, new code and project code can be input into a preset project semantic model. The model parses the corresponding code semantics to understand the code logic, project hierarchy, etc. It verifies the logical rationality of the new code and project code and whether the new code can solve the new requirements, such as code syntax verification, code logic verification, and code writing style verification. Once the new code passes the verification, it is confirmed that the new code is legal, does not conflict with the project code, and meets the new requirements. Then, the integrated target code is generated to complete the project update based on the new requirements. This eliminates the need for developers to perform code integration, improving project development and iteration efficiency.
[0020] S30: Conduct a release risk assessment of the target code and determine the corresponding release risk level of the target code.
[0021] The target code can implement the functions corresponding to the new requirements, but it may have potential risks and vulnerabilities. Therefore, risk assessment of the target code is required to ensure its stable operation, improve the stability of the software development project, and reduce its operational risks.
[0022] For example, risk quantification can be performed based on the potential risks of the target code and coding standards to assess the release risk level of the target code. This includes assessing code syntax correctness, business logic consistency, module call compatibility, security vulnerability risks, exception handling integrity, and performance degradation risks. Accordingly, if at least one of the following issues is detected: serious security vulnerability, logical collapse, or module conflict, the release risk level of the target code can be determined to be high-risk; if at least one of the following issues is detected: potential defects or non-compliance with standards, the release risk level of the target code can be determined to be medium-risk; and if at least one of the following issues is detected: non-standard code formatting, non-standard comments, or non-standard naming, the release risk level of the target code can be determined to be low-risk.
[0023] S40: Determine the release access control policy for target code based on the release risk level.
[0024] In some embodiments, different release access control policies can be adopted for target code based on different risk levels. These policies can be used to constrain code merging, submission, integration, and deployment, ensuring the stability of software development projects. Policies may include allowing submission, issuing warnings, automatic repair, manual review, and blocking submissions. For example, if the risk level is determined to be high, a submission blocking policy can be used to prohibit the submission of target code; if the risk level is determined to be medium, a manual review policy can be used, allowing processing to continue after developers confirm the repairs; if the risk level is determined to be low, an allow policy can be used, allowing the deployment and release process to begin.
[0025] Compared with related technologies, this embodiment can automatically parse the code semantics of the original project code and the new code corresponding to the new requirements when there are new requirements in the software development project. When the new code passes the verification, the new code is merged with the project code to generate the merged target code, which is the project code that meets the new requirements. This realizes the automatic verification and updating of project code based on new requirements, effectively improving code development efficiency. Then, a risk assessment is performed, and different release access control strategies are adopted based on different release risk levels to achieve targeted code control and thus ensure system stability.
[0026] Furthermore, such as Figure 3 As shown, step S20 specifically includes the following steps: S21: Generate a project knowledge base corresponding to the software development project based on the historical requirements and project code of the software development project.
[0027] S22: Generate the latest knowledge base corresponding to the software development project based on the project knowledge base and new requirements.
[0028] S23: Using a pre-defined project semantic model based on the latest knowledge base, perform semantic parsing on the new code and project code to obtain code semantics. Based on the semantic matching degree between the code semantics and the new requirements, integrate the new code and project code to generate target code.
[0029] Historical requirements can be a collection of requirements data throughout the development cycle of a software development project, such as initial business requirements, iterative requirements, change requirements, and defect fixing requirements. A project knowledge base can be used to parse and structure relevant data from a software development project, creating a searchable knowledge base document that facilitates learning and understanding of the project content. For example, historical requirements and project code of a software development project can be sorted, statistically analyzed, and used to create a knowledge table, build a project knowledge base, and update the project knowledge base as the software development project's requirements and code are updated. This prevents the loss of project knowledge, provides unified project knowledge for relevant developers, and improves collaborative development efficiency and project maintainability.
[0030] In some embodiments, the project knowledge base can be updated based on new requirements in the current iteration cycle to generate a new knowledge base. This can be achieved by integrating and analyzing the requirement documents for new requirements with the knowledge base documents of the project knowledge base to generate the latest knowledge table, resulting in the latest knowledge document of the latest knowledge base. The latest knowledge document of the latest knowledge base is then input into a preset project semantic model to aid in understanding the code semantics of the new code and project code. Specifically, business objects and constraints in the new code and project code can be identified first, and the code semantics of the new code and project code can be extracted by combining them with the latest knowledge document of the latest knowledge base. Then, the code semantics are matched with the new requirements, such as calculating the overlap and similarity between the code semantics and the new requirements based on keywords, as the semantic matching degree, to predict whether the integration of the new code and the project code can achieve the function corresponding to the new requirements.
[0031] For example, in a premium management system developed and maintained for an insurance management project, if a premium calculation function for a certain insurance product needs to be added, a project knowledge base can be generated based on relevant project data and historical requirement documents of the insurance management project. Then, new code corresponding to the premium calculation function for that insurance product can be generated. The new code and the project code of the premium management system are input into a preset project semantic model. This model uses the project knowledge base to parse the semantics of both codes, obtain the requirement semantics corresponding to the new requirement, and calculate the semantic matching degree between the code semantics and the requirement semantics. If the calculated semantic matching degree is greater than or equal to the preset matching degree, it can be determined that merging the new code with the project code can solve the new requirement, and code integration can be performed to generate the target code. If the calculated semantic matching degree is less than the preset matching degree, it can be determined that merging the new code with the project code cannot solve the new requirement, and a new code review prompt can be generated to regenerate the new code. The preset matching degree can be a matching degree threshold set according to the project development requirements.
[0032] In this way, after a new requirement is proposed in a software development project, the semantics of the new code and the project code, obtained by parsing from the project knowledge base, are semantically matched with the new requirement to determine whether the new code can solve the new requirement. Once it is confirmed that the new requirement can be solved, the code is integrated, reducing the workload of manual code integration and thus improving project development efficiency.
[0033] The preset project semantic model can be multiple semantic models trained according to the different code verification requirements of different software development projects, used for verification across multiple code editing dimensions. These preset project semantic models may include, but are not limited to, component dependency relationship models, capability call relationship models, data flow propagation relationship models, and security boundary constraint models. These models can be large language models used for code semantic parsing, such as CodeBERT, GraphCodeBERT, etc.
[0034] For example, the component dependency model can be trained based on the project component dependency dataset. The source code in the dataset is imported into the input layer, the code semantics corresponding to the code statements in the source code are identified based on the project knowledge base, the overall project structure is inferred, and cross-layer reference verification is performed in combination with the project layering rules. Finally, the component dependency relationship corresponding to the project code is output through the output layer to obtain the component (module) adjacency structure. Correspondingly, the capability call relationship model can be trained based on the capability call relationship dataset. The source code in the dataset is imported into the input layer, and the functions in the source code are identified based on the third-party libraries corresponding to the source code. The function call expressions are normalized and matched to construct the function call mapping relationship between functional modules and key components. This is used to identify whether the common encapsulation layer is bypassed. Finally, the capability call relationship corresponding to the project code is output through the output layer. Here, the third-party library can refer to a reusable software component developed by other developers or organizations, which can provide a series of functions, classes, methods or interfaces so that developers can directly call them in the development project.
[0035] Correspondingly, the data flow propagation relationship model can be trained based on the data flow propagation relationship dataset. The source code in the dataset is imported into the input layer, the data source points and data output points of each data in the source code are identified, and the propagation paths such as variable assignment, function parameter passing, and object attribute passing are tracked to output the data propagation link.
[0036] Correspondingly, the security boundary constraint model can be trained based on the security boundary constraint dataset. The source code in the dataset is imported into the input layer, and boundary constraint information such as the module layering, domain whitelist, native interface permission table and release phase strategy corresponding to the source code is identified. The boundary constraint information is compared with the preset security rules in the dataset to determine whether the cross-boundary behavior in the source code is legal, and the security boundary judgment result is output.
[0037] Furthermore, using a pre-defined project semantic model based on the latest knowledge base, semantic parsing is performed on the newly added code and project code to obtain code semantics. Specifically, this may include: using a component dependency relationship model, identifying the reference relationships between different components in the newly added code and project code based on the latest knowledge base, and parsing the project structure semantic information corresponding to the newly added code and project code; using a capability call relationship model, identifying function call expressions in the newly added code and project code based on the latest knowledge base, performing normalized matching, determining the function call mapping relationship between the newly added code and project code, and parsing the common encapsulation semantic information corresponding to the newly added code and project code based on the function call mapping relationship; using a data flow propagation relationship model, identifying the data source points and data output points corresponding to the transmitted data in the newly added code and project code based on the latest knowledge base, and parsing the data propagation link semantic information corresponding to the newly added code and project code; and using a security boundary constraint model, identifying code boundary attributes in the newly added code and project code based on the latest knowledge base, and parsing the code security semantic information corresponding to the newly added code and project code.
[0038] For example, by using a component dependency model, the system compares the component reference relationships, package paths, class affiliations, and module affiliations of the newly added code with the project code based on the latest knowledge base. This determines whether the code structure of the newly added code conflicts with the project code after integration, and obtains the semantic information of the project structure. This information may include information such as layered architecture, package paths, class responsibilities, module affiliations, code levels, component dependencies, and layered calling conventions. This allows for the addition of new code within the original structure of the project code, preventing issues such as cross-layered and cross-module code storage and the creation of new independent classes after integration.
[0039] Correspondingly, the capability call relationship model can be used to compare the function call expressions of the newly added code and the project code based on the latest knowledge base. Input parameter validation and method encapsulation validation can be performed on the newly added code and the project code to generate common encapsulation semantic information. This information may include method encapsulation specifications, input parameter validation rules, return value format, exception handling encapsulation rules, public variable definitions, etc., so as to uniformly schedule existing functions and make the newly added code and the project code consistent with the common encapsulation method.
[0040] Correspondingly, the data flow propagation relationship model can traverse and parse both the newly added code and the project code. Based on the project knowledge base, it identifies function call expressions in the code and performs normalization matching processes such as function name normalization, parameter type normalization, call logic normalization, and return value semantic normalization. It identifies the data source and output points corresponding to various types of transmitted data in the code snippets, and traces the transmission path of each data point from its source, through parameter input, logic processing, cross-function transmission, and variable flow to the final output point. This yields data propagation link semantic information, which is used to verify whether the parameter types, transmission order, and data dependencies of the newly added code and the project code are consistent. It also determines whether there are invalid parameters, redundant parameters, undefined variables, broken data chains, or illegal data flow anomalies, ensuring the normal operation of the integrated code. The data propagation link semantic information can include data source points, data output points, data flow order, parameter transmission semantics, data processing semantics, variable dependencies, cross-method call data links, field mapping relationships, data reuse and transmission scope, and upstream and downstream data interaction logic.
[0041] Correspondingly, a security boundary constraint model can be used, based on the latest security specifications in the knowledge base, such as sensitive parameter verification rules, numerical boundary restrictions, and anomaly tolerance standards, to identify code boundary attributes in newly added code and project code, generating code security semantic information to ensure the compliance and security of code integration. Code boundary attributes can include: parameter boundaries: the range of input parameter values, data types, and non-null constraints, such as an insured age of 18-65 years old; logical boundaries: the judgment conditions of business logic, anomaly triggering thresholds, and calculation boundaries, such as not allowing negative number operations in premium calculation; risk boundaries: the processing boundaries of sensitive data and the interception boundaries of illegal input parameters, such as prohibiting direct premium calculation without verification; and fault tolerance boundaries: the scope of anomaly capture and error handling, such as anomaly throwing when parameters are illegal and protection against numerical overflow. Code security semantic information can include parameter boundary constraint information, data validity verification information, business logic boundary restriction information, anomaly capture and fault tolerance handling information, sensitive data protection information, numerical operation security constraint information, illegal input parameter interception semantics, risk operation isolation semantics, access control semantics, and code error prevention and overflow prevention constraint semantics.
[0042] Optionally, based on the semantic matching degree between the code semantics and the new requirements, the new code and the project code are integrated to generate target code. Specifically, this may include: determining the code addition position of the new code in the project code based on the semantic matching degree between the code semantics and the new requirements; integrating the new code and the project code according to the code addition position to obtain the integrated project code; verifying the integrated project code based on project structure semantic information, common encapsulation semantic information, data propagation link semantic information, and code security semantic information to determine the code verification result corresponding to the integrated project code; when the code verification result is that the verification passes, the integrated project code is determined as the target code.
[0043] In some embodiments, the project structure of the project code can be identified first based on code semantics. Then, the location where the new code is added to the project code can be determined according to the project structure, such as the target line of the target file in the software development project. The new code is then automatically added to that location, which may include the start position (such as the start line) and the end position (such as the end line), resulting in the integrated project code. Next, code verification is performed based on project structure semantic information, common encapsulation semantic information, data propagation link semantic information, and code security semantic information. When the code verification result is that the verification passes, the integrated project code is determined as the target code. If the code verification result is that the verification fails, a code prompt indicating that the verification failed is generated. For example, if the data input / output link of the new code is inconsistent with the data propagation link semantic information, it may lead to data anomalies.
[0044] For example, the project structure semantic information, common encapsulation semantic information, data propagation link semantic information, and code security semantic information corresponding to the newly added code and the project code are extracted and compared respectively. For instance, the project structure semantic information of the newly added code is checked to see if it is consistent with that of the project code. If there are structural semantic conflicts, such as missing rules, logical anomalies, or architectural misalignments, the project structure semantic information is deemed unqualified. Similarly, code verification is performed on dimensions such as common encapsulation semantic information, data propagation link semantic information, and code security semantic information to obtain the code verification results. If any of the following verifications fails, the code verification result is determined to be unqualified; if all verifications pass, the code verification result is determined to be qualified.
[0045] This approach enables semantic-level judgment based on component dependency structure, capability call relationships, and data flow propagation paths. It ensures code consistency and security boundary constraints at the architectural level, not only identifying surface-level syntax features but also understanding the project's layered structure. It can determine whether public capability encapsulation has been bypassed, identify the true destination of data after propagation through multiple layers of variables, and complete a structured analysis of the legality of the call chain, architectural consistency, and data propagation path, providing clear evidence of the propagation path.
[0046] Optionally, the newly added code and project code can be integrated according to the addition location to obtain the integrated project code. Specifically, this may include: generating a source identifier for the newly added code based on the requirements document of the new requirements; the newly added code includes code snippets generated by using an AI model based on the requirements document; the source identifier is used to perform fragment-level structured marking of the newly added code; adding the newly added code at the code addition location, and adding the source identifier for the newly added code at the beginning and end positions of the code addition location, respectively, to obtain the integrated project code.
[0047] The source tracing markers may include unique identifiers such as code, AI model version, prompt word summary fingerprint, context summary fingerprint, generation strategy type, and timestamp. The AI model can be used to generate AI code based on new requirements and the project knowledge base. As new code, the AI model may include existing AI tools or code generation models trained based on the project knowledge base.
[0048] In some embodiments, functional information can be extracted from the requirements document. When generating new code based on new requirements using an AI model, structured traceability markers can be automatically generated and bound to specific code line intervals. Comment lines are added at the beginning and end of the code addition location to mark the new code, enabling traceability of code origin. This facilitates the differentiation between new code and project code, improving the maintainability of project code iterations. Correspondingly, during the code submission and build phases, these traceability markers are parsed to form a queryable data structure, allowing for the location of the specific generation scope and source. This achieves code-level and fragment-level traceability capabilities, enabling rapid differentiation between AI code and manually written code, and improving auditing and statistical capabilities.
[0049] Optionally, step S30 may specifically include: determining the release risk assessment indicators corresponding to the target code based on the code verification results and the code development specifications corresponding to the software development project; classifying and quantifying the release risk assessment indicators according to the risk quantification rules corresponding to the software development project, and determining the release risk level corresponding to the target code.
[0050] The code development specifications can be pre-defined code editing standards based on the software development project, including coding standards, architecture specifications, security specifications, naming conventions, exception specifications, deployment specifications, etc., to facilitate risk assessment of the project from the code editing perspective, thereby improving code quality. The release risk assessment indicators can include at least one risk assessment indicator extracted based on the code development specifications, such as data propagation path length, sensitivity level, number of affected modules, code coverage, etc., which can be used to quantify the release risk of the target code. The risk quantification rules can be risk level classification rules based on the development requirements of the software development project, such as dividing the risk into multiple risk levels according to different score ranges of the release risk assessment indicators, to achieve quantitative classification of the release risk of the target code, facilitate code management, and thus ensure system stability. Furthermore, by identifying the propagation path of sensitive data and outputting clear propagation evidence, the interpretability of risk judgment can be improved.
[0051] For example, for a payment system developed for a payment project, risk assessment indicators such as the probability of financial loss, the probability of timeout, the number of affected users, the number of affected transactions, the number of sensitive data exposed, and the number of high-level vulnerabilities can be used. Risk weights can be set for each of these indicators, along with the project's corresponding code development specifications and risk quantification rules. After integrating the payment system's code, the risk assessment indicators are calculated based on the target code's code verification results and the payment project's corresponding code development specifications. Multiple risk assessment indicators are then summed according to their risk weights to obtain a comprehensive risk value. Based on the score range of the comprehensive risk value, the release risk level corresponding to the integrated target code is determined, thereby achieving an overall risk assessment of the payment system and facilitating project management.
[0052] By introducing a risk quantification mechanism, the weights of indicators are accumulated based on risk quantification rules to calculate a comprehensive risk value, and the comprehensive risk value is mapped to multiple risk levels. Different risk levels correspond to different release strategies, thereby realizing the quantification of project release risks.
[0053] Optionally, step S40 may specifically include: determining the release access control policy corresponding to the release risk level based on the project release rules corresponding to the software development project; and generating release access control prompts corresponding to the release access control policy.
[0054] The project release rules can be standardized pre-defined deployment management systems based on the development needs of software development projects. These rules may include deployment constraints, approval processes, deployment methods, prohibition conditions, and gray-scale requirements corresponding to different risk levels, facilitating the release management of updated software development projects. Access control policies can be dynamically selected based on risk level, release stage, and module importance. These policies may include allowance, notification, automatic repair, manual review, and blocking. Differentiated access control policies are implemented according to the release stage. Deterministic blocking can be embedded in continuous integration processes, meeting the stability and explainability requirements of enterprise-level engineering governance, improving the flexibility of project maintenance, and making project management methods more adaptable and controllable.
[0055] Correspondingly, when different release access control policies are executed, corresponding release access control prompts can be generated. The release access control prompts can be standardized text prompts that are automatically generated based on the access control prompt template, which are used to inform developers of the current code's online permissions, operation requirements, reasons for restrictions, and subsequent processing actions.
[0056] For example, for the target code after adding the critical illness supplementary insurance calculation function to the premium management system, if the release risk level is low, an automatic release strategy can be executed, generating a corresponding release access control prompt: The target code release risk level is low, meeting the project release rules and access control conditions, the release strategy is automatically triggered, and normal full release operation can be performed. For the target code after adding the refund function to the payment system, if data link anomalies, missing parameter validations, or high-risk security vulnerabilities are detected, and the release risk level is determined to be high, a release blocking strategy can be adopted, generating a release access control prompt: The target code has security risks and data link violations, the release risk level is high, access control validation failed, this release has been blocked, please fix the defects.
[0057] Optionally, code verification results can be fed back to the risk quantification rules and prompt word templates corresponding to the software development project, forming a closed-loop mechanism of generation, detection, repair, and optimization, achieving continuous evolution rather than a static set of rules. Through closed-loop feedback, the risk quantification rules and prompt word templates are continuously optimized, reducing the risk of duplication and establishing a closed-loop optimization mechanism for enterprise-level AI code governance infrastructure.
[0058] This embodiment proposes a structured, computable, quantifiable, and schedulable AI code governance technology solution. It can dynamically match release strategies based on different risk levels and generate release access prompts to achieve dynamic release control of software development projects and reduce the probability of failure after project launch.
[0059] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0060] In one embodiment, a project code generation apparatus is provided, which corresponds one-to-one with the project code generation method described in the above embodiments. For example... Figure 4 As shown, the code generation device for this project includes an acquisition module 101, a generation module 102, an evaluation module 103, and a determination module 104. Detailed descriptions of each functional module are as follows: The acquisition module 101 is used to acquire the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project. The generation module 102 is used to use a preset project semantic model to parse the code semantics of the project code and the newly added code, integrate the newly added code and the project code based on the code semantics and the new requirements, and generate the target code corresponding to the software development project. The target code is the project code after the project version is updated for the new requirements. The assessment module 103 is used to assess the release risk of the target code and determine the release risk level of the target code. Module 104 is used to determine the release access control policy for target code based on the release risk level.
[0061] In one embodiment, the generation module 102 is specifically used for: Based on the historical requirements and project code of software development projects, a project knowledge base corresponding to the software development projects is generated. Based on the project knowledge base and new requirements, generate the latest knowledge base corresponding to the software development project. Using a pre-defined project semantic model based on the latest knowledge base, semantic parsing is performed on the new code and project code to obtain code semantics. Based on the semantic matching degree between the code semantics and the new requirements, the new code and project code are integrated to generate the target code.
[0062] In one embodiment, the preset project semantic model includes a component dependency model, a capability invocation model, a data flow propagation model, and a security boundary constraint model; the generation module 102 is specifically used for: By using the component dependency model, the reference relationships between different components in the newly added code and project code are identified based on the latest knowledge base, and the project structure semantic information corresponding to the newly added code and project code is parsed. By utilizing the capability call relationship model, the function call expressions in the newly added code and project code are identified based on the latest knowledge base, and normalized matching is performed to determine the function call mapping relationship between the newly added code and the project code. Based on the function call mapping relationship, the common encapsulated semantic information corresponding to the newly added code and the project code is parsed. By utilizing the data flow propagation relationship model and based on the latest knowledge base, we can identify the data source and data output points corresponding to the transmitted data in the new code and project code, and parse the semantic information of the data propagation link corresponding to the new code and project code. By utilizing a security boundary constraint model and based on the latest knowledge base, code boundary attributes in newly added code and project code are identified, and the code security semantic information corresponding to the newly added code and project code is analyzed.
[0063] In one embodiment, the generation module 102 is specifically used for: Based on the semantic matching degree between the code semantics and the new requirements, determine the location in the project code where the new code should be added; Based on the location where the code was added, integrate the newly added code and the project code to obtain the integrated project code; Based on project structure semantic information, common encapsulation semantic information, data propagation link semantic information, and code security semantic information, the integrated project code is verified, and the code verification result corresponding to the integrated project code is determined. When the code verification result is "verification passed", the integrated project code will be identified as the target code.
[0064] In one embodiment, the generation module 102 is specifically used for: Based on the requirements document for the new requirements, a source identification tag is generated for the new code. The new code includes code snippets generated by the AI model based on the requirements document. The source identification tag is used to perform fragment-level structured marking of the new code. Add the new code at the code addition location, and add the source identifier corresponding to the new code at the beginning and end of the code addition location to obtain the integrated project code.
[0065] In one embodiment, the evaluation module 103 is specifically used for: Based on the code verification results and the code development specifications corresponding to the software development project, determine the release risk assessment indicators for the target code; Based on the risk quantification rules corresponding to the software development project, the release risk assessment indicators are graded and quantified to determine the release risk level corresponding to the target code.
[0066] In one embodiment, the determining module 104 is specifically used for: Based on the project release rules corresponding to the software development project, determine the release access control strategy corresponding to the release risk level; Generate and publish access control prompts corresponding to the published access control policies.
[0067] This invention provides a project code generation device that, when a software development project has new requirements, automatically parses the semantics of the original project code and the new code corresponding to the new requirements using a preset project semantic model. When the new code passes verification, it is merged with the original project code to generate merged target code, which is the project code that meets the new requirements. This achieves automatic verification and updating of project code based on new requirements, effectively improving code development efficiency. Furthermore, a risk assessment is performed, and different release access control strategies are adopted based on different release risk levels to achieve targeted code control and ensure system stability. It can also utilize AI models to generate new code and its structured traceability tags based on new requirements, forming a queryable data structure that can pinpoint the specific generation scope and source, thereby achieving code-level and fragment-level traceability capabilities. This enables rapid differentiation between AI-generated code and manually written code, improving auditing and statistical capabilities.
[0068] Specific limitations regarding the project code generation device can be found in the limitations of the intelligent question-answering method described above, and will not be repeated here. Each module in the aforementioned project code generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0069] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a project code generation method on the server side.
[0070] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the client side of a project code generation method.
[0071] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Obtain the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; Using a pre-defined project semantic model, the code semantics of the project code and the newly added code are analyzed. Based on the code semantics and the new requirements, the new code and the project code are integrated to generate the target code corresponding to the software development project. The target code is the project code after the project version is updated to meet the new requirements. Conduct a release risk assessment of the target code to determine the corresponding release risk level of the target code; Determine the access control policy for the release of target code based on the risk level of the release.
[0072] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: Obtain the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; Using a pre-defined project semantic model, the code semantics of the project code and the newly added code are analyzed. Based on the code semantics and the new requirements, the new code and the project code are integrated to generate the target code corresponding to the software development project. The target code is the project code after the project version is updated to meet the new requirements. Conduct a release risk assessment of the target code to determine the corresponding release risk level of the target code; Determine the access control policy for the release of target code based on the risk level of the release.
[0073] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0074] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0075] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0076] It should be noted that any software tools or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
[0077] 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 the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A project code generation method, characterized in that, include: Obtain the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; Using a preset project semantic model, the code semantics of the project code and the newly added code are analyzed. Based on the code semantics and the new requirements, the new code and the project code are integrated to generate the target code corresponding to the software development project. The target code is the project code after the project version is updated for the new requirements. A release risk assessment is performed on the target code to determine the release risk level corresponding to the target code; Based on the aforementioned risk level, determine the access control policy for the release of the target code.
2. The project code generation method as described in claim 1, characterized in that, The process of using a preset project semantic model to parse the code semantics of the project code and the newly added code, integrating the newly added code with the project code based on the code semantics and the new requirements, and generating the target code corresponding to the software development project includes: Based on the historical requirements of the software development project and the project code, a project knowledge base corresponding to the software development project is generated. Based on the project knowledge base and the new requirements, generate the latest knowledge base corresponding to the software development project; Using the preset project semantic model based on the latest knowledge base, the newly added code and the project code are semantically parsed to obtain the code semantics. Based on the semantic matching degree between the code semantics and the newly added requirement, the newly added code and the project code are integrated to generate the target code.
3. The project code generation method as described in claim 2, characterized in that, The preset project semantic model includes a component dependency relationship model, a capability invocation relationship model, a data flow propagation relationship model, and a security boundary constraint model; The step of using the preset project semantic model based on the latest knowledge base to perform semantic analysis on the newly added code and the project code to obtain the code semantics includes: Using the component dependency model, the reference relationships between different components in the newly added code and the project code are identified based on the latest knowledge base, and the project structure semantic information corresponding to the newly added code and the project code is parsed. Using the capability call relationship model, based on the latest knowledge base, the function call expressions in the newly added code and the project code are identified and normalized for matching to determine the function call mapping relationship between the newly added code and the project code. Based on the function call mapping relationship, the common encapsulation semantic information corresponding to the newly added code and the project code is parsed. Using the data flow propagation relationship model, the data source points and data output points corresponding to the transmitted data in the newly added code and the project code are identified based on the latest knowledge base, and the semantic information of the data propagation link corresponding to the newly added code and the project code is analyzed; Using a security boundary constraint model, the code boundary attributes in the newly added code and the project code are identified based on the latest knowledge base, and the code security semantic information corresponding to the newly added code and the project code is parsed.
4. The project code generation method as described in claim 3, characterized in that, The process of integrating the new code with the project code based on the semantic matching degree between the code semantics and the new requirement to generate the target code includes: Based on the semantic matching degree between the code semantics and the new requirement, the code insertion position of the new code in the project code is determined; According to the location where the code was added, the newly added code and the project code are integrated to obtain the integrated project code; Based on the project structure semantic information, the common encapsulation semantic information, the data propagation link semantic information, and the code security semantic information, the integrated project code is verified, and the code verification result corresponding to the integrated project code is determined. When the code verification result is successful, the integrated project code is identified as the target code.
5. The project code generation method as described in claim 4, characterized in that, The step of integrating the newly added code and the project code according to the added location to obtain the integrated project code includes: Based on the requirement document for the new requirements, a traceability identifier is generated for the new code. The new code includes code snippets generated by an AI model based on the requirement document. The traceability identifier is used to perform fragment-level structured marking on the new code. Add the new code at the specified code addition location, and add the source identifier corresponding to the new code at the start and end positions of the code addition location, respectively, to obtain the integrated project code.
6. The project code generation method as described in claim 4, characterized in that, The step of conducting a release risk assessment on the target code and determining the release risk level corresponding to the target code includes: Based on the code verification results and the code development specifications corresponding to the software development project, the release risk assessment indicators corresponding to the target code are determined. The release risk assessment indicators are graded and quantified according to the risk quantification rules corresponding to the software development project to determine the release risk level corresponding to the target code.
7. The project code generation method as described in claim 1, characterized in that, The step of determining the release access control policy for the target code according to the release risk level includes: Based on the project release rules corresponding to the software development project, determine the release access control strategy corresponding to the release risk level; Generate the access control notification corresponding to the access control policy.
8. A project code generation device, characterized in that, include: The acquisition module is used to acquire the project code of the software development project, as well as the new code corresponding to the new requirements of the software development project; The generation module is used to parse the code semantics of the project code and the newly added code using a preset project semantic model, integrate the newly added code and the project code based on the code semantics and the new requirements, and generate the target code corresponding to the software development project. The target code is the project code after updating the project version for the new requirements. The assessment module is used to assess the release risk of the target code and determine the release risk level corresponding to the target code; The determination module is used to determine the release access control policy for the target code according to the release risk level.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the project code generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the project code generation method as described in any one of claims 1 to 7.