refactor: 归整工作流执行与差异比较
This commit is contained in:
1 parent
f4f34a83b4
commit
c989e544e4
15 files changed
+41
-32
No files matched your search
@@ -86,7 +86,7 @@ hose-use workflow eval-script --code="return a + b;" --input='{"a":1,"b":2}'
|
||||
- `timedOut`、`diagnosticsComplete`、`diagnosticsErrors` 区分执行超时、读取失败与没有失败节点;权限错误不再被当成空的成功结果。
|
||||
- 条件解释支持已声明的比较操作符、嵌套 AND/OR 和循环上下文;缺少证据、不支持的值类型或执行尚未结束时,`evaluation` / `matched` 为 `null`,不据此声称分支判定为 False。
|
||||
- `diff-job` 按父任务路径、循环路径及重复次数配对实例;JSON 节点包含 `instanceKey` / `currentLoopPath`,输出变化也计入差异。
|
||||
- `execution-context.ts` 是条件解释和 Job diff 共用的纯执行实例索引,不负责请求或 CLI 输出。
|
||||
- `execution/context.ts` 是条件解释和 Job diff 共用的纯执行实例索引,不负责请求或 CLI 输出。
|
||||
- 代码出参摘要使用同一执行树展开函数,覆盖条件、循环及已有子执行容器;同名节点的多次执行分别保留。
|
||||
- `logs --has-error` 包括已经产生错误的在途任务,错误标记不被 RUNNING/STARTED 覆盖。`--state` 保留原有终态筛选兼容语义,不能替代“包含错误”筛选;筛选仍针对当前返回页。
|
||||
- `job` 无法读取工作流详情时,状态显示“未知”,不会把可用 Job 的未知工作流状态显示成“已停用”。
|
||||
@@ -207,9 +207,6 @@ MVEL 本地仿真支持的是转译子集:零参 `HashMap` / `ArrayList` 及 `
|
||||
|---|---|
|
||||
| [api.ts](./api.ts)、[types.ts](./types.ts) | HTTP 请求/响应校验与工作流 Zod 模型 |
|
||||
| [services.ts](./services.ts) | 显式业务出口及既有能力目录的统一导出 |
|
||||
| [execution.ts](./execution.ts)、[execution-context.ts](./execution-context.ts) | 执行树展开、失败节点提取及执行实例上下文 |
|
||||
| [diff.ts](./diff.ts) | 配置快照与执行结果差异 |
|
||||
| [debug.ts](./debug.ts) | 调试、输入采样和结果汇总 |
|
||||
|
||||
### 子目录
|
||||
|
||||
@@ -217,6 +214,8 @@ MVEL 本地仿真支持的是转译子集:零参 `HashMap` / `ArrayList` 及 `
|
||||
|---|---|
|
||||
| [management](./management/README.management.md) | 工作流列表、查询、创建、复制、保存及启停 |
|
||||
| [catalog](./catalog/README.catalog.md) | DSL、节点权限与业务枚举字典 |
|
||||
| [execution](./execution/README.execution.md) | 执行树、实例上下文及调试结果汇总 |
|
||||
| [comparison](./comparison/README.comparison.md) | 配置快照和 Job 执行结果的差异比较 |
|
||||
| [triggers](./triggers/README.triggers.md) | 触发器分类、初始节点构建及 Webhook 地址与复制规则;实际调度由合思服务端负责 |
|
||||
| [nodes](./nodes/README.nodes.md) | 节点树遍历、定位、增删改和重排,以及灰度节点目录 |
|
||||
| [analysis](./analysis/README.analysis.md) | 工作流结构、引用依赖和配置的静态分析与诊断 |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { WorkflowTaskExecution } from "../types.js";
|
||||
import { indexExecutionContexts } from "../execution-context.js";
|
||||
import { indexExecutionContexts } from "../execution/context.js";
|
||||
import type { ConditionBranchExplanation, ConditionRuleExplanation } from "./types.js";
|
||||
|
||||
export const OP_MAP: Record<string, string> = {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# 工作流差异比较
|
||||
|
||||
[diff.ts](./diff.ts) 比较工作流配置快照和 Job 执行结果;执行实例索引来自同级 [execution](../execution/README.execution.md)。比较为纯本地计算,不发起请求或修改工作流。
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import { indexExecutionContexts } from "./execution-context.js";
|
||||
import { WorkflowTask, WorkflowTaskExecution, WorkflowSnapshot, WorkflowSnapshotDiff, TaskConfigDiff, WorkflowJobDetail, WorkflowJobDiff, NodeExecutionDiff } from "./types.js";
|
||||
import { flattenWorkflowTasks } from "./execution.js";
|
||||
import { indexExecutionContexts } from "../execution/context.js";
|
||||
import { WorkflowTask, WorkflowTaskExecution, WorkflowSnapshot, WorkflowSnapshotDiff, TaskConfigDiff, WorkflowJobDetail, WorkflowJobDiff, NodeExecutionDiff } from "../types.js";
|
||||
import { flattenWorkflowTasks } from "../execution/tree.js";
|
||||
|
||||
|
||||
/**
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { diffWorkflowJobs } from "./services.js";
|
||||
import type { WorkflowJobDetail, WorkflowTaskExecution } from "./types.js";
|
||||
import { diffWorkflowJobs } from "../services.js";
|
||||
import type { WorkflowJobDetail, WorkflowTaskExecution } from "../types.js";
|
||||
|
||||
const job = { id: "job", status: "COMPLETED" } as WorkflowJobDetail;
|
||||
const node = (id: string, loop: string, status = "COMPLETED", value = 1): WorkflowTaskExecution => ({ id, name: "edit", type: "code", status, currentLoopPath: loop, inputs: { value } });
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { diffWorkflowSnapshots } from "./services.js";
|
||||
import { diffWorkflowSnapshots } from "../services.js";
|
||||
for (const field of ["mapping", "inputs", "fields", "form", "header", "params", "onError", "customConfig"]) {
|
||||
test(`snapshot diff includes ${field} changes`, () => {
|
||||
const before = { id: "a", tasks: [{ name: "node", type: "http", [field]: { target: "old" } }] } as any;
|
||||
@@ -0,0 +1,7 @@
|
||||
# 工作流执行与调试
|
||||
|
||||
- [tree.ts](./tree.ts):执行树展开、失败识别和节点查找,也提供工作流任务树展开。
|
||||
- [context.ts](./context.ts):构建执行实例索引,供条件解释与 Job 差异比较复用。
|
||||
- [debug.ts](./debug.ts):调试输入、发起 Job、轮询和诊断汇总。
|
||||
|
||||
执行监听位于同级 [watch](../watch/README.watch.md),条件解释位于 `branch/`;HTTP 传输位于上级 `api.ts`。
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { WorkflowTaskExecution } from "./types.js";
|
||||
import type { WorkflowTaskExecution } from "../types.js";
|
||||
|
||||
export interface ExecutionContext {
|
||||
node: WorkflowTaskExecution;
|
||||
+9
-9
@@ -1,8 +1,8 @@
|
||||
import * as api from "./api.js";
|
||||
import { ValidationError } from "../../../core/errors.js";
|
||||
import { explainConditionBranches } from "./branch/index.js";
|
||||
import { WorkflowJobDetail } from "./types.js";
|
||||
import { extractFailureExecutions } from "./execution.js";
|
||||
import * as api from "../api.js";
|
||||
import { ValidationError } from "../../../../core/errors.js";
|
||||
import { explainConditionBranches } from "../branch/index.js";
|
||||
import { WorkflowJobDetail } from "../types.js";
|
||||
import { extractFailureExecutions } from "./tree.js";
|
||||
|
||||
|
||||
export function getWebhookInfo(...args: Parameters<typeof api.getWebhookInfo>) {
|
||||
@@ -31,14 +31,14 @@ export async function runWorkflowDebugTest(
|
||||
options: {
|
||||
flowCodeOrId?: string;
|
||||
data?: Record<string, any>;
|
||||
triggerCategory?: import("./types.js").WorkflowTriggerCategory;
|
||||
triggerCategory?: import("../types.js").WorkflowTriggerCategory;
|
||||
triggerType?: string;
|
||||
triggerLabel?: string;
|
||||
autoPublish?: boolean;
|
||||
timeoutMs?: number;
|
||||
pollIntervalMs?: number;
|
||||
} = {}
|
||||
): Promise<import("./types.js").WorkflowTestReport> {
|
||||
): Promise<import("../types.js").WorkflowTestReport> {
|
||||
if (!Number.isFinite(options.timeoutMs ?? 15000) || (options.timeoutMs ?? 15000) < 0 || !Number.isFinite(options.pollIntervalMs ?? 500) || (options.pollIntervalMs ?? 500) <= 0) {
|
||||
throw new ValidationError("timeoutMs 必须为非负数,pollIntervalMs 必须为正数");
|
||||
}
|
||||
@@ -115,7 +115,7 @@ export async function runWorkflowDebugTest(
|
||||
const diagnosticsComplete = diagnosticsErrors.length === 0;
|
||||
const status = jobState(finalJob);
|
||||
const hasExecutionError = rawFailed.length > 0 || finalJob?.hasError === true || Number(finalJob?.errorTaskCount ?? 0) > 0;
|
||||
let outcome: import("./types.js").WorkflowTestReport["outcome"] = "incomplete";
|
||||
let outcome: import("../types.js").WorkflowTestReport["outcome"] = "incomplete";
|
||||
if (timedOut) outcome = "timed_out";
|
||||
else if (terminal.has(status) && (status !== "COMPLETED" || hasExecutionError)) outcome = "failed";
|
||||
else if (status === "COMPLETED" && diagnosticsComplete) outcome = "completed";
|
||||
@@ -146,6 +146,6 @@ export async function getWorkflowSampleData(
|
||||
client: import("ky").KyInstance,
|
||||
pipelineId: string,
|
||||
type = "webhook"
|
||||
): Promise<import("./types.js").WorkflowSampleDataResult> {
|
||||
): Promise<import("../types.js").WorkflowSampleDataResult> {
|
||||
return api.getWorkflowSampleData(client, pipelineId, type);
|
||||
}
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import type { KyInstance } from "ky";
|
||||
import { z } from "zod";
|
||||
import { AuthenticationError, EkbApiError } from "../../../core/errors.js";
|
||||
import { classifyCliError } from "../../../cli/errors.js";
|
||||
import { listRunningJobs, unwrap } from "./api.js";
|
||||
import { watchWorkflowPipeline } from "./watch/pipeline-watcher.js";
|
||||
import { AuthenticationError, EkbApiError } from "../../../../core/errors.js";
|
||||
import { classifyCliError } from "../../../../cli/errors.js";
|
||||
import { listRunningJobs, unwrap } from "../api.js";
|
||||
import { watchWorkflowPipeline } from "../watch/pipeline-watcher.js";
|
||||
|
||||
const responding = (body: unknown) => ({ get: async () => Response.json(body) }) as unknown as KyInstance;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { WorkflowTask, WorkflowTaskExecution } from "./types.js";
|
||||
import { WorkflowTask, WorkflowTaskExecution } from "../types.js";
|
||||
|
||||
|
||||
/**
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { runWorkflowDebugTest } from "./services.js";
|
||||
import { runWorkflowDebugTest } from "../services.js";
|
||||
|
||||
function setup(status = "COMPLETED", errors: string[] = []) {
|
||||
const posts: string[] = [];
|
||||
@@ -51,19 +51,19 @@ export {
|
||||
triggerWorkflowDebug,
|
||||
runWorkflowDebugTest,
|
||||
getWorkflowSampleData,
|
||||
} from "./debug.js";
|
||||
} from "./execution/debug.js";
|
||||
export {
|
||||
flattenExecutionTree,
|
||||
isTaskExecutionFailed,
|
||||
extractFailureExecutions,
|
||||
findExecutionNode,
|
||||
flattenWorkflowTasks,
|
||||
} from "./execution.js";
|
||||
} from "./execution/tree.js";
|
||||
export {
|
||||
generateTextDiff,
|
||||
diffWorkflowSnapshots,
|
||||
diffWorkflowJobs,
|
||||
} from "./diff.js";
|
||||
} from "./comparison/diff.js";
|
||||
|
||||
export {
|
||||
explainConditionBranches,
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
- [initial.ts](./initial.ts):创建工作流时构建初始触发器节点。
|
||||
- [webhook.ts](./webhook.ts):Webhook 地址解析,以及新建和复制时的地址、样本处理。
|
||||
|
||||
通用 Job 调试和传输仍由工作流的 `debug.ts`、`api.ts` 负责;CLI 参数和输出仍在命令层。既有 `types.ts` 和 `services.ts` 导出保留兼容。
|
||||
通用 Job 调试和传输分别由 [execution/debug.ts](../execution/debug.ts) 和上级 `api.ts` 负责;CLI 参数和输出仍在命令层。既有 `types.ts` 和 `services.ts` 导出保留兼容。
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { WorkflowTaskExecution } from "../types.js";
|
||||
import { flattenExecutionTree, isTaskExecutionFailed } from "../execution.js";
|
||||
import { flattenExecutionTree, isTaskExecutionFailed } from "../execution/tree.js";
|
||||
import type { WorkflowWatchEvent } from "./types.js";
|
||||
import { extractTaskErrorMessage } from "./helpers.js";
|
||||
|
||||
|
||||
Reference in new issue
Block a user