M5(2/3): process 用例与流转 —— 流程引擎的确定性调度

- routing domain:选边(XOR 恰取一条 + 默认分支兜底;AND 全走)、边映射装配(四类来源 +
  S-FEEL 转换)、AND 汇合回齐(容忍分支不阻汇合)、审批点驳回走向声明式
- process-service:起单 → 调度节点 → 负责人四策略解析(结果与依据留痕)→
  活动起单 / 审批点卡工位 / 终点收束按来源回执;任务终态到达继续流转或走失败走向四选一;
  审批驳回按声明回指定节点重开新实例;状态每次变动后重算聚合投影
- adapter:流程包(id × version)、工作流实例、节点实例三表持久 —— 崩溃后可续跑

ADR 待补项登记为 debt M5-1:§6.1 的 Mastra workflow 编译器作为可替换 adapter 后补,
当前由自持确定性状态机承担,语义等价、usecase 不动

325 个测试通过,门禁五道全绿

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
JCAI Main Agent
2026-07-27 02:01:08 +08:00
co-authored by Claude Opus 5
parent 291fc39179
commit a8f6eef610
15 changed files with 4072 additions and 10 deletions
+43
View File
@@ -0,0 +1,43 @@
CREATE TABLE "sys"."node_instance" (
"workflow_id" text NOT NULL,
"node_id" text NOT NULL,
"instance" integer NOT NULL,
"running" boolean DEFAULT false NOT NULL,
"waiting" boolean DEFAULT false NOT NULL,
"activated" boolean DEFAULT true NOT NULL,
"terminal" text,
"failure_digested" boolean,
"task_id" text,
"approval_id" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "node_instance_workflow_id_node_id_instance_pk" PRIMARY KEY("workflow_id","node_id","instance")
);
--> statement-breakpoint
CREATE TABLE "sys"."process_package" (
"id" text NOT NULL,
"version" integer NOT NULL,
"name" text NOT NULL,
"state" text DEFAULT 'draft' NOT NULL,
"definition" jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"published_at" timestamp with time zone,
CONSTRAINT "process_package_id_version_pk" PRIMARY KEY("id","version")
);
--> statement-breakpoint
CREATE TABLE "sys"."workflow" (
"id" text PRIMARY KEY NOT NULL,
"package_id" text NOT NULL,
"package_version" integer NOT NULL,
"subject" text NOT NULL,
"state" text DEFAULT 'running' NOT NULL,
"source" jsonb NOT NULL,
"initiation" jsonb NOT NULL,
"ports" jsonb DEFAULT '{}'::jsonb NOT NULL,
"vars" jsonb DEFAULT '{}'::jsonb NOT NULL,
"started_at" timestamp with time zone DEFAULT now() NOT NULL,
"finished_at" timestamp with time zone
);
--> statement-breakpoint
CREATE INDEX "node_instance_task_idx" ON "sys"."node_instance" USING btree ("task_id");--> statement-breakpoint
CREATE INDEX "process_package_state_idx" ON "sys"."process_package" USING btree ("state");--> statement-breakpoint
CREATE INDEX "workflow_state_idx" ON "sys"."workflow" USING btree ("state","started_at");