Document synchronization method and apparatus for code change, and electronic device
By changing the capture engine and acceptance rules, and building a change-paragraph mapping list, the mapping problem between code changes and document synchronization was solved. This enabled automated verification and synchronization of code deployment and document synchronization, improving the accuracy and efficiency of document updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- QINGDAO JUSHANGHUI NETWORK TECH CO LTD
- Filing Date
- 2026-02-11
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies cannot establish a mapping relationship between code-level changes and document-level editable paragraphs, resulting in the separation of interface structure and interface behavior logic detection results, and making it impossible to achieve a unified document synchronization process and decision-making.
By monitoring code changes through a change capture engine, a unified change set is generated. Combining static analysis and dynamic behavior analysis, a change-paragraph mapping list is constructed. Based on acceptance rules, verification and decision-making are carried out to ensure that code deployment is synchronized with documentation.
It enables precise location of changes from abstract code to technical document paragraphs, forming a unified and feasible chain of evidence, ensuring synchronization between documents and code, and improving the synchronicity and quality assurance of document updates.
Smart Images

Figure CN122111495A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of distributed application technology, such as a document synchronization method device or electronic device for code changes. Background Technology
[0002] Currently, in modern software engineering practice, to meet the demands of rapid iteration, the concepts of DevOps (Development and Operations) and Docs-as-Code are widely adopted. This approach advocates for versioning documentation as if it were source code, and using automated pipelines for building, testing, and releasing to improve the quality and timeliness of documentation. Against this backdrop, a series of automated tools have emerged to ensure consistency between code and documentation.
[0003] To ensure consistency between code and documentation, relevant technologies employ interface signature detection schemes or behavioral consistency verification schemes, as well as documentation quality measurement and gate control schemes. Interface signature detection schemes detect changes in interface structure by comparing two versions of the interface definition file. Behavioral consistency verification schemes, represented by contract testing or document-driven testing, verify whether the code implementation conforms to predefined contracts or documentation specifications through automated testing. Documentation quality measurement and gate control schemes establish quality gates by checking the completeness and standardization of documentation.
[0004] In the process of implementing the embodiments of this disclosure, at least the following problems were found in the related art: While interface signature difference detection schemes can identify destructive and non-destructive changes by detecting interface structure and generate change logs, this interface detection method is limited to the structural level and cannot detect interface behavioral logic, let alone locate the modified document paragraphs. Behavioral consistency verification schemes, although capable of detecting interface behavioral logic, only output test results (pass or fail), failing to locate the modified document paragraphs. Document quality metrics and access control schemes cannot directly link to content update requirements caused by code changes. Therefore, these technologies possess the ability to detect interface structure or behavioral logic, but cannot establish a mapping relationship between code-level changes and document-level paragraphs to be edited. Furthermore, these technologies cannot simultaneously detect interface structure and behavioral logic, resulting in a separation between static interface signature analysis results and dynamic interface behavioral assertion results, failing to form a unified and feasible chain of evidence to jointly drive the document synchronization process and decision-making.
[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] To provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This summary is not intended as a general commentary, nor is it intended to identify key / important components or describe the scope of protection of these embodiments, but rather as a prelude to the detailed description that follows.
[0007] This disclosure provides a document synchronization method, apparatus, and electronic device for code changes, enabling precise location of abstract code changes to technical document paragraphs, forming a unified and feasible chain of evidence to jointly drive the document synchronization process and decision-making.
[0008] In some embodiments, the document synchronization method includes: in response to a code deployment request, monitoring code changes through a change capture engine and obtaining a unified change set; locating document paragraphs in the interface definition file according to the unified change set, constructing a change-paragraph mapping list and a document synchronization task; performing acceptance verification on the document synchronization task based on acceptance rules and obtaining verification results; and making a decision based on blocking conditions, the unified change set, the change-paragraph mapping list, and the verification results to determine whether to block code deployment and complete document synchronization.
[0009] In some embodiments, in response to a code deployment request, monitoring code changes and obtaining a unified changeset through a change capture engine includes: in response to a code deployment request, monitoring file objects of interface definition files through a static analysis engine to obtain change items; in response to a code deployment request, executing automated tests and monitoring interface behavior through a dynamic behavior analysis engine to obtain test results including interface behavior failure items; wherein, interface behavior failure items include assertion type and failure reason, failure association scope; encapsulating change items and interface behavior failure items to generate a unified changeset.
[0010] In some embodiments, the interface definition file is located according to a unified change set, and a change-paragraph mapping list and document synchronization task are constructed. This includes: preprocessing the interface definition file to obtain structured data; wherein the structured data is in paragraph form, and each paragraph corresponds to a unit index, and the unit index is paragraph metadata consisting of paragraph identifiers, text content, and heading levels; matching change items with the structured data to obtain matching results; obtaining the location paragraph identifier of the change item based on the matching results; constructing a mapping relationship between change items and location paragraph identifiers to generate a change-paragraph mapping list, and creating a document synchronization task corresponding to each mapping relationship.
[0011] In some embodiments, matching change items with structured data to obtain matching results includes: performing hard matching of change items with structured data to obtain template matching results; wherein the template matching results include template scores corresponding to different units; performing semantic matching of change items with structured data to obtain semantic matching results; wherein the semantic matching results include semantic scores corresponding to different units; and performing weighted processing on the template score and semantic score corresponding to each unit to obtain the unit confidence level corresponding to each unit.
[0012] In some embodiments, the matching result includes the unit confidence level corresponding to each unit; based on the matching result, the location paragraph identifier of the change item is obtained, including: selecting the maximum value of the unit confidence level corresponding to each unit as the candidate confidence level; determining the comprehensive confidence level based on the candidate confidence level and the location confidence level threshold; using the paragraph identifier in the unit index of the unit corresponding to the comprehensive confidence level as the location paragraph identifier of the change item; constructing a mapping relationship between the change item and the location paragraph identifier to generate a change-paragraph mapping list, including: constructing a mapping relationship between the change item and the location paragraph identifier and the comprehensive confidence level, and generating a change-paragraph mapping list.
[0013] In some embodiments, the change item includes a severity level; the change-paragraph mapping list is generated based on the mapping relationship between the change item and the location paragraph identifier and the overall confidence level; a decision is made based on the blocking conditions, the unified change set, the change-paragraph mapping list, and the verification results to determine whether to block code deployment and complete document synchronization, including: if the blocking conditions are met, determining to block code deployment and prompting to complete the document synchronization task; wherein, the blocking conditions include meeting some or all of the following conditions: the severity level of the change item is higher than the single-count level threshold and the overall confidence level corresponding to the change item is lower than the location confidence level threshold; the verification result corresponding to the document synchronization task is a failure; the severity level and value of all change items are higher than the cumulative level threshold.
[0014] In some embodiments, the document synchronization task is inspected and verified based on the acceptance rules to obtain the verification result, including: if the document synchronization task meets the acceptance rules, the verification result is determined to be passed; if the document synchronization task does not meet the acceptance rules, the verification result is determined to be failed; the acceptance rules include some or all of the conditions for meeting the coverage verification condition or the example executability verification condition and the link integrity verification condition.
[0015] In some embodiments, the document synchronization device includes: an interface monitoring module configured to monitor code changes and obtain a unified changeset through a change capture engine in response to a code deployment request; a document location module configured to locate document paragraphs in the interface definition file according to the unified changeset, construct a change-paragraph mapping list and a document synchronization task; a task verification module configured to perform acceptance verification on the document synchronization task based on acceptance rules and obtain verification results; and an access control module configured to make decisions based on blocking conditions, the unified changeset, the change-paragraph mapping list, and the verification results to determine whether to block code deployment and complete document synchronization.
[0016] In some embodiments, the document synchronization apparatus includes a processor and a memory storing program instructions, the processor being configured to execute the document synchronization method for code changes as described above when the program instructions are executed.
[0017] In some embodiments, the electronic device includes: an electronic device body; and a document synchronization device for code changes as described above, installed on the electronic device body.
[0018] The document synchronization method, apparatus, and electronic device for code changes provided in this disclosure can achieve the following technical effects: In response to a code deployment request, this embodiment first monitors code changes through a change capture engine to obtain a unified changeset. Static interface structure differences and dynamic interface behavior assertion results are aggregated to form a comprehensive and reliable chain of change evidence (i.e., the unified changeset), which is then used as part of the decision-making input. After obtaining the unified changeset, the interface definition files are located according to the unified changeset to construct a change-paragraph mapping list and a document synchronization task, achieving precise mapping from abstract code changes to physical document paragraphs. The document synchronization task is then inspected and verified based on acceptance rules, and the verification results are obtained. This transforms the update requirement into a structured task containing acceptance rules, achieving fully automated verification from "what to do" to "whether it's done correctly." Finally, based on blocking conditions, the unified changeset, the change-paragraph mapping list, and the verification results, a decision is made to determine whether to block code deployment and complete document synchronization, forming a flexible quality assurance system to ensure that documents and code remain synchronized. The embodiments of this disclosure can comprehensively capture the change evidence chain through the change capture engine, realize the accurate positioning of abstract code changes to technical document paragraphs, and also enforce the synchronization of code changes and document updates through a decision mechanism based on blocking conditions, so as to form a unified and feasible evidence chain to achieve document closed-loop driving.
[0019] The above general description and the description below are exemplary and illustrative only and are not intended to limit this application. Attached Figure Description
[0020] One or more embodiments are illustrated by way of example with reference to the accompanying drawings. These illustrations and drawings do not constitute a limitation on the embodiments. Elements having the same reference numerals in the drawings are shown as similar elements. The drawings are not to be scaled. And wherein: Figure 1 This is a schematic diagram of a document synchronization method for code changes provided in an embodiment of this disclosure; Figure 2 This is a schematic diagram of another document synchronization method for code changes provided in an embodiment of this disclosure; Figure 3 This is a schematic diagram of another document synchronization method for code changes provided in an embodiment of this disclosure; Figure 4 This is an application illustration of an embodiment of the present disclosure; Figure 5 This is a schematic diagram of a document synchronization device for code changes provided in an embodiment of this disclosure; Figure 6 This is a schematic diagram of another document synchronization device for code changes provided in an embodiment of this disclosure. Detailed Implementation
[0021] To provide a more detailed understanding of the features and technical content of the embodiments of this disclosure, the implementation of the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for illustrative purposes only and are not intended to limit the embodiments of this disclosure. In the following technical description, for ease of explanation, several details are used to provide a full understanding of the disclosed embodiments. However, one or more embodiments may still be implemented without these details. In other cases, well-known structures and devices may be simplified in their depiction to simplify the drawings.
[0022] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this disclosure described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion.
[0023] Unless otherwise stated, the term "multiple" means two or more.
[0024] In this embodiment of the disclosure, the character " / " indicates that the objects before and after it are in an "or" relationship. For example, A / B means: A or B.
[0025] The term "and / or" describes an association between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or A and B.
[0026] The term "correspondence" can refer to an association or binding relationship. The correspondence between A and B means that there is an association or binding relationship between A and B.
[0027] In this embodiment of the disclosure, the interface definition file is a standardized document used to clearly describe the interaction interfaces between software components, systems, or services. The interface definition file defines in detail the interface functions, interface inputs / outputs, calling methods, data formats, and other information to ensure that different modules or systems can communicate and collaborate correctly and effectively.
[0028] Combination Figure 1 As shown in the embodiments of this disclosure, a document synchronization method for code changes is provided, including: S01, the processor responds to code deployment requests by monitoring code changes through the change capture engine and obtaining a unified changeset.
[0029] In this step, the processor monitors code changes by modifying the capture engine, specifically by modifying the interface definition file and interface behavior. This achieves comprehensive monitoring of interface structure differences and interface behavior assertion structures.
[0030] S02, the processor locates document paragraphs in the interface definition file based on the unified changeset, and builds a changes-paragraph mapping list and document synchronization task.
[0031] S03, the processor performs acceptance verification on the document synchronization task based on the acceptance rules and obtains the verification result.
[0032] S04, the processor makes a decision based on the blocking conditions, unified change set, change-paragraph mapping list, and verification results to determine whether to block code deployment and complete document synchronization.
[0033] The document synchronization method for code changes provided in this disclosure responds to code deployment requests by first monitoring code changes through a change capture engine to obtain a unified changeset. Static interface structure differences and dynamic interface behavior assertion results are aggregated to form a comprehensive and reliable chain of change evidence (i.e., the unified changeset), which is then used as part of the decision-making input. After obtaining the unified changeset, the interface definition files are located according to the unified changeset to construct a change-segment mapping list and a document synchronization task, achieving accurate mapping from abstract code changes to physical document segments. The document synchronization task is then inspected and verified based on acceptance rules, transforming update requirements into structured tasks containing acceptance rules, thus achieving fully automated verification from "what to do" to "whether it's done correctly." Finally, a decision is made based on blocking conditions, the unified changeset, the change-segment mapping list, and the verification results to determine whether to block code deployment and complete document synchronization, forming a flexible quality assurance system to ensure that documents and code remain synchronized.
[0034] In summary, the embodiments of this disclosure can comprehensively capture the change evidence chain through the change capture engine, achieve precise positioning of abstract code changes to technical document paragraphs, and enforce the synchronization of code changes and document updates through a decision-making mechanism based on blocking conditions, so as to form a unified and feasible evidence chain to achieve document closed-loop driving.
[0035] Optionally, the change capture engine includes a static analysis engine and a dynamic behavior analysis engine.
[0036] The static analysis engine is used to monitor the core objects in the interface definition file.
[0037] In some alternative embodiments, the static analysis engine compares the core objects of the interface definition files before and after the code change to obtain the changes. These core objects include paths and methods, parameters, request bodies, responses, data schemas, and enumeration values.
[0038] Interface definition files and change items have a one-to-one or one-to-many mapping relationship. Change items include change type, change content, scope of impact, and severity level. Change types include destructive changes, compatibility changes, and enhancement changes. Change content is a detailed description of the change. Scope of impact refers to the path and method by which the change occurs. Severity level is the degree of impact generated based on the change type, and the degree of impact includes high, medium, and low. Destructive changes correspond to a high severity level, compatibility changes to a medium severity level, and enhancement changes to a low severity level.
[0039] It should be noted that there is a one-to-one or one-to-many mapping between change items and change types, a one-to-one mapping between change types and change content, and a one-to-one mapping between change items and severity levels. Specifically, when the core object in the interface definition file before and after the code change matches at least two change types, the static analysis engine determines the optional severity levels corresponding to all change types that the core object matches; the static analysis engine then determines the highest of the optional severity levels as the severity level of the change item. Thus, when a change matches multiple change types simultaneously, the highest severity level is taken as the severity rating of the change item.
[0040] The static analysis engine determines the severity level based on the adaptation results between the core objects in the interface definition file and the change type. As an example, if the core objects in the interface definition file before and after the code change are adapted to the deletion of existing interface paths or methods in a destructive change, the static analysis engine determines the severity level to be high. If the core objects in the interface definition file before and after the code change are adapted to the modification of parameter / field constraints in a compatibility change, the static analysis engine determines the severity level to be medium. If the core objects in the interface definition file before and after the code change are adapted to the fixing of errors in the documentation in an enhancement change, but this does not affect the actual behavior adaptation, the static analysis engine determines the severity level to be low. The change types and severity levels for each change item can be found in Table 1.
[0041] Table 1 Examples of Change Types and Severity Levels in Change Items
[0042] The dynamic behavior analysis engine is used to perform automated tests and monitor interface behavior.
[0043] In some optional embodiments, the dynamic behavior analysis engine is used to perform automated testing and monitor interface behavior, including: the dynamic behavior analysis engine running test cases to obtain the interface response corresponding to the interface request; the dynamic behavior analysis engine determining whether the interface response and interface request are compatible; and if the interface response and interface request are incompatible, the dynamic behavior analysis engine outputting interface behavior failure items. The interface behavior failure items include assertion type, failure reason, and failure association scope. Here, assertion type includes response structure mismatch or business rule validation failure, failure reason is the cause of assertion failure, and failure association scope is the interface and / or scenario where the assertion failed.
[0044] Combination Figure 2 As shown, in response to a code deployment request, the processor monitors code changes through a change capture engine and obtains a unified changeset, including: S11, the processor responds to the code deployment request by monitoring the file objects of the defined files through the static analysis engine monitoring interface to obtain the changes.
[0045] In this step, the change items include the change type and content, the scope of impact, and the severity level.
[0046] S12, in response to the code deployment request, the processor executes automated tests and monitors interface behavior through the dynamic behavior analysis engine, obtaining test results including interface behavior failure items. These failure items include assertion type, failure reason, and failure association scope.
[0047] S13, processor encapsulation changes and interface behavior failures, generate a unified changeset.
[0048] In this way, by constructing a unified change set, static differences in interface structure and dynamic failure results of interface behavior assertions are brought together to form a comprehensive and credible chain of change evidence, which serves as a unified input for location and decision-making.
[0049] Optionally, combined Figure 3 As shown, the processor locates document paragraphs in the interface definition file based on the unified changeset, constructs a changes-paragraph mapping list and a document synchronization task, including: S21, the processor preprocesses the interface definition file to obtain structured data. This structured data is organized by paragraphs, with each paragraph corresponding to a unit index. The unit index contains paragraph metadata consisting of the paragraph identifier, text content, and heading level. As an example, the paragraph metadata is api-path: / users / {ID},method: GET,section: request-example.
[0050] S22, the processor matches the changes with the structured data to obtain the matching results.
[0051] S23, the processor obtains the location segment identifier of the change item based on the matching result.
[0052] S24, the processor constructs a mapping relationship between change items and location paragraph identifiers to generate a change-paragraph mapping list, and creates a document synchronization task corresponding to each mapping relationship.
[0053] Therefore, before performing document paragraph location, this embodiment of the disclosure needs to preprocess the interface definition file to obtain structured data with paragraphs as units and each unit corresponding to a unit index, so as to facilitate document paragraph location. After preprocessing the interface definition file to obtain structured data, this embodiment of the disclosure matches the change items and the structured data to obtain matching results. Then, the location paragraph identifier of the change item is obtained according to the matching results. Finally, the mapping relationship between change items and location paragraph identifiers is constructed to generate a change-paragraph mapping list, and a document synchronization task corresponding to each mapping relationship is created. In this way, this embodiment of the disclosure can perform document paragraph location on the interface definition file based on a unified change set to construct a change-paragraph mapping list and document synchronization tasks, so as to achieve accurate mapping from abstract code changes to document physical paragraphs.
[0054] Optionally, the matching results include the cell confidence score for each cell. The processor matches the changes with the structured data to obtain the matching results, including: The processor performs a hard match between the changes and the structured data to obtain template matching results. These results include template scores for different units.
[0055] The processor performs semantic matching between the changes and the structured data to obtain semantic matching results. These results include semantic scores for different units.
[0056] The processor performs weighted processing on the template score and semantic score corresponding to each unit to obtain the unit confidence score for each unit.
[0057] Thus, this embodiment of the disclosure achieves template-based precise matching by performing hard matching between change items and structured data to obtain template matching results, and achieves semantic-based fuzzy matching by performing semantic matching between change items and structured data to obtain semantic matching results. Finally, the template score corresponding to each unit in the module matching results and the semantic score corresponding to each unit in the semantic matching results are weighted to obtain the unit confidence score corresponding to each unit, which helps to improve the accuracy of change item paragraph location.
[0058] Optionally, hard matching includes the following multi-level matching rules. The processor performs hard matching between the change items and the structured data to obtain template matching results, including: the processor performs hard matching between the change items and the structured data according to the priority order of the multi-level matching rules to obtain template matching results.
[0059] Multi-level matching rules include mandatory matching rules with priority from high to low, fine-grained matching rules, and related paragraph matching rules.
[0060] The mandatory matching rule is: both the interface path matching and the HTTP (Hypertext Transfer Protocol) method matching must be satisfied.
[0061] Specifically, API path matching means that the API path in the change item is exactly the same as the API path in the paragraph metadata. HTTP method matching means that the HTTP method in the change item is exactly the same as the HTTP method in the paragraph metadata.
[0062] The fine-grained matching rule is: after the mandatory matching rule is met, the specific paragraph is located based on the change type in the change item.
[0063] In some alternative embodiments, when the change type is a destructive change, the fine-grained matching rule is as follows: the section field in the paragraph metadata is request-parameters or query-parameters, path-parameters, and the text content of the paragraph contains the parameter names involved in the change.
[0064] In some alternative embodiments, when the change type is a compatibility change (such as modifying the requestBody structure), the fine-grained matching rule is as follows: the section field in the paragraph metadata is request-body or request-example, and the text content of the paragraph contains the field names involved in the change.
[0065] In some alternative embodiments, when the change type is a compatibility change (such as modifying a response field but maintaining backward compatibility), the fine-grained matching rules specifically include: the section field in the paragraph metadata is response-schema or response-example.
[0066] The associated paragraph matching rule is as follows: for paragraphs that have been matched by the mandatory matching rule and / or the fine-grained matching rule, find other paragraphs associated with the matched paragraphs.
[0067] In some alternative embodiments, when the paragraph matched by the forced matching rule is an example code paragraph, the associated paragraph matching rule is specifically: find other paragraphs that belong to the same interface as the matched paragraph and whose section is code-example or usage-example.
[0068] In some alternative embodiments, when the paragraphs matched by the forced matching rule and the fine-grained matching rule are descriptive paragraphs, the associated paragraph matching rule is specifically: to find descriptive paragraphs that belong to the same parent chapter as the title level of the matched paragraphs and contain relevant keywords.
[0069] Optionally, the processor performs a hard match between the change item and the structured data to obtain a template matching result, including: if the change item and the structured data are successfully matched, the processor determines the template score to be 1; if the change item and the structured data are not successfully matched, the processor determines the template score to be 0.
[0070] Optionally, semantic matching specifically includes: the processor obtaining the description text of the change item; the processor converting the description text and the text content of each paragraph into description semantic vectors and paragraph semantic vectors respectively using natural language processing technology; the processor calculating the similarity between the description semantic vectors and the semantic vectors of each paragraph; and the processor determining the maximum value of all similarities as the semantic score. It should be noted that semantic matching can be enabled by the processor after hard matching fails or after code changes are associated with complex business logic.
[0071] Optionally, the matching results include the cell confidence score for each cell. Based on the matching results, the processor obtains the segment identifier for the location of the change item, including: The processor selects the maximum value of the cell confidence corresponding to each cell as the candidate confidence value.
[0072] The processor determines the overall confidence level based on the candidate confidence levels and the location confidence threshold. In some optional embodiments, the processor determines the overall confidence level based on the candidate confidence levels and the location confidence threshold, including: the processor determines the candidate confidence levels that exceed the location confidence threshold as the overall confidence level.
[0073] The processor uses the paragraph identifier in the cell index of the cell corresponding to the comprehensive confidence level as the location paragraph identifier for the change item. It should be noted that there may be multiple location paragraph identifiers for a change item, because a change item may need to update multiple paragraphs.
[0074] The processor constructs a mapping between change items and location paragraph identifiers to generate a change-paragraph mapping list, including: The processor constructs a mapping relationship between change items, location paragraph identifiers, and overall confidence scores, generating a change-paragraph mapping list. Each change item maps to one or more location paragraph identifiers, and each location paragraph identifier maps to an overall confidence score.
[0075] In this embodiment, the maximum unit confidence score for each unit is selected as the candidate confidence score. Then, a comprehensive confidence score is determined based on the candidate confidence score and the location confidence score threshold. Finally, the paragraph identifier in the unit index corresponding to the comprehensive confidence score is used as the location paragraph identifier for the change item, achieving a precise mapping from abstract code changes to physical document paragraphs. After determining the location paragraph identifier, this embodiment constructs a mapping relationship between change items, location paragraph identifiers, and comprehensive confidence scores to generate a change-paragraph mapping list. The change-paragraph mapping list includes not only change items and location paragraph identifiers but also the comprehensive confidence score corresponding to the change item, providing a basis for subsequent decision-making.
[0076] As an example, each paragraph is a unit, and each unit corresponds to a unit index. The unit index consists of paragraph metadata, which includes the paragraph identifier, text content, and heading level.
[0077] The document contains N paragraphs, with paragraph identifiers ID1, ID2, ... ID1. N Each unit corresponds to a unit confidence score (i.e., the unit confidence scores for N paragraphs are Score1, Score2, ... Score). N ), where N is greater than or equal to 2.
[0078] Based on the matching results, the processor obtains the location paragraph identifier of the change item, specifically including: Processor selection: Score1 and Score2, ...Score N The maximum value is the candidate confidence score. k .
[0079] Due to Score k The score is higher than the location confidence threshold; therefore, the processor determines the score. k This represents the overall confidence level. Among them, the Score... k Corresponding paragraph 4 (i.e., Score) k The paragraph identifier in the cell index of the corresponding cell is ID4. The processor will score k The paragraph identifier in the cell index of the corresponding cell is used as the positioning paragraph identifier for the change item. Therefore, the positioning paragraph identifier for the change item is determined to be the fourth paragraph in the document.
[0080] Optionally, the processor performs weighted processing on the template score in the template matching result and the semantic score in the semantic matching result to obtain a comprehensive confidence score, including: Overall confidence score = (template score × template matching weight) + (semantic score × semantic matching weight). Or, Overall confidence score = (template score × template matching weight) + (semantic score × semantic matching weight) + structural anchor point reward.
[0081] In this formula, template matching weight + semantic matching weight = 1, where 0 ≤ template matching weight ≤ 1 and 0 ≤ semantic matching weight ≤ 1. Both template matching weight and semantic matching weight are pre-configured by the processor to adjust the relative importance of hard matching and semantic matching in the decision-making process. Typically, template matching weight is higher than semantic matching weight.
[0082] The structural anchor reward is configured by the processor when it determines that the text content of a paragraph's heading level or adjacent paragraphs contains words related to the changed content. Adjacent paragraphs refer to the previous or next paragraph of a given paragraph. As an example, the structural anchor reward is configured to 0.01 when the processor determines that the text content of the previous paragraph contains words related to the changed content.
[0083] Optionally, the processor creates a document synchronization task corresponding to each mapping relationship, including: the processor traverses the change-paragraph mapping list and creates a document synchronization task corresponding to each change item.
[0084] In some optional embodiments, the document synchronization task includes the document name to be updated, the paragraph identifiers to be updated, and the changes to be updated. The changes to be updated are the changes corresponding to the paragraph identifiers to be updated. As an example, a certain change item may be mapped to three paragraph identifiers: {document path}#{paragraph ID1}, {document path}#{paragraph ID4}, and {document path}#{paragraph ID7}. The document synchronization task created by the processor after traversing the change-paragraph mapping list simultaneously includes the document name to be updated, the paragraph identifiers to be updated (i.e., paragraph ID1, paragraph ID4, and paragraph ID7), and the changes corresponding to each paragraph identifier.
[0085] In some alternative embodiments, the document synchronization task includes the document name to be updated, the paragraph identifier to be updated, the changes to be updated, and the update direction. The update direction is the suggested modification direction. In other alternative embodiments, the document synchronization task includes the document name to be updated, the paragraph identifier to be updated, the changes to be updated, and the name of the person responsible for updating. The name of the person responsible for updating the document is the name of the person responsible for updating the document. Here, the processor determines the update direction based on the interface behavior failure item. As an example, if the interface behavior failure item is "Response structure mismatch: the actual returned orderStatus field is an array type, but it is expected to be a string type," then the update direction is to change the type description of the orderStatus field in the document from "string" to "string array."
[0086] Optionally, the change-paragraph mapping list is generated based on the mapping relationship between change items and location paragraph identifiers, and overall confidence levels. The processor makes decisions based on blocking conditions, a unified change set, the change-paragraph mapping list, and verification results to determine whether to block code deployment and complete document synchronization, including: If the blocking conditions are met, the processor determines the blocking code deployment and prompts the user to complete the document synchronization task.
[0087] The blocking conditions include meeting some or all of the following conditions: the severity level of the change item is higher than the single-level threshold and the overall confidence level corresponding to the change item is lower than the location confidence threshold; the verification result corresponding to the document synchronization task is a failure; the severity level and value of all changes are higher than the cumulative level threshold. Here, the single-level threshold, location confidence threshold, and cumulative level threshold are all pre-configured by the processor.
[0088] Thus, if three conditions are met—that the severity level of a change item is higher than the single-level threshold, the overall confidence level of the change item is lower than the location confidence threshold (i.e., the paragraph corresponding to the change item was not successfully located), the verification result of the document synchronization task is a failure, and the severity level and value of all changes are higher than the cumulative level threshold—then code deployment will be blocked and a prompt to complete the document synchronization task will be displayed. This embodiment of the disclosure constructs a causal closed loop of code change leading to document synchronization update by combining precise location of abstract code and physical paragraphs of the document with mandatory gate construction. Whenever a change occurs in the code that requires document synchronization, this decision-making mechanism ensures that the corresponding document modifications are executed and verified, thereby keeping the document consistent with the code and restoring its credibility as the team's single source of truth.
[0089] Optionally, the processor makes decisions based on blocking conditions, a unified changeset, a changes-paragraph mapping list, and verification results to determine whether to block code deployment and complete document synchronization, and also includes: If the blocking conditions are not met, the processor decides to allow code deployment.
[0090] Optionally, the document synchronization method for code changes also includes: In response to a code deployment request, the processor monitors code changes through the change capture engine and obtains a unified changeset. Then, it receives a manual exemption request and executes the code deployment. This manual exemption request is generated by the user in emergency situations and includes the reason for the exemption.
[0091] After the processor executes code deployment, it generates an audit log. This audit log includes the exemption reason and the code deployment log.
[0092] Thus, in order to deal with emergencies such as online hotfixes, this disclosure also provides a manual exemption mechanism, and generates audit logs after code deployment to facilitate subsequent tracking and documentation updates.
[0093] Optionally, the changes to be updated in the document synchronization task include code examples. The processor performs acceptance verification on the document synchronization task based on acceptance rules, and obtains the verification results, including: If the document synchronization task meets the acceptance rules, the processor determines the verification result as passed.
[0094] If the document synchronization task does not meet the acceptance rules, the processor determines the verification result as a failure.
[0095] Acceptance criteria include meeting some or all of the coverage verification conditions, example executability verification conditions, and link integrity verification conditions.
[0096] The coverage verification criteria include that the updated paragraph contains all fields or status codes and business terms in the change items.
[0097] The example executability check condition includes that the code example extracted from the document synchronization task can run successfully.
[0098] Link integrity checks include valid cross-references within paragraphs or valid external links.
[0099] In this way, by accepting and verifying document synchronization tasks based on acceptance rules and obtaining verification results, update requirements are transformed into structured tasks containing acceptance rules. This achieves fully automated verification from "what to do" to "whether it's done correctly," greatly shortening document maintenance time. At the same time, the accuracy of documents is guaranteed by the system, avoiding repeated communication and rework caused by inconsistencies in information between upstream and downstream teams, and improving the smoothness and efficiency of the entire R&D process.
[0100] In some optional embodiments, the changes obtained by the core objects of the static analysis engine monitoring interface definition document include the change type, change content, scope of impact, and severity level. Here, the change type specifically refers to a new change (such as adding a response field). The change content specifically refers to the addition of a 409 status code to the POST / orders interface, indicating a duplicate order submission. The scope of impact specifically refers to POST / orders. The severity level specifically refers to medium.
[0101] The processor determines whether a document synchronization task meets the acceptance criteria using the following method: The processor extracts status codes from the changes to be updated contained in the document synchronization task.
[0102] If the document synchronization task simultaneously meets the following coverage verification conditions or link integrity verification conditions, the processor determines the verification result as passed.
[0103] If the document synchronization task does not simultaneously meet the following coverage verification conditions or link integrity verification conditions, the processor determines the verification result as a failure.
[0104] Specifically, the coverage check condition requires that the updated paragraph contains the description of status code 409 in the change items. The link integrity check condition specifically checks that the triggering conditions and error message format for status code 409 have been explained. If the triggering conditions and error message format for status code 409 have been explained, it indicates that the cross-references within the paragraph or external links are valid, meaning the link integrity check condition is met.
[0105] In some alternative embodiments, the changes obtained by the core object of the static analysis engine monitoring interface definition document include the change type, change content, scope of impact, and severity level. Here, the change type specifically refers to the addition of a required field. The change content specifically refers to the addition of a required field `loyaltyProgramId` to the POST / orders interface request body, with data type string and description "user's membership program identifier". The scope of impact specifically refers to POST / orders. The severity level is specifically medium.
[0106] The processor determines whether a document synchronization task meets the acceptance criteria using the following method: The processor extracts fields and business terms from the changes to be updated contained in the document synchronization task. Specifically, the fields are the `loyaltyProgramId` field name and whether it's a required or optional field. The business terms are business concepts including membership programs or membership identifiers.
[0107] The processor determines the verification result as passed if the document synchronization task meets the following coverage verification conditions.
[0108] If the document synchronization task does not meet the following coverage verification conditions, the processor determines that the verification result is a failure.
[0109] The coverage verification criteria include the following fields or business terms in the updated paragraph containing the change item: "loyaltyProgramId" (i.e., field name), "membership program or member identifier" (i.e., business concept), "string" (i.e., data type), "required" or "required" (i.e., constraint).
[0110] In practical applications, such as Figure 4As shown, the document synchronization method for code changes specifically performs the following steps: S31, in response to a code deployment request, the processor monitors the file objects defined by the static analysis engine interface to obtain change items. These change items include the change type and content, scope of impact, and severity level.
[0111] S32, in response to a code deployment request, the processor executes automated tests and monitors interface behavior through a dynamic behavior analysis engine, obtaining test results including interface behavior failure items. These failure items include assertion type, failure reason, and failure-related scope.
[0112] S33, processor encapsulation changes and interface behavior failures, generate a unified changeset.
[0113] S34, the processor preprocesses the interface definition file to obtain structured data. The structured data is organized into paragraphs, with each paragraph corresponding to a unit index. The unit index is paragraph metadata consisting of paragraph identifiers, text content, and heading levels.
[0114] S35, the processor matches the changes with the structured data to obtain the matching results.
[0115] S36, the processor obtains the location paragraph identifier of the change item based on the matching result.
[0116] S37, the processor constructs a mapping relationship between change items and location paragraph identifiers to generate a change-paragraph mapping list, and creates a document synchronization task corresponding to each mapping relationship.
[0117] S38, the processor performs acceptance verification on the document synchronization task based on the acceptance rules and obtains the verification result.
[0118] S39, the processor determines whether the blocking condition is met; if yes, execute S40, otherwise execute S41.
[0119] S40, the processor determines that the blocking code deployment has been completed and prompts the user to complete the document synchronization task.
[0120] S41, the processor determines to allow code deployment.
[0121] Combination Figure 5As shown in the figure, this disclosure provides a document synchronization device 200 for code changes, including an interface monitoring module 201, a document location module 202, a task verification module 203, and an access control module 204. The interface monitoring module 201 is configured to monitor code changes and obtain a unified changeset through a change capture engine in response to a code deployment request. The document location module 202 is configured to locate document paragraphs in the interface definition file based on the unified changeset, construct a change-paragraph mapping list, and a document synchronization task. The task verification module 203 is configured to perform acceptance verification on the document synchronization task based on acceptance rules and obtain verification results. The access control module 204 is configured to make decisions based on blocking conditions, the unified changeset, the change-paragraph mapping list, and the verification results to determine whether to block code deployment and complete document synchronization.
[0122] Combination Figure 6 As shown, this disclosure provides a document synchronization device 70 for code changes, including a processor 700 and a memory 701. Optionally, the device 70 may further include a communication interface 702 and a bus 703. The processor 700, communication interface 702, and memory 701 can communicate with each other via the bus 703. The communication interface 702 can be used for information transmission. The processor 700 can call logical instructions in the memory 701 to execute the document synchronization method for code changes described in the above embodiment.
[0123] Furthermore, the logic instructions in the aforementioned memory 701 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.
[0124] The memory 701, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of this disclosure. The processor 700 executes functional applications and data processing by running the program instructions / modules stored in the memory 701, thereby implementing the document synchronization method for code changes in the above embodiments.
[0125] The memory 701 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 701 may include high-speed random access memory and may also include non-volatile memory.
[0126] This disclosure provides an electronic device, including: an electronic device body, and the aforementioned document synchronization device 200 (70) for code modification. The document synchronization device 200 (70) for code modification is installed on the electronic device body. The installation relationship described herein is not limited to placement inside the electronic device body, but also includes installation connections with other components of the electronic device, including but not limited to physical connections, electrical connections, or signal transmission connections. Those skilled in the art will understand that the document synchronization device 200 (70) for code modification can be adapted to feasible electronic device bodies to achieve other feasible embodiments.
[0127] This disclosure provides a computer-readable storage medium storing computer-executable instructions configured to execute the above-described document synchronization method for code changes.
[0128] The technical solutions of this disclosure can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes one or more instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in this disclosure. The aforementioned storage medium can be a non-transitory storage medium, such as a USB flash drive, external hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc., and other media capable of storing program code.
[0129] The foregoing description and accompanying drawings fully illustrate embodiments of this disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, procedural, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the order of operation may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. Moreover, the terminology used in this application is for describing embodiments only and is not intended to limit the claims. As used in the description of embodiments and claims, the singular forms “a,” “an,” and “the” are intended to equally include the plural forms unless the context clearly indicates otherwise. Similarly, the term “and / or” as used in this application means including one or more of the associated listed items and all possible combinations thereof. Additionally, when used in this application, the term "comprise" and its variations "comprises" and / or "comprising" refer to the presence of stated features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof. Without further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, or apparatus that includes said element. In this document, each embodiment may focus on the differences from other embodiments, and similar or identical parts between embodiments can be referred to mutually. For methods, products, etc., disclosed in the embodiments, if they correspond to the method section disclosed in the embodiments, the relevant parts can be referred to the description of the method section.
[0130] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this disclosure. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0131] The methods and products (including but not limited to devices and equipment) disclosed in the embodiments herein can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of units may be merely a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed units may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to implement this embodiment according to actual needs. Furthermore, the functional units in the embodiments of this disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0132] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different blocks may also occur in a different order than disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. Each block in a block diagram and / or flowchart, and combinations of blocks in a block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
Claims
1. A document synchronization method for code changes, characterized in that, include: In response to code deployment requests, the change capture engine monitors code changes and obtains a unified change set; Based on the unified change set, the interface definition file is located by document paragraph, and a change-paragraph mapping list and document synchronization task are constructed. The document synchronization task is inspected and verified based on the acceptance rules to obtain the verification results. The decision to block code deployment and complete document synchronization is based on the blocking conditions, unified change set, change-paragraph mapping list, and verification results.
2. The document synchronization method according to claim 1, characterized in that, In response to code deployment requests, the change capture engine monitors code changes and obtains a unified change set, including: In response to code deployment requests, the static analysis engine monitors the file objects defined by the interface to obtain change items; In response to code deployment requests, automated tests are executed and interface behavior is monitored through a dynamic behavior analysis engine to obtain test results including interface behavior failure items; among which, interface behavior failure items include assertion type and failure reason, failure association scope; Encapsulate change items and interface behavior failure items to generate a unified change set.
3. The document synchronization method according to claim 2, characterized in that, Based on the unified change set, the interface definition file is located by document paragraph, and a change-paragraph mapping list and document synchronization task are constructed, including: The interface definition file is preprocessed to obtain structured data. The structured data is divided into paragraphs, and each paragraph corresponds to a unit index. The unit index is paragraph metadata consisting of paragraph identifier, text content, and heading level. Match the changes with the structured data to obtain the matching results; Based on the matching results, obtain the location paragraph identifier of the change item; Build a mapping relationship between change items and location paragraph identifiers to generate a change-paragraph mapping list, and create a document synchronization task corresponding to each mapping relationship.
4. The document synchronization method according to claim 3, characterized in that, Matching changes with structured data to obtain matching results includes: The change items are hard-matched with the structured data to obtain template matching results; the template matching results include template scores corresponding to different units. The change items are semantically matched with the structured data to obtain semantic matching results; the semantic matching results include semantic scores corresponding to different units. The template score and semantic score corresponding to each unit are weighted to obtain the unit confidence score for each unit.
5. The document synchronization method according to claim 3, characterized in that, The matching results include the unit confidence score for each unit; Based on the matching results, the location paragraph identifiers of the changes are obtained, including: The maximum value of the cell confidence score for each cell is selected as the candidate confidence score. The overall confidence level is determined based on the candidate confidence level and the location confidence threshold. Use the paragraph identifier in the cell index corresponding to the comprehensive confidence level as the location paragraph identifier for the change item; Establish a mapping between change items and location paragraph identifiers to generate a change-paragraph mapping list, including: Construct a mapping relationship between change items, location paragraph identifiers, and overall confidence levels to generate a change-paragraph mapping list.
6. The document synchronization method according to any one of claims 1 to 5, characterized in that, The changes include severity levels; the change-paragraph mapping list is generated based on the mapping relationship between the changes, the located paragraph identifiers, and the overall confidence level. The decision to block code deployment and complete document synchronization is based on blocking conditions, a unified change set, a change-paragraph mapping list, and verification results, including: If the blocking conditions are met, confirm the deployment of the blocking code and prompt the user to complete the document synchronization task. The blocking conditions include some or all of the following conditions: The severity level of the change item is higher than the individual level threshold and the overall confidence level corresponding to the change item is lower than the location confidence threshold; The verification result for the document synchronization task was failed. The severity level and value of all changes are higher than the cumulative severity threshold.
7. The document synchronization method according to any one of claims 1 to 5, characterized in that, The document synchronization task is inspected and verified based on the acceptance rules, and the verification results are obtained, including: If the document synchronization task meets the acceptance criteria, the verification result is determined to be passed; If the document synchronization task does not meet the acceptance criteria, the verification result is determined to be a failure. Acceptance criteria include meeting some or all of the coverage verification conditions, example executability verification conditions, and link integrity verification conditions.
8. A document synchronization device for code changes, characterized in that, include: The interface monitoring module is configured to respond to code deployment requests by monitoring code changes through a change capture engine and obtaining a unified change set. The document location module is configured to locate document paragraphs in the interface definition file based on the unified change set, and to build a change-paragraph mapping list and document synchronization task. The task verification module is configured to verify document synchronization tasks based on acceptance rules and obtain verification results. The access control module is configured to make decisions based on blocking conditions, a unified change set, a change-paragraph mapping list, and verification results to determine whether to block code deployment and complete document synchronization.
9. A document synchronization device for code changes, comprising a processor and a memory storing program instructions, characterized in that, The processor is configured to execute, when running the program instructions, the document synchronization method for code changes as described in any one of claims 1 to 7.
10. An electronic device, characterized in that, include: The electronic device itself; The document synchronization device for code changes as described in claim 8 or 9 is installed on the electronic device body.