From 7e3fe1961a528f630f1427e8483b4450f8900291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Sun, 28 Jun 2026 03:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20execution=5Fid=20String?= =?UTF-8?q?=E2=86=92ExecutionId=20=E7=B1=BB=E5=9E=8B=E5=88=AB=E5=90=8D=20+?= =?UTF-8?q?=20=E6=9B=B4=E6=96=B0=E5=BE=85=E5=86=B3=E7=AD=96=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/df-types/src/events.rs | 12 ++++++------ crates/df-workflow/src/executor.rs | 6 +++--- crates/df-workflow/src/node.rs | 4 ++-- docs/todo.md | 10 +++++----- src-tauri/src/commands/workflow.rs | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/df-types/src/events.rs b/crates/df-types/src/events.rs index 24326d7..67505af 100644 --- a/crates/df-types/src/events.rs +++ b/crates/df-types/src/events.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; -use crate::types::NodeId; +use crate::types::{ExecutionId, NodeId}; /// 人工审批选择类型(F-260615-01) /// - Single: 单选(decision 单值),缺省值,向后兼容现有调用方 @@ -24,7 +24,7 @@ pub enum SelectType { /// 旧调用方仍可只填 decision,HumanNode 下游兼容两者。 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct HumanApprovalResponse { - pub execution_id: String, + pub execution_id: ExecutionId, pub node_id: NodeId, pub decision: String, #[serde(default)] @@ -81,7 +81,7 @@ pub enum WorkflowEvent { /// #[serde(default)] 向后兼容: 老事件/老 DB 反序列化(无 execution_id)填空串不炸。 WorkflowCompleted { #[serde(default)] - execution_id: String, + execution_id: ExecutionId, total_duration_ms: u64, }, /// 工作流执行失败 @@ -89,13 +89,13 @@ pub enum WorkflowEvent { /// B-03b-R10 ③(波17 治本): execution_id 字段标识本次终态事件归属的工作流执行(同 WorkflowCompleted)。 WorkflowFailed { #[serde(default)] - execution_id: String, + execution_id: ExecutionId, error: String, failed_node: NodeId, }, /// 人工审批请求 HumanApprovalRequest { - execution_id: String, + execution_id: ExecutionId, node_id: NodeId, title: String, description: String, @@ -106,7 +106,7 @@ pub enum WorkflowEvent { }, /// 人工审批响应 HumanApprovalResponse { - execution_id: String, + execution_id: ExecutionId, node_id: NodeId, decision: String, /// F-260615-01: 多选结果(Single 模式长度=1,Multiple 模式长度≥1) diff --git a/crates/df-workflow/src/executor.rs b/crates/df-workflow/src/executor.rs index dbe9ef4..f0d01dc 100644 --- a/crates/df-workflow/src/executor.rs +++ b/crates/df-workflow/src/executor.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use df_types::events::WorkflowEvent; -use df_types::types::NodeId; +use df_types::types::{ExecutionId, NodeId}; use crate::conditions::ConditionEngine; use crate::dag::Dag; @@ -18,7 +18,7 @@ pub struct DagExecutor { /// 节点状态机 state_machine: StateMachine, /// 工作流执行 ID(由调用方传入,下沉到每个 NodeContext) - execution_id: String, + execution_id: ExecutionId, } impl DagExecutor { @@ -26,7 +26,7 @@ impl DagExecutor { /// /// `execution_id` 为本次工作流执行的唯一标识,会下沉到每个节点的 NodeContext, /// 用于节点内的事件关联、审计追踪等。 - pub fn new(event_bus: EventBus, execution_id: String) -> Self { + pub fn new(event_bus: EventBus, execution_id: ExecutionId) -> Self { Self { event_bus, state_machine: StateMachine::new(), diff --git a/crates/df-workflow/src/node.rs b/crates/df-workflow/src/node.rs index ff7ead9..38afbf9 100644 --- a/crates/df-workflow/src/node.rs +++ b/crates/df-workflow/src/node.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use serde::{Deserialize, Serialize}; -use df_types::types::NodeId; +use df_types::types::{ExecutionId, NodeId}; use super::eventbus::EventBus; use super::state::StateMachine; @@ -18,7 +18,7 @@ pub struct NodeContext { /// 节点配置参数 pub config: serde_json::Value, /// 工作流执行 ID - pub execution_id: String, + pub execution_id: ExecutionId, /// 事件总线 pub event_bus: EventBus, /// 节点状态机(用于检查取消状态) diff --git a/docs/todo.md b/docs/todo.md index b785d8b..fbce6a0 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -86,11 +86,11 @@ graph TD 4. **REFACTOR-260619-04 审批状态机 ↔ `queue=decision` 待决策池**:审批对齐 ### 待决策 -| 决策点 | 选项 | -|---|---| -| 多工程合并 | 方案 A 合并 V28(前提:确认子1 表设计,find 未找到独立文档)/ 知识图谱独立 Phase 1 | -| conditions 启用 | 启用求值 / 保留观察 | -| BUG-260620-05 层2 | workspace_root 外默认放行(黑名单制)?— 详见 `## 🔴 2026-06-20 BUG-260620-05` | +| 决策点 | 选项 | 状态 | +|--------|------|------| +| 多工程合并 | ✅ 已决:知识图谱独立 Phase 1(V29),多工程 V30+ | ✅ 已归档 | +| conditions 启用 | ✅ 已决:conditions-eval feature 默认开,引擎已完成,前端 UI 待列待办 | ✅ 已实施 | +| BUG-260620-05 层2 | workspace_root 外默认放行(黑名单制)? 详见 `## 🔴 2026-06-20 BUG-260620-05` | 🟡 待决策 | --- diff --git a/src-tauri/src/commands/workflow.rs b/src-tauri/src/commands/workflow.rs index 42a8540..c5000a6 100644 --- a/src-tauri/src/commands/workflow.rs +++ b/src-tauri/src/commands/workflow.rs @@ -8,7 +8,7 @@ use tauri::{AppHandle, Emitter, State}; use tokio::sync::broadcast::error::RecvError; use df_types::events::{WorkflowEvent, HumanApprovalResponse, SelectType}; -use df_types::types::{new_id, NodeStatus}; +use df_types::types::{new_id, ExecutionId, NodeStatus}; use df_nodes::task_advance_node::advance_task_atomic; // F-260616-06 ②-4: 工作流失败时按 target_status 推算任务退回态。 // regression_target 已收敛到 df-nodes::task_state_machine(状态机业务契约,单一可信源), @@ -29,7 +29,7 @@ use super::{err_str, now_millis}; #[derive(Debug, Clone, Serialize)] struct WorkflowEventPayload { /// 工作流执行记录 ID - execution_id: String, + execution_id: ExecutionId, /// 原始工作流事件(serde tag = "type") event: WorkflowEvent, } @@ -385,7 +385,7 @@ pub async fn get_workflow_execution( pub async fn approve_human_approval( app: AppHandle, state: State<'_, AppState>, - execution_id: String, + execution_id: ExecutionId, node_id: String, decision: String, // F-260615-01: 多选结果数组,缺省空数组(单选调用方不传) @@ -466,7 +466,7 @@ pub async fn approve_human_approval( #[tauri::command] pub async fn cancel_workflow_node( state: State<'_, AppState>, - execution_id: String, + execution_id: ExecutionId, node_id: String, ) -> Result<(), String> { // 经 execution_id 取执行器状态机(与 NodeContext.node_status 共享同一 HashMap)