新增: F-04多Provider负载均衡池(数据层+选择器+并发原语)+CR-52白项

This commit is contained in:
2026-06-17 02:04:58 +08:00
parent 31ea151bb2
commit 79b6a43095
12 changed files with 463 additions and 16 deletions

View File

@@ -76,7 +76,8 @@ pub async fn run_workflow(
) -> Result<String, String> {
// 瘦转发到 run_workflow_inner(B-260617-01:抽取共用核心供 ai_approve 经
// execute_run_workflow_for_tool 直接调,无需构造 tauri::State)。
run_workflow_inner(&app, &state, name, dag, config, task_id, target_status).await
// CR-52: 命令层(前端 invoke run_workflow)是人工手动触发 → triggered_by="manual"。
run_workflow_inner(&app, &state, name, dag, config, task_id, target_status, "manual").await
}
/// 工作流执行核心逻辑(B-260617-01 抽取,命令层瘦转发)。
@@ -84,6 +85,11 @@ pub async fn run_workflow(
/// 原 `run_workflow` 命令体拆出,使 ai_approve 经 execute_run_workflow_for_tool 直接调用
/// (持 &AppState 而非 tauri::State,绕开 tauri::State 在非命令上下文不可构造的限制)。
/// 语义与原命令完全一致:模板选 DAG → 落执行记录 → spawn 事件转发 + DAG 执行 + 任务联动推进。
///
/// `triggered_by` 落入 WorkflowRecord.triggered_by,区分触发来源:
/// - 命令层 run_workflow(前端 invoke,人工手动)传 "manual"
/// - execute_run_workflow_for_tool(AI 工具经 ai_approve 审批后执行)传 "ai"
/// CR-52:原硬编码 "manual" 致 AI 路径误标,改由调用方透传。
pub async fn run_workflow_inner(
app: &AppHandle,
state: &AppState,
@@ -92,6 +98,7 @@ pub async fn run_workflow_inner(
config: serde_json::Value,
task_id: Option<String>,
target_status: Option<String>,
triggered_by: &str,
) -> Result<String, String> {
// 0. F-260616-06 ①-1: DagDef 来源选模板(方案A·最小)。
// 规则:
@@ -121,11 +128,9 @@ pub async fn run_workflow_inner(
name,
dag_json,
status: "running".to_string(),
// B-260617-01: AI 工具经 ai_approve 触发时标 triggered_by=ai(区分人工手动触发)。
// 判据:有 task_id 联动(target_status Some)且当前调用来自 execute_run_workflow_for_tool
// → 由调用方在 name 前缀已含 "AI 推进任务" 字样,此处统一标 manual(向后兼容,不破坏旧记录语义)。
// 精细化 triggered_by=ai 留待后续(需加参数透传,本次最小改动)。
triggered_by: Some("manual".to_string()),
// CR-52: triggered_by 由调用方透传(命令层 run_workflow="manual",
// execute_run_workflow_for_tool="ai"),不再硬编码 "manual" 致 AI 路径误标。
triggered_by: Some(triggered_by.to_string()),
project_id: None,
task_id: task_id.clone(),
created_at: now_millis(),