三面拆分⑭:纯编排第三轮 —— 活动卸岗位、卡点废除全真边、边号 E1–En 图上可选

活动契约不带负责人岗位(用户定):
- schema:活动节点删 owner(审批点的 approver 是「卡到人的工位」的功能语义,保留)
- 运行时:活动任务默认**全员轮值**(在岗候选并集、最闲者先、staffId 稳定排序,
  owner-resolved 事件岗位记「(全员轮值)」);运营分派机制落地后让位 —— 债已记
- closure:活动点不核岗位,missing-owner-position 只出自审批点
- 员工面链条:活动点报**实际承接人**(实例→任务→人),没起的如实报「轮值待派」;
  NodeInstance 公开 taskId/approvalId(店面读回,与端口型合流)
- 画布/导出依赖文件/属性卡全线摘岗位;属性卡活动点明说「分派归运营」

卡点画法废除,顺序流一律真边(用户定):
- 种子图重画:四条回跳/直达(E4 直接定价、E6 选型后定价、E10 不通过、E12 有异议)
  全部画成折线真边,车道分层零交叉(顶 y30 / y190 / y230 / 缝隙对开 / 底 y380);
  卡点节点删净,图=恰 10 语义节点 + 14 真边一一对应(测试守着)
- graph-to-pkg 卡点认亲机制删除;pkg-to-graph 直接按 from→to 认亲
- 元素盘删卡点件;图例、属性卡卡点分支、kindLabel/kindTone 随删

边号 E1、E2…(用户定):
- 语义边 id 即边号:种子 E1–E14;合并器铸号(旧边保号、新边取下一空号,回归测试守着)
- 画布线标带号(`E3 直接寻源`,无注记的边也标 `E1`);拣选条以边号立牌,
  **条件不再上按钮** —— 条件/映射只住属性面
- 边在图上可选中:FlowDiagram 连线加宽透明命中垫(边可点时注解层提到形状层上),
  点线即切属性卡到该边(实测 E4 命中)

测试:closure 28、advance-order 6、graph-to-pkg 5(新增铸号例)、seed 8、
端到端八例真库全绿(全员轮值下照跑);五闸退出码验过。
库:purge 后重种,唯一 unified-quote@v1 生效(双面判据齐)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
2026-07-28 19:02:07 +08:00
co-authored by Claude Fable 5
parent 281f4ef084
commit 7f0d25c337
21 changed files with 361 additions and 436 deletions
-60
View File
@@ -498,16 +498,6 @@ export declare const listProcessPackagesRoute: {
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
@@ -682,16 +672,6 @@ export declare const saveProcessRoute: {
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
@@ -854,16 +834,6 @@ export declare const saveProcessRoute: {
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
@@ -1065,16 +1035,6 @@ export declare const setProcessStateRoute: {
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
@@ -1242,16 +1202,6 @@ export declare const validateProcessRoute: {
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
@@ -2271,16 +2221,6 @@ export declare const govWorkflowRoute: {
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
-20
View File
@@ -157,16 +157,6 @@ export declare const processNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
@@ -311,16 +301,6 @@ export declare const processPackageSchema: z.ZodObject<{
in: z.ZodOptional<z.ZodArray<z.ZodString>>; in: z.ZodOptional<z.ZodArray<z.ZodString>>;
out: z.ZodOptional<z.ZodArray<z.ZodString>>; out: z.ZodOptional<z.ZodArray<z.ZodString>>;
activityVersion: z.ZodOptional<z.ZodString>; activityVersion: z.ZodOptional<z.ZodString>;
owner: z.ZodObject<{
position: z.ZodString;
strategy: z.ZodDefault<z.ZodEnum<{
assigned: "assigned";
sole: "sole";
rotation: "rotation";
"follow-source": "follow-source";
}>>;
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{ failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"terminate">; kind: z.ZodLiteral<"terminate">;
}, z.core.$strip>, z.ZodObject<{ }, z.core.$strip>, z.ZodObject<{
@@ -1,14 +1,14 @@
/** /**
* 流程包(无网关版)—— 守四件事:拓扑齐且零网关、分支即条件出边、 * 流程包(纯编排版)—— 守四件事:拓扑齐、分支即条件出边、
* 审批点两个去向都由图表达、回边标了 reopen。 * 审批点两个去向都由图表达、图上每条语义边都画成真边(卡点画法已废)。
*/ */
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { MVP_PACKAGE } from '../seed-mvp-flow.ts'; import { MVP_PACKAGE } from '../seed-mvp-flow.ts';
describe('MVP_PACKAGE', () => { describe('MVP_PACKAGE', () => {
it('10 语义节点 · 14 边 · 一审批点双终点(网关在 schema 里已不存在)', () => { it('10 语义节点 · 14 边编号 E1–E14 · 一审批点双终点', () => {
expect(MVP_PACKAGE.nodes).toHaveLength(10); expect(MVP_PACKAGE.nodes).toHaveLength(10);
expect(MVP_PACKAGE.edges).toHaveLength(14); expect(MVP_PACKAGE.edges.map((e) => e.id)).toEqual(Array.from({ length: 14 }, (_, i) => `E${i + 1}`));
expect(MVP_PACKAGE.nodes.filter((n) => n.kind === 'approval')).toHaveLength(1); expect(MVP_PACKAGE.nodes.filter((n) => n.kind === 'approval')).toHaveLength(1);
expect(MVP_PACKAGE.nodes.filter((n) => n.kind === 'end')).toHaveLength(2); expect(MVP_PACKAGE.nodes.filter((n) => n.kind === 'end')).toHaveLength(2);
}); });
@@ -62,35 +62,29 @@ describe('MVP_PACKAGE', () => {
]); ]);
}); });
it('手绘图存证:10 语义节点 + 4 卡点(直达两枚是正向边的呈现,回跳两枚照旧)', () => { it('手绘图存证:恰是 10 个语义节点,零卡点(卡点画法已废)', () => {
const nodes = (MVP_PACKAGE.diagram as { nodes: { id: string; kind: string }[] }).nodes; const nodes = (MVP_PACKAGE.diagram as { nodes: { id: string; kind: string }[] }).nodes;
expect(nodes.filter((n) => n.kind === 'callout')).toHaveLength(4); expect(nodes.filter((n) => n.kind === 'callout')).toHaveLength(0);
expect(nodes).toHaveLength(14); expect(nodes).toHaveLength(10);
const drawn = new Set(nodes.map((n) => n.id)); const drawn = new Set(nodes.map((n) => n.id));
for (const n of MVP_PACKAGE.nodes) expect(drawn.has(n.id), `图上缺 ${n.id}`).toBe(true); for (const n of MVP_PACKAGE.nodes) expect(drawn.has(n.id), `图上缺 ${n.id}`).toBe(true);
}); });
/* /*
* 语义边必须**每条都画在图上**(直连线,或指向带 `to` 卡点的线)—— * 语义边必须**每条都画成真边** —— 画布保存由画出来的边反推语义边,
* 画布保存由画出来的边反推语义边,没画的那条会在第一次存盘时被静默丢掉 * 没画的那条会在第一次存盘时被静默丢掉
* (实测:A1→A3「直接寻源」漏画,mergeGraphIntoPackage 一过就没了)。 * (实测:A1→A3「直接寻源」漏画,mergeGraphIntoPackage 一过就没了)。
*/ */
it('图边对账:每条语义边都有画出来的对应(直连或经卡点)', () => { it('图边对账:每条语义边都画成真边,一一对应', () => {
const dia = MVP_PACKAGE.diagram as { const dia = MVP_PACKAGE.diagram as { edges: { from: string; to: string }[] };
nodes: { id: string; kind: string; to?: string }[]; const drawnPairs = dia.edges.map((e) => `${e.from}→${e.to}`).sort();
edges: { from: string; to: string }[]; const semPairs = MVP_PACKAGE.edges.map((e) => `${e.from}→${e.to}`).sort();
}; expect(drawnPairs).toEqual(semPairs);
const calloutTo = new Map(dia.nodes.filter((n) => n.kind === 'callout').map((n) => [n.id, n.to]));
const drawnPairs = new Set(dia.edges.map((e) => `${e.from}→${calloutTo.get(e.to) ?? e.to}`));
for (const e of MVP_PACKAGE.edges) {
expect(drawnPairs.has(`${e.from}→${e.to}`), `语义边 ${e.id}(${e.from}→${e.to})没画在图上`).toBe(true);
}
}); });
it('几何:坐标吸附 10px 珊格,框不重叠', () => { it('几何:坐标吸附 10px 珊格,框不重叠', () => {
const nodes = (MVP_PACKAGE.diagram as { nodes: { id: string; kind: string; x: number; y: number }[] }).nodes; const nodes = (MVP_PACKAGE.diagram as { nodes: { id: string; kind: string; x: number; y: number }[] }).nodes;
const size = (kind: string) => const size = (kind: string) => (kind === 'activity' ? { w: 100, h: 40 } : { w: 20, h: 20 });
kind === 'callout' ? { w: 100, h: 30 } : kind === 'activity' ? { w: 100, h: 40 } : { w: 20, h: 20 };
for (const n of nodes) { for (const n of nodes) {
expect(n.x % 10, `${n.id} x`).toBe(0); expect(n.x % 10, `${n.id} x`).toBe(0);
expect(n.y % 10, `${n.id} y`).toBe(0); expect(n.y % 10, `${n.id} y`).toBe(0);
+20 -10
View File
@@ -93,29 +93,39 @@ export function registerDeskRoutes(app: Hono<AppEnv>, container: Container): voi
return await Promise.all( return await Promise.all(
nodes.map(async (n) => { nodes.map(async (n) => {
const spec = n.kind === 'approval' ? n.approver : n.owner;
/* /*
* 报谁,要和**真正派单时的口径一致**(ADR-011:绑定先于策略)。 * 报谁,要和**真正派单时的口径一致**。
* 只按岗位报人的话,装了工作组的单会当面说谎:整条流实际都归起单人, * 审批点:ADR-011 绑定先于策略 —— 先看工作组绑定,再退回岗位解析。
* 链上却写着各岗位的常驻人。所以这里也先看工作组绑定,再退回岗位解析。 * 活动点:契约不带岗位(分派归运营)—— 起了单的报**实际承接人**(任务上的),
* 还没起的如实报「轮值待派」,不编造具体承接人。
*/ */
let who;
let fallbackName = '轮值待派';
let fallbackRole = '全员轮值';
if (n.kind === 'approval') {
const spec = n.approver;
fallbackName = spec.position;
fallbackRole = spec.position;
const bound = workflow.workGroup?.[spec.position]; const bound = workflow.workGroup?.[spec.position];
const boundStaff = const boundStaff =
bound === undefined bound === undefined
? undefined ? undefined
: await container.org.getStaff(staffIdSchema.parse(bound)).catch(() => undefined); : await container.org.getStaff(staffIdSchema.parse(bound)).catch(() => undefined);
// 岗位唯一解析(sole)即报人名;否则只报岗位
// 岗位唯一解析(sole)即报人名;否则只报岗位 —— 不编造具体承接人
const holders = const holders =
boundStaff !== undefined ? [] : await container.org.staffOfPosition(spec.position).catch(() => []); boundStaff !== undefined ? [] : await container.org.staffOfPosition(spec.position).catch(() => []);
const who = boundStaff ?? (holders.length === 1 ? holders[0] : undefined); who = boundStaff ?? (holders.length === 1 ? holders[0] : undefined);
} else {
const inst = instances.find((x) => x.nodeId === n.id && x.taskId !== undefined);
const owned = inst?.taskId === undefined ? undefined : await container.task.get(taskIdSchema.parse(inst.taskId)).catch(() => undefined);
who = owned === undefined ? undefined : await container.org.getStaff(owned.ownerId).catch(() => undefined);
}
return { return {
nodeId: n.id, nodeId: n.id,
label: n.label, label: n.label,
kind: n.kind === 'approval' ? ('approval' as const) : ('activity' as const), kind: n.kind === 'approval' ? ('approval' as const) : ('activity' as const),
ownerName: who?.name ?? spec.position, ownerName: who?.name ?? fallbackName,
ownerRole: who?.position.name ?? spec.position, ownerRole: who?.position.name ?? fallbackRole,
state: state:
n.id === task.nodeId n.id === task.nodeId
? ('current' as const) ? ('current' as const)
+90 -82
View File
@@ -1,34 +1,23 @@
/** /**
* 「统一报价」流程包 —— **无网关**:语义取自 `docs/MVP示例工作流.html`,结构按新模型展开。 * 「统一报价」流程包 —— **纯编排**:语义取自 `docs/MVP示例工作流.html`,结构按新模型展开。
* *
* 分支 = 源节点的条件出边(恰取一条,无条件边作默认兜底);汇合 = 多入边异或。 * 节点只分活动点与审批点(起止是结构件);分支 = 源节点的条件出边(恰取一条,
* FIG.1 的 G1/G2/G4 各自消失成 A1/A2/A6 的条件出边;G2J 与 G3 整颗不再需要。 * 无条件边作默认兜底);汇合 = 多入边异或。活动契约不带负责人岗位 —— 分派归运营。
* 10 节点 14 边;审批点 A5 的两个去向就是它自己的两条条件出边(verdict 由引擎注入)。 * 10 节点 14 边(E1–E14);审批点 A5 的两个去向就是它自己的两条条件出边(verdict 由引擎注入)。
* *
* 几何:两带换行、零交叉;直达与回跳都用**卡点**表达(不画长线)—— * 几何:顺序流一律画成**真边**(卡点画法已废除,2026-07-28 第三轮),零交叉:
* 卡点带 `to`,`mergeGraphIntoPackage` 只认语义边已存在的还原,编辑器保存不丢边。 * 直达与回跳各占一条车道,长线避框走 —— 见 diagram 里逐段注记。
*/ */
import { processPackageSchema, triggerConfigSchema } from '@contracts'; import { processPackageSchema, triggerConfigSchema } from '@contracts';
import type { ProcessPackage } from '@contracts'; import type { ProcessPackage } from '@contracts';
import type { Container } from './container.ts'; import type { Container } from './container.ts';
/** 活动节点:岗位独任、失败即终止 —— 槽位期不谈容忍 */ /** 活动节点:失败即终止(槽位期不谈容忍);岗位不入契约 —— 分派归运营 */
const activityNode = ( const activityNode = (id: string, label: string, activityId: string, col: number, row: number, x: number, y: number) => ({
id: string,
label: string,
activityId: string,
position: string,
col: number,
row: number,
x: number,
y: number,
) => ({
id, id,
kind: 'activity' as const, kind: 'activity' as const,
label, label,
sub: position,
activityId, activityId,
owner: { position, strategy: 'sole' as const },
failure: { kind: 'terminate' as const }, failure: { kind: 'terminate' as const },
layout: { row, col, x, y }, layout: { row, col, x, y },
}); });
@@ -60,21 +49,16 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
output: { type: 'object', properties: { landingRate: { type: 'number' } } }, output: { type: 'object', properties: { landingRate: { type: 'number' } } },
}, },
/* /*
* **无网关**(产品决策 2026-07-28):分支 = 源节点的多条条件出边(恰取一条,
* 无条件边作默认兜底),汇合 = 多入边异或(上游互斥,只会来一条)。
* 与 Mastra 同构:条件挂在步与步之间,步保持纯粹。
* FIG.1 的 G1/G2/G4 于是各自消失成 A1/A2/A6 的条件出边;
* G2J(当年为绕「隐式合并」禁令而生的显式汇合点)与 G3(审批结果)整颗不再需要 ——
* A4 的三条正向入边互斥即合法,A5 的裁决就是它自己的两条条件出边。
*
* 10 节点:start · A1 受理 · A2 选型 · A3 寻源 · A4 定价 · A5 审批 · A6 议价 · A7 归档 · 双终点。 * 10 节点:start · A1 受理 · A2 选型 · A3 寻源 · A4 定价 · A5 审批 · A6 议价 · A7 归档 · 双终点。
* 原 G1/G2/G4 各自消失成 A1/A2/A6 的条件出边;G2J 与 G3 整颗不再需要 ——
* A4 的三条正向入边互斥即合法,A5 的裁决就是它自己的两条条件出边。
*/ */
nodes: [ nodes: [
{ id: 'start', kind: 'start', label: '客户RFQ询价', layout: { row: 0, col: 0, x: 30, y: 70 } }, { id: 'start', kind: 'start', label: '客户RFQ询价', layout: { row: 0, col: 0, x: 30, y: 70 } },
activityNode('A1', '客户RFQ受理', 'rfq-intake', 'BD', 1, 0, 110, 60), activityNode('A1', '客户RFQ受理', 'rfq-intake', 1, 0, 110, 60),
activityNode('A2', '替代选型', 'alt-selection', 'FAE', 2, 0, 290, 60), activityNode('A2', '替代选型', 'alt-selection', 2, 0, 290, 60),
activityNode('A3', '寻源询价', 'sourcing-inquiry', 'PRM', 3, 0, 470, 60), activityNode('A3', '寻源询价', 'sourcing-inquiry', 3, 0, 470, 60),
activityNode('A4', '成本定价', 'cost-pricing', 'BD', 4, 1, 110, 310), activityNode('A4', '成本定价', 'cost-pricing', 4, 1, 110, 310),
{ {
id: 'A5', id: 'A5',
kind: 'approval', kind: 'approval',
@@ -83,7 +67,7 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
approver: { position: 'PM', strategy: 'sole' }, approver: { position: 'PM', strategy: 'sole' },
/* /*
* 驳回走向声明式,不由临场决定:退回 A4 重新定价。 * 驳回走向声明式,不由临场决定:退回 A4 重新定价。
* 图上由 A5 自己的 `verdict = "reject"` 条件出边**显式表达同一件事**, * 图上由 A5 自己的 `verdict = "reject"` 条件出边(E10)**显式表达同一件事**,
* 引擎先看图(有边走边,没边才退回本声明),两处须字字对齐 —— 有测试守着。 * 引擎先看图(有边走边,没边才退回本声明),两处须字字对齐 —— 有测试守着。
* 本声明不能删:schema 必填,且它是通用机制(不是每条流都把驳回画成边)。 * 本声明不能删:schema 必填,且它是通用机制(不是每条流都把驳回画成边)。
*/ */
@@ -91,14 +75,14 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
nudge: { steps: [{ after: 'PT20M', action: 'nudge' }], deadline: 'PT30M' }, nudge: { steps: [{ after: 'PT20M', action: 'nudge' }], deadline: 'PT30M' },
layout: { row: 1, col: 5, x: 290, y: 310 }, layout: { row: 1, col: 5, x: 290, y: 310 },
}, },
activityNode('A6', '报价议价', 'quote-negotiation', 'BD', 6, 1, 470, 310), activityNode('A6', '报价议价', 'quote-negotiation', 6, 1, 470, 310),
activityNode('A7', '情报归档', 'intel-archive', 'BD', 7, 2, 630, 410), activityNode('A7', '情报归档', 'intel-archive', 7, 2, 630, 410),
{ id: 'end_won', kind: 'end', label: '转订单履约', layout: { row: 1, col: 7, x: 630, y: 320 } }, { id: 'end_won', kind: 'end', label: '转订单履约', layout: { row: 1, col: 7, x: 630, y: 320 } },
{ id: 'end_arch', kind: 'end', label: '归档闭环', layout: { row: 2, col: 8, x: 790, y: 420 } }, { id: 'end_arch', kind: 'end', label: '归档闭环', layout: { row: 2, col: 8, x: 790, y: 420 } },
], ],
edges: [ edges: [
{ {
id: 'e-start-a1', id: 'E1',
from: 'start', from: 'start',
to: 'A1', to: 'A1',
mapping: [ mapping: [
@@ -113,7 +97,7 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
/* A1 的三条出边 —— 原 G1「是否需要选型」+ G2「是否需要寻源」在直达路径上的合并展开 */ /* A1 的三条出边 —— 原 G1「是否需要选型」+ G2「是否需要寻源」在直达路径上的合并展开 */
{ {
id: 'e-a1-a2', id: 'E2',
from: 'A1', from: 'A1',
to: 'A2', to: 'A2',
condition: 'needAlternative = true', condition: 'needAlternative = true',
@@ -126,7 +110,7 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
reopen: false, reopen: false,
}, },
{ {
id: 'e-a1-a3', id: 'E3',
from: 'A1', from: 'A1',
to: 'A3', to: 'A3',
condition: 'needAlternative = false and needSourcing = true', condition: 'needAlternative = false and needSourcing = true',
@@ -135,11 +119,11 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
reopen: false, reopen: false,
}, },
// 默认兜底:不选型不寻源 → 直接定价(条件全不中时走它,旗齐时它就是第三种情形) // 默认兜底:不选型不寻源 → 直接定价(条件全不中时走它,旗齐时它就是第三种情形)
{ id: 'e-a1-a4', from: 'A1', to: 'A4', label: '直接定价', mapping: REENTER_A4, reopen: false }, { id: 'E4', from: 'A1', to: 'A4', label: '直接定价', mapping: REENTER_A4, reopen: false },
/* A2 的两条出边 —— 原 G2 在选型路径上的那一问 */ /* A2 的两条出边 —— 原 G2 在选型路径上的那一问 */
{ {
id: 'e-a2-a3', id: 'E5',
from: 'A2', from: 'A2',
to: 'A3', to: 'A3',
condition: 'needSourcing = true', condition: 'needSourcing = true',
@@ -147,10 +131,10 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
mapping: [{ target: 'pn', source: { from: 'output-port', port: 'intake', path: 'pn' } }], mapping: [{ target: 'pn', source: { from: 'output-port', port: 'intake', path: 'pn' } }],
reopen: false, reopen: false,
}, },
{ id: 'e-a2-a4', from: 'A2', to: 'A4', label: '选型后定价', mapping: REENTER_A4, reopen: false }, { id: 'E6', from: 'A2', to: 'A4', label: '选型后定价', mapping: REENTER_A4, reopen: false },
{ {
id: 'e-a3-a4', id: 'E7',
from: 'A3', from: 'A3',
to: 'A4', to: 'A4',
label: '供应商底价表', label: '供应商底价表',
@@ -161,11 +145,11 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
], ],
reopen: false, reopen: false,
}, },
{ id: 'e-a4-a5', from: 'A4', to: 'A5', mapping: [], label: '报价草案提审', reopen: false }, { id: 'E8', from: 'A4', to: 'A5', mapping: [], label: '报价草案提审', reopen: false },
/* A5 审批点自己的两条条件出边 —— 裁决(verdict)由引擎在裁决时放进载荷 */ /* A5 审批点自己的两条条件出边 —— 裁决(verdict)由引擎在裁决时放进载荷 */
{ {
id: 'e-a5-a6', id: 'E9',
from: 'A5', from: 'A5',
to: 'A6', to: 'A6',
condition: 'verdict = "pass"', condition: 'verdict = "pass"',
@@ -179,7 +163,7 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
reopen: false, reopen: false,
}, },
{ {
id: 'e-a5-a4', id: 'E10',
from: 'A5', from: 'A5',
to: 'A4', to: 'A4',
condition: 'verdict = "reject"', condition: 'verdict = "reject"',
@@ -192,7 +176,7 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
/* A6 的三条条件出边 —— outcome 由放行选口给出(选择组恰选一口) */ /* A6 的三条条件出边 —— outcome 由放行选口给出(选择组恰选一口) */
{ {
id: 'e-a6-won', id: 'E11',
from: 'A6', from: 'A6',
to: 'end_won', to: 'end_won',
condition: 'outcome = "won"', condition: 'outcome = "won"',
@@ -202,7 +186,7 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
reopen: false, reopen: false,
}, },
{ {
id: 'e-a6-a4', id: 'E12',
from: 'A6', from: 'A6',
to: 'A4', to: 'A4',
condition: 'outcome = "revise"', condition: 'outcome = "revise"',
@@ -212,7 +196,7 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
reopen: true, reopen: true,
}, },
{ {
id: 'e-a6-a7', id: 'E13',
from: 'A6', from: 'A6',
to: 'A7', to: 'A7',
condition: 'outcome = "lost"', condition: 'outcome = "lost"',
@@ -227,17 +211,19 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
], ],
reopen: false, reopen: false,
}, },
{ id: 'e-a7-end', from: 'A7', to: 'end_arch', mapping: [], label: '归档闭环', reopen: false }, { id: 'E14', from: 'A7', to: 'end_arch', mapping: [], label: '归档闭环', reopen: false },
], ],
variables: [], variables: [],
/* /*
* 手绘几何存证 —— 呈现以它为真相。两带换行、零交叉: * 手绘几何存证 —— 呈现以它为真相。顺序流全是真边,零交叉:
* 顶车道 y30:A1「直接寻源」跨过 A2 直达 A3(带上方,不碰任何框) * 顶车道 y30:E3 直接寻源(A1 北口 → A3 北口,跨过 A2)
* 带 0(y60) start → A1 → A2 → A3 受理 · 选型 · 寻源 * 带 0(y60–100) start → A1 → A2 → A3
* 换行车道 y190:A3 右探下折横扫回左,进 A4 北口 * E4 直接定价:A1 南口 x130 直落 A4 北口(x130 在所有横车道的左端之外)
* 带 1(y310) A4 → A5 → A6 → end_won 定价 · 审批 · 议价 · 成交 * 车道 y190:E6 选型后定价(A2 南口 x310 落下,西行,x160 进 A4 北口)
* 带 2(y410) A7 → end_arch 未成交闭环 * 车道 y230:E7 供应商底价表(A3 东探 x610 下行,西扫,x200 进 A4 北口)
* 直达与回跳都用**卡点**表达(不画长线):A1/A2 的「直接定价」牌与 A5/A6 的回 A4 牌。 * 带 1(y310–350) A4 → A5 → A6 → end_won;E8/E10 在 A4–A5 缝隙里一上一下对开
* 车道 y380:E12 有异议(A6 南口 x500 落下,西扫,x160 上顶 A4 南口)
* E13 拒绝/超时:A6 南口 x520 下行右拐进 A7;带 2(y410+) A7 → end_arch
*/ */
diagram: { diagram: {
manual: true, manual: true,
@@ -245,25 +231,20 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
anchors: [], anchors: [],
nodes: [ nodes: [
{ id: 'start', kind: 'start', label: '客户RFQ询价', x: 30, y: 70, lx: 44, ly: 104 }, { id: 'start', kind: 'start', label: '客户RFQ询价', x: 30, y: 70, lx: 44, ly: 104 },
{ id: 'A1', kind: 'activity', label: '客户RFQ受理', code: 'A1', owner: 'BD', x: 110, y: 60 }, { id: 'A1', kind: 'activity', label: '客户RFQ受理', code: 'A1', x: 110, y: 60 },
{ id: 'A2', kind: 'activity', label: '替代选型', code: 'A2', owner: 'FAE', x: 290, y: 60 }, { id: 'A2', kind: 'activity', label: '替代选型', code: 'A2', x: 290, y: 60 },
{ id: 'A3', kind: 'activity', label: '寻源询价', code: 'A3', owner: 'PRM', x: 470, y: 60 }, { id: 'A3', kind: 'activity', label: '寻源询价', code: 'A3', x: 470, y: 60 },
{ id: 'A4', kind: 'activity', label: '成本定价', code: 'A4', owner: 'BD', x: 110, y: 310 }, { id: 'A4', kind: 'activity', label: '成本定价', code: 'A4', x: 110, y: 310 },
{ id: 'A5', kind: 'activity', label: '定价审批', code: 'A5', owner: 'PM', flavor: 'approval', x: 290, y: 310 }, { id: 'A5', kind: 'activity', label: '定价审批', code: 'A5', owner: 'PM', flavor: 'approval', x: 290, y: 310 },
{ id: 'A6', kind: 'activity', label: '报价议价', code: 'A6', owner: 'BD', x: 470, y: 310 }, { id: 'A6', kind: 'activity', label: '报价议价', code: 'A6', x: 470, y: 310 },
{ id: 'A7', kind: 'activity', label: '情报归档', code: 'A7', owner: 'BD', x: 630, y: 410 }, { id: 'A7', kind: 'activity', label: '情报归档', code: 'A7', x: 630, y: 410 },
{ id: 'end_won', kind: 'end', label: '转订单履约', x: 630, y: 320, lx: 640, ly: 352 }, { id: 'end_won', kind: 'end', label: '转订单履约', x: 630, y: 320, lx: 640, ly: 352 },
{ id: 'end_arch', kind: 'end-bad', label: '归档闭环', x: 790, y: 420, lx: 800, ly: 452 }, { id: 'end_arch', kind: 'end-bad', label: '归档闭环', x: 790, y: 420, lx: 800, ly: 452 },
/* 四枚卡点:直达两枚(正向,语义边真实存在)、回跳两枚 —— 全在各自源节点的上下车道 */
{ id: 'c_d1', kind: 'callout', label: '直接定价', to: 'A4', x: 110, y: 170 },
{ id: 'c_d2', kind: 'callout', label: '选型后定价', to: 'A4', x: 290, y: 170 },
{ id: 'c_reject', kind: 'callout', label: '退回调整', to: 'A4', x: 290, y: 240 },
{ id: 'c_revise', kind: 'callout', label: '返回调整', to: 'A4', x: 470, y: 240 },
], ],
edges: [ edges: [
{ from: 'start', to: 'A1', points: [{ x: 50, y: 80 }, { x: 110, y: 80 }] }, { from: 'start', to: 'A1', points: [{ x: 50, y: 80 }, { x: 110, y: 80 }] },
{ from: 'A1', to: 'A2', label: '需要选型', points: [{ x: 210, y: 80 }, { x: 290, y: 80 }] }, { from: 'A1', to: 'A2', label: '需要选型', points: [{ x: 210, y: 80 }, { x: 290, y: 80 }] },
// 直接寻源走顶车道 y30(A1 北口 → A3 北口):画布保存只认画出来的边,这条不画就会丢 // E3 顶车道:跨过 A2 直达 A3 北口
{ {
from: 'A1', from: 'A1',
to: 'A3', to: 'A3',
@@ -275,32 +256,59 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
{ x: 520, y: 60 }, { x: 520, y: 60 },
], ],
}, },
// E4 直落:x130 在 E6(x160 起)与 E7(x200 起)两条横车道左端之外,零交叉
{ from: 'A1', to: 'A4', label: '直接定价', lx: 88, ly: 200, points: [{ x: 130, y: 100 }, { x: 130, y: 310 }] },
{ from: 'A2', to: 'A3', label: '仍需寻源', points: [{ x: 390, y: 80 }, { x: 470, y: 80 }] }, { from: 'A2', to: 'A3', label: '仍需寻源', points: [{ x: 390, y: 80 }, { x: 470, y: 80 }] },
// 换行那一笔:A3 右探 → 降到 190 车道 → 横扫回左 → 落 A4 北口 // E6 车道 y190:A2 南口下行、西行、进 A4 北口
{ {
from: 'A3', from: 'A2',
to: 'A4', to: 'A4',
label: '供应商底价表', label: '选型后定价',
// 标注钉在 y190 车道的空档(x390–610)—— 默认取折线中点,会被「选型后定价→A4」卡点压住 lx: 235,
lx: 450, ly: 182,
ly: 183,
points: [ points: [
{ x: 570, y: 80 }, { x: 310, y: 100 },
{ x: 610, y: 80 }, { x: 310, y: 190 },
{ x: 610, y: 190 },
{ x: 160, y: 190 }, { x: 160, y: 190 },
{ x: 160, y: 310 }, { x: 160, y: 310 },
], ],
}, },
// 直达两枚卡点(正向):不选不寻 → 直接定价;选完不寻 → 定价 // E7 车道 y230:A3 东探绕行(x610),在 E6 之下、A5 上行线之上零交叉扫回
{ from: 'A1', to: 'c_d1', label: '不选不寻', points: [{ x: 160, y: 100 }, { x: 160, y: 170 }] }, {
{ from: 'A2', to: 'c_d2', label: '不再寻源', points: [{ x: 340, y: 100 }, { x: 340, y: 170 }] }, from: 'A3',
{ from: 'A4', to: 'A5', label: '报价草案提审', points: [{ x: 210, y: 330 }, { x: 290, y: 330 }] }, to: 'A4',
label: '供应商底价表',
lx: 420,
ly: 222,
points: [
{ x: 570, y: 80 },
{ x: 610, y: 80 },
{ x: 610, y: 230 },
{ x: 200, y: 230 },
{ x: 200, y: 310 },
],
},
// E8/E10:A4–A5 缝隙里一上一下对开(y320 提审,y340 退回)
{ from: 'A4', to: 'A5', label: '报价草案提审', lx: 250, ly: 312, points: [{ x: 210, y: 320 }, { x: 290, y: 320 }] },
{ from: 'A5', to: 'A6', label: '通过', tone: 'ok', points: [{ x: 390, y: 330 }, { x: 470, y: 330 }] }, { from: 'A5', to: 'A6', label: '通过', tone: 'ok', points: [{ x: 390, y: 330 }, { x: 470, y: 330 }] },
{ from: 'A5', to: 'c_reject', label: '不通过', tone: 'bad', points: [{ x: 340, y: 310 }, { x: 340, y: 270 }], lx: 310, ly: 292 }, { from: 'A5', to: 'A4', label: '不通过', tone: 'bad', lx: 250, ly: 352, points: [{ x: 290, y: 340 }, { x: 210, y: 340 }] },
{ from: 'A6', to: 'end_won', label: '成交', tone: 'ok', points: [{ x: 570, y: 330 }, { x: 630, y: 330 }] }, { from: 'A6', to: 'end_won', label: '成交', tone: 'ok', points: [{ x: 570, y: 330 }, { x: 630, y: 330 }] },
{ from: 'A6', to: 'c_revise', label: '有异议', tone: 'bad', points: [{ x: 520, y: 310 }, { x: 520, y: 270 }], lx: 545, ly: 292 }, // E12 车道 y380:A6 南口西扫,上顶 A4 南口
{ from: 'A6', to: 'A7', label: '拒绝/超时', tone: 'bad', points: [{ x: 520, y: 350 }, { x: 520, y: 430 }, { x: 630, y: 430 }], lx: 545, ly: 388 }, {
from: 'A6',
to: 'A4',
label: '有异议',
tone: 'bad',
lx: 330,
ly: 372,
points: [
{ x: 500, y: 350 },
{ x: 500, y: 380 },
{ x: 160, y: 380 },
{ x: 160, y: 350 },
],
},
{ from: 'A6', to: 'A7', label: '拒绝/超时', tone: 'bad', lx: 560, ly: 405, points: [{ x: 520, y: 350 }, { x: 520, y: 430 }, { x: 630, y: 430 }] },
{ from: 'A7', to: 'end_arch', label: '归档闭环', points: [{ x: 730, y: 430 }, { x: 790, y: 430 }] }, { from: 'A7', to: 'end_arch', label: '归档闭环', points: [{ x: 730, y: 430 }, { x: 790, y: 430 }] },
], ],
}, },
+12 -4
View File
@@ -29,14 +29,22 @@
随手画的半成品也存得进来(存出来即 `retired`,不生效);`setPackageState` 激活时 随手画的半成品也存得进来(存出来即 `retired`,不生效);`setPackageState` 激活时
跑 `checkClosure`,不闭合抛 `NotClosedError`(HTTP 412 带整份报告)。 跑 `checkClosure`,不闭合抛 `NotClosedError`(HTTP 412 带整份报告)。
违规项:未完成边、必填未映射、类型冲突、孤立节点、多默认出边、 违规项:未完成边、必填未映射、类型冲突、孤立节点、多默认出边、
活动未装载、岗位不存在、容忍分支被下游必填依赖 —— 任一即 `closed = false`,激活被拒。 活动未装载、审批岗位不存在、容忍分支被下游必填依赖 —— 任一即 `closed = false`,激活被拒。
- **纯编排模型**(产品决策 2026-07-28 第二轮):流程包只决定**活动编排**与 (活动点不核岗位 —— 契约不带负责人,`missing-owner-position` 只出自审批点。)
- **纯编排模型**(产品决策 2026-07-28 二、三轮):流程包只决定**活动编排**与
**活动传递的契约**,不决定活动的实现方式(范式/版本住活动库,节点仅以 **活动传递的契约**,不决定活动的实现方式(范式/版本住活动库,节点仅以
`activityId` 链接)。节点只分**活动点**与**审批点**(起点/终点是结构件); `activityId` 链接),**也不带负责人岗位**(分派归运营;运营分派机制未建前,
`kind: 'gateway'` 已从 schema 摘除(库经外科手术清空,无历史包袱)。 活动任务运行时默认全员轮值 —— 在岗候选并集、最闲者先、staffId 稳定排序。
审批点例外:「卡到人的工位」是它的功能语义,`approver` 留在声明里,
工作组绑定 ADR-011 也只对它生效)。节点只分**活动点**与**审批点**
(起点/终点是结构件);`kind: 'gateway'` 已从 schema 摘除。
分支 = 源节点的多条条件出边(恰取一条,无条件边作默认兜底、至多一条), 分支 = 源节点的多条条件出边(恰取一条,无条件边作默认兜底、至多一条),
汇合 = 多入边异或(上游互斥,只会来一条 —— `joinReady` 已删,没有「等回齐」)。 汇合 = 多入边异或(上游互斥,只会来一条 —— `joinReady` 已删,没有「等回齐」)。
AND 并行暂无声明机制,将来以「并行组」加回(对应 Mastra `.parallel`,见 debt.md)。 AND 并行暂无声明机制,将来以「并行组」加回(对应 Mastra `.parallel`,见 debt.md)。
- **边有编号身份**:语义边 id 即边号(E1、E2…,服务端/合并器铸号,旧边保号、
新边取下一个空号);画布线标带号、边在图上可选中,条件与映射住属性面。
顺序流一律画成**真边**(卡点画法已废除)—— 画布保存由画出来的边反推语义边,
图上没画的语义边会在存盘时丢失,种子与测试按「一一对应」守着。
- **激活双判据**:①图编排闭合完善(结构 + 属性 + 传递契约,`checkClosure` 的 - **激活双判据**:①图编排闭合完善(结构 + 属性 + 传递契约,`checkClosure` 的
非 unknown-activity 项)②活动装载(节点链接的实现已安装,`unknown-activity` 项)。 非 unknown-activity 项)②活动装载(节点链接的实现已安装,`unknown-activity` 项)。
两面都清零才可激活;图照画照存,未装载不拦保存。 两面都清零才可激活;图照画照存,未装载不拦保存。
@@ -34,7 +34,6 @@ const pkg = (over: Partial<ProcessPackage> = {}): ProcessPackage =>
kind: 'activity', kind: 'activity',
label: 'A4 成本定价', label: 'A4 成本定价',
activityId: 'a4' as never, activityId: 'a4' as never,
owner: { position: 'BD', strategy: 'sole' },
failure: { kind: 'terminate' }, failure: { kind: 'terminate' },
}, },
{ id: 'end' as never, kind: 'end', label: '终点' }, { id: 'end' as never, kind: 'end', label: '终点' },
@@ -101,9 +100,31 @@ describe('checkClosure —— 不闭合不得激活', () => {
expect(report.violations.map((v) => v.kind)).toContain('unknown-activity'); expect(report.violations.map((v) => v.kind)).toContain('unknown-activity');
}); });
it('岗位不存在即拦', () => { /* 活动点不核岗位(契约不带负责人);审批点的岗位是功能语义,不存在即拦 */
const report = checkClosure({ pkg: pkg(), contracts, positions: new Set(['PM']) }); it('审批点岗位不存在即拦;活动点没有岗位可核', () => {
expect(report.violations.map((v) => v.kind)).toContain('missing-owner-position'); const withApproval = pkg({
nodes: [
...pkg().nodes,
{
id: 'AP' as never,
kind: 'approval',
label: '审批',
approver: { position: 'GONE', strategy: 'sole' },
reject: { kind: 'terminate' },
},
],
edges: [
...pkg().edges.filter((e) => e.id !== 'e2'),
{ id: 'e2', from: 'A4' as never, to: 'AP' as never, mapping: [], reopen: false },
{ id: 'e3', from: 'AP' as never, to: 'end' as never, mapping: [], reopen: false },
],
});
const violations = checkClosure({ pkg: withApproval, contracts, positions }).violations;
expect(violations.filter((v) => v.kind === 'missing-owner-position').map((v) => v.nodeId)).toEqual(['AP']);
// 活动节点引用的岗位集合再小也与它无关 —— 不产生岗位类违规
const noPositions = checkClosure({ pkg: pkg(), contracts, positions: new Set() }).violations;
expect(noPositions.filter((v) => v.kind === 'missing-owner-position')).toEqual([]);
}); });
it('孤立节点即拦', () => { it('孤立节点即拦', () => {
@@ -115,7 +136,6 @@ describe('checkClosure —— 不闭合不得激活', () => {
kind: 'activity', kind: 'activity',
label: '游离节点', label: '游离节点',
activityId: 'a4' as never, activityId: 'a4' as never,
owner: { position: 'BD', strategy: 'sole' },
failure: { kind: 'terminate' }, failure: { kind: 'terminate' },
}, },
], ],
@@ -156,7 +176,6 @@ describe('checkClosure —— 不闭合不得激活', () => {
kind: 'activity', kind: 'activity',
label: 'A3 渠道寻源', label: 'A3 渠道寻源',
activityId: 'a4' as never, activityId: 'a4' as never,
owner: { position: 'PRM', strategy: 'sole' },
failure: { kind: 'tolerate' }, failure: { kind: 'tolerate' },
}, },
{ {
@@ -164,7 +183,6 @@ describe('checkClosure —— 不闭合不得激活', () => {
kind: 'activity', kind: 'activity',
label: 'A4 成本定价', label: 'A4 成本定价',
activityId: 'a4' as never, activityId: 'a4' as never,
owner: { position: 'BD', strategy: 'sole' },
failure: { kind: 'terminate' }, failure: { kind: 'terminate' },
}, },
{ id: 'end' as never, kind: 'end', label: '终点' }, { id: 'end' as never, kind: 'end', label: '终点' },
@@ -126,6 +126,8 @@ export function createProcessStore(db: Db): ProcessStore {
activated: r.activated, activated: r.activated,
...(r.terminal === null ? {} : { terminal: r.terminal as TerminalState }), ...(r.terminal === null ? {} : { terminal: r.terminal as TerminalState }),
...(r.failureDigested === null ? {} : { failureDigested: r.failureDigested }), ...(r.failureDigested === null ? {} : { failureDigested: r.failureDigested }),
...(r.taskId === null ? {} : { taskId: r.taskId }),
...(r.approvalId === null ? {} : { approvalId: r.approvalId }),
}), }),
); );
}, },
@@ -57,8 +57,9 @@ export function checkClosure(input: ClosureInput): ClosureReport {
} }
if (node.kind === 'activity') { if (node.kind === 'activity') {
violations.push(...checkActivityNode(node, incoming.get(node.id) ?? [], contracts, positions)); violations.push(...checkActivityNode(node, incoming.get(node.id) ?? [], contracts));
} }
// 活动点不核岗位(契约不带负责人 —— 分派归运营);审批点的岗位是功能语义,照核
if (node.kind === 'approval' && !positions.has(node.approver.position)) { if (node.kind === 'approval' && !positions.has(node.approver.position)) {
violations.push({ violations.push({
kind: 'missing-owner-position', kind: 'missing-owner-position',
@@ -94,7 +95,6 @@ function checkActivityNode(
node: Extract<ProcessNode, { kind: 'activity' }>, node: Extract<ProcessNode, { kind: 'activity' }>,
inbound: readonly Edge[], inbound: readonly Edge[],
contracts: ReadonlyMap<string, ActivityContractFace>, contracts: ReadonlyMap<string, ActivityContractFace>,
positions: ReadonlySet<string>,
): ClosureViolation[] { ): ClosureViolation[] {
const out: ClosureViolation[] = []; const out: ClosureViolation[] = [];
const face = contracts.get(node.activityId); const face = contracts.get(node.activityId);
@@ -108,14 +108,6 @@ function checkActivityNode(
return out; return out;
} }
if (!positions.has(node.owner.position)) {
out.push({
kind: 'missing-owner-position',
nodeId: node.id,
message: `节点「${node.label}」的岗位不存在:${node.owner.position}`,
});
}
// 连一条边即须完成该边映射 // 连一条边即须完成该边映射
for (const edge of inbound) { for (const edge of inbound) {
if (edge.mapping.length === 0) { if (edge.mapping.length === 0) {
@@ -120,6 +120,9 @@ export type NodeInstance = {
readonly failureDigested?: boolean; readonly failureDigested?: boolean;
/** XOR 未选分支从未激活 —— 不入集合 */ /** XOR 未选分支从未激活 —— 不入集合 */
readonly activated: boolean; readonly activated: boolean;
/** 该实例派出的任务 / 审批(结构件与终点没有)—— 链条视图按它报实际承接人 */
readonly taskId?: string;
readonly approvalId?: string;
}; };
export function aggregateWorkflowState( export function aggregateWorkflowState(
@@ -1,7 +1,7 @@
/** /**
* process 用例 —— 流程引擎:确定性流转,**零 LLM、零临场**(编码规范 §5.3;语义出处 OS 03 / 04)。 * process 用例 —— 流程引擎:确定性流转,**零 LLM、零临场**(编码规范 §5.3;语义出处 OS 03 / 04)。
* *
* 起单 · 调度节点 · 审批点卡工位 · 网关分合 · 每次流转记入事件。 * 起单 · 调度节点 · 审批点卡工位 · 条件出边选路 · 每次流转记入事件。
*/ */
import type { ProcessNode, ProcessPackage, StaffId, TerminalState, WorkflowState } from '@contracts'; import type { ProcessNode, ProcessPackage, StaffId, TerminalState, WorkflowState } from '@contracts';
import type { ProcessService, StartWorkflowInput } from '../../contract.ts'; import type { ProcessService, StartWorkflowInput } from '../../contract.ts';
@@ -87,7 +87,7 @@ export function createProcessService(deps: ProcessServiceDeps): ProcessService {
const dispatch = dispatchOf(node, payload); const dispatch = dispatchOf(node, payload);
if (dispatch === undefined) { if (dispatch === undefined) {
// 网关本身不是责任单元:直接继续流转 // 只剩起点会走到这(结构件无调度):被指为目标时直通,不建实例
await advanceFrom(record, pkg, node.id, payload); await advanceFrom(record, pkg, node.id, payload);
return; return;
} }
@@ -122,15 +122,31 @@ export function createProcessService(deps: ProcessServiceDeps): ProcessService {
return; return;
} }
// 负责人 / 审批人:编排声明岗位,起单时确定性解析;结果与依据留痕
const spec = dispatch.kind === 'start-task' ? dispatch.node.owner : dispatch.node.approver;
const candidates = await deps.org.candidates(spec.position);
/* /*
* 绑定先于策略:工作组说了这个岗位是谁,策略就无从发问(ADR-011)。 * 谁来干:**活动契约不带岗位**(纯编排,2026-07-28 第三轮)—— 分派是运营的事。
* 在岗与否在这里核 —— 绑定是**跨岗位**指派,拿该岗位的候选集核不了它。 * 运营分派机制未建前,活动任务默认**全员轮值**(在岗候选并集,最闲者先,
* staffId 稳定排序保证同输入必同结果);审批点例外,「卡到人的工位」是它的
* 功能语义,仍按 approver 岗位解析,工作组绑定(ADR-011)也只对它生效。
*/ */
let spec;
let candidates;
let bound;
if (dispatch.kind === 'start-task') {
spec = { position: '(全员轮值)', strategy: 'sole' as const };
const seen = new Map<string, { staffId: string; name: string; openTasks: number }>();
for (const position of await deps.org.positions()) {
for (const c of await deps.org.candidates(position)) if (!seen.has(c.staffId)) seen.set(c.staffId, c);
}
candidates = [...seen.values()];
bound = undefined;
} else {
spec = dispatch.node.approver;
candidates = await deps.org.candidates(spec.position);
// 绑定先于策略:工作组说了这个岗位是谁,策略就无从发问(ADR-011)。
// 在岗与否在这里核 —— 绑定是**跨岗位**指派,拿该岗位的候选集核不了它。
const boundTo = record.workGroup?.[spec.position]; const boundTo = record.workGroup?.[spec.position];
const bound = boundTo !== undefined && (await deps.org.isActive(boundTo)) ? boundTo : undefined; bound = boundTo !== undefined && (await deps.org.isActive(boundTo)) ? boundTo : undefined;
}
const resolution = resolveOwner(spec, { candidates, ...(bound === undefined ? {} : { bound }) }); const resolution = resolveOwner(spec, { candidates, ...(bound === undefined ? {} : { bound }) });
if (resolution.kind === 'vacant') throw new PositionVacantError(spec.position); if (resolution.kind === 'vacant') throw new PositionVacantError(spec.position);
@@ -68,14 +68,6 @@ function flowsOf(packages: readonly ProcessPackage[]) {
/* ── 边属性:传递契约(条件 + 映射)──────────────────────────────────── */ /* ── 边属性:传递契约(条件 + 映射)──────────────────────────────────── */
/** 卡点 id → 去向节点 id(边属性按语义对端认亲:A5→c_reject 即 A5→A4) */
function calloutToOf(graph: FlowGraph | null): Map<string, string> | undefined {
if (graph === null) return undefined;
return new Map(
graph.nodes.filter((n) => n.kind === 'callout' && n.to !== undefined).map((n) => [n.id, n.to!]),
);
}
/** 映射行的工作形状 —— 语义边 mapping 的元素;设计者只见三种来源,其余是系统隐性上下文 */ /** 映射行的工作形状 —— 语义边 mapping 的元素;设计者只见三种来源,其余是系统隐性上下文 */
type MapRow = { target: string; source: Record<string, unknown> & { from: string } }; type MapRow = { target: string; source: Record<string, unknown> & { from: string } };
const SOURCE_KINDS = [ const SOURCE_KINDS = [
@@ -84,21 +76,13 @@ const SOURCE_KINDS = [
{ k: 'constant', label: '常量' }, { k: 'constant', label: '常量' },
] as const; ] as const;
function EdgeProps({ function EdgeProps({ edge, onPatch }: { edge: FlowEdge; onPatch: (f: (e: FlowEdge) => FlowEdge) => void }) {
edge,
toSem,
onPatch,
}: {
edge: FlowEdge;
toSem: string;
onPatch: (f: (e: FlowEdge) => FlowEdge) => void;
}) {
const rows = (edge.mapping ?? []) as MapRow[]; const rows = (edge.mapping ?? []) as MapRow[];
const setRows = (next: MapRow[]) => onPatch((e) => ({ ...e, mapping: next })); const setRows = (next: MapRow[]) => onPatch((e) => ({ ...e, mapping: next }));
const patchRow = (i: number, f: (r: MapRow) => MapRow) => setRows(rows.map((r, j) => (j === i ? f(r) : r))); const patchRow = (i: number, f: (r: MapRow) => MapRow) => setRows(rows.map((r, j) => (j === i ? f(r) : r)));
return ( return (
<div className="g-props"> <div className="g-props">
<Prop ico="git-branch" title={`条件 · ${edge.from} → ${toSem}`} extra="多出边异或:命中即走;留空 = 默认兜底"> <Prop ico="git-branch" title={`${edge.code ?? '边'} · ${edge.from} → ${edge.to}`} extra="多出边异或:命中即走;条件留空 = 默认兜底">
<Field k="S-FEEL 条件" hint="如 needSourcing = true;可用 and / or 连接。留空即无条件(默认边,至多一条)"> <Field k="S-FEEL 条件" hint="如 needSourcing = true;可用 and / or 连接。留空即无条件(默认边,至多一条)">
<input <input
className="g-input mono" className="g-input mono"
@@ -272,7 +256,7 @@ function minimalFlow(id: string, name: string): ProcessPackage {
{ id: 'start', kind: 'start', label: '开始', layout: { row: 0, col: 0, x: 30, y: 70 } }, { id: 'start', kind: 'start', label: '开始', layout: { row: 0, col: 0, x: 30, y: 70 } },
{ id: 'end', kind: 'end', label: '结束', layout: { row: 0, col: 1, x: 150, y: 70 } }, { id: 'end', kind: 'end', label: '结束', layout: { row: 0, col: 1, x: 150, y: 70 } },
], ],
edges: [{ id: 'e-start-end', from: 'start', to: 'end', mapping: [], reopen: false }], edges: [{ id: 'E1', from: 'start', to: 'end', mapping: [], reopen: false }],
variables: [], variables: [],
}); });
} }
@@ -532,17 +516,8 @@ function FlowLab({
}; };
const kindLabel = (n: FlowNode) => const kindLabel = (n: FlowNode) =>
n.kind === 'activity' n.kind === 'activity' ? (n.flavor === 'approval' ? '审批点' : '活动点') : n.kind === 'start' ? '调用接口' : '显式终点';
? n.flavor === 'approval' const kindTone = (n: FlowNode) => (n.kind === 'activity' ? (n.flavor === 'approval' ? 'warn' : 'auto') : 'mute');
? '审批点'
: '活动点'
: n.kind === 'callout'
? '卡点'
: n.kind === 'start'
? '调用接口'
: '显式终点';
const kindTone = (n: FlowNode) =>
n.kind === 'activity' ? (n.flavor === 'approval' ? 'warn' : 'auto') : n.kind === 'callout' ? 'danger' : 'mute';
// 画布上的选中态:diagram-js 给每个形状挂了 data-element-id,外挂一个类,不改画布件 // 画布上的选中态:diagram-js 给每个形状挂了 data-element-id,外挂一个类,不改画布件
useEffect(() => { useEffect(() => {
@@ -680,7 +655,7 @@ function FlowLab({
nodeId: n.id, nodeId: n.id,
label: n.label, label: n.label,
activityId: n.activityId, activityId: n.activityId,
owner: n.owner, // 契约不带负责人岗位 —— 分派归运营,依赖文件只描述干什么
// 编排上手写的注记(给人读) // 编排上手写的注记(给人读)
declaredIn: n.in ?? [], declaredIn: n.in ?? [],
declaredOut: n.out ?? [], declaredOut: n.out ?? [],
@@ -825,7 +800,7 @@ function FlowLab({
<FlowFigureBlock <FlowFigureBlock
key={`${pkg.id}@${pkg.version}`} key={`${pkg.id}@${pkg.version}`}
title={`${pkg.name} v${pkg.version}`} title={`${pkg.name} v${pkg.version}`}
oneLiner={`蓝 = 活动点 · 琥珀 = 审批点 · 红 = 卡点`} oneLiner={`蓝 = 活动点 · 琥珀 = 审批点 · 线标 = 边号`}
graph={graph} graph={graph}
drilledIds={nodes.filter((n) => n.kind === 'activity').map((n) => n.id)} drilledIds={nodes.filter((n) => n.kind === 'activity').map((n) => n.id)}
/* /*
@@ -835,6 +810,12 @@ function FlowLab({
*/ */
canEdit canEdit
onNodeClick={(nid) => { setSel(nid); setSelEdge(null); }} onNodeClick={(nid) => { setSel(nid); setSelEdge(null); }}
onEdgeClick={(edge) => {
const i = (graph?.edges ?? []).findIndex(
(x) => x.from === edge.from && x.to === edge.to && x.code === edge.code,
);
if (i >= 0) { setSelEdge(i); setSel(null); }
}}
onEditNodeText={async (nid, p2) => { onEditNodeText={async (nid, p2) => {
setGraph((g) => setGraph((g) =>
g === null g === null
@@ -949,22 +930,18 @@ function FlowLab({
</button> </button>
))} ))}
</div> </div>
{/* 边拣选条:边属性 = 传递契约(条件 + 映射)—— 图只定顺序,契约在这儿填 */} {/* 边拣选条:边号立牌(E1、E2…),条件住属性面不上按钮 —— 图只定顺序,契约在属性里填 */}
<div className="g-picker"> <div className="g-picker">
{(graph?.edges ?? []).map((e, i) => { {(graph?.edges ?? []).map((e, i) => (
const toSem = calloutToOf(graph)?.get(e.to) ?? e.to;
const brief = e.condition !== undefined && e.condition !== '' ? ` [${e.condition}]` : '';
return (
<button <button
key={`${e.from}→${e.to}-${i}`} key={`${e.from}→${e.to}-${i}`}
className={'g-pick t-mute' + (selEdge === i ? ' on' : '')} className={'g-pick t-mute' + (selEdge === i ? ' on' : '')}
onClick={() => { setSelEdge(selEdge === i ? null : i); setSel(null); }} onClick={() => { setSelEdge(selEdge === i ? null : i); setSel(null); }}
> >
<b className="g-mono">{e.from}→{toSem}</b> <b className="g-mono">{e.code ?? `边${i + 1}`}</b>
{(e.label ?? '') + brief} {e.from}→{e.to}
</button> </button>
); ))}
})}
</div> </div>
{node === null && selEdge === null ? ( {node === null && selEdge === null ? (
<Note> <Note>
@@ -974,7 +951,6 @@ function FlowLab({
) : node === null && selEdge !== null && graph !== null ? ( ) : node === null && selEdge !== null && graph !== null ? (
<EdgeProps <EdgeProps
edge={graph.edges[selEdge]!} edge={graph.edges[selEdge]!}
toSem={calloutToOf(graph)?.get(graph.edges[selEdge]!.to) ?? graph.edges[selEdge]!.to}
onPatch={(f) => { onPatch={(f) => {
setGraph((g) => setGraph((g) =>
g === null ? g : { ...g, edges: g.edges.map((e, i) => (i === selEdge ? f(e) : e)) }, g === null ? g : { ...g, edges: g.edges.map((e, i) => (i === selEdge ? f(e) : e)) },
@@ -1036,10 +1012,8 @@ function FlowLab({
/> />
</Field> </Field>
)} )}
<Field {node.flavor === 'approval' && (
k={node.flavor === 'approval' ? '审批岗位' : '责任岗位'} <Field k="审批岗位" hint="「卡到人的工位」是审批点的功能语义,审批单派给它">
hint={node.flavor === 'approval' ? '审批单派给它' : '任务的负责人由它解析而来'}
>
<select <select
className="g-select" className="g-select"
value={node.owner ?? ''} value={node.owner ?? ''}
@@ -1047,7 +1021,7 @@ function FlowLab({
patch((n) => ({ ...n, owner: e.target.value === '' ? undefined : e.target.value })) patch((n) => ({ ...n, owner: e.target.value === '' ? undefined : e.target.value }))
} }
> >
<option value="">未指定 —— 保存前选一个岗位</option> <option value="">未指定 —— 激活前选一个岗位</option>
{positions.map((q2) => ( {positions.map((q2) => (
<option key={q2.id} value={q2.abbr}> <option key={q2.id} value={q2.abbr}>
{q2.abbr} · {q2.name} {q2.abbr} · {q2.name}
@@ -1055,6 +1029,12 @@ function FlowLab({
))} ))}
</select> </select>
</Field> </Field>
)}
{node.flavor !== 'approval' && (
<Note>
活动点<b>不带岗位</b> —— 谁来干是运营的事(分派机制未建前,运行时全员轮值、最闲者先)。
</Note>
)}
{node.kind === 'activity' && node.flavor === 'approval' && ( {node.kind === 'activity' && node.flavor === 'approval' && (
<Note> <Note>
<b>审批点是系统内置要素</b>,不是活动 —— 声明即用、零开发、不进活动库(一个流程包里需要开发的 <b>审批点是系统内置要素</b>,不是活动 —— 声明即用、零开发、不进活动库(一个流程包里需要开发的
@@ -1062,11 +1042,8 @@ function FlowLab({
(声明式:回指定节点重开新实例 / 终止)· 催办阶梯。运行时它产出<b>审批单</b>而非任务。 (声明式:回指定节点重开新实例 / 终止)· 催办阶梯。运行时它产出<b>审批单</b>而非任务。
</Note> </Note>
)} )}
{node.owner === undefined && ( {node.flavor === 'approval' && node.owner === undefined && (
<Note tone="warn"> <Note tone="warn">这个审批点还没指定岗位 —— 不指定,起单时就不知道审批单该派给谁。</Note>
这个节点还没指定岗位 —— 不指定,起单时就不知道
{node.flavor === 'approval' ? '审批单' : '任务'}该派给谁。
</Note>
)} )}
</Prop> </Prop>
@@ -1088,28 +1065,6 @@ function FlowLab({
/> />
</Prop> </Prop>
)} )}
{node.kind === 'callout' && (
<Prop ico="rotate-ccw" title="去向" extra="失败走向 / 驳回去向">
<Field k="回到节点">
<select
className="g-select"
value={node.to ?? ''}
onChange={(e) =>
patch((n) => ({ ...n, to: e.target.value === '' ? undefined : e.target.value }))
}
>
<option value="">未指定</option>
{nodes
.filter((n) => n.kind === 'activity')
.map((n) => (
<option key={n.id} value={n.id}>
{n.id} · {n.label}
</option>
))}
</select>
</Field>
</Prop>
)}
{node.kind === 'activity' && node.flavor !== 'approval' && ( {node.kind === 'activity' && node.flavor !== 'approval' && (
<Prop ico="boxes" title="链接活动实现" extra="装载面:编排不含实现,链接决定可运行"> <Prop ico="boxes" title="链接活动实现" extra="装载面:编排不含实现,链接决定可运行">
<Field k="实现" hint="活动住库;链好了这节点才算装载(激活判据之二)"> <Field k="实现" hint="活动住库;链好了这节点才算装载(激活判据之二)">
+32 -9
View File
@@ -9,6 +9,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { import {
layoutFlow, layoutFlow,
type ConnectionLayout, type ConnectionLayout,
type FlowEdge,
type FlowGraph, type FlowGraph,
type FlowLayoutResult, type FlowLayoutResult,
type FlowNode, type FlowNode,
@@ -68,13 +69,25 @@ const rendererModule = {
}; };
/** 连线 + 箭头 + 线上标签,画进注解图层(几何全部来自布局引擎)。 */ /** 连线 + 箭头 + 线上标签,画进注解图层(几何全部来自布局引擎)。 */
function drawConnection(layer: SVGElement, connection: ConnectionLayout, variant: FlowVariant): void { function drawConnection(
layer: SVGElement,
connection: ConnectionLayout,
variant: FlowVariant,
onEdgeClick?: (edge: FlowEdge) => void,
): void {
const color = TONE_COLOR[connection.tone]; const color = TONE_COLOR[connection.tone];
const [first, ...rest] = connection.waypoints; const [first, ...rest] = connection.waypoints;
if (first === undefined) return; if (first === undefined) return;
const d = `M${first.x},${first.y} ${rest.map((p) => `L${p.x},${p.y}`).join(" ")}`; const d = `M${first.x},${first.y} ${rest.map((p) => `L${p.x},${p.y}`).join(" ")}`;
layer.append(svg("path", { d, fill: "none", stroke: color, "stroke-width": 1.4 })); if (onEdgeClick !== undefined) {
layer.append(svg("polygon", { points: arrowHeadPoints(connection.waypoints), fill: color })); // 加宽透明命中垫:线太细点不着 —— 边在图上可选中,属性(条件/映射)去属性卡改
const hit = svg("path", { d, fill: "none", stroke: "transparent", "stroke-width": 12, cursor: "pointer" });
(hit as SVGElement & { style: CSSStyleDeclaration }).style.pointerEvents = "stroke";
hit.addEventListener("click", () => onEdgeClick(connection.edge));
layer.append(hit);
}
layer.append(svg("path", { d, fill: "none", stroke: color, "stroke-width": 1.4, "pointer-events": "none" }));
layer.append(svg("polygon", { points: arrowHeadPoints(connection.waypoints), fill: color, "pointer-events": "none" }));
if (connection.label) { if (connection.label) {
layer.append( layer.append(
@@ -94,8 +107,13 @@ function drawConnection(layer: SVGElement, connection: ConnectionLayout, variant
} }
} }
function drawAnnotations(layer: SVGElement, layout: FlowLayoutResult, variant: FlowVariant): void { function drawAnnotations(
for (const connection of layout.connections) drawConnection(layer, connection, variant); layer: SVGElement,
layout: FlowLayoutResult,
variant: FlowVariant,
onEdgeClick?: (edge: FlowEdge) => void,
): void {
for (const connection of layout.connections) drawConnection(layer, connection, variant, onEdgeClick);
for (const caption of layout.captions) { for (const caption of layout.captions) {
const style = CAPTION_STYLE[caption.role]; const style = CAPTION_STYLE[caption.role];
// 严格索引:未知 role 不画注记,而不是画一个半成品 // 严格索引:未知 role 不画注记,而不是画一个半成品
@@ -124,6 +142,8 @@ export interface FlowDiagramProps {
variant: FlowVariant; variant: FlowVariant;
/** 点击活动节点(下钻);不传则节点不可点。 */ /** 点击活动节点(下钻);不传则节点不可点。 */
onNodeClick?: (nodeId: string) => void; onNodeClick?: (nodeId: string) => void;
/** 点击连线(选中边,按边号/两端认);不传则边不可点。 */
onEdgeClick?: ((edge: FlowEdge) => void) | undefined;
/** 双击活动节点就地改文字(标题/小字/主办);不传则不可改。 */ /** 双击活动节点就地改文字(标题/小字/主办);不传则不可改。 */
onEditNode?: ((nodeId: string, patch: { label: string; owner?: string }) => Promise<void>) | undefined; onEditNode?: ((nodeId: string, patch: { label: string; owner?: string }) => Promise<void>) | undefined;
/** 执行人候选(L1 业务能力)——传了则执行字段只能下拉选缩写,不开自由填。 */ /** 执行人候选(L1 业务能力)——传了则执行字段只能下拉选缩写,不开自由填。 */
@@ -137,11 +157,13 @@ interface NodeEdit {
top: number; top: number;
} }
export function FlowDiagram({ graph, variant, onNodeClick, onEditNode, ownerOptions, ariaLabel }: FlowDiagramProps) { export function FlowDiagram({ graph, variant, onNodeClick, onEdgeClick, onEditNode, ownerOptions, ariaLabel }: FlowDiagramProps) {
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
const editRef = useRef<HTMLDivElement>(null); const editRef = useRef<HTMLDivElement>(null);
const clickRef = useRef(onNodeClick); const clickRef = useRef(onNodeClick);
clickRef.current = onNodeClick; clickRef.current = onNodeClick;
const edgeClickRef = useRef(onEdgeClick);
edgeClickRef.current = onEdgeClick;
const editNodeRef = useRef(onEditNode); const editNodeRef = useRef(onEditNode);
editNodeRef.current = onEditNode; editNodeRef.current = onEditNode;
// 单击下钻延时:等一拍看是否双击(双击=改文字,取消下钻)。 // 单击下钻延时:等一拍看是否双击(双击=改文字,取消下钻)。
@@ -189,9 +211,10 @@ export function FlowDiagram({ graph, variant, onNodeClick, onEditNode, ownerOpti
); );
} }
// 连线与标注画在形状之下的图层(层序号小于默认元素层)。 // 连线与标注画在形状之下的图层(层序号小于默认元素层);
const annotationLayer = canvas.getLayer("flow-annotations", -1); // 边可点时提到形状层之上(层序 1),命中垫才接得到点击 —— 线避框走,不遮节点
drawAnnotations(annotationLayer as SVGElement, layout, variant); const annotationLayer = canvas.getLayer("flow-annotations", edgeClickRef.current === undefined ? -1 : 1);
drawAnnotations(annotationLayer as SVGElement, layout, variant, (edge) => edgeClickRef.current?.(edge));
if (layout.ghost) { if (layout.ghost) {
(canvas.getContainer().querySelector(".djs-container svg, svg") as SVGElement | null)?.setAttribute( (canvas.getContainer().querySelector(".djs-container svg, svg") as SVGElement | null)?.setAttribute(
"opacity", "opacity",
+6 -3
View File
@@ -13,7 +13,7 @@ import type { ProcessPackage } from '@contracts';
import { Ico } from '@ui'; import { Ico } from '@ui';
import { FlowDiagram } from './FlowDiagram.tsx'; import { FlowDiagram } from './FlowDiagram.tsx';
import { FlowEditor } from './FlowEditor.tsx'; import { FlowEditor } from './FlowEditor.tsx';
import type { FlowGraph } from './flow-layout.ts'; import type { FlowEdge, FlowGraph } from './flow-layout.ts';
import type { SpPosition } from './support.tsx'; import type { SpPosition } from './support.tsx';
import { packageToGraph } from './pkg-to-graph.ts'; import { packageToGraph } from './pkg-to-graph.ts';
import type { InstanceMark } from './pkg-to-graph.ts'; import type { InstanceMark } from './pkg-to-graph.ts';
@@ -27,6 +27,7 @@ export function FlowFigureBlock({
positions, positions,
canEdit, canEdit,
onNodeClick, onNodeClick,
onEdgeClick,
onEditNodeText, onEditNodeText,
onSaveFlowGraph, onSaveFlowGraph,
}: { }: {
@@ -38,6 +39,8 @@ export function FlowFigureBlock({
positions?: SpPosition[] | undefined; positions?: SpPosition[] | undefined;
canEdit: boolean; canEdit: boolean;
onNodeClick: (nodeId: string) => void; onNodeClick: (nodeId: string) => void;
/** 点击连线选中边(属性卡随之切到该边);不传则边不可点 */
onEdgeClick?: ((edge: FlowEdge) => void) | undefined;
/** 双击流程图活动就地改文字(标题 / 主办) */ /** 双击流程图活动就地改文字(标题 / 主办) */
onEditNodeText?: ((nodeId: string, patch: { label: string; owner?: string }) => Promise<void>) | undefined; onEditNodeText?: ((nodeId: string, patch: { label: string; owner?: string }) => Promise<void>) | undefined;
/** 手工绘图:整图保存(idMap = 本次编辑会话 原id→现id,宿主用它重键下钻内容) */ /** 手工绘图:整图保存(idMap = 本次编辑会话 原id→现id,宿主用它重键下钻内容) */
@@ -52,7 +55,7 @@ export function FlowFigureBlock({
<button <button
type="button" type="button"
className="dc2-addbtn" className="dc2-addbtn"
title="手工绘图(珊格正交:活动/网关/起止/卡点,拖拽连线);画布内工具栏有 取消/保存绘图" title="手工绘图(珊格正交:活动点/审批点/起止,拖拽连线);画布内工具栏有 取消/保存绘图"
onClick={() => setEditing(true)} onClick={() => setEditing(true)}
> >
<Ico name="pen-line" s={11} /> 编辑 <Ico name="pen-line" s={11} /> 编辑
@@ -87,6 +90,7 @@ export function FlowFigureBlock({
graph={graph} graph={graph}
variant="business" variant="business"
onNodeClick={onNodeClick} onNodeClick={onNodeClick}
onEdgeClick={onEdgeClick}
onEditNode={canEdit ? onEditNodeText : undefined} onEditNode={canEdit ? onEditNodeText : undefined}
ownerOptions={positions} ownerOptions={positions}
ariaLabel={`${title}业务流程图`} ariaLabel={`${title}业务流程图`}
@@ -105,7 +109,6 @@ export function FlowFigureBlock({
{/* 节点只分活动点/审批点 —— 标准/案例是实现方式,不进编排面的词汇表 */} {/* 节点只分活动点/审批点 —— 标准/案例是实现方式,不进编排面的词汇表 */}
<span><i className="lg-i fe-pi-sop" aria-hidden /> 活动点</span> <span><i className="lg-i fe-pi-sop" aria-hidden /> 活动点</span>
<span><i className="lg-i fe-pi-approval" aria-hidden /> 审批点</span> <span><i className="lg-i fe-pi-approval" aria-hidden /> 审批点</span>
<span><i className="lg-i fe-pi-callout" aria-hidden /> 卡点</span>
<span><i className="lg-i lg-flow" aria-hidden /> 顺序流</span> <span><i className="lg-i lg-flow" aria-hidden /> 顺序流</span>
<span className="sep">|</span> <span className="sep">|</span>
<span> <span>
@@ -2,9 +2,9 @@
* 画布图 → 流程包:**合并**,不是重建。 * 画布图 → 流程包:**合并**,不是重建。
* *
* 这里守三条容易丢东西的路: * 这里守三条容易丢东西的路:
* ① 画布装不下的声明(驳回走向、负责人策略)保存后必须还在; * ① 画布装不下的声明(驳回走向、失败走向)保存后必须还在;
* ② 回边以**卡点**呈现(MVP 的画法)—— 存盘要还原成语义边,不能连边一起丢; * ② 属性卡的工作副本(节点的链接实现 act、边的条件/映射)保存时要合并为语义;
* ③ 属性卡的工作副本(节点的链接实现 act、边的条件/映射)保存时要合并为语义。 * ③ 边号 E1、E2… 是语义边的编号身份 —— 旧边保号,新画的边铸下一个空号。
*/ */
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { processPackageSchema } from '@contracts'; import { processPackageSchema } from '@contracts';
@@ -20,93 +20,67 @@ const basePkg: ProcessPackage = processPackageSchema.parse({
callInterface: { input: { type: 'object' }, output: { type: 'object' } }, callInterface: { input: { type: 'object' }, output: { type: 'object' } },
nodes: [ nodes: [
{ id: 'S', kind: 'start', label: '起' }, { id: 'S', kind: 'start', label: '起' },
{ { id: 'A', kind: 'activity', label: '甲', activityId: 'act-a', failure: { kind: 'terminate' } },
id: 'A', { id: 'B', kind: 'activity', label: '乙', activityId: 'act-b', failure: { kind: 'terminate' } },
kind: 'activity',
label: '甲',
activityId: 'act-a',
owner: { position: 'BD', strategy: 'rotation' },
failure: { kind: 'terminate' },
},
{
id: 'B',
kind: 'activity',
label: '乙',
activityId: 'act-b',
owner: { position: 'PM', strategy: 'sole' },
failure: { kind: 'terminate' },
},
{ id: 'E', kind: 'end', label: '终' }, { id: 'E', kind: 'end', label: '终' },
], ],
edges: [ edges: [
{ id: 'e-s-a', from: 'S', to: 'A', mapping: [{ target: 'x', source: { from: 'initiation', path: 'x' } }] }, { id: 'E1', from: 'S', to: 'A', mapping: [{ target: 'x', source: { from: 'initiation', path: 'x' } }] },
{ id: 'e-a-b', from: 'A', to: 'B', mapping: [] }, { id: 'E2', from: 'A', to: 'B', mapping: [] },
// 乙的两条互斥出边:通过 → 终点;有异议 → 回甲重开(无网关:分支就在节点身上) // 乙的两条互斥出边:通过 → 终点;有异议 → 回甲重开(无网关:分支就在节点身上)
{ id: 'e-b-e', from: 'B', to: 'E', condition: 'ok = true', mapping: [] }, { id: 'E3', from: 'B', to: 'E', condition: 'ok = true', mapping: [] },
{ id: 'e-b-a', from: 'B', to: 'A', condition: 'ok = false', mapping: [], reopen: true }, { id: 'E4', from: 'B', to: 'A', condition: 'ok = false', mapping: [], reopen: true },
], ],
variables: [], variables: [],
}); });
/** 画布的样子:回边不画长线,画一枚卡点 */ /** 画布的样子:顺序流全是真边(卡点画法已废),回边照画 */
const graph: FlowGraph = { const graph: FlowGraph = {
manual: true, manual: true,
rows: [], rows: [],
anchors: [], anchors: [],
nodes: [ nodes: [
{ id: 'S', kind: 'start', label: '起' }, { id: 'S', kind: 'start', label: '起' },
{ id: 'A', kind: 'activity', label: '甲', owner: 'BD' }, { id: 'A', kind: 'activity', label: '甲' },
{ id: 'B', kind: 'activity', label: '乙', owner: 'PM' }, { id: 'B', kind: 'activity', label: '乙' },
{ id: 'E', kind: 'end', label: '终' }, { id: 'E', kind: 'end', label: '终' },
{ id: 'c1', kind: 'callout', label: '返回调整', to: 'A' },
], ],
edges: [ edges: [
{ from: 'S', to: 'A' }, { from: 'S', to: 'A' },
{ from: 'A', to: 'B' }, { from: 'A', to: 'B' },
{ from: 'B', to: 'E', label: '通过', tone: 'ok' }, { from: 'B', to: 'E', label: '通过', tone: 'ok' },
{ from: 'B', to: 'c1', label: '有异议', tone: 'bad' }, { from: 'B', to: 'A', label: '有异议', tone: 'bad' },
], ],
}; };
describe('mergeGraphIntoPackage', () => { describe('mergeGraphIntoPackage', () => {
it('卡点还原成语义边 —— 回边不因「画成卡点」而消失', () => { it('回边按 from→to 认亲 —— 旧边的号、reopen 与条件都保留', () => {
const merged = mergeGraphIntoPackage(basePkg, graph); const merged = mergeGraphIntoPackage(basePkg, graph);
const back = merged.edges.find((e) => e.from === 'B' && e.to === 'A'); const back = merged.edges.find((e) => e.from === 'B' && e.to === 'A');
expect(back).toBeDefined(); expect(back?.id).toBe('E4');
// 旧边的 id 与 reopen 标记跟着保留:合并按 from→to 认亲
expect(back?.id).toBe('e-b-a');
expect(back?.reopen).toBe(true); expect(back?.reopen).toBe(true);
expect(back?.condition).toBe('ok = false'); expect(back?.condition).toBe('ok = false');
}); });
it('卡点本身不入语义节点,但整张图存进 diagram', () => { it('新画的边铸下一个空号 —— E5,不与旧号相撞', () => {
const merged = mergeGraphIntoPackage(basePkg, graph); const withNew: FlowGraph = {
expect(merged.nodes.map((n) => n.id)).toEqual(['S', 'A', 'B', 'E']);
const diagram = merged.diagram as { nodes: { id: string }[] };
expect(diagram.nodes.map((n) => n.id)).toContain('c1');
});
it('卡点只认亲、不新建 —— 审批点的驳回牌子不该被当成一条边', () => {
// 「审批点 → 退回卡点(to: A)」在旧包里没有对应的边:它是 reject 声明的呈现
const withReject: FlowGraph = {
...graph, ...graph,
nodes: [...graph.nodes, { id: 'AP', kind: 'activity', label: '审批', flavor: 'approval' }], nodes: [...graph.nodes, { id: 'C', kind: 'activity', label: '丙' }],
edges: [...graph.edges, { from: 'AP', to: 'c1', label: '不通过' }], edges: [...graph.edges, { from: 'A', to: 'C' }, { from: 'C', to: 'B' }],
}; };
const merged = mergeGraphIntoPackage(basePkg, withReject); const merged = mergeGraphIntoPackage(basePkg, withNew);
expect(merged.edges.some((e) => e.from === 'AP' && e.to === 'A')).toBe(false); const minted = merged.edges.filter((e) => e.from === 'C' || e.to === 'C').map((e) => e.id);
// 旧包里有的回边照旧认得出来 expect(minted.sort()).toEqual(['E5', 'E6']);
expect(merged.edges.some((e) => e.from === 'B' && e.to === 'A')).toBe(true);
}); });
it('画布装不下的声明原样保留:边映射与负责人策略', () => { it('画布装不下的声明原样保留:边映射与失败走向', () => {
const merged = mergeGraphIntoPackage(basePkg, graph); const merged = mergeGraphIntoPackage(basePkg, graph);
expect(merged.edges.find((e) => e.id === 'e-s-a')?.mapping).toHaveLength(1); expect(merged.edges.find((e) => e.id === 'E1')?.mapping).toHaveLength(1);
const a = merged.nodes.find((n) => n.id === 'A'); const a = merged.nodes.find((n) => n.id === 'A');
expect(a?.kind === 'activity' && a.owner.strategy).toBe('rotation'); expect(a?.kind === 'activity' && a.failure.kind).toBe('terminate');
}); });
/* ── 属性卡工作副本的合并(2026-07-28 第二轮:节点链接实现、边传递契约) ── */ /* ── 属性卡工作副本的合并(节点链接实现、边传递契约) ── */
it('节点的 act(链接的活动实现)优先于旧声明成为 activityId', () => { it('节点的 act(链接的活动实现)优先于旧声明成为 activityId', () => {
const linked: FlowGraph = { const linked: FlowGraph = {
@@ -127,18 +101,18 @@ describe('mergeGraphIntoPackage', () => {
edges: graph.edges.map((e) => edges: graph.edges.map((e) =>
e.from === 'B' && e.to === 'E' e.from === 'B' && e.to === 'E'
? { ...e, condition: 'ok = true and sum > 3', mapping: [{ target: 'y', source: { from: 'initiation', path: 'y' } }] } ? { ...e, condition: 'ok = true and sum > 3', mapping: [{ target: 'y', source: { from: 'initiation', path: 'y' } }] }
: e.from === 'B' && e.to === 'c1' : e.from === 'B' && e.to === 'A'
? { ...e, condition: '' } // 设计者把条件清空:这条边成了默认兜底 ? { ...e, condition: '' } // 设计者把条件清空:这条边成了默认兜底
: e, : e,
), ),
}; };
const merged = mergeGraphIntoPackage(basePkg, edited); const merged = mergeGraphIntoPackage(basePkg, edited);
const pass = merged.edges.find((e) => e.id === 'e-b-e'); const pass = merged.edges.find((e) => e.id === 'E3');
expect(pass?.condition).toBe('ok = true and sum > 3'); expect(pass?.condition).toBe('ok = true and sum > 3');
expect(pass?.mapping).toHaveLength(1); expect(pass?.mapping).toHaveLength(1);
const back = merged.edges.find((e) => e.id === 'e-b-a'); const back = merged.edges.find((e) => e.id === 'E4');
expect(back?.condition).toBeUndefined(); expect(back?.condition).toBeUndefined();
// 没动过的边沿用旧声明 // 没动过的边沿用旧声明
expect(merged.edges.find((e) => e.id === 'e-s-a')?.mapping).toHaveLength(1); expect(merged.edges.find((e) => e.id === 'E1')?.mapping).toHaveLength(1);
}); });
}); });
@@ -432,14 +432,13 @@ const modelingModule = {
/* /*
* 节点只分**活动点**与**审批点**(2026-07-28 第二轮): * 节点只分**活动点**与**审批点**(2026-07-28 第二轮):
* 编排面不选实现方式(标准/案例是活动库的事,链接哪个实现在属性卡决定); * 编排面不选实现方式(标准/案例是活动库的事,链接哪个实现在属性卡决定);
* 网关不存在(分支 = 条件出边);起止与卡点是结构件与呈现件。 * 网关与卡点都不存在(分支 = 条件出边,顺序流一律画成真边);起止是结构件。
*/ */
export const PALETTE_SPECS: Array<{ key: string; label: string; className: string; spec: NewNodeSpec }> = [ export const PALETTE_SPECS: Array<{ key: string; label: string; className: string; spec: NewNodeSpec }> = [
{ key: "create.act", label: "活动点(蓝 · 链接活动实现后可运行)", className: "fe-pi fe-pi-sop", spec: { kind: "activity" } }, { key: "create.act", label: "活动点(蓝 · 链接活动实现后可运行)", className: "fe-pi fe-pi-sop", spec: { kind: "activity" } },
{ key: "create.approval", label: "审批点(琥珀 · 人裁节点)", className: "fe-pi fe-pi-approval", spec: { kind: "activity", flavor: "approval" } }, { key: "create.approval", label: "审批点(琥珀 · 人裁节点)", className: "fe-pi fe-pi-approval", spec: { kind: "activity", flavor: "approval" } },
{ key: "create.start", label: "起始事件", className: "fe-pi fe-pi-start", spec: { kind: "start" } }, { key: "create.start", label: "起始事件", className: "fe-pi fe-pi-start", spec: { kind: "start" } },
{ key: "create.end", label: "结束事件", className: "fe-pi fe-pi-end", spec: { kind: "end" } }, { key: "create.end", label: "结束事件", className: "fe-pi fe-pi-end", spec: { kind: "end" } },
{ key: "create.callout", label: "卡点(红 · 标去向)", className: "fe-pi fe-pi-callout", spec: { kind: "callout" } },
]; ];
class FlowPalette { class FlowPalette {
+8 -4
View File
@@ -72,6 +72,8 @@ export interface FlowAnchor {
export interface FlowEdge { export interface FlowEdge {
from: string; from: string;
to: string; to: string;
/** 边号(E1、E2…)—— 语义边的编号身份,画在线标前;拣选与选中按它认 */
code?: string | undefined;
label?: string; label?: string;
tone?: FlowTone; tone?: FlowTone;
/** 边属性(传递契约)的工作副本:S-FEEL 条件。属性卡填写,保存时合并为语义边的 condition。 */ /** 边属性(传递契约)的工作副本:S-FEEL 条件。属性卡填写,保存时合并为语义边的 condition。 */
@@ -309,10 +311,12 @@ export function manualEdgeLabel(
edge: FlowEdge, edge: FlowEdge,
points: Array<{ x: number; y: number }>, points: Array<{ x: number; y: number }>,
): ConnectionLayout["label"] { ): ConnectionLayout["label"] {
if (!edge.label) return undefined; // 边号进线标:`E3 需要选型`;没有注记的边也标出编号 —— 图上能认出这是哪条边
const text = [edge.code, edge.label].filter((t) => t !== undefined && t !== '').join(' ');
if (text === '') return undefined;
// 手工摆放过的标签位(中心点)优先。 // 手工摆放过的标签位(中心点)优先。
if (edge.lx !== undefined && edge.ly !== undefined) { if (edge.lx !== undefined && edge.ly !== undefined) {
return { text: edge.label, x: edge.lx, y: edge.ly + 3.5, anchor: "middle" }; return { text, x: edge.lx, y: edge.ly + 3.5, anchor: "middle" };
} }
let best = 0; let best = 0;
let bestLen = -1; let bestLen = -1;
@@ -327,9 +331,9 @@ export function manualEdgeLabel(
const b = points[best]; const b = points[best];
if (a === undefined || b === undefined) return undefined; if (a === undefined || b === undefined) return undefined;
if (a.y === b.y) { if (a.y === b.y) {
return { text: edge.label, x: (a.x + b.x) / 2, y: a.y - 5, anchor: "middle" }; return { text, x: (a.x + b.x) / 2, y: a.y - 5, anchor: "middle" };
} }
return { text: edge.label, x: a.x + 6, y: (a.y + b.y) / 2 + 3, anchor: "start" }; return { text, x: a.x + 6, y: (a.y + b.y) / 2 + 3, anchor: "start" };
} }
/** 手绘图直排:节点按存储坐标放置,连线按存储折线画,起止/网关的名字作旁注。 */ /** 手绘图直排:节点按存储坐标放置,连线按存储折线画,起止/网关的名字作旁注。 */
+14 -29
View File
@@ -6,8 +6,8 @@
* 负责人策略、调用接口 —— 一律**从旧包按 id 保留**;id 变过号的经 idMap 跟过去。 * 负责人策略、调用接口 —— 一律**从旧包按 id 保留**;id 变过号的经 idMap 跟过去。
* 所以保存永远不会把「画布上看不见的声明」抹掉。 * 所以保存永远不会把「画布上看不见的声明」抹掉。
* *
* 卡点(callout)与行分组/锚定/折线点属于画布事实,语义 schema 不收: * 顺序流一律画成**真边**(卡点画法已废除,2026-07-28 第三轮);行分组/锚定/折线点
* 整张手绘图原样存进 `pkg.diagram`(手绘几何即呈现真相),流转判断不读它。 * 属于画布事实,整张手绘图原样存进 `pkg.diagram`(手绘几何即呈现真相),流转判断不读它。
*/ */
import type { Edge, ProcessNode, ProcessPackage } from '@contracts'; import type { Edge, ProcessNode, ProcessPackage } from '@contracts';
import { activityIdSchema, nodeIdSchema } from '@contracts'; import { activityIdSchema, nodeIdSchema } from '@contracts';
@@ -32,7 +32,7 @@ export function mergeGraphIntoPackage(
priorEdge.set(`${from}→${to}`, e); priorEdge.set(`${from}→${to}`, e);
} }
// 画布节点里只有活动点/审批点/起终点入语义;卡点(callout)留在 diagram // 画布节点里只有活动点/审批点/起终点入语义(卡点画法已废,滤除只为容错旧数据)
const semantic = graph.nodes.filter((n) => n.kind !== 'callout'); const semantic = graph.nodes.filter((n) => n.kind !== 'callout');
const nodes: ProcessNode[] = semantic.map((n) => { const nodes: ProcessNode[] = semantic.map((n) => {
@@ -82,11 +82,7 @@ export function mergeGraphIntoPackage(
kind: 'activity' as const, kind: 'activity' as const,
// 链接优先级:属性卡刚选的(act)> 旧声明 > 占位软引用(闭合校验标「未装载」) // 链接优先级:属性卡刚选的(act)> 旧声明 > 占位软引用(闭合校验标「未装载」)
activityId: n.act !== undefined && n.act !== '' ? activityIdSchema.parse(n.act) : (priorAct?.activityId ?? placeholderActivityId(n.label)), activityId: n.act !== undefined && n.act !== '' ? activityIdSchema.parse(n.act) : (priorAct?.activityId ?? placeholderActivityId(n.label)),
owner: { // 契约不带负责人岗位:分派归运营(运行时默认全员轮值;审批点的 approver 是功能语义,另算)
position: n.owner ?? priorAct?.owner.position ?? '未声明',
strategy: priorAct?.owner.strategy ?? ('sole' as const),
...(priorAct?.owner.staffId === undefined ? {} : { staffId: priorAct.owner.staffId }),
},
failure: priorAct?.failure ?? { kind: 'terminate' as const }, failure: priorAct?.failure ?? { kind: 'terminate' as const },
...(priorAct?.message === undefined ? {} : { message: priorAct.message }), ...(priorAct?.message === undefined ? {} : { message: priorAct.message }),
...(n.in === undefined || n.in.length === 0 ? {} : { in: [...n.in] }), ...(n.in === undefined || n.in.length === 0 ? {} : { in: [...n.in] }),
@@ -97,34 +93,23 @@ export function mergeGraphIntoPackage(
const semanticIds = new Set(semantic.map((n) => n.id)); const semanticIds = new Set(semantic.map((n) => n.id));
/* /*
* 卡点是**回跳的呈现**:图上不画长线,画一枚「返回调整→A4」的小牌子。 * 边号 E1、E2… —— 服务端语义边的**编号身份**:图上标它、拣选条按它认。
* 「X → 卡点(to: Y)」要还原成语义边 X→Y,否则一存盘回边就没了 * 旧边保号(按 from→to 认亲),新画的边铸下一个空号;非 E 系的历史号不续用。
* (卡点不入语义,这条边有一端不在 semanticIds 里,会被滤掉)。
*
* 但还原只用于**认亲**,不用于**新建**:只有旧包里确有 X→Y 这条边才认。
* 不设这道闸,审批点的「退回调整→A4」卡点(它是 `reject` 声明的呈现、不是边)
* 会被当成 A5→A4 凭空造出一条边来 —— 实测就多出过一条 `e-A5-A4`。
* 真要新连一条边,画一条线;卡点只是牌子。
*/ */
const calloutTarget = new Map( let nextEdgeNo =
graph.nodes pkg.edges.reduce((max, e) => {
.filter((n) => n.kind === 'callout' && n.to !== undefined && semanticIds.has(n.to)) const m = /^E(\d+)$/.exec(e.id);
.map((n) => [n.id, n.to!]), return m === null ? max : Math.max(max, Number(m[1]));
); }, 0) + 1;
const resolved = graph.edges.map((e) => {
const via = calloutTarget.get(e.to);
if (via === undefined) return e;
return priorEdge.has(`${e.from}→${via}`) ? { ...e, to: via } : e;
});
const edges: Edge[] = resolved const edges: Edge[] = graph.edges
.filter((e) => semanticIds.has(e.from) && semanticIds.has(e.to)) .filter((e) => semanticIds.has(e.from) && semanticIds.has(e.to))
.map((e) => { .map((e) => {
const prior = priorEdge.get(`${e.from}→${e.to}`); const prior = priorEdge.get(`${e.from}→${e.to}`);
// 边属性(传递契约)以属性卡的工作副本优先;没动过的沿用旧声明 // 边属性(传递契约)以属性卡的工作副本优先;没动过的沿用旧声明
const condition = e.condition !== undefined ? (e.condition.trim() === '' ? undefined : e.condition) : prior?.condition; const condition = e.condition !== undefined ? (e.condition.trim() === '' ? undefined : e.condition) : prior?.condition;
return { return {
id: prior?.id ?? `e-${e.from}-${e.to}`, id: prior?.id ?? `E${nextEdgeNo++}`,
from: nodeIdSchema.parse(e.from), from: nodeIdSchema.parse(e.from),
to: nodeIdSchema.parse(e.to), to: nodeIdSchema.parse(e.to),
mapping: (e.mapping as Edge['mapping'] | undefined) ?? prior?.mapping ?? [], mapping: (e.mapping as Edge['mapping'] | undefined) ?? prior?.mapping ?? [],
@@ -139,7 +124,7 @@ export function mergeGraphIntoPackage(
...pkg, ...pkg,
nodes, nodes,
edges, edges,
// 手绘图原样存证:卡点/行分组/锚定/折线点都在这里,呈现以它为真相 // 手绘图原样存证:行分组/锚定/折线点都在这里,呈现以它为真相
diagram: JSON.parse(JSON.stringify(graph)) as Record<string, unknown>, diagram: JSON.parse(JSON.stringify(graph)) as Record<string, unknown>,
}; };
} }
+7 -8
View File
@@ -44,7 +44,7 @@ export function packageToGraph(pkg: ProcessPackage, marks: readonly InstanceMark
kind: n.kind === 'start' ? ('start' as const) : n.kind === 'end' ? ('end' as const) : ('activity' as const), kind: n.kind === 'start' ? ('start' as const) : n.kind === 'end' ? ('end' as const) : ('activity' as const),
label: n.label, label: n.label,
...(n.kind === 'approval' ? { flavor: 'approval' as const, owner: n.approver.position } : {}), ...(n.kind === 'approval' ? { flavor: 'approval' as const, owner: n.approver.position } : {}),
...(n.kind === 'activity' ? { code: n.id, owner: n.owner.position, act: n.activityId } : {}), ...(n.kind === 'activity' ? { code: n.id, act: n.activityId } : {}),
x: 30 + (i % 6) * 160, x: 30 + (i % 6) * 160,
y: bottom + Math.floor(i / 6) * 60, y: bottom + Math.floor(i / 6) * 60,
})); }));
@@ -59,19 +59,17 @@ export function packageToGraph(pkg: ProcessPackage, marks: readonly InstanceMark
return state === undefined ? base : { ...base, note: state }; return state === undefined ? base : { ...base, note: state };
}); });
/* /*
* 边属性(条件/映射)从语义边回填到画布边:属性卡编辑的是画布工作副本, * 边属性(编号/条件/映射)从语义边回填到画布边:属性卡编辑的是画布工作副本,
* 保存时 graph-to-pkg 又以它为准 —— 回填缺席的话,打开即保存会把契约冲掉。 * 保存时 graph-to-pkg 又以它为准 —— 回填缺席的话,打开即保存会把契约冲掉。
* 经卡点的边按卡点 `to` 认亲(A5→c_reject 即 A5→A4)。 * 顺序流全是真边(卡点画法已废),按 from→to 直接认亲;code 即边号 E1、E2…
*/ */
const calloutTo = new Map(
stored.nodes.filter((n) => n.kind === 'callout' && n.to !== undefined).map((n) => [n.id, n.to!]),
);
const semEdge = new Map(pkg.edges.map((e) => [`${e.from}→${e.to}`, e])); const semEdge = new Map(pkg.edges.map((e) => [`${e.from}→${e.to}`, e]));
const edges = stored.edges.map((e) => { const edges = stored.edges.map((e) => {
const sem = semEdge.get(`${e.from}→${calloutTo.get(e.to) ?? e.to}`); const sem = semEdge.get(`${e.from}→${e.to}`);
if (sem === undefined) return e; if (sem === undefined) return e;
return { return {
...e, ...e,
code: sem.id as string,
...(sem.condition === undefined ? {} : { condition: sem.condition }), ...(sem.condition === undefined ? {} : { condition: sem.condition }),
mapping: sem.mapping as unknown[], mapping: sem.mapping as unknown[],
}; };
@@ -99,7 +97,7 @@ export function packageToGraph(pkg: ProcessPackage, marks: readonly InstanceMark
} }
return { return {
...base, ...base,
owner: n.owner.position, // 契约不带负责人岗位 —— 角标不再标岗位,链接的实现(装载面)以 act 携带
act: n.activityId, act: n.activityId,
...(n.in === undefined ? {} : { in: [...n.in] }), ...(n.in === undefined ? {} : { in: [...n.in] }),
...(n.out === undefined ? {} : { out: [...n.out] }), ...(n.out === undefined ? {} : { out: [...n.out] }),
@@ -114,6 +112,7 @@ export function packageToGraph(pkg: ProcessPackage, marks: readonly InstanceMark
const edges: FlowEdge[] = pkg.edges.map((e) => ({ const edges: FlowEdge[] = pkg.edges.map((e) => ({
from: e.from, from: e.from,
to: e.to, to: e.to,
code: e.id as string,
// 回边按声明走「回 A4 重开新实例」,视觉上标红以区分正向流转 // 回边按声明走「回 A4 重开新实例」,视觉上标红以区分正向流转
...(e.tone !== undefined ? { tone: e.tone } : e.reopen ? { tone: 'bad' as const } : {}), ...(e.tone !== undefined ? { tone: e.tone } : e.reopen ? { tone: 'bad' as const } : {}),
...(e.label === undefined ? (e.condition === undefined ? {} : { label: e.condition }) : { label: e.label }), ...(e.label === undefined ? (e.condition === undefined ? {} : { label: e.condition }) : { label: e.label }),
+8
View File
@@ -18,6 +18,14 @@
| M5-4 | AND 并行没有声明机制 —— 网关废除后(2026-07-28)多出边一律异或,画不出并行分叉 | 分支=条件出边、汇合=多入边异或已够 MVP;真要并行时以「并行组」声明加回(对应 Mastra `.parallel` 结构块),与 M5-1 编译器同批设计 | 需要并行的第一条流 | 进行中 | | M5-4 | AND 并行没有声明机制 —— 网关废除后(2026-07-28)多出边一律异或,画不出并行分叉 | 分支=条件出边、汇合=多入边异或已够 MVP;真要并行时以「并行组」声明加回(对应 Mastra `.parallel` 结构块),与 M5-1 编译器同批设计 | 需要并行的第一条流 | 进行中 |
| M5-5 | ~~含网关历史版本的运行时兼容三处~~ | 用户令库只留一条流一个版本(外科手术清空),在途与历史归零 —— schema 的 `kind: 'gateway'`、`joinReady`、汇合等待、`gateway-deprecated` 违规项已于次轮全部摘除 | 2026-07-28 | 已清理 | | M5-5 | ~~含网关历史版本的运行时兼容三处~~ | 用户令库只留一条流一个版本(外科手术清空),在途与历史归零 —— schema 的 `kind: 'gateway'`、`joinReady`、汇合等待、`gateway-deprecated` 违规项已于次轮全部摘除 | 2026-07-28 | 已清理 |
## 活动分派 · 全员轮值默认(2026-07-28)
活动契约不带负责人岗位(纯编排第三轮)——「谁来干」归运营,但运营分派机制还没做
(用户明示先不做)。运行时垫了一个诚实默认:**全员轮值**(在岗候选并集、最闲者先、
staffId 稳定排序保证确定性),`owner-resolved` 事件里岗位记作「(全员轮值)」。
运营中心做了任务分派(按人/按组/认领池)后,这个默认让位;审批点不在此列
(approver 是功能语义,照岗位解析,ADR-011 绑定仍生效)。
## 鉴权(ADR-010 落地后的已知欠账) ## 鉴权(ADR-010 落地后的已知欠账)
- **登录失败无次数限制**:可无限次试口令。单组织 ≤50 人、内网部署下暂缓; - **登录失败无次数限制**:可无限次试口令。单组织 ≤50 人、内网部署下暂缓;
+5 -1
View File
@@ -153,7 +153,11 @@ export const processNodeSchema = z.discriminatedUnion('kind', [
out: z.array(z.string()).optional(), out: z.array(z.string()).optional(),
/** 版本约束:留空 = 装配时取最新生效版 */ /** 版本约束:留空 = 装配时取最新生效版 */
activityVersion: z.string().optional(), activityVersion: z.string().optional(),
owner: ownerSpecSchema, /*
* **不带负责人岗位**(产品决策 2026-07-28 第三轮):谁来干是运营的事,
* 编排契约只管干什么、什么顺序。运营分派机制未建前,运行时默认全员轮值(最闲者先);
* 审批点例外 —— 「卡到人的工位」是它的功能语义,approver 留在声明里。
*/
failure: failureDispositionSchema.default({ kind: 'terminate' }), failure: failureDispositionSchema.default({ kind: 'terminate' }),
/** 委托消息模板,可插值载荷字段;缺省为空 */ /** 委托消息模板,可插值载荷字段;缺省为空 */
message: z.string().optional(), message: z.string().optional(),