A fully automated code programming method and system based on a large model
By adopting a fully automated code programming method based on a large model, the entire process from multimodal requirements to executable programs is automated, solving the problem of missing closed loop in the generation-compilation-execution-evaluation of existing technologies, improving the success rate and consistency of code generation, and ensuring code quality and security compliance.
Patent Information
- Application Number
- CN202511748678.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2045-11-26
AI Technical Summary
Existing code generation technologies lack an end-to-end closed loop of generation-compilation-execution-evaluation-error correction, making it difficult to automatically generate and execute code under multimodal requirements. Furthermore, they lack automatic orchestration and dependency resolution for the target runtime environment, have vague success criteria, and provide unstructured error feedback, making it difficult to meet engineering quality and compliance requirements.
We adopt a fully automated code programming method based on a large model. Through multimodal requirement collection, parsing and standardized representation, we automatically select the development environment and generate code, compile and execute it, and combine structured evaluation and closed-loop error correction to ensure code quality and security compliance.
It achieves full-process automation from multimodal requirements to executable programs, supports the fusion and parsing of text, voice, image, and video, ensures the quality and security of code generation, provides structured feedback for efficient use by large models, and improves the success rate and consistency of generated code.
Smart Images

Figure CN121541867B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a fully automated code programming method and system based on a large model, belonging to the fields of software engineering and artificial intelligence technology. Background Technology
[0002] To lower the development threshold, automated code programming has developed into several technical routes: Domain-specific languages or model-driven engineering are customized for specific business scenarios, such as process orchestration, reports, interface protocols, or state machine descriptions. They emphasize "modeling before generation," generating functional code through preset structures or models. While the engineering implementation is controllable, it has poor adaptability to open requirements and dynamic environments. Secondly, constraint-based program synthesis and search / evolutionary software engineering can solve and optimize within formal or search spaces, possessing theoretical or coverage advantages, but suffer from problems such as susceptibility to search explosion and difficulty in integrating with real-world projects. Thirdly, deep learning-based Natural Language to Code (NL2Code) and Retrieval Augmentation (RAG) can generate code from natural language and improve API usage correctness, but they lack understanding of long-specification requirements and the ability to automatically verify and correct errors in real-world environments, leading to difficulties in practical application. Automated Program Repair (APR) focuses on generating patches after failures, making it difficult to implement complete requirements from scratch. Finally, while the large-scale interactive assistant and tool enhancement agent have initially formed a "generate, execute, and regenerate" closed loop, the feedback is mostly unstructured logs, the environment is not reproducible, and the success determination process lacks unified acceptance criteria. Although the exploration from multimodal to code can extract intent from voice / screenshots / videos, it is not yet deeply coupled with building, testing, and closed-loop error correction. Overall, existing solutions generally lack an end-to-end closed loop encompassing multimodal requirements, standardized representation, reproducible environments, automated testing and measurement, structured backfeedback, and self-iterative optimization, making it difficult to stably produce executable programs that meet engineering quality and compliance requirements.
[0003] Existing automatic code generation relies heavily on a single round of natural language to code (NL2Code) mapping, which has the following problems: (1) Lack of an end-to-end generation-compilation-execution-evaluation-error correction closed loop, requiring manual reading of error messages and rewriting of prompts; (2) Lack of automatic orchestration and dependency resolution for the target runtime environment, which can easily lead to failure due to SDK (Software Development Kit) version, permission or dependency conflicts; (3) The criteria for success are vague and there is a lack of automated testing and indicator evaluation mechanisms; (4) Error feedback is mostly unstructured long logs, which is not conducive to the effective absorption and iteration of large models.
[0004] Therefore, there is an urgent need for a fully automated programming method and system that supports multimodal requirement analysis, can automatically generate and execute code, and continuously correct and optimize based on structured feedback. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a fully automated code programming method based on large models (Automatic Code Programming Driven by Large Models, ACPLM), which automates the entire process from multimodal requirements to executable programs: automatically parsing requirements, automatically selecting languages and toolchains, generating code, automatically compiling / deploying, automatically executing and evaluating, feeding structured results back into the large model for error correction, until the requirements are met or the termination conditions are reached.
[0006] The present invention also provides a fully automated code programming system based on a large model.
[0007] Terminology Explanation: 1. Automatic Speech Recognition (ASR): The process of automatically converting acoustic signals (speech waveforms sampled by a microphone) into readable text, which typically includes acoustic modeling, language modeling, and decoding.
[0008] 2. Optical Character Recognition (OCR): A technology that detects and recognizes text from image / video frames, including text detection, layout analysis, and character / word line recognition, and can be extended to table structuring and formula recognition when necessary.
[0009] 3. Target or process identification: Locate and classify target objects in images / videos, identify interface elements or chart types, convert visual objects into executable constraints related to requirements, and automatically transcribe user demonstration videos or GUI operations into executable functional processes, and record them as program use cases and acceptance items.
[0010] 4. Semantic summarization: Compresses long-term or multimodal inputs (text / speech / image / video) into concise expressions that retain key information. It can be extractive (extracting key sentences / keywords) or generative (abstract generalization / multimodal captions and descriptions).
[0011] The technical solution of this invention is as follows: A fully automated code programming method based on a large model includes: Step 1: Multimodal requirement collection, parsing, and normalized representation; Step 2: Automatic orchestration of the development environment; Step 3: Code candidate generation and quality inspection; Step 4: Compile / Build and Execute Automatically; Step 5: Structured evaluation and success determination; Step 6: Closed-loop error correction and self-optimization control; Step 7: Safety and compliance controls.
[0012] According to a preferred embodiment of the present invention, the specific implementation process of step 1 includes: Step 1.1: Receive input; receive at least one of text, voice, image, or video; Step 1.2: Parsing and Unified Representation: Perform Automatic Speech Recognition (ASR) on speech, and perform Optical Character Recognition (OCR), target or process recognition, and semantic summarization on images or videos to obtain a unified text description; Step 1.3: Program Specification Graph Construction: Based on the large model and domain vocabulary, the unified text description is mapped to a program specification graph (PSG).
[0013] A further preferred embodiment is the Program Specification Graph (PSG), which is a visual intermediate representation of the program specification, comprising a directed graph consisting of four types of specific nodes and two types of relational edges; wherein, the node set... Including functional nodes Data pattern node Constraint nodes With test intent node ,Right now Functional nodes clearly define the specific operations or core objectives that the program needs to achieve; data pattern nodes define the structure, type, or format specifications of input / output data; constraint nodes specify the rules and boundary conditions that the program must follow to run, execute functions, or use data; test intent nodes clearly define the goals to verify the achievement of the specifications; edge sets Including dependency edges With constraint relationship edge ,Right now Dependency edge With constraint relationship edge All are directed connections; dependency edges represent the existence, readiness, or execution of the starting node, which are necessary prerequisites for the ending node, while constraint edges represent the rules of the starting node, which directly restrict the behavior or result of the ending node.
[0014] According to a preferred embodiment of the present invention, step 2 includes the following specific implementation process: Step 2.1: Based on the program specification diagram, PSG automatically determines the target language and the SDK / library version and operating system image required for the runtime; it uses container technology to implement environment orchestration, encapsulating the language, runtime, dependencies and configuration into independent units to meet isolation requirements; Step 2.2: Automatically pull dependencies, prepare sample data, and simulate external APIs in an isolated sandbox / container; Step 2.3: Perform hash operations on the specific version information and environment configuration parameters of all dependencies to generate an environment snapshot that uniquely identifies the current environment state, including the dependency lock file, container fingerprint, and configuration hash. The dependency lock file is an immutable list that is parsed once and used to determine the versions and sources of all direct and transitive dependencies. The container fingerprint is used to uniquely identify the base image and its layer that hosts the operation. Specifically, the runtime environment is defined as E = (L, R, D, C), where E represents the final isolated and reproducible runtime environment, L is the target programming language, R is the runtime environment corresponding to the target programming language, D is the set of dependencies required for program execution, and C is the environment configuration parameters. At the same time, define environment snapshots This is used to store various configurations of the runtime environment; where Hash() represents the hash function, Dv is the set of specific version information of all dependencies, Cfg is the set of specific values of environment configuration parameters, and ∪ is the set union operation.
[0015] According to a preferred embodiment of the present invention, step 3 specifically includes the following steps: Step 3.1: Call the Large Language Model (LLM) to translate the Program Specification Graph (PSG) into a code framework and implementation, and use diversified decoding to generate multiple code candidates; Step 3.2: Perform static analysis, including syntax, type, and complexity, and rank the code candidates based on heuristic scoring; Syntax, type, and complexity are reduced to feature vectors and weighted to form a heuristic score. As shown below: ; in, For the first A positive quality indicator, For the first Each importance weight, For the first The severity of the defect, For the first The penalty weight of the item.
[0016] According to a preferred embodiment of the present invention, step 4 includes the following specific implementation process: Step 4.1: Automatically compile or build each code candidate, capturing compilation errors and warnings; Step 4.2: Automatically generate test artifacts based on the program specification diagram PSG; including unit tests, attribute tests, boundary / random data, deformation rules, performance and resource constraint scripts; Step 4.3: Execute the test suite and end-to-end acceptance test cases in the sandbox, and record the running logs, functional correctness, return values, standard outputs / outputs, coverage, performance, resource usage, and operational safety.
[0017] According to a preferred embodiment of the present invention, step 5 includes the following specific implementation process: Step 5.1: Summarize the runtime output, including: functional correctness, error category, minimum reproducibility, coverage gap, stack trace summary, abstract syntax tree location, and unmet acceptance criteria, into a log refiner for structured feedback; Step 5.2: Determine whether the acceptance criteria and thresholds based on PSG are successful; if successful, output the product and solidify the environmental snapshot.
[0018] According to a preferred embodiment of the present invention, step 6 includes the following specific implementation process: Step 6.1: Closed-loop error correction: If the acceptance criteria are not met, the differences between the compilation / run log, stack trace and abstract syntax tree are transformed into structured feedback and historical attempt summaries with embedded prompt words, and LLM is called again to generate patches and new candidate refactoring schemes; Step 6.2: Search strategy: Use priority search or bundle search and majority voting strategy to find the best option within a finite number of iterations.
[0019] Step 6.3: Stop rule: Repeat steps 6.1 to 6.2 until a success determination is reached, the acceptance criteria are met, or the iteration limit is reached, then the process terminates.
[0020] A further preferred approach employs a beam search and majority voting strategy to find the optimal solution within a finite number of iterations; including: Setting the beam width in beam search K The candidate solution set collected iteratively is The set of automatic validators is Each validator v For candidates s Give a score A hard assertion is acceptable. Continuous indices are normalized to monotonic values. ; Assign a trusted weight to each validator And satisfy The iterative process focuses only on Top- K A number of candidate solutions are used to control the search size, along with a preset maximum number of iterations. T By establishing finite constraints, the support of all iterative candidate solutions is ultimately calculated using a majority voting strategy. Vote(s) : ; The set of candidate solutions collected through all iterations is: ; Subsequently, the first T The set of candidate solutions after the next iteration The solution with the highest support is determined as the optimal solution. : ; in, Argmax To select the largest Vote(s) The index position; The memory cache stores error signatures and repair prompt templates in a targeted manner. Before each candidate solution is generated or an operation is performed, the cache is queried to directly filter the recorded error items, thus avoiding repeating the same mistakes from the source.
[0021] According to a preferred embodiment of the present invention, step 7 is specifically implemented as follows: Step 7.1: Perform compliance checks on external dependencies and licenses, including API whitelisting, network / file system minimum permissions, sensitive information masking, and key proxying; Step 7.2: Conduct license and third-party compliance checks; Step 7.3: If the output does not conform to the rules, block the output and provide alternative implementation suggestions.
[0022] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the above-described fully automated code programming method based on a large model.
[0023] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described fully automated code programming method based on a large model.
[0024] A fully automated code programming system based on a large model, comprising: The multimodal parsing module is configured to: collect, parse, and normalize multimodal requirements. The environment orchestration module is configured as follows: automatic development environment orchestration; The code generation module is configured for: code candidate generation and quality verification; The build and execution module is configured as: compile / build and auto-execute; The evaluation and judgment module is configured as: structured evaluation and success judgment; The closed-loop error correction and self-optimization control module is configured to convert the differences between logs, stack traces and AST into structured feedback. The optimized control module is configured as: closed-loop error correction and self-optimization control; The security and compliance module is configured as: security and compliance control.
[0025] Compared with the prior art, the present invention has at least the following advantages: 1. Full-modal to code: Supports the fusion and parsing of text, voice, image, and video, and automatically extracts program specifications and acceptance criteria; 2. End-to-end closed loop: Automatic generation, compilation, execution, evaluation and error correction, without manual intervention in log interpretation and prompt word rewriting; 3. Reproducibility and portability: Automatic environment orchestration and snapshot fixing ensure consistent results across machines; 4. Robust error correction: Transforms compilation / runtime / semantic / performance issues into structured feedback for efficient use by LLM, and improves the success rate by combining bundle search and majority voting; 5. Measurable quality and safety: Coverage, performance, and compliance checks are incorporated into success criteria, ensuring controllable output quality; 6. Scalable: Incremental learning of the knowledge base and memory of error signatures make it stronger the more it is used. Attached Figure Description
[0026] Figure 1 A flowchart illustrating a fully automated code programming method based on a large model; Figure 2 A flowchart illustrating the specific implementation of a fully automated code programming method based on a large model; Figure 3 This is a schematic diagram of the modal performance (success rate SR@10m / TTAS median). Detailed Implementation
[0027] The present invention will be further defined below with reference to the accompanying drawings and embodiments, but is not limited thereto.
[0028] Example 1 A fully automated code programming method based on a large model, such as Figure 1 As shown, it includes: Step 1: Multimodal requirement collection, parsing, and normalized representation; Step 2: Automatic orchestration of the development environment; Step 3: Code candidate generation and quality inspection; Step 4: Compile / Build and Execute Automatically; Step 5: Structured evaluation and success determination; Step 6: Closed-loop error correction and self-optimization control; Step 7: Safety and compliance controls.
[0029] Example 2 The difference between the fully automated code programming method based on a large model described in Example 1 and the method described in Example 1 is as follows: like Figure 2 As shown, the specific implementation process of step 1 includes: Step 1.1: Receive input; receive at least one of text, voice, image, or video; Step 1.2: Parsing and Unified Representation: Perform Automatic Speech Recognition (ASR) on the speech, and Optical Character Recognition (OCR), target or process recognition, and semantic summarization on the image or video to obtain a unified text description; Step 1.3: Program Specification Graph Construction: Based on the large model and domain vocabulary, the unified text description is mapped to a Program Specification Graph (PSG). This specifically includes:
[0030] First, the unified text description is standardized (sentence segmentation, reference resolution, and standardization of units and time / path). Subsequently, requirements are extracted using a three-layer semantic parsing framework of intent, entity, and constraint. The intent layer extracts target functions and core operational verbs; the entity layer identifies input / output data, target objects, external user program interfaces (APIs) or files, and runtime environment elements; and the constraint layer parses boundary conditions, performance, security, compliance metrics, and interaction restrictions. The parsing results are aligned with a domain lexicon or ontology to achieve synonym normalization and ambiguity resolution (e.g., unifying "graph," "chart," and "bar chart" as visual objects, and quantifying "batch processing" as concurrency or throughput thresholds). Based on this, nodes are generated and populated according to a predefined PSG pattern: functional nodes, data nodes, interface nodes, constraint nodes, test intent nodes, and environment dependency nodes. Edges are then generated according to semantic relationships and their types are labeled. Subsequently, acceptance criteria and default parameters are automatically completed based on explicit statements and empirical rules, forming a structured PSG with attributes (including I / O types, parameter values, thresholds, fault tolerance, and fallback strategies), with confidence levels and clarification prompts for uncertainties.
[0031] Ultimately, the PSG serves as a direct, computable input for subsequent language and toolchain selection, code generation, test generation, and closed-loop error correction.
[0032] The Program Specification Graph (PSG) is a visual intermediate representation of the program specification, consisting of a directed graph comprising four types of specific nodes and two types of relational edges; where the node set... Including functional nodes Data pattern node Constraint nodes With test intent node ,Right now Functional nodes clearly define the specific operations or core objectives that the program needs to achieve; data pattern nodes define the structure, type, or format specifications of input / output data; constraint nodes specify the rules and boundary conditions that the program must follow to run, execute functions, or use data; test intent nodes clearly define the goals to verify the achievement of the specifications; edge sets Including dependency edges With constraint relationship edge ,Right now Dependency edge With constraint relationship edge All are directed connections; dependency edges represent the existence, readiness, or execution of the starting node, which are necessary prerequisites for the ending node, while constraint edges represent the rules of the starting node, which directly restrict the behavior or result of the ending node.
[0033] The specific implementation process of step 2 includes: Step 2.1: Based on the program specification diagram PSG, automatically determine the required SDK / library versions and operating system images for the target language and runtime (such as Python / Java / JS); implement environment orchestration through container technology (such as Docker, Kubernetes), encapsulating the language, runtime, dependencies, and configuration into independent units to meet isolation requirements; specifically, environment orchestration is automatically completed by a closed-loop process of decision-making, building, and running: First, the system extracts functional objectives, peripheral platform constraints (such as GPU, target operating system, CPU architecture), performance and security thresholds, and license restrictions from PSG, and combines them with the built-in environment configuration (language × runtime × SDK version × base image × hardware availability) to form a constraint-solving problem; then, it performs a search with priority given to satisfiability, second-best performance, and weighted by ecosystem availability and compliance, to obtain the target language and runtime (e.g., Python 3.11 + CUDA 12.2, or Java 21 + Temurin JRE) and the corresponding operating system base image.
[0034] During the build phase, the system generates container blueprints in real time according to the solution: selects a streamlined base image, creates a non-root user, minimizes the system package, sets a read-only root file system, mounts a temporary write layer, injects environment variables and configuration files (such as SDK path, certificate, region and time zone) by PSG, precompiles local extension dependencies when necessary, and performs image size reduction and vulnerability scanning after completion. The system outputs the image, lock files and build trace as an environment snapshot.
[0035] During the runtime phase, the scheduler creates a one-time sandbox using Docker (container technology) or Kubernetes (container orchestration architecture). The container entry script is uniformly encapsulated, compiled, tested end-to-end, and acceptance metrics are collected. Test artifacts and logs are returned via volumes or auxiliary containers. If compilation or runtime fails, the system automatically adjusts the blueprint based on structured errors (dependency conflicts, incompatible application interfaces, missing libraries, insufficient permissions, etc.) (e.g., switching minor versions of the base image, replacing application interfaces, adding system packages or permission declarations) and triggers a rapid rebuild until a stable environment image that meets the PSG acceptance criteria is obtained. This encapsulates language, runtime, dependencies, and configuration into reproducible, traceable, and strongly isolated independent units.
[0036] Step 2.2: Automatically pull dependencies, prepare sample data, and simulate external APIs in an isolated sandbox / container; Specifically, upon receiving the PSG, the environment orchestrator first selects the minimum available base image, pulls and verifies the signature and software bill of materials from a trusted image repository, then creates a fully isolated namespace and controls quotas, enables a read-only root file system, opens a few writable mount points, configures a minimum set of capabilities, and distinguishes between build-time and runtime containers to reduce supply chain risks and narrow the attack surface. The dependency resolver determines the exact version based on the PSG or existing lock files, prioritizing the use of enterprise private proxy repositories and local read-only caches to improve reproducibility and pull speed. After installation, a dependency list and hash snapshot are generated, and vulnerability and license scans are performed, blocking non-compliance. Finally, an environment snapshot is generated for subsequent reproduction and rollback.
[0037] Secondly, sample data and test artifacts are automatically generated by the test generator. Based on the input patterns and acceptance criteria in the PSG, synthetic samples are generated, covering boundary, extreme, and random distributions. Units and end-to-end test scripts and resource quotas (timeout, CPU / memory limits) are generated simultaneously. Finally, external APIs are virtualized as services within the sandbox to achieve testability and controllability. Contract tests are prioritized based on existing open-source standards; if no contract exists, simulated endpoints are built using recording, playback, or rule-driven methods, injecting latency and error codes according to scenarios. Then, the target domain name is transparently mapped to a stub address via the container's DNS, ensuring smooth operation in the simulated environment without code modification.
[0038] Step 2.3: Perform hash operations on the specific version information and environment configuration parameters of all dependencies to generate an environment snapshot that uniquely identifies the current environment state. This includes the dependency lock file, container fingerprint, and configuration hash. The dependency lock file is an immutable list that is parsed once and used to determine the versions and sources of all direct and transitive dependencies. The container fingerprint is used to uniquely identify the base image and its layer that hosts the program. A stable fingerprint can be obtained by using hierarchical digest aggregation. Any change in any layer or package will cause a change in the fingerprint, thereby reflecting changes in the dependency environment in a timely manner to ensure the reproducibility of the program.
[0039] Specifically, the runtime environment is defined as E = (L, R, D, C), where E represents the final isolated and reproducible runtime environment, L is the target programming language (such as Python, Java, C++, etc.), R is the runtime environment corresponding to the target programming language (such as Python interpreter, JRE), D is the set of dependencies required for program execution (such as third-party libraries, tool components), and C is the environment configuration parameters (such as port, resource limits, path settings). At the same time, define environment snapshots This is used to store various configurations of the runtime environment; where Hash() represents a hash function (such as SHA-256), Dv is a collection of specific version information of all dependencies (such as requests 2.31.0, Spring Boot 3.2.0), Cfg is a collection of specific values for environment configuration parameters, and ∪ is the union of sets. It is used to integrate dependency versions and configuration information into a unified input, ensuring that the hash result uniquely corresponds to the environment state, thereby achieving accurate environment reproduction.
[0040] The specific implementation process of step 3 includes: Step 3.1: Call the Large Language Model (LLM) to translate the Program Specification Graph (PSG) into a code framework and implementation, and use diverse decoding methods (such as temperature / Top-k / Top-p) to generate multiple code candidates; In implementation, the system first maps the PSG into structured generation instructions and embeds templated prompts to assemble them: the pre-system instructions limit the target language / runtime and security policy, the task paragraphs are expanded with key PSG fields, and the output paragraphs are strictly limited by syntax constraints and stop characters to only return code. Then, the LLM is called to adopt a two-stage generation approach: the first stage produces the project architecture and main file or function signature, and the second stage sequentially fills in the implementation details and test cases. To obtain diverse candidates, the system runs multiple decoding strategies in parallel: grid / step values are taken for temperature, top-k, and top-p (e.g., T∈{0.2,0.5,0.8}, k∈{20,50}, p∈{0.8,0.95}), and different few-sample examples and prompt variations are combined. After generation, each candidate undergoes machine-readable post-processing: parsing into an abstract syntax tree to check syntactic integrity and import dependency consistency, and performing static analysis scoring. The metadata (decoding hyperparameters used, referenced knowledge fragments, and covered PSG entries) is sorted according to the comprehensive score to form multiple code candidates.
[0041] Step 3.2: Perform static analysis, including syntax, type, and complexity, and rank the code candidates based on heuristic scoring; Static analysis is triggered after each code candidate is generated: first, the source code is normalized (formatted, dependency resolution, entry point identification), then lexical / syntactic analysis is performed using the corresponding language front-end to construct an abstract syntax tree and symbol table; based on this, type analysis is performed: compile-time type checking is performed for statically typed languages, and type hints and convention-driven type inference and interface consistency checks are used for dynamic languages to locate unbound symbols, nullability risks, and call signature mismatches; control flow / data flow analysis is performed in parallel to calculate maintainability indicators such as cyclomatic complexity, maximum nesting depth, number of paths, function / file size, and duplication rate; syntax, type, and complexity are reduced to feature vectors and weighted to form a heuristic score. As shown below: ; in, For the first A positive quality indicator, For the first Each importance weight, For the first The severity of the defect, For the first The penalty weights for each item are determined. Candidates are then sorted by score and filtered using a threshold. If necessary, minimum patch suggestions are generated or highly similar / high-risk candidates are directly eliminated to reduce failure costs in subsequent compilation and execution stages and improve the first-pass yield.
[0042] The specific implementation process of step 4 includes: Step 4.1: Automatically compile or build each code candidate, capturing compilation errors and warnings; Step 4.2: Automatically generate test artifacts based on the program specification diagram PSG; including unit tests, attribute tests, boundary / random data, metamorphic rules, performance and resource constraint scripts; Specifically, the system first unifies the functional nodes, data patterns (type, value range, distribution), constraints (correctness, security, performance, resources) and acceptance criteria in the PSG into an intermediate representation of the test plan, and determines the test framework and execution environment accordingly, and generates an executable test blueprint for each functional unit. Subsequently, the blueprint is instantiated into specific use cases and scripts: unit tests automatically construct simulations of inputs, stubs, and external dependencies based on function / interface signatures and examples and preconditions and postconditions provided by PSG; attribute tests translate explicit or derivable invariants in PSG into repeatable attribute assertions and use a controlled random generator to sample large-scale inputs according to type and constraints; boundary / random data derives minimum / maximum, null / missing, extreme length, illegal encoding, and other boundary points from data patterns and value ranges, and then expands them into random clusters using stratified or biased sampling to improve coverage and failure detection probability; transformation rules are derived from equivalent transformations and invariant relations of PSG (such as scaling, rearrangement, noise injection, format transformation), the system first runs the base example, then transforms the input and applies the corresponding invariant judgments or equality relations to the output, so that it can still automatically check for errors when there is no explicit best answer. The performance and resource constraint scripts are automatically generated from the budget thresholds and scenario loads in the PSG: the test driver wraps the code under test in an isolated sandbox, embeds timing and counting probes, memory / handle / thread monitors and I / O statistics, sets container-level quotas (CPU quota, memory limit, network / disk speed), and collects steady-state metrics according to repeated runs and warm-up strategies; the script finally provides a structured report with assertions of whether a violation has occurred, and outputs coverage, minimum reproducible input, and failure details for the closed-loop error correction module to backtrack. The entire process remains reproducible and is automatically linked in the generation, execution, and evaluation stages, forming a complete and scalable test artifact flow from PSG to unit / attribute / boundary-random / variant rules and performance resource scripts.
[0043] Step 4.3: Execute the test suite and end-to-end acceptance test cases in the sandbox, and record the running logs, functional correctness, return values, standard outputs / outputs, coverage, performance, resource usage, and operational safety.
[0044] Specifically, once the code enters the sandbox, it is uniformly started by the execution wrapper. The wrapper attaches probes at the process boundary: intercepting and buffering standard output and standard error streams, recording exit codes and uncaught exceptions; enabling coverage and call tracing (such as statement / branch / function granularity) at the language layer or bytecode layer, while registering high-precision timers and system-level samplers; enabling audit hooks for peripheral and network access, recording domain names, ports, and access directions and comparing them with a whitelist, triggering a violation and immediately interrupting and marking it as a security failure.
[0045] Test execution proceeds in two layers: unit and attribute boundary test cases are first run in batches within the same sandbox session to quickly identify compilation and semantic defects; then, an end-to-end acceptance flow is initiated as needed, replaying multi-step interactions or data pipelines that closely resemble user scenarios, and replacing real dependencies with service virtualization when necessary to ensure controllability. At the end of each test case, assertion results, return values, and key intermediate outputs are compared against acceptance criteria; simultaneously, coverage thresholds, performance, and resource constraints are used as conditions for judgment, and failure is declared if the criteria are not met.
[0046] The specific implementation process of step 5 includes: Step 5.1: Summarize the runtime output, including: functional correctness, error category, minimum reproducibility, coverage gap, stack trace summary, abstract syntax tree location, and unmet acceptance criteria, into a log refiner for structured feedback; Specifically, the log refiner first collects and aligns the compilation, testing, and runtime logs and coverage data on a unified timeline, performing noise reduction, anonymization, and context completion. To obtain the minimum reproducible test case, parameter reduction and replay verification are performed on the first failed test case to obtain the minimum input and steps that can reliably trigger the same error signature. Simultaneously, the system compares the current coverage with the threshold, identifies uncovered functions / branches, and generates a non-compliance list by comparing each acceptance criterion in the PSG. Finally, this information is organized into a structured feedback object, including error type and root cause, minimum reproducible code snippet, stack trace summary, abstract syntax tree location slice, coverage gap, unmet acceptance criteria, and remediation suggestions. This generates a large input model based on the exception type, after secondary anonymization and embedding of a prompt template, driving subsequent automatic repair and retries.
[0047] Step 5.2: Determine whether the process is successful based on the PSG's acceptance criteria and thresholds (e.g., all required assertions pass, coverage, latency, and security). If successful, output artifacts (code, binary, image, etc.) and solidify the environment snapshot.
[0048] Specifically, the system first compiles the acceptance criteria in the PSG into an executable inspection plan, that is, converting functional requirements into assertions and use cases, and converting coverage, latency, resources, and security into quantifiable thresholds. Then, candidate programs are built and run in an isolated sandbox, collecting assertion results, coverage, latency and resource peaks, file access traces, etc. If successful, artifacts (source code / binary / image / report) are output and archived, while an environment snapshot is fixed, including freezing dependencies and versions, and recording the image environment status; if unsuccessful, the evidence is refined into structured feedback (error category, abstract syntax tree location, items not reaching the threshold, and remediation suggestions) and fed back to the model for the next round of verification.
[0049] The specific implementation process of step 6 includes: Step 6.1: Closed-loop error correction: If the acceptance criteria are not met, the differences between the compilation / run log, stack trace and abstract syntax tree are transformed into structured feedback and historical attempt summaries with embedded prompt words, and LLM is called again to generate patches and new candidate refactoring schemes; When automated tests fail, the system first analyzes the compilation / runtime logs and stack traces, extracting the error type, triggering conditions, minimum reproducibility examples, and affected code locations and abstract syntax tree nodes. It then establishes a correspondence between these and unmet acceptance criteria in the PSG (Power-Only Group), forming structured feedback. Simultaneously, it generates a historical attempt summary, recording attempted fixes, failure signatures, and effective changes to avoid repeating the same mistakes. Subsequently, the system embeds this information into the LLM context (including problem statements, environment fingerprints, boundary conditions, etc.) with constraint hints, along with failed test cases / assertions, requiring the LLM to generate several candidate minimum fix patches or refactoring solutions. For each candidate, the system automatically applies the patch, rebuilds, and retests; if the requirements are still not met, it updates the failure signatures and memory cache, and continues iterating using bundle search, majority voting, or early stopping rules. This achieves a closed-loop self-optimization process from error, feedback, fix to verification until all acceptance assertions pass or the iteration limit is reached.
[0050] Step 6.2: Search Strategy: Employ priority search or bundle search combined with majority voting to find the optimal solution within a finite number of iterations. Support memory caching to avoid duplicate errors.
[0051] Specifically, after each round of automatic generation and testing, candidate solutions are scored, and the most promising solution is retained using either heuristic prioritization or bundle search. The system first calculates a priority score for each candidate based on metrics such as functional pass rate, coverage, performance, and security. When using priority search, the candidate with the highest score is always expanded first. Subsequently, when using bundle search, the top-scoring candidate is retained. KThe system iterates through multiple candidates in a finite number of iterations. To improve robustness, the system tests multiple independent candidates generated in the same round or several adjacent rounds and uses majority voting to determine the outcome: convergence is confirmed only when a majority of candidates simultaneously meet the acceptance criteria under independent environment snapshots, thus reducing the risk of misjudgment due to accidental success or environmental fluctuations. Simultaneously, a memory cache is maintained to extract compile errors, runtime anomalies, or unmet acceptance criteria into matchable error patterns. Targeted fixes are automatically injected in subsequent iterations, and candidates triggering known error patterns are either downgraded or directly excluded to avoid repeatedly exploring the same failure paths.
[0052] Step 6.3: Stop rule: Repeat steps 6.1 to 6.2 until a success determination is reached (such as the code improving test accuracy, meeting latency requirements, etc.), the acceptance criteria are met, or the iteration limit is reached, then terminate.
[0053] Optimization within a finite number of iterations is achieved using beam search and majority voting strategies; including: Setting the beam width in beam search K (The number of highest priority candidate solutions retained in each iteration), the set of candidate solutions collected in each iteration is: The set of automatic validators is Each validator v For candidates s Give a score A hard assertion is acceptable. Continuous metrics (such as latency and coverage) are normalized to monotonic values. ; Assign a trusted weight to each validator And satisfy The iterative process focuses only on Top- K A number of candidate solutions are used to control the search size, along with a preset maximum number of iterations. T To create finite constraints (avoiding overcomputation), the support of all iterative candidate solutions is finally calculated using a majority voting strategy. Vote(s) : ; The set of candidate solutions collected through all iterations is: ; Subsequently, the first T The set of candidate solutions after the next iteration The solution with the highest support is determined as the optimal solution. : ; in, Argmax To select the largest Vote(s) The index position; The memory cache stores error signatures (characteristic identifiers of failed operations) and repair prompt templates (templates for solutions that have been verified to be invalid). Before each candidate solution is generated or an operation is executed, the cache is queried to directly filter recorded error items, thus preventing repeated errors from the source.
[0054] The specific implementation process of step 7 includes: Step 7.1: Perform compliance checks on external dependencies and licenses, including API whitelisting, network / file system minimum permissions, sensitive information masking, and key proxying. First, limit available dependencies and callable external interfaces to a pre-approved set, locking versions and hashes. During the build and runtime phases, this is achieved through dependency resolvers and function calls respectively; any unauthorized imports or accesses are blocked and logged. Second, network / file system minimum permissions employ a default denial, on-demand permission strategy: only allow access to specified domains and ports, limiting outbound bandwidth / protocols; the file system operates in a read-only base layer and an isolated temporary writable zone, prohibiting the mounting of sensitive directories and the main directory. Third, sensitive information masking ensures that keys, passwords, tokens, and potentially sensitive personal / business data do not enter the main model context and logs, performing masking in prompts and logs. Finally, key proxying is implemented using logical identifiers and short-term credentials, injecting them into the minimum scope as needed during execution, retaining audit trails, and destroying them upon task completion. The above mechanisms work together to reduce attack surface and supply chain risks on the one hand, and transform unauthorized attempts into structured events that can be consumed by the feedback module on the other, thereby ensuring both security and compliance and not compromising the availability and reproducibility of closed-loop automation.
[0055] Step 7.2: Conduct license and third-party compliance checks; First, analyze the license type and source of each component and compare it with the built-in policy library. Simultaneously verify the availability and source of code snippets introduced by the large model and external resources, and assess whether obligations such as attribution, copyright notice retention, source code disclosure, and patent licensing are triggered.
[0056] Step 7.3: If non-compliance occurs, block the output and provide alternative implementation suggestions. The review results are output in the form of a machine-readable "compliance checklist," providing the required license documents, compliance annotations, and rectification suggestions. If high-risk items are found, the system will block the release and automatically try alternative solutions, such as rewriting code, replacing dependencies, or switching to a compatible version, or returning to the structured prompt-driven model for regeneration, until the preset compliance threshold is reached.
[0057] The evaluation settings for this embodiment are as follows: Task set: text requirements, speech-to-text requirements, image / interface screenshots, short video demonstrations; covering five categories: data processing, script tools, small web interfaces, visualization, and batch file processing.
[0058] Operating environment: Containerized sandbox (8 vCPU / 16GB RAM), with optional Python / Java / JS toolchains; minimum network permissions; dependency locking and environment snapshots enabled.
[0059] Iteration and hyperparameters: Maximum iterations = 6, bundle width = 3, majority voting enabled; Timeout and resource thresholds: 10 minutes per task / 2GB memory.
[0060] Comparison methods: B1 (single-round LLM generation + one-time execution), B2 (automatic execution + unstructured log backfeeding, no PSG and AST level positioning), ACPLM (the present invention's solution: PSG + environment snapshot + structured feedback + bundle search + voting).
[0061] The indicator is defined as follows: SR@10m: Success rate of meeting acceptance criteria within 10 minutes.
[0062] TTAS / 95 (Median / 95th percentile): Time-To-Acceptable-Solution, the time (in minutes) to meet the acceptance criteria.
[0063] FCPR: First-Compile Pass Rate.
[0064] Test pass rate or coverage: percentage of functional assertions that pass / statement coverage (when passing).
[0065] Peak resource: Peak memory usage (GB).
[0066] Reproducibility rate: The percentage of cases where the content can be successfully reproduced with a single replay across different hosts (based on environment snapshots).
[0067] Human intervention rate: The percentage of logs that require manual reading or modification of prompts (ideally 0%).
[0068] The overall results are shown in Table 1: Table 1
[0069] Experimental results show that, under the same time / iteration budget, SR is improved by 27–36 percentage points; the median TTAS is shortened by 11%, and the reproducibility rate increases from 52–64% to 73%, thanks to environmental snapshots and dependency locking; the manual intervention rate is reduced to 7%. Modal performance (success rate SR@10m / median TTAS) is as follows: Figure 3 As shown.
[0070] Experiments show that the proposed method is more significantly improved in multimodal scenarios, and PSG is particularly crucial for extracting acceptance criteria from visual / operational intentions.
[0071] The ablation experiments (removing a component item by item on the ACPLM baseline) are shown in Table 2: Table 2
[0072] The typical final execution result is recorded as follows: 1) CSV → Bar Chart: Language / Environment: Python 3.10 + pandas 2.2 + matplotlib, environment snapshot ID=sha256:… Iteration: 2 rounds (Round 1: Memory overflow → structured feedback prompts "block reading + dtype precision reduction") Final time: 1.9 minutes; peak memory usage: 0.7GB; coverage: 82%; all 12 assertions passed; deliverables: / artifacts / bar.png, requirements-lock.txt, test report.
[0073] 2) Video Operations → Batch Rename Script; Language / Environment: PowerShell; the sandbox only simulates the file system with minimal permissions.
[0074] Iteration: 3 rounds (Insufficient permissions in the first round; incorrect path matching in the second round; passed in the third round) Final time: 3.4 minutes; coverage: 75%; deliverables: rename.ps1 and user manual (automatically generated).
[0075] 3) AST Differential Repair TypeError: Initial error: TypeError: expected str, got bytes (locating AST opening mode inconsistency) Generate a minimal patch (4 lines of changes), passes second round; Final time: 1.2 minutes; coverage: 80%.
[0076] Example 3 A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the fully automated code programming method based on a large model as described in Embodiment 1 or 2.
[0077] Example 4 A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the fully automated code programming method based on a large model as described in Embodiment 1 or 2.
[0078] Example 5 A fully automated code programming system based on a large model, comprising: The multimodal parsing module is configured to: collect, parse, and normalize multimodal requirements. The environment orchestration module is configured as follows: automatic development environment orchestration; The code generation module is configured for: code candidate generation and quality verification; The build and execution module is configured as: compile / build and auto-execute; The evaluation and judgment module is configured as: structured evaluation and success judgment; The closed-loop error correction and self-optimization control module is configured to convert the differences between logs, stack traces and AST (Abstract Syntax Tree) into structured feedback. The optimized control module is configured as: closed-loop error correction and self-optimization control; The security and compliance module is configured as: security and compliance control.
Claims
1. A fully automated code programming method based on a large model, characterized in that, include: Step 1: Multimodal requirements collection, parsing, and standardized representation; including: mapping unified text descriptions to a Program Specification Graph (PSG) based on a large model and domain vocabulary; the PSG is a visual intermediate representation of the program specifications, including a directed graph with four types of specific nodes and two types of relational edges; the node set includes functional nodes, data pattern nodes, constraint nodes, and test intent nodes, and the edge set includes dependency edges and constraint edges; Step 2: Automatic development environment orchestration; including: automatically determining the target language and required SDK / library versions and operating system image based on the program specification diagram PSG; orchestrating and isolating the runtime environment through container technology; performing hash calculations on the specific version information and environment configuration parameters of all dependencies to generate an environment snapshot that uniquely identifies the current environment state for subsequent reproduction; Step 3: Code candidate generation and quality inspection; including: calling the Large Language Model (LLM) to translate the Program Specification Graph (PSG) into a code framework and implementation, generating multiple code candidates; performing static analysis on the generated code candidates, and ranking the code candidates based on heuristic scoring; Step 4: Compile / Build and Automated Execution; including: automatically compiling or building each code candidate; automatically generating test artifacts based on the program specification diagram PSG; executing in a sandbox and recording the output; Step 5: Structured evaluation and success determination; including: summarizing the operational output into structured feedback; determining success based on PSG acceptance criteria and thresholds; if successful, outputting the product and solidifying the environmental snapshot; Step 6: Closed-loop error correction and self-optimization control; including: if the acceptance criteria are not met, embed structured feedback and historical attempt summaries into prompt words, call LLM to generate patches and reconstruct new candidate solutions, use bundle search with limited bundle width to determine the optimal solution of the candidate solution set; memory cache stores error signatures and repair prompt templates in a targeted manner, and queries the cache before each generation of candidate solutions or execution of operations to directly filter the recorded error items; Step 7: Security and compliance controls; including: conducting compliance checks, blocking outputs if non-compliant, and providing alternative implementation suggestions.
2. The fully automated code programming method based on a large model according to claim 1, characterized in that, The specific implementation process of step 1 includes: Step 1.1: Receive input; receive at least one of text, voice, image, or video; Step 1.2: Parsing and Unified Representation: Perform Automatic Speech Recognition (ASR) on speech, and perform Optical Character Recognition (OCR), target or process recognition, and semantic summarization on images or videos to obtain a unified text description; Step 1.3: Program Specification Graph Construction: Based on the large model and domain vocabulary, the unified text description is mapped to a program specification graph (PSG); The Program Specification Graph (PSG) is a visual intermediate representation of the program specification, consisting of a directed graph comprising four types of specific nodes and two types of relational edges; where the node set... Including functional nodes Data pattern node Constraint nodes With test intent node , Functional nodes clearly define the specific operations or core objectives that the program needs to achieve; data pattern nodes define the structure, type, or format specifications of input / output data; constraint nodes specify the rules and boundary conditions that the program must follow to run, execute functions, or use data; test intent nodes clearly define the goals to verify the achievement of the specifications; edge sets Including dependency edges With constraint relationship edge , Dependency edge With constraint relationship edge All are directed connections; dependency edges represent the existence, readiness, or execution of the starting node, which are necessary prerequisites for the ending node, while constraint edges represent the rules of the starting node, which directly restrict the behavior or result of the ending node.
3. The fully automated code programming method based on a large model according to claim 1, characterized in that, The specific implementation process of step 2 includes: Step 2.1: Based on the program specification diagram, PSG automatically determines the target language and the SDK / library version and operating system image required for the runtime; it uses container technology to implement environment orchestration, encapsulating the language, runtime, dependencies and configuration into independent units to meet isolation requirements; Step 2.2: Automatically pull dependencies, prepare sample data, and simulate external APIs in an isolated sandbox / container; Step 2.3: Perform hash operations on the specific version information and environment configuration parameters of all dependencies to generate an environment snapshot that uniquely identifies the current environment state, including the dependency lock file, container fingerprint, and configuration hash. The dependency lock file is an immutable list that is parsed once and used to determine the versions and sources of all direct and transitive dependencies. The container fingerprint is used to uniquely identify the base image and its layer that hosts the operation. Specifically, the runtime environment is defined as E = (L, R, D, C), where E represents the final isolated and reproducible runtime environment, L is the target programming language, R is the runtime environment corresponding to the target programming language, D is the set of dependencies required for program execution, and C is the environment configuration parameters. At the same time, define environment snapshots This is used to store various configurations of the runtime environment; where Hash() represents the hash function, Dv is the set of specific version information of all dependencies, Cfg is the set of specific values of environment configuration parameters, and ∪ is the set union operation.
4. The fully automated code programming method based on a large model according to claim 1, characterized in that, The specific implementation process of step 3 includes: Step 3.1: Call the Large Language Model (LLM) to translate the Program Specification Graph (PSG) into a code framework and implementation, and use diversified decoding to generate multiple code candidates; Step 3.2: Perform static analysis, including syntax, type, and complexity, and rank the code candidates based on heuristic scoring; Syntax, type, and complexity are reduced to feature vectors and weighted to form a heuristic score. As shown below: ; in, For the first A positive quality indicator, For the first Each importance weight, For the first The severity of the defect, For the first The penalty weight of the item.
5. The fully automated code programming method based on a large model according to claim 1, characterized in that, The specific implementation process of step 4 includes: Step 4.1: Automatically compile or build each code candidate, capturing compilation errors and warnings; Step 4.2: Automatically generate test artifacts based on the program specification diagram PSG; including unit tests, attribute tests, boundary / random data, deformation rules, performance and resource constraint scripts; Step 4.3: Execute the test suite and end-to-end acceptance test cases in the sandbox, and record the running logs, functional correctness, return values, standard output / output, coverage, performance, resource consumption, and operational safety; The specific implementation process of step 5 includes: Step 5.1: Summarize the runtime output, including: functional correctness, error category, minimum reproducibility, coverage gap, stack trace summary, abstract syntax tree location, and unmet acceptance criteria, into a log refiner for structured feedback; Step 5.2: Determine whether the acceptance criteria and thresholds based on PSG are successful; if successful, output the product and solidify the environmental snapshot.
6. The fully automated code programming method based on a large model according to claim 1, characterized in that, The specific implementation process of step 6 includes: Step 6.1: Closed-loop error correction: If the acceptance criteria are not met, the differences between the compilation / run log, stack trace and abstract syntax tree are transformed into structured feedback and historical attempt summaries with embedded prompt words, and LLM is called again to generate patches and new candidate refactoring schemes; Step 6.2: Search strategy: Use priority search or bundle search and majority voting strategy to find the best option within a finite number of iterations; Step 6.3: Stop rule: Repeat steps 6.1 to 6.2 until a success determination is reached, the acceptance criteria are met, or the iteration limit is reached, then the process terminates. Optimization within a finite number of iterations is achieved using a beam search and majority voting strategy; including: Setting the beam width in beam search K The candidate solution set collected iteratively is The set of automatic validators is Each validator v For candidates s Give a score A hard assertion is acceptable. Continuous indices are normalized to monotonic values. ; Assign a trusted weight to each validator And satisfy The iterative process focuses only on Top- K A number of candidate solutions are used to control the search size, along with a preset maximum number of iterations. T By establishing finite constraints, the support of all iterative candidate solutions is ultimately calculated using a majority voting strategy. Vote(s) : ; The set of candidate solutions collected through all iterations is: ; Subsequently, the first T The set of candidate solutions after the next iteration The solution with the highest support is determined as the optimal solution. : ; in, Argmax To select the largest Vote(s) The index position; The memory cache stores error signatures and repair prompt templates in a targeted manner. Before each candidate solution is generated or an operation is performed, the cache is queried to directly filter the recorded error items, thus avoiding repeating the same mistakes from the source.
7. The fully automated code programming method based on a large model according to claim 1, characterized in that, The specific implementation process of step 7 includes: Step 7.1: Perform compliance checks on external dependencies and licenses, including API whitelisting, network / file system minimum permissions, sensitive information masking, and key proxying; Step 7.2: Conduct license and third-party compliance checks; Step 7.3: If the output does not conform to the rules, block the output and provide alternative implementation suggestions.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the fully automated code programming method based on a large model as described in any one of claims 1-7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the fully automated code programming method based on a large model as described in any one of claims 1-7.
10. A fully automated code programming system based on a large model, used to implement the fully automated code programming method based on a large model as described in any one of claims 1-7, characterized in that, include: The multimodal parsing module is configured to: collect, parse, and normalize multimodal requirements. The environment orchestration module is configured as follows: automatic development environment orchestration; The code generation module is configured for: code candidate generation and quality verification; The build and execution module is configured as: compile / build and auto-execute; The evaluation and judgment module is configured as: structured evaluation and success judgment; The closed-loop error correction and self-optimization control module is configured to convert the differences between logs, stack traces and AST into structured feedback. The optimized control module is configured as: closed-loop error correction and self-optimization control; The security and compliance module is configured as: security and compliance control.
Citation Information
Patent Citations
Large language model cue word automatic optimization method
CN120542583A
Code writing, checking and modifying method based on large model
CN120780347A
