An event bus-based workflow full-link audit tracking and real-time notification method
By introducing event bus and bridge modules into the workflow platform, cross-layer audit record separation storage and external notification decoupling are achieved, solving the problems of missing cross-layer association identifiers and logical coupling in existing technologies, and improving the accuracy of fault diagnosis and operation and maintenance efficiency.
Patent Information
- Application Number
- CN202611356981.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-03
- Publication Date
- 2026-11-27
AI Technical Summary
The existing workflow platform's audit mechanism only covers the user operation level, lacks cross-layer association identifiers, and has coupled tracking logic with execution logic, while state management and external notifications are mixed, which makes it time-consuming and easy to miss fault chains when maintenance personnel need to manually piece them together.
By inheriting the event emitter base class through the workflow execution engine and node executor, an independent event-audit bridge module is established. The audit records are subscribed to and stored hierarchically using the event bus, generating a globally unique association identifier, and independently recording user operations, execution status, and canvas change events, thus decoupling external notifications from internal audit logic.
It achieves cross-level separation of audit record storage and retrieval, ensuring the accuracy of parameters and environment for fault reproduction, and completely decoupling external notifications from internal status management, thereby improving operational efficiency and the accuracy of fault diagnosis.
Smart Images

Figure CN123178200A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer auditing and observability technology, specifically to a method, system, device, and medium for end-to-end audit tracing and real-time notification of workflows based on an event bus. Background Technology
[0002] The visual workflow platform involves three heterogeneous activities: user operations, engine execution, and canvas data changes. User actions such as creating workflows, modifying node configurations, and manually triggering execution are user-level behaviors; the workflow execution engine schedules the operation of each node according to the DAG graph, and each node internally calls external services or performs computational tasks, which are engine-level activities; operations such as adding or deleting nodes, changing connections, and editing configurations on the workflow canvas cause changes to the workflow data itself.
[0003] Existing workflow platform auditing mechanisms typically only cover the user operation level. Each HTTP request's action type, operator identifier, operation object identifier, and timestamp are recorded in the server-side API middleware and written to the audit log table. This single API-level auditing cannot reveal details of the actual workflow execution process—such as whether a specific node failed, what the node's configuration parameters were at the time of failure, and how many retries were made. When workflow execution fails, operations personnel need to check multiple scattered data sources, including API audit logs, execution record tables, and execution logs. Furthermore, there is a lack of a unified key to connect these different data sources, making manually piecing together the complete fault chain time-consuming and prone to omissions.
[0004] Existing workflow execution tracing solutions suffer from coupling issues between tracing logic and execution logic. In synchronous logging solutions, log writing logic is scattered across the code paths of various executors, tightly coupled with the core execution logic. Aspect-based interceptor patterns require runtime support for aspect mechanisms, increasing the complexity of the workflow construction. In solutions that uniformly collect state after node execution, state management and external notification logic are intertwined—code pushing progress notifications to WebSockets needs direct access to the global state object, blurring the boundaries between state management and message push modules.
[0005] Another existing workflow execution auditing solution records execution events by injecting callback functions into each node. It captures the start, retries, errors, and execution time of each execution in chronological order as a single event stream, and tags each event with a runtime identifier for log association. This event stream recording solution has three main drawbacks: First, all events are mixed in a single event stream, without hierarchical storage based on event source, making it impossible to differentiate and retrieve user operations, engine execution, and canvas data changes. Second, the event stream only records the error information itself; the node configuration parameters at the time of failure are not captured, meaning the configuration may have been edited during post-incident investigation, making it impossible to restore the faulty environment. Third, audit callbacks and user-facing progress pushes are mixed in the same path, blurring the boundaries between state management and message pushes, meaning changes on one side will affect the other. Summary of the Invention
[0006] The purpose of this invention is to provide a workflow end-to-end audit tracing and real-time notification method based on an event bus, which solves the problems of existing audit mechanisms that only cover the user operation layer, lack cross-layer association identifiers, have coupled tracing logic and execution logic, and have mixed state management and external notifications.
[0007] To achieve the above objectives, the technical solution of this invention is as follows: Both the workflow execution engine main class and the node executor base class inherit from the event emitter base class, enabling the engine and all executors to share the same event infrastructure. An independent event-audit bridge module is established. This module obtains execution status change events (including execution start events, execution completion events, execution failure events, node execution start events, node execution completion events, node execution failure events, and node retry events) by subscribing to the workflow execution engine's event bus interface, and obtains canvas change events by subscribing to the message communication service's event bus interface, without modifying the internal code of the monitored modules. Each time a workflow execution starts, the bridge generates a globally unique association identifier and binds it to that execution. Thereafter, all event handling triggered by that execution carries this association identifier. The bridge stores audit records hierarchically according to the event source: user operation events are recorded in the user operation audit data table, engine execution events (including node execution start, completion, failure, and retry, as well as the results of condition evaluation completion events) are recorded in the execution status audit data table, and canvas change events are recorded in the data change audit data table. When an engine-layer event indicates a node failure, the bridge additionally retrieves the node's current configuration parameter values at the time of failure through the engine's query interface and writes them to the audit log. When an engine-layer event indicates a node retry, the bridge records the current retry sequence number and the maximum number of retries. When a conditional node completes condition evaluation, the bridge records the evaluation result and the matching status of each branch. Furthermore, a WebSocket notification handling function, independent of the internal audit logic, is registered on the engine event bus as a post-listener. This function extracts key fields from the event payload, constructs a lightweight progress notification message, and pushes it to subscribed clients via WebSocket, without participating in any internal audit status management. During audit queries, cross-table joins are performed using association identifiers to sequentially connect the complete behavior chain of a workflow execution.
[0008] Compared to existing technologies, this invention offers more direct benefits. The event emitter inheritance chain allows the engine and all executors to share the same event infrastructure. The event definition for execution tracing is completely separated from the business execution logic at the code level—when an executor emits an event, it only needs to construct a structured metadata payload and call the emission interface, without needing to worry about which consumers are involved or how they process the data. Simultaneously, the audit bridge, by subscribing to the event bus, systematically records the engine's internal runtime state (node execution status, failure reasons, retry counts, condition evaluation results, and execution time) as audit data, addressing the shortcoming of existing solutions that only cover the user operation layer. Unlike callback-injection-based auditing schemes that record all events in chronological order into a single event stream, this invention writes audit records to three separate data tables—user operation, execution status, and data change—based on the event source. Each type of record is stored and retrieved independently according to its own field structure. During querying, the three tables are linked together using association identifiers. This hierarchical recording and unified association identifier combination allows any audit record to be independently retrieved by type and its position in an execution within the entire chain view—something that single-stream recording, regardless of filtering, cannot achieve. Of particular note is the snapshot of configuration parameters upon node failure: the snapshot is captured instantly via the configuration query interface of the execution engine when the node failure event is triggered, taking data from the engine's runtime, rather than being reconstructed afterward from potentially modified data. This ensures reliable parameter environment when the failure recurs. The event stream logging approach only records error information, not parameter environment; if the configuration has been edited during post-failure troubleshooting, the cause of the failure cannot be verified. Furthermore, external notifications and internal auditing share a single event bus but each has its own callbacks. Internal listening monitors node retries and condition evaluation results, while external notifications manage user-facing progress pushes. Their listening scope and callback logic do not interfere with each other, and state management and real-time notifications are completely decoupled, ensuring that changes on one side do not affect the other. Additionally, the bridge is entirely non-intrusive, subscribing only through an external event interface without modifying the engine or message service's internal code. It can be deployed and upgraded as an independent module, simplifying integration costs and subsequent maintenance. Attached Figure Description
[0009] Figure 1 This is a system architecture diagram of the workflow end-to-end audit tracing and real-time notification method based on event bus in this embodiment of the invention.
[0010] Figure 2 This is a flowchart of the association identifier propagation and hierarchical audit record generation in an embodiment of the present invention.
[0011] Figure 3 This is a flowchart of cross-table audit query based on association identifier in an embodiment of the present invention.
[0012] Figure 4 This is a schematic diagram illustrating the relationship between the event payload structure and the consumer in an embodiment of the present invention.
[0013] The meanings of the markings in the diagram are as follows: 101 - Workflow engine class inherits from event emitter base class; 102 - Node executor class inherits from event emitter base class; 103 - Audit bridge registers event listeners; 104 - Workflow startup triggers execution start event; 105 - Each node completes execution and emits node completion event; 106 - Node execution fails and emits node failure event; 107 - Conditional nodes emit condition evaluation complete event; 108 - Node retries and emits node retry event; 109 - Engine collects node status and determines the overall result; 110 - Emits execution complete event or execution failure event; 111 - External WebSocket notification handling function listens for all events; 112 - Event payload metadata is written to the audit data table; 113 - Canvas change event is captured via event bus; 201 - Execution lifecycle timeline; 202 - Execution start event. 203 - Node Completion and Failure Events, 204 - Condition Evaluation Events, 205 - Node Retry Events, 206 - Execution Completion or Failure Events, 207 - Canvas Change Events, 301 - User Operation Audit Data Table, 302 - Query Execution Startup Records, 303 - Extract Association Identifiers, 304 - Cross-Table Retrieval by Association Identifier, 305 - Execution Status Audit Data Table, 306 - Get Node Execution Records, 307 - Data Change Audit Data Table, 308 - Get Canvas Change Records, 309 - Merge in Ascending Order by Timestamp, 310 - Output Audit View, 401 - Event Payload Structure, 402 - Basic Field Set, 403 - Special Field Extensions, 404 - Consumer, 405 - Event-Audit Bridge (Internal Listener), 406 - WebSocket Notification Handler (External Notification). Detailed Implementation
[0014] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings.
[0015] like Figure 1 As shown, this embodiment provides a workflow end-to-end audit tracing and real-time notification method based on an event bus. The system deployment includes two layers of modules: an event infrastructure layer based on an event emitter inheritance chain, and an audit and notification application layer based on an event bus.
[0016] like Figure 1 As shown by markers 101 and 102, in the event infrastructure layer, both the workflow execution engine main class and the node executor base class inherit from the event emitter base class provided by the runtime environment. After inheriting the event emitter base class, both classes obtain standard event registration, event emission, and event listening interfaces. Figure 1As shown in mark 103, after instantiation, the engine main class creates executor instances for each node and registers listener callbacks for specific event types through the event registration interface of the executor instance.
[0017] like Figure 1 As shown in Figure 103, in the audit and notification application layer, the system deploys an independent event-audit bridge module. After the workflow execution engine is initialized, this bridge calls the registered listener interface provided by the engine to subscribe to various events emitted by the engine, including execution start events, execution completion events, execution failure events, node execution start events, node execution completion events, node execution failure events, node retry events, and condition evaluation completion events. Figure 1 As shown in mark 113, the bridge also subscribes to canvas change events through the channel broadcast interface of the message communication service. The bridge communicates with the monitored module only through the event interface, without importing or modifying the source code files of the monitored module.
[0018] like Figure 1 As shown in marker 104, when a user triggers a workflow execution via the POST interface at the API layer, the engine main class first generates a globally unique execution identifier, records the start timestamp, and then emits an execution start event. After the event-audit bridge listens for this event, it calls the unique identifier generation function to generate a globally unique associated identifier string. For example... Figure 2 As shown in mark 202, this association identifier remains alive as a closure variable throughout the entire lifecycle of the bridge's handling of the execution-related events, ensuring that all audit records generated during the same workflow execution share the same association identifier. The bridge creates a first-class audit record object containing the association identifier, an action type field (with the value of execution start), an execution identifier, a workflow identifier, a trigger method field, and a trigger timestamp, and persists it to the user operation audit data table.
[0019] like Figure 1 As shown in markers 105 and 106, the engine schedules the execution of each node according to the DAG dependency topology. Each node is executed by a specific node executor instance. The node executor records the start timestamp when executing a node and the end timestamp after executing the business logic, calculating the difference between the two as the execution time. If the business logic returns normally, the node executor constructs a payload object for the node completion event, with fields including execution identifier, workflow identifier, node identifier, node type, execution time (a value in milliseconds), and a success flag (a Boolean true value), emitting an event with the event type string "node completed". If the business logic throws an exception, the node executor catches the exception object, constructs a payload object for the node failure event, sets the success flag to a Boolean false value, and appends a failure reason string field and an error message field. Figure 2 As shown in marker 203, the completion and failure events of each node occur sequentially according to the execution lifecycle timeline. This execution lifecycle timeline is as follows: Figure 2 As shown in mark 201, this records the complete lifecycle of this workflow execution from start to finish.
[0020] The event-audit bridge receives node completion and node failure events. Upon receiving a node failure event, in addition to extracting the aforementioned fields from the event data, the bridge also calls the execution engine's node configuration query interface, passing in the execution identifier and node identifier, to immediately query the current configuration parameter values of the node at the time of execution. The bridge creates a second type of audit record object, containing an association identifier, an action type field (valued as node failure), a node identifier, a node type, an error message, a snapshot of the node configuration parameters, and a failure timestamp. This second type of audit record is persisted to the execution status audit data table. The immediate retrieval of the node configuration parameter snapshot ensures the accuracy of the parameter environment when reproducing a failure—if only the current data in the workflow table is relied upon (which may have been subsequently edited or modified), it is impossible to restore the actual configuration state at the time of node failure.
[0021] like Figure 1 Mark 108 and Figure 2 As shown in mark 205, for scenarios where a retry is triggered due to a momentary failure during node execution, the retry logic built into the node executor base class emits a node retry event before each retry attempt. The payload includes the current retry sequence number (counting from 1), the remaining available retry counts, and the reason for the failure that triggered the retry. After receiving the retry event, the event-audit bridge creates a retry audit record, including the association identifier, node identifier, current retry sequence number, maximum number of retries, and error information, and writes it to the execution status audit data table.
[0022] like Figure 1 Mark 107 and Figure 2 As shown in marker 204, for nodes of the conditional judgment type, the corresponding executor emits an additional condition evaluation completion event after evaluating the conditional expression. The payload of this event includes the evaluation result (the true or false values of each conditional branch) and the matching status of each branch path. The event-audit bridge receives this event and writes the condition evaluation result into the execution status audit data table for subsequent branch route auditing.
[0023] like Figure 1 Mark 113 and Figure 2As shown in mark 207, when multiple users perform operations on the same workflow canvas in a collaborative editing session, the message communication service broadcasts the canvas change to other users in the same room via WebSocket, and simultaneously emits a canvas change event. After the bridge listens for the canvas change event, it extracts the workflow node data and edge data before and after the change from the event data, calculates the difference in the changed content by comparing each field, and organizes the difference objects according to the field path. The bridge creates a third type of audit record object, which includes an association identifier, an action type field (with the value being canvas change), the change content difference object, and a change timestamp, and persists it to the data change audit data table.
[0024] like Figure 1 As shown by markers 109 and 110, after all nodes in the workflow have completed scheduling, the engine main class summarizes the final status of each node. If all nodes complete successfully, the engine issues an execution completion event, appending an aggregated list of execution results for each node to the payload. If any node ends in failure, the engine issues an execution failure event, appending a list of failed nodes and detailed status information for each node to the payload. Figure 2 As shown in mark 206, the execution completion or failure event marks the end of the execution lifecycle.
[0025] like Figure 1 As shown in label 111, the WebSocket notification mechanism is implemented through a separate listener. This listener is registered as a global callback for all event types and is attached to the event bus of the engine's main class during the initialization phase. Figure 4 As indicated by label 401, the event payload is organized in a structured key-value pair format. The listener's processing function does not contain any audit state management logic; it is only responsible for extracting, for example... Figure 4 Using the key information (node identifier, node type, success flag, current progress description) from the basic and special fields in the event payload shown by markers 402 and 403, a lightweight notification message object is constructed and pushed to subscribed clients via a WebSocket connection. Figure 1 As shown by marker 112, the event payload metadata for each execution event is written to the audit data table during event processing, proceeding in parallel with external notification pushes. For example... Figure 4 As indicated by marker 404, the event payload is handled separately by two types of consumers: the event-audit bridge and the external WebSocket notification handling function. For example... Figure 4As shown in the comparison of markers 405 and 406, the WebSocket notification listener and the internal listener of the event-audit bridge are registered on the same event bus, but their callback functions are independent and the range of event types they listen to is also different. The WebSocket notification listener listens to all event types to obtain complete progress updates, while the internal audit listener only listens to specific event types that require internal state updates, such as node retry events and condition evaluation completion events.
[0026] like Figure 3 As shown in marks 301 to 310, when the system receives an audit query request from operations and maintenance personnel (e.g., querying the full-link audit information of a specific execution of a workflow identifier), the audit query module first... Figure 3 Markers 301 and 302 show the process of querying the corresponding execution startup record from the user operation audit data table and extracting the associated identifier. For example... Figure 3 As shown in markers 303 and 304, the query conditions are then defined as follows: Figure 3 As shown in marks 305 and 306, the execution status audit data table and such Figure 3 Markers 307 and 308 show the records retrieved from the data change audit data table. (Example...) Figure 3 As shown in mark 309, the query results from the three tables are sorted in ascending order by the event timestamp field of the records, and merged into a single time-series chain. For example... Figure 3 As shown in mark 310, the audit query module organizes the data in this chain into an audit view and returns it. The audit view includes: execution summary (start time, triggering method, overall result), execution start time and end time of each node, execution time, success or failure status, configuration snapshot and error details of failed nodes, retry records, condition evaluation results, and canvas change records that occurred during execution (if any).
Claims
1. A workflow end-to-end audit tracing and real-time notification method based on an event bus, characterized in that, Includes at least the following steps: The main class of the workflow execution engine and the base class of the node executor are constructed by inheriting from the base class of the event emitter; Establish an event-audit bridge, subscribe to the workflow execution engine event bus to receive execution status change events, and subscribe to the message communication service event bus to receive canvas change events; When an execution start event is received, a globally unique association identifier is generated and bound to the current execution. An audit record containing the association identifier and execution information is created and written to the user operation audit data table. When a node execution failure event is received, the node identifier and error information are extracted. When the node failure event is triggered, the configuration query interface of the execution engine is called immediately to obtain a snapshot of the node configuration parameters at the time of failure. An audit record containing the associated identifier, node failure action type, node identifier, error information and configuration parameter snapshot is created and written to the execution status audit data table. The configuration parameter snapshot is taken from the engine runtime data at the time of failure rather than being reconstructed from the workflow definition data afterward. When a node retry event is received, a retry audit record containing the association identifier, node identifier, and number of retries is created and written to the execution status audit data table; Once the condition evaluation node completes the condition evaluation, the event-audit bridge receives the condition evaluation completion event and records the evaluation result to the execution status audit data table. When a canvas change event is received, the workflow data before and after the change is compared to extract the differences in the changed content, and an audit record is created and written to the data change audit data table. Register a WebSocket notification handling function that is independent of the internal audit listening logic on the event bus, extract key fields of the event payload to construct a notification message and push the execution progress to the subscribed clients via WebSocket; When responding to an audit query request, a cross-table join query is performed based on the association identifier, and the entire execution audit view is obtained by connecting the events in time.
2. The method according to claim 1, characterized in that, The node execution failure event is a node-level event, which triggers the writing of audit records when a single node fails, rather than being added in batches after the overall workflow execution is completed; the configuration parameter snapshot is used to restore the actual parameter environment at the moment of node failure when the fault is reproduced. If it is rebuilt from the current data of the workflow table afterward, the state at the moment of failure cannot be restored because the configuration may have been edited and modified subsequently.
3. The method according to claim 1, characterized in that, The execution status change events also include node execution start events and node execution completion events; when a node execution completion event is received, the event-audit bridge creates an audit record containing the associated identifier, node completion action type, node identifier, and execution time, and writes it into the execution status audit data table.
4. The method according to claim 1, characterized in that, The associated identifier generated by the event-audit bridge after receiving the execution start event is passed between multiple event handling functions through closure variables or context parameters during the lifecycle of the event-audit bridge, so that all audit records generated by the same workflow execution share the same associated identifier.
5. The method according to claim 1, characterized in that, The establishment and operation of the event-audit bridge do not modify the internal code of the workflow execution engine and the message communication service. The event-audit bridge only obtains event data by subscribing to external event interfaces.
6. The method according to claim 1, characterized in that, The WebSocket notification handling function and the internal audit listening logic of the event-audit bridge are independent of each other. The WebSocket notification handling function listens to all execution event types to obtain complete progress updates, while the internal audit listening logic of the event-audit bridge only listens to node retry event types and condition evaluation completion event types to update the internal audit status. The two have different listening scopes and their callback logics do not interfere with each other.
7. The method according to claim 1, characterized in that, The event payload is organized in the form of structured key-value pairs. All event types share a set of basic fields, which at least include an execution identifier field, a workflow identifier field, and a timestamp field. Each event type adds its own dedicated fields on top of the basic fields.
8. A workflow end-to-end audit tracing and real-time notification system based on an event bus, characterized in that, include: The engine event module is used to build the main class of the workflow execution engine and the base class of the node executor, which inherit from the event emitter base class. It provides the event infrastructure for the executor to emit node completion events, node failure events, node retry events and condition evaluation completion events. The event-audit bridge module is used to subscribe to the event bus of the workflow execution engine and message communication service, receive execution status change events and canvas change events, and query the node configuration snapshot from the execution engine when a node failure event is received and store it along with the audit record. The association identifier management module is used to generate a globally unique association identifier when an execution start event is received and to propagate the association identifier to subsequent event processing. The hierarchical audit log module is used to write audit logs to the user operation audit data table, execution status audit data table and data change audit data table according to the source of the event. When a node retry event is received, a retry audit log containing the number of retries and error information is created. The external notification module serves as a unified post-event listener for all execution events. It extracts key fields from the event payload to construct notification messages and pushes the execution progress to subscribed clients via WebSocket. The external notification module and the event-audit bridge module have different listening ranges and do not interfere with each other. The audit query module is used for cross-table join queries based on association identifiers and outputs audit views in chronological order.
9. The system according to claim 8, characterized in that, The event-audit bridge module subscribes to events through an external event interface without modifying the internal code of the service module being monitored.
10. A terminal device, characterized in that, The invention includes a processor and a memory, the memory storing a computer program, wherein the processor executes the computer program to implement the method of any one of claims 1 to 7; and a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the method of any one of claims 1 to 7.
