Deterministic execution of frozen query templates, template tamper protection, and result mode drift handling methods, systems, equipment, and media.

By using a deterministic execution method that freezes query templates, the uncertainties and template tampering issues in data query tasks are resolved, achieving deterministic execution and result consistency, thus ensuring security and cost-effectiveness.

CN123116335APending Publication Date: 2026-11-17WUXI LANJI ZHIDA TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611451603.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-18
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In data query tasks, existing technologies suffer from uncertainties in query execution, susceptibility to tampering with query templates, and difficulty in ensuring the consistency of query results, leading to governance gaps in security and cost.

Method used

By freezing the deterministic execution method of the query template, including receiving the run request, prohibiting language model calls, performing parameter parsing and verification, using template fingerprint comparison to prevent tampering, constructing cache keys for cache management, detecting the result size and performing difference detection between the result contract state and the schema version state, and propagating the failure state along the reference graph, the determinism and security of query execution are ensured.

Benefits of technology

It achieves deterministic execution during the runtime phase, avoids model call costs and delays, prevents template tampering, ensures result consistency, reduces noise and improves repair efficiency, and can accurately propagate the impact of data changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123116335A_ABST
    Figure CN123116335A_ABST
Patent Text Reader

Abstract

This specification provides a method, system, device, and medium for deterministic execution of frozen query templates, template anti-tampering, and result pattern drift handling. During the runtime phase, the method does not invoke a language model, but parses runtime parameters according to a preset priority and performs contract verification. Before execution, the cryptographic hash fingerprint of the query template text is recalculated and compared with the frozen fingerprint; if they do not match, execution is rejected and an alarm is triggered. During execution, resource limits are applied, and failure occurs if the number of rows exceeds the limit. After execution, the result pattern is compared with the frozen result contract to obtain the result contract status, and the pattern version status is obtained based on the comparison between the pattern snapshot version and the current pattern version of the data source. When the result contract status is in a destructive drift state, result writing is blocked, and the previous valid result is retained. When the query template is refrozen, causing column deletion, column name changes, or type incompatibility changes, the failure state is propagated downstream along the reference graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the fields of database access security and data consistency governance technology, and in particular to a deterministic execution of frozen query templates, template anti-tampering, and result pattern drift handling method, system, device, and medium. Background Technology

[0002] With the development of natural language querying, intelligent data analysis, low-code reporting, and automated data application systems, an increasing number of data query tasks are driven by natural language input to generate database query statements, and then the query results are bound to reports, pages, dashboards, or externally published materials. Under this trend, the reproducibility, security, and consistency of query execution have become core governance requirements for data application platforms.

[0003] However, in engineering practice, runtime query execution faces multiple sources of uncertainty. On the one hand, if the runtime phase still relies on language models to generate or rewrite query statements, the execution results are probabilistic; the same input may produce different outputs, leading to unpredictable delays and invocation costs. On the other hand, query templates may be accidentally or maliciously tampered with in the configuration rendering channel, and traditional parameter binding cannot block injection paths into the statement text via non-parameter channels. Furthermore, query results exceeding size limits are often silently truncated, changes in result structure lack runtime detection, and the impact of upstream data changes is difficult to accurately propagate to downstream content assets consuming the query results. These issues collectively result in significant governance gaps in query execution regarding security, cost, and consistency.

[0004] Therefore, in the above scenario, there is a need for a technical solution that can operate without relying on a language model, ensure that the query template is not tampered with, perform closed-loop governance of parameters and results, and accurately propagate the impact of data changes to downstream assets. Summary of the Invention

[0005] This specification provides a method, system, device, and medium for deterministic execution of a frozen query template, template tamper-proofing, and result pattern drift handling. The method is applied to a data query operation system, which pre-receives a frozen component formed during the design phase. The frozen component includes at least a frozen query template, template fingerprint, parameter pattern, frozen result contract, pattern snapshot version, data source identifier, and node identifier.

[0006] The method includes the following steps: receiving a run request for a target query node, the run request including explicit input parameters and caller information; prohibiting the calling of the language model during the run phase, performing subsequent processing only based on the frozen component, and maintaining an invariant that the number of language model calls is zero for the run path; parsing the run parameters according to a preset priority, the preset priority from high to low being the explicit input parameters of this call, fixed node binding, path inheritance binding, and default values ​​in the parameter mode; performing parameter contract verification on each of the parsed run parameters, the parameter contract verification including type coercion, value range verification, enumeration member verification, and mandatory field verification, if any verification fails, the execution is rejected and returned. Return the corresponding error message; obtain the query template text to be executed at runtime, recalculate the cryptographic hash value of the query template text, compare the recalculated runtime template fingerprint with the template fingerprint in the frozen document, if they do not match, refuse execution and generate a template tampering security alarm event; construct a cache key based on the data source identifier, template fingerprint, and normalized parameter digest, and determine whether the cache is hit according to the cache configuration. If a valid cache is hit, return the cache result or enter the frozen result contract verification process; if the cache is not hit, bind the running parameters to the frozen query template in a parameter binding manner under resource quota constraints and submit it to the data source for execution. The resource quota shall at least include This includes one or more of the following: single statement timeout, maximum number of returned rows, maximum result size, maximum concurrent execution, and periodic quota; the size of the returned result is checked, and if the number of returned rows exceeds the limit, a failure closure method is used to reject the return of part of the result, returning a truncated result only when the caller explicitly declares that truncation is allowed, and carrying a truncation flag in the return value; the result pattern returned in this execution is extracted, and the difference between the result pattern and the frozen result contract is checked to obtain the result contract status; and the pattern version status is obtained based on the comparison result between the pattern snapshot version corresponding to the frozen contract and the current pattern version of the data source; and corresponding processing is performed according to the result contract status and the pattern version status. The result contract state includes at least consistency, incremental drift, and destructive drift, and the pattern version state includes at least latest and lagging states: When the result pattern is consistent with the frozen result contract, a structured result is written; when the result pattern only has a new column relative to the frozen result contract and the original frozen column type is compatible, a structured result is written and an incremental drift warning is generated; when a column in the frozen result contract is missing in the result pattern, or the column type changes incompatiblely, it is determined to be a destructive drift, and circuit breaker processing is performed; when the pattern version state is lagging and the result contract state is not a destructive drift type, the pattern version lagging event is recorded and a refresh pattern snapshot and recompile suggestion are generated;When the result contract status is a destructive drift type, or when the frozen query template corresponding to the query node is refrozen to a new version and the new version of the frozen result contract has column deletions, column name changes, or data type incompatibility changes compared to the frozen result contract before refreezing, a directed traversal is performed along the reference graph starting from the target query node. Downstream assets consuming the query result are collected. The intersection of the referenced columns recorded by the reference edges and the actual missing or incompatible columns is used to determine the truly affected assets. Failure markers are applied to the affected assets, and an impact surface report is output.

[0007] Optionally, the configuration field containing the frozen query template is declared as an interpolation-free field, so that the configuration renderer retains the field as is when traversing the configuration object without performing variable substitution. Optionally, the template fingerprint is a cryptographic hash value calculated from the frozen query template text; the calculation object of the template fingerprint is the normalized template text obtained after the frozen query template text has undergone preset normalization processing. The same character encoding is used to read the query template text during the frozen period and the runtime period, and the runtime parameter values ​​do not participate in the calculation of the template fingerprint. Optionally, the parameter normalization includes sorting by parameter name in lexicographical order, unifying date or time parameters to a preset standard format, removing meaningless precision or unifying the numerical representation of numerical parameters, and explicitly filling in default values. Optionally, the type compatibility is determined based on the principle of lossless inheritance, including integer to floating-point type compatibility but floating-point type to integer type incompatibility, fixed-length character to variable-length character compatibility but variable-length character to fixed-length character incompatibility, and date to timestamp compatibility but timestamp to date incompatibility. Optionally, the circuit breaker mechanism includes not writing to the current structured result, preserving the previous valid result from being overwritten, setting the target query node to a contract-broken state, propagating the failure status to downstream consumers along the reference graph, and generating an impact report. Optionally, the reference graph includes the reference relationships between query nodes and assets in the consumer query results. The assets include one or more of downstream query nodes, content nodes, report sections, visualization view nodes, page components, dashboard cards, and externally published items. Optionally, the failure propagation strategy includes one or more of soft failure, hard failure, and lazy retrieval. Soft failure means marking the asset as failed but allowing continued access; hard failure means blocking access until repair; lazy retrieval means attempting to re-acquire or regenerate dependent data the next time the asset is accessed. Optionally, the allowable truncation mark is used for preview, detailed sampling, debugging, or non-statistical display scenarios. When the returned data carries the truncation mark, the aggregation, summarization, year-on-year comparison, month-on-month comparison, forecasting, and external publishing operations on the returned data are disabled.

[0008] Through the above technical solutions, the embodiments in this specification can achieve query execution path determinism by not calling the language model during the runtime phase, and obtain stable and reproducible execution results under the same parameters and data conditions, while avoiding model inference costs and model service delays. Double protection is formed by interpolation-free fields and pre-run template fingerprint recalculation comparison, blocking injection paths into the query statement text through the configured rendering channel outside of parameter binding. Clear four-level parameter parsing priority and parameter contract verification prevent illegal parameters from being silently replaced with default values, thus avoiding inconsistencies in query interpretation. A cache key containing data source identifier, template fingerprint, and normalized parameter summary is used, ensuring that historical caches naturally become invalid after template refreezing, correctly distinguishing parameter value changes, and reducing cache fragmentation caused by parameter order, format differences, and explicit or implicit default values. A failure closure strategy is adopted when the number of result rows exceeds the limit to avoid returning partial results and leading to incorrect statistical conclusions. Result contract comparison promptly detects column deletions, column renamings, and type incompatibility changes, and differentiates incremental drift and destructive drift, preventing silent errors caused by null or zero values ​​in downstream rendering. It can propagate the impact of disruptive drift from data query nodes to heterogeneous assets such as reports, pages, visualizations, and external publications, and accurately identify the truly affected consumers by taking the intersection of referenced columns and actual missing or incompatible columns, thereby reducing noise and improving repair efficiency.

[0009] This specification also provides a deterministic execution, template anti-tampering, and result pattern drift handling system for frozen query templates. The system includes a frozen template acquisition module, a run request receiving module, a zero-model execution control module, a parameter parsing and verification module, a configuration rendering module, a template fingerprint verification module, a cache management module, a resource quota module, a query execution module, a result pattern difference detection module, a result processing module, a reference graph management module, a failure propagation module, and an impact surface reporting module. The functions of each module correspond to the steps in the above method embodiments, and will not be repeated here.

[0010] This specification also provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the aforementioned method.

[0011] This specification also provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the aforementioned method.

[0012] This specification also provides a computer program product, including a computer program that, when executed by a processor, implements the aforementioned method. Attached Figure Description

[0013] Figure 1This is a flowchart illustrating a method for deterministic execution of a frozen query template, template anti-tampering, and result pattern drift handling, provided for some embodiments of this specification.

[0014] Figure 2 This is a schematic diagram of a configured rendering channel injection and template fingerprint blocking mechanism provided for some embodiments of this specification.

[0015] Figure 3 This is a flowchart illustrating a two-dimensional determination process for the result contract status and the mode version status, provided for some embodiments of this specification.

[0016] Figure 4 This is a schematic diagram illustrating a process for precise failure propagation across asset types, provided for some embodiments of this specification. Detailed Implementation

[0017] The embodiments in this specification are applicable to natural language query systems, intelligent reporting systems, low-code data application platforms, enterprise business analysis platforms, data middleware, indicator platforms, BI platforms, automated report generation systems, and external data publishing systems. In these scenarios, query tasks are typically generated from natural language questions or configurations into frozen query templates during the design phase, and only receive parameters and execute them during runtime.

[0018] Figure 1 This is a flowchart illustrating a method for deterministic execution of a frozen query template, template anti-tampering, and result pattern drift handling, provided in some embodiments of this specification. Figure 1 The method shown may include the following steps:

[0019] Step S110: Receive a run request for the target query node. The run request can come from a panel filter, an external API call, a scheduled task, or a content refresh task. The run request can carry explicit input parameters and caller information. The system has completed the compilation, verification, and freezing of the query node during the design phase, obtaining the corresponding frozen component. The frozen component includes at least the node identifier, data source identifier, frozen query template, cryptographic hash fingerprint of the frozen query template, parameter pattern, frozen result contract, pattern snapshot version, caching strategy, and resource quota strategy.

[0020] Step S120: During the runtime phase, language model calls are prohibited. The runtime executor does not contain model retry logic for natural language understanding, statement generation, statement rewriting, or when the result is empty. The system maintains an invariant that the number of language model calls is zero for the execution path, which can be achieved through code dependency isolation, model client stubs, runtime interceptors, or audit logs. If future code changes introduce language model call logic, the relevant assertions will fail, thus preventing the changes from entering the runtime system. Therefore, under the condition that the frozen query template, runtime parameters, and data source status are the same, the executed statement and parameter binding values ​​are the same, which can obtain reproducible results while avoiding model call costs and inference delays.

[0021] Step S130: Parse the execution parameters according to preset priorities. The preset priorities, from highest to lowest, are: explicit input parameters of this call, fixed bindings on nodes, path inheritance bindings, and default values ​​in parameter patterns. For example, if the parameter pattern of a query node declares the default value of parameter days as 7, the region declared in the path inheritance binding is East China, and the business line declared in the node fixed binding is self-operated, and this call explicitly passes days=30, then in the final parameter set, days will take the explicit value 30, region will take the path inheritance binding value, and biz will take the node fixed binding value.

[0022] Step S140 involves performing parameter contract verification on each of the parsed runtime parameters. Parameter contract verification includes type enforcement, value range verification, enumeration member verification, and mandatory field verification. Type enforcement requires that parameters declared as date types must be parsed into valid dates, and parameters declared as integers must be losslessly converted to integers. Value range verification requires that parameter values ​​fall within the numeric range, date range, string length, or string format declared in the parameter pattern. Enumeration member verification requires that identifier-type parameters must be members of the enumeration set declared in the parameter pattern; if the input value does not belong to the enumeration set, the system will directly refuse execution without escaping, concatenating, or providing a fallback. Mandatory field verification requires that for parameters without default values ​​and declared as mandatory, execution will be refused if none of the four levels of sources provide a default value. If any parameter verification fails, the system immediately returns a clear error code and error reason, without silent fallback. For example, if the caller passes in an invalid date string as start_dt, date parsing will fail, and the system will return an illegal parameter error and the expected format, instead of automatically replacing it with the current date or the default date. This avoids the caller getting a completely different result that appears normal but is actually correct when the caller passes the wrong parameter.

[0023] Step S150: Obtain the query template text to be executed at runtime, recalculate the cryptographic hash value of the query template text, and compare it with the frozen template fingerprint. In some embodiments, the configuration field containing the frozen query template is declared as an interpolation-free field, so that the configuration renderer retains the field as is when traversing the configuration object without performing variable substitution. In other embodiments, regardless of whether the configuration object has been rendered, the system takes the final query template text to be executed before submitting for execution, calculates the runtime fingerprint using the same hash algorithm as the frozen period, and compares the runtime fingerprint with the frozen fingerprint stored in the frozen file. If the two are inconsistent, the system refuses to execute, returns a template tampering error code, and generates a security alarm event. The security alarm event may include node identifier, caller identifier, request identifier, summary of differences before and after rendering, frozen fingerprint, runtime fingerprint, and occurrence time. Template fingerprint verification and parameter binding protect different attack surfaces, forming two orthogonal security defenses.

[0024] In some embodiments, the template fingerprint is calculated using the normalized template text obtained after the frozen query template text has undergone preset normalization processing. The same character encoding is used to read the query template text during both the freezing and runtime periods; for example, it is read using UTF-8 encoding and the byte order marker at the beginning of the document is removed. The preset normalization processing includes at least one of the following: unifying line breaks to preset line breaks; removing trailing whitespace characters and unifying tab characters to preset whitespace characters; removing comment text according to preset rules, or retaining comment text according to preset rules. The preset normalization processing does not change the query semantics, and the normalization range remains consistent between the freezing and runtime periods, thereby avoiding false alarms due to differences in formatting spaces, line breaks, or character encoding. Simultaneously, the range of the preset normalization processing is recorded in the frozen document. When the normalization rule version changes, the template fingerprint will be recalculated and frozen to avoid inconsistencies in the normalization range masking changes in the template text. Runtime parameter values ​​do not participate in the calculation of the template fingerprint. Runtime parameters are injected via parameter binding before being submitted to the database for execution; therefore, changes in parameter values ​​will not change the template fingerprint. For identifier enumeration mapping, the system completes the mapping from identifier to target data source identifier during the compilation and freezing phase, and uses the final template text after mapping as the fingerprint comparison object.

[0025] Step S160: Construct a cache key based on the data source identifier, template fingerprint, and normalized parameter summary, and determine whether a cache hit occurs based on the cache configuration. Parameter normalization includes sorting parameters by lexicographical order, converting dates to a preset standard format, removing meaningless precision from values ​​or unifying their numerical representation, and explicitly padding parameters that are not explicitly passed but have default values. When a query template is frozen as a new template due to recompilation, even if the parameters are the same, the new template fingerprint is different, and the cache key is different accordingly. The old cache will no longer be hit by the query and does not need to be explicitly cleared. For time-sensitive queries, the node cache lifetime can be configured to zero, thereby disabling caching. If a valid cache is hit, the result schema or result contract version associated with the cached entry is validated. If the validation passes, database execution is skipped, and the cached structured result that has passed the result contract validation is returned.

[0026] In step S170, if the cache is not hit, the execution parameters are bound to the frozen query template using parameter binding under resource quota constraints, and the data source is submitted for execution. Resource quotas include at least one or more of the following: single statement timeout, maximum number of rows returned, maximum result volume, maximum concurrent execution, and periodic quota. For single statement timeout, the system can simultaneously employ data source session-level timeout and application-side fallback timeout, returning a clear timeout error code when a timeout occurs. For the concurrent execution limit, the system can configure execution semaphores according to the data source; when concurrent requests exceed the limit, remaining queries are queued or fail quickly to avoid overwhelming the data source with instantaneous pressure. For periodic quota, the system can count by data source, tenant, or caller; when the quota is exhausted, execution is rejected, and the remaining quota and reset time are returned.

[0027] Step S180 involves checking the size of the returned result. When the number of returned rows exceeds the upper limit, the system uses a failure closure approach, returning an error indicating that the number of returned rows exceeds the upper limit, instead of returning the first N rows as a successful result. For example, if a query has an upper limit of 10,000 rows but actually returns 14,000 rows, the system will return a message indicating that the 14,000 rows exceed the upper limit of 10,000, instead of returning the first 10,000 rows as a normal result. This avoids downstream operations performing aggregation based on incomplete data, which could lead to seemingly normal but erroneous conclusions. If the caller explicitly declares that truncation is allowed, the system can return the first N rows, but must include a truncation flag in the returned data. The truncation flag is used for preview, detailed sampling, debugging, or non-statistical display scenarios. After detecting the truncation flag, downstream assets must not perform aggregation calculations on the result and must disable at least one of the following operations: summarization, aggregation, year-on-year comparison, month-on-month comparison, forecasting, and external release of the returned data carrying the truncation flag; or they must disable aggregation capabilities and display a preview prompt to the user. Regarding the upper limit of the result volume, the system can estimate the volume before serialization. If the volume exceeds the upper limit, it can be configured to fail, or it can be configured to overflow the complete result to external object storage and return the reference address and integrity verification information in the structured result.

[0028] Step S190: Extract the result pattern returned by this execution, perform difference detection between the result pattern and the frozen result contract to obtain the result contract status; and obtain the pattern version status based on the comparison result between the pattern snapshot version corresponding to the frozen contract and the current pattern version of the data source. The frozen result contract is represented as a mapping from column names to types, and the result pattern returned by this execution is also represented as a mapping from column names to types. The system compares the two to obtain the result contract status, and records the result contract status and the pattern version status as two independent dimensions that can coexist.

[0029] The current schema version of the data source can be obtained through at least one of the following methods: reading the DDL version number of the data source; obtaining the current schema snapshot version of the data source from the metadata service; calculating the hash value of the database schema metadata as the schema version identifier; collecting the object and column definitions of the data source at a preset period and generating a version number accordingly; receiving database change events and generating a version number based on the database change events. The current schema version of the data source is refreshed before each comparison or at a preset refresh period. The schema snapshot version corresponding to the frozen document is recorded along with the frozen document during the compilation and freezing phase. Therefore, the system can directly compare the schema snapshot version with the current schema version of the data source to obtain the schema version status.

[0030] The data types of each column in the result schema can be obtained through at least one of the following methods: reading column metadata returned by the database driver; reading type information from the result set field description object; querying column definitions in the database system catalog; reading type object identifiers returned by the database; or reading type identifiers carried by explicit projections in the query statement. When multiple methods are available simultaneously, the system selects one of them as the data type in the result schema according to a preset priority, and records the type source consistent with the freeze period in the frozen result contract, thereby ensuring that the freeze period and the runtime period use the same criteria for type determination.

[0031] Figure 3 This is a flowchart illustrating a two-dimensional determination process for result contract status and schema version status, provided for some embodiments of this specification. When the result schema matches the frozen result contract, i.e., the column name set is the same and the corresponding column types are compatible, the system determines the result contract status as a consistent type, writes the structured result normally, and can update the cache.

[0032] When all columns in the frozen result contract exist in the current result schema and their corresponding types are compatible, but the current result schema has several newly added columns, the system determines the result contract status as incremental drift. For example, if the underlying view adds a `refund_amt` column, while all existing columns in the frozen result contract still exist and their types are compatible, the system writes the structured result normally and records a notification message indicating the detection of new columns. Incremental drift does not interrupt business operations.

[0033] When any column in the frozen result contract is missing in the current result pattern, or the corresponding column type undergoes an incompatible change, the system determines the result contract status as a destructive drift type and executes circuit breaker processing. For example, if the frozen result contract contains a "gmv" column, but this column has been renamed in the current result, or if "gmv" was a floating-point type in the frozen result contract but has become a string type in the current result and cannot be seamlessly inherited, the system performs the following circuit breaker processing: does not write to the current structured result, does not overwrite the previous valid result, sets the query node to a contract-broken state, records the destructive drift event, propagates the failure state along the reference graph, and outputs an impact surface report. Circuit breaker processing is superior to rendering null values. If a missing column is rendered as a null or zero value downstream, it may generate content that appears normal but is actually incorrect. Circuit breaker processing makes downstream users clearly aware that upstream data is unavailable.

[0034] When the system detects that the local schema snapshot version is behind the current schema version of the data source, but the result contract state is not a destructive drift type, the schema version state is determined to be in a backward state, the schema version backward event is recorded, and a refresh schema snapshot and recompile suggestion are generated without blocking the current execution; at this time, the result contract state and the schema version state are retained at the same time, and the two are independent of each other and can coexist.

[0035] Type compatibility is determined based on the principle of lossless acceptance, including compatibility between integer and floating-point types but incompatibility between floating-point and integer types, compatibility between fixed-length characters and variable-length characters but incompatibility between variable-length characters and fixed-length characters, and compatibility between date and timestamp but incompatibility between timestamp and date. Those skilled in the art can extend the compatibility rules based on the data source type system.

[0036] Step S200: When the result contract status is of the destructive drift type, or when the frozen query template corresponding to the query node is refrozen to a new version, the failure status is propagated downstream along the reference graph to the assets.

[0037] Figure 4 This document provides a flowchart illustrating a precise failure propagation process across asset types, as illustrated in some embodiments. The system maintains a reference graph. Source nodes in the reference graph can be data query nodes, and sink nodes can be assets consuming query results, including downstream query nodes, content nodes, report sections, visualization view nodes, page components, dashboard cards, and externally published items. Reference edges record consumption relationships and specific reference paths or reference columns. When a destructive drift occurs at the target query node, the system obtains the actual set of missing or incompatible columns. Starting from the target query node, it performs a directed traversal along the reference graph, collecting all reachable consumers. For each consumer, the system takes the intersection of the set of reference columns recorded by the reference edges and the set of missing or incompatible columns. If the intersection is not empty, the consumer is determined to be truly affected; otherwise, the consumer is not marked. For example, if a data warehouse renames the `gmv` column, the system discovers that `gmv` is missing in the frozen result contract and determines it as a destructive drift. Multiple consumers exist in the reference graph. The system only marks consumers referencing `gmv` as obsolete, and does not process consumers referencing only other unchanged columns. The system outputs an impact report, which includes the affected asset identifier, asset type, missing or incompatible columns referenced, upstream query nodes, cause of impact, and recommended actions.

[0038] In scenarios where query templates are refrozen, when the frozen query template corresponding to the query node is refrozen to a new version, the system obtains the new version freeze result contract corresponding to the new version and compares the new version freeze result contract with the freeze result contract corresponding to the query node before refreezing. If the new version freeze result contract has column deletions, column name changes, or data type incompatibility changes compared to the freeze result contract before refreezing, it is determined that the new version freeze result contract has undergone destructive changes. The missing or modified columns in the freeze result contract before refreezing are used as abnormal columns, and the failure status is propagated to downstream assets along the reference graph in the same way as destructive drift, generating an impact surface report. If the new version freeze result contract only has newly added columns compared to the freeze result contract before refreezing, and the original column types are compatible, the failure status is not propagated to downstream assets.

[0039] Failure propagation strategies can be configured by asset type or business level, and each strategy is implemented through fields, access control modules, and retrieval executors in the data query operation system. Soft failures are implemented as follows: a failure flag field is written into the asset metadata of the affected asset, and the value of the failure flag field is set to obsolete. The failure flag field is read by the read interface of the data query operation system. Assets whose failure flag field is read have an obsolete flag overlaid on the display layer, but the access channel remains available. This is suitable for internal analysis or low-risk scenarios. Hard failures are implemented as follows: when an access request arrives, the access control module reads the failure flag field from the asset metadata. When the value of the failure flag field is obsolete, the access control module blocks the response before it is generated and returns a failure message until the failure flag field is cleared. This is suitable for high-risk scenarios such as externally released materials, financial indicators, and regulatory reports. The lazy retrieval mechanism works as follows: When the next access to the affected asset is triggered, the retrieval executor calls the upstream query node indicated by the reference graph to re-execute the parameter binding query. The returned result pattern from the re-execution is then compared with the frozen result contract for another difference check. If the result is of a consistent or incremental drift type, the failure flag field is cleared. If the result is of a destructive drift type, the failure flag field is retained, and a failure message is displayed. The execution result of the lazy retrieval is reflected by writing back the failure flag field to the asset metadata. Therefore, soft failure, hard failure, and lazy retrieval strategies share the same failure flag field, differing only in the timing of reading and clearing. Through this method, the system can not only detect contract violations in data query results but also extend the impact to the content products consuming those results, answering the question of which published pages or reports will be affected by this column renaming.

[0040] The above describes a method for deterministic execution, template anti-tampering, and result pattern drift handling of a frozen query template, as provided in the embodiments of this specification. Based on the same technical concept, embodiments of this specification also provide a system, an electronic device, a computer-readable storage medium, and a computer program product. The system includes a frozen document acquisition module, a run request receiving module, a zero-model execution control module, a parameter parsing and verification module, a configuration rendering module, a template fingerprint verification module, a cache management module, a resource quota module, a query execution module, a result pattern difference detection module, a result processing module, a reference graph management module, a failure propagation module, and an impact surface reporting module. The electronic device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the aforementioned method. The computer-readable storage medium stores a computer program, which, when executed by the processor, implements the aforementioned method. The computer program product includes a computer program, which, when executed by the processor, implements the aforementioned method.

[0041] The above descriptions are merely some embodiments of this specification and are not intended to limit this specification. Any modifications, equivalent substitutions, and improvements made within the scope of the technical concept of this specification should be included within the protection scope of this specification.

Claims

1. A method for deterministic execution of a frozen query template, template tamper-proofing, and result pattern drift handling, characterized in that, include: Obtain the frozen components generated and frozen during the design phase. The frozen components include at least the query template text, template fingerprint, parameter pattern, frozen result contract, and pattern snapshot version. During the runtime phase, the system receives call requests for query nodes and prohibits calls to the language model within the query execution path of the runtime phase. Runtime parameters are parsed from multiple parameter sources according to a preset priority, and parameter contract verification is performed on the parsed runtime parameters according to the parameter pattern. Before submitting the query template text to the database for execution, obtain the current query template text to be executed, calculate the cryptographic hash value of the current query template text to be executed, and compare the cryptographic hash value with the template fingerprint; If the comparison is inconsistent, the query template text will not be executed, and a template tampering alarm event will be generated. When the comparison is consistent and the parameter contract verification passes, the parameter binding query is executed based on the query template text and the running parameters, and at least one of the following restrictions is imposed on the parameter binding query according to the preset resource quota strategy: execution timeout, number of returned rows, result volume, number of concurrent requests and periodic quota. Obtain the result pattern returned by this query, perform difference detection between the result pattern and the frozen result contract to obtain the result contract status, and obtain the mode version status based on the comparison result between the mode snapshot version corresponding to the frozen contract and the current mode version of the data source. The result contract status and the mode version status are independent of each other, and the two together constitute the contract comparison status type. Perform corresponding actions based on the contract comparison status type. Specifically, when the result contract status is a destructive drift type, block the writing of the current structured result to the result storage area of ​​the query node, retain the previous valid structured result, and mark the query node as a contract-broken state.

2. The method according to claim 1, characterized in that, The multiple parameter sources include explicit input parameters of this call, fixed node bindings, path inheritance bindings, and default values ​​of parameter modes; The preset priorities, from highest to lowest, are: explicit input parameters of this call, fixed node binding, path inheritance binding, and default parameter mode.

3. The method according to claim 1, characterized in that, The parameter contract verification includes at least one of the following: Perform type conversion on the parameter value according to the declared type, and refuse to execute if the conversion fails; Perform value range validation based on the numerical range, date range, string length, or string format declared in the parameter mode; Perform enumeration member validation on the identifier class parameter, and refuse to execute if the identifier class parameter is not an enumeration member; Perform missing validation on required parameters; If any parameter fails the contract validation, an invalid parameter error code is returned, and the failed parameter value is not replaced with a default value or other parameter values.

4. The method according to claim 1, characterized in that, Before receiving call requests for query nodes during the runtime phase, it also includes: Declare the configuration field that carries the query template text as an interpolation-free field; When rendering the query node configuration using variable interpolation, the renderer skips the non-interpolation fields, ensuring that the query template text remains unchanged during the rendering process.

5. The method according to claim 1, characterized in that, The template tampering alarm event includes at least one of the following information: The query includes node identifier, caller identifier, frozen template fingerprint, template fingerprint calculated at runtime, summary of differences before and after rendering, alarm time, and reason for refusal to execute.

6. The method according to claim 1, characterized in that, Before executing the parameter binding query, the following is also included: Generate a cache key based on the data source identifier, the template fingerprint, and the normalized parameter summary; The cache entry is queried based on the cache key, wherein the cache entry stores a structured result and the result pattern or result contract version corresponding to the structured result; When a cache hit occurs and the cache entry has not exceeded its lifetime, the result schema or result contract version associated with the cache entry is validated, and database execution is skipped after the validation passes, and the cached structured result that has passed the result contract validation is returned. When a cache miss occurs or a cache entry expires, the parameter binding query is executed. The normalized parameter summary is calculated by sorting parameter names, normalizing parameter values ​​by type, and supplementing parameters that are not explicitly provided but have default values.

7. The method according to claim 6, characterized in that, The type normalization includes at least one of the following: Standardize the date parameters to ISO date format; The numerical parameters are normalized to a numerical expression after removing meaningless precision. Unify Boolean parameters into a unified Boolean expression; Standardize the string parameters according to the preset encoding method.

8. The method according to claim 1, characterized in that, The restrictions imposed according to the preset resource quota strategy include at least one of the following: Limit the timeout of a single statement execution by using database session-level settings and application-side timers; The upper limit of the number of rows returned is limited by the application-side counter. Estimate the result volume and limit the upper limit of the result volume before serialization; Limit the number of concurrent executions by setting semaphores according to the data source; Limit periodic quotas by counting based on data source or caller.

9. The method according to claim 8, characterized in that, When the number of returned rows exceeds the maximum number of returned rows, the method refuses to return part of the result and returns a row count error code. When the call request contains a truncation allow flag, the truncation result is allowed to be returned, and the truncation flag is carried in the returned data; The allow truncation marker is used for preview, detailed sampling, debugging, or non-statistical display scenarios; When the downstream processing flow reads the truncation mark, it refuses to execute the aggregation operator that takes the returned data carrying the truncation mark as input, and disables at least one of the following operations on the returned data carrying the truncation mark: summarization, aggregation, year-on-year comparison, month-on-month comparison, forecasting, and external release.

10. The method according to claim 1, characterized in that, The freeze result contract includes the set of column names at the time of freeze and the data type of each column; The result format includes the set of column names returned by this query and the data type of each column; A difference detection is performed between the resulting pattern and the frozen result contract to obtain the result contract status; and a pattern version status is obtained based on the comparison result between the pattern snapshot version corresponding to the frozen contract and the current pattern version of the data source. The result contract status and the pattern version status are independent of each other and together constitute the contract comparison status type; wherein, the result contract status includes: Consistent type: The set of column names returned in this query is the same as the set of column names when the data was frozen, and the data types of the corresponding columns are compatible; Incremental drift type: The set of column names at the time of freezing is a subset of the set of column names returned by this query, and the data types of each column at the time of freezing are compatible; Destructive drift type: At least one column name does not exist in the set of column names returned by the current query when the column name is frozen, or the data type of at least one column name has changed incompatiblely when the column name is frozen; The mode version status includes: latest status, where the mode snapshot version corresponding to the frozen component is the same as the current mode version of the data source; and lagging status, where the mode snapshot version corresponding to the frozen component is lagging behind the current mode version of the data source. The result contract status and the mode version status are independent of each other and can coexist at the same time.

11. The method according to claim 10, characterized in that, The data type compatibility is determined according to the lossless acceptance rule, which includes at least one of the following: Integer to floating-point is compatible, floating-point to integer is not compatible; Fixed-length character types are compatible with variable-length character types, while variable-length character types are not compatible with fixed-length character types. Date type to timestamp type is compatible, timestamp type to date type is not compatible.

12. The method according to claim 10, characterized in that, Perform corresponding actions based on the contract comparison status type, including: When the resulting contract status is of the consistent type, write it into the current structured result; When the result contract status is of the incremental drift type, write the current structured result and record the new column prompt event; When the result contract state is a destructive drift type, the writing of the current structured result to the result storage area of ​​the query node is blocked, the previous valid structured result is retained, the query node is set to a contract destruction state, and failure propagation is initiated. When the mode version state is outdated and the result contract state is not a destructive drift type, record the mode version outdated event and generate a suggestion to refresh the mode snapshot and recompile.

13. The method according to claim 1, characterized in that, The reference graph includes a data query node as the source node, downstream assets as the sink node, and reference edges connecting the data query node and the downstream assets. The downstream assets include at least one of the following: downstream query nodes, content nodes, visual view nodes, and externally published items; The reference edge records the result column path of downstream asset references.

14. The method according to claim 13, characterized in that, The failure status is propagated along the reference graph to downstream assets that consume the query node results, including: Starting from the query node where the destructive drift occurred, a directed traversal of the reference graph is performed to obtain the set of reachable downstream assets; Retrieve the missing columns or incompatible type change columns corresponding to destructive drift; Take the intersection of the reference column recorded by each reference edge with the missing column or the column of incompatible type change; When the intersection is not empty, the corresponding downstream assets are marked as affected assets; Set the affected assets to a failure state and generate an impact report.

15. The method according to claim 14, characterized in that, The impact report includes at least one of the following: affected asset identifier, affected asset type, referenced anomaly column, anomaly type, and recommended action; The failure state propagation strategy includes at least one of soft failure, hard failure, and lazy retake, wherein: Soft failures are used to mark affected assets but allow access; A hard failure is used to block access until the repair is complete. Lazy retrieval is used to retrieve the upstream query results again the next time the affected asset is accessed.

16. The method according to claim 13, characterized in that, Also includes: When the frozen query template corresponding to the query node is refrozen to a new version, obtain the new version freeze result contract corresponding to the new version, and compare the new version freeze result contract with the freeze result contract corresponding to the query node before refreezing. When the new version of the frozen result contract has undergone column deletion, column name change, or data type incompatibility changes compared to the frozen result contract before refreezing, it is determined that the new version of the frozen result contract has undergone destructive changes. The failure status is propagated along the reference graph to downstream assets that consume the query node results, and an impact surface report is generated.

17. The method according to claim 1, characterized in that, Calls to the language model are prohibited in the query execution path during the runtime phase, including at least one of the following: The language model client is not loaded in the query execution path; This is achieved by replacing the language model client with an empty one through dependency injection; Block access to the model service through runtime interceptors; Access control policies should be used to prevent query executors from accessing the model service interface; Configure a language model client call counter in the runtime environment. Count the number of language model client calls within the query execution path during automated testing or runtime detection. If the number of language model client calls is not zero, it is determined that the query execution path does not meet the deterministic execution constraint.

18. A deterministic execution system for freezing query templates, a template anti-tampering system, and a result pattern drift handling system, characterized in that, include: The frozen document acquisition module is used to acquire frozen documents generated and frozen during the design phase. The frozen documents include at least the query template text, template fingerprint, parameter pattern, frozen result contract, and pattern snapshot version. The run request receiving module is used to receive run requests for query nodes, the run request including explicit input parameters and caller information; The zero-model execution control module is used to prevent the language model from being called in the query execution path during the runtime phase; The parameter parsing and verification module is used to parse running parameters from multiple parameter sources according to a preset priority, and to perform parameter contract verification on the parsed running parameters according to the parameter pattern. Configure the rendering module to perform variable interpolation rendering on the query node configuration, and skip the non-interpolation fields that carry the query template text during the rendering process; The template fingerprint verification module is used to calculate the cryptographic hash value of the query template text to be executed before submitting it to the database for execution and compare it with the template fingerprint. If the comparison is inconsistent, the execution is rejected and a template tampering alarm event is generated. The cache management module is used to generate a cache key based on the data source identifier, the template fingerprint, and the normalized parameter digest, and to query, verify, and write cache entries based on the cache key; The query execution module is used to perform a parameter binding query based on the query template text and the running parameters when the comparison is consistent and the parameter contract verification passes. The resource quota module is used to impose at least one of the following restrictions on the parameter binding query according to a preset resource quota strategy: execution timeout, number of returned rows, result volume, number of concurrent requests, and periodic quota. The result pattern difference detection module is used to obtain the result pattern returned by this query, perform difference detection between the result pattern and the frozen result contract to obtain the result contract status, and obtain the pattern version status based on the comparison result between the pattern snapshot version corresponding to the frozen contract and the current pattern version of the data source. The result processing module is used to perform corresponding processing according to the contract comparison status type. When the result contract status is a destructive drift type, the current structured result is blocked from being written to the result storage area of ​​the query node, the previous valid structured result is retained, and the query node is marked as a contract destruction state. The reference graph management module is used to maintain a reference graph that includes data query nodes, downstream assets, and reference edges connecting the two. The reference edges record the result column paths referenced by the downstream assets. The failure propagation module is used to propagate the failure status along the reference graph to the downstream assets consuming the query node results when the result contract status is of the destructive drift type, or when the frozen query template corresponding to the query node is refrozen to a new version and the new version of the frozen result contract has column deletion, column name change or data type incompatibility change. The impact reporting module is used to generate an impact report that includes at least one of the following: affected asset identifier, affected asset type, referenced anomaly column, anomaly type, and recommended action.

19. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements the method as described in any one of claims 1 to 17.

20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 17.