Archived
三面拆分⑭:纯编排第三轮 —— 活动卸岗位、卡点废除全真边、边号 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:
@@ -29,14 +29,22 @@
|
||||
随手画的半成品也存得进来(存出来即 `retired`,不生效);`setPackageState` 激活时
|
||||
跑 `checkClosure`,不闭合抛 `NotClosedError`(HTTP 412 带整份报告)。
|
||||
违规项:未完成边、必填未映射、类型冲突、孤立节点、多默认出边、
|
||||
活动未装载、岗位不存在、容忍分支被下游必填依赖 —— 任一即 `closed = false`,激活被拒。
|
||||
- **纯编排模型**(产品决策 2026-07-28 第二轮):流程包只决定**活动编排**与
|
||||
活动未装载、审批岗位不存在、容忍分支被下游必填依赖 —— 任一即 `closed = false`,激活被拒。
|
||||
(活动点不核岗位 —— 契约不带负责人,`missing-owner-position` 只出自审批点。)
|
||||
- **纯编排模型**(产品决策 2026-07-28 二、三轮):流程包只决定**活动编排**与
|
||||
**活动传递的契约**,不决定活动的实现方式(范式/版本住活动库,节点仅以
|
||||
`activityId` 链接)。节点只分**活动点**与**审批点**(起点/终点是结构件);
|
||||
`kind: 'gateway'` 已从 schema 摘除(库经外科手术清空,无历史包袱)。
|
||||
`activityId` 链接),**也不带负责人岗位**(分派归运营;运营分派机制未建前,
|
||||
活动任务运行时默认全员轮值 —— 在岗候选并集、最闲者先、staffId 稳定排序。
|
||||
审批点例外:「卡到人的工位」是它的功能语义,`approver` 留在声明里,
|
||||
工作组绑定 ADR-011 也只对它生效)。节点只分**活动点**与**审批点**
|
||||
(起点/终点是结构件);`kind: 'gateway'` 已从 schema 摘除。
|
||||
分支 = 源节点的多条条件出边(恰取一条,无条件边作默认兜底、至多一条),
|
||||
汇合 = 多入边异或(上游互斥,只会来一条 —— `joinReady` 已删,没有「等回齐」)。
|
||||
AND 并行暂无声明机制,将来以「并行组」加回(对应 Mastra `.parallel`,见 debt.md)。
|
||||
- **边有编号身份**:语义边 id 即边号(E1、E2…,服务端/合并器铸号,旧边保号、
|
||||
新边取下一个空号);画布线标带号、边在图上可选中,条件与映射住属性面。
|
||||
顺序流一律画成**真边**(卡点画法已废除)—— 画布保存由画出来的边反推语义边,
|
||||
图上没画的语义边会在存盘时丢失,种子与测试按「一一对应」守着。
|
||||
- **激活双判据**:①图编排闭合完善(结构 + 属性 + 传递契约,`checkClosure` 的
|
||||
非 unknown-activity 项)②活动装载(节点链接的实现已安装,`unknown-activity` 项)。
|
||||
两面都清零才可激活;图照画照存,未装载不拦保存。
|
||||
|
||||
@@ -34,7 +34,6 @@ const pkg = (over: Partial<ProcessPackage> = {}): ProcessPackage =>
|
||||
kind: 'activity',
|
||||
label: 'A4 成本定价',
|
||||
activityId: 'a4' as never,
|
||||
owner: { position: 'BD', strategy: 'sole' },
|
||||
failure: { kind: 'terminate' },
|
||||
},
|
||||
{ id: 'end' as never, kind: 'end', label: '终点' },
|
||||
@@ -101,9 +100,31 @@ describe('checkClosure —— 不闭合不得激活', () => {
|
||||
expect(report.violations.map((v) => v.kind)).toContain('unknown-activity');
|
||||
});
|
||||
|
||||
it('岗位不存在即拦', () => {
|
||||
const report = checkClosure({ pkg: pkg(), contracts, positions: new Set(['PM']) });
|
||||
expect(report.violations.map((v) => v.kind)).toContain('missing-owner-position');
|
||||
/* 活动点不核岗位(契约不带负责人);审批点的岗位是功能语义,不存在即拦 */
|
||||
it('审批点岗位不存在即拦;活动点没有岗位可核', () => {
|
||||
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('孤立节点即拦', () => {
|
||||
@@ -115,7 +136,6 @@ describe('checkClosure —— 不闭合不得激活', () => {
|
||||
kind: 'activity',
|
||||
label: '游离节点',
|
||||
activityId: 'a4' as never,
|
||||
owner: { position: 'BD', strategy: 'sole' },
|
||||
failure: { kind: 'terminate' },
|
||||
},
|
||||
],
|
||||
@@ -156,7 +176,6 @@ describe('checkClosure —— 不闭合不得激活', () => {
|
||||
kind: 'activity',
|
||||
label: 'A3 渠道寻源',
|
||||
activityId: 'a4' as never,
|
||||
owner: { position: 'PRM', strategy: 'sole' },
|
||||
failure: { kind: 'tolerate' },
|
||||
},
|
||||
{
|
||||
@@ -164,7 +183,6 @@ describe('checkClosure —— 不闭合不得激活', () => {
|
||||
kind: 'activity',
|
||||
label: 'A4 成本定价',
|
||||
activityId: 'a4' as never,
|
||||
owner: { position: 'BD', strategy: 'sole' },
|
||||
failure: { kind: 'terminate' },
|
||||
},
|
||||
{ id: 'end' as never, kind: 'end', label: '终点' },
|
||||
|
||||
@@ -126,6 +126,8 @@ export function createProcessStore(db: Db): ProcessStore {
|
||||
activated: r.activated,
|
||||
...(r.terminal === null ? {} : { terminal: r.terminal as TerminalState }),
|
||||
...(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') {
|
||||
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)) {
|
||||
violations.push({
|
||||
kind: 'missing-owner-position',
|
||||
@@ -94,7 +95,6 @@ function checkActivityNode(
|
||||
node: Extract<ProcessNode, { kind: 'activity' }>,
|
||||
inbound: readonly Edge[],
|
||||
contracts: ReadonlyMap<string, ActivityContractFace>,
|
||||
positions: ReadonlySet<string>,
|
||||
): ClosureViolation[] {
|
||||
const out: ClosureViolation[] = [];
|
||||
const face = contracts.get(node.activityId);
|
||||
@@ -108,14 +108,6 @@ function checkActivityNode(
|
||||
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) {
|
||||
if (edge.mapping.length === 0) {
|
||||
|
||||
@@ -120,6 +120,9 @@ export type NodeInstance = {
|
||||
readonly failureDigested?: boolean;
|
||||
/** XOR 未选分支从未激活 —— 不入集合 */
|
||||
readonly activated: boolean;
|
||||
/** 该实例派出的任务 / 审批(结构件与终点没有)—— 链条视图按它报实际承接人 */
|
||||
readonly taskId?: string;
|
||||
readonly approvalId?: string;
|
||||
};
|
||||
|
||||
export function aggregateWorkflowState(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* process 用例 —— 流程引擎:确定性流转,**零 LLM、零临场**(编码规范 §5.3;语义出处 OS 03 / 04)。
|
||||
*
|
||||
* 起单 · 调度节点 · 审批点卡工位 · 网关分合 · 每次流转记入事件。
|
||||
* 起单 · 调度节点 · 审批点卡工位 · 条件出边选路 · 每次流转记入事件。
|
||||
*/
|
||||
import type { ProcessNode, ProcessPackage, StaffId, TerminalState, WorkflowState } from '@contracts';
|
||||
import type { ProcessService, StartWorkflowInput } from '../../contract.ts';
|
||||
@@ -87,7 +87,7 @@ export function createProcessService(deps: ProcessServiceDeps): ProcessService {
|
||||
const dispatch = dispatchOf(node, payload);
|
||||
|
||||
if (dispatch === undefined) {
|
||||
// 网关本身不是责任单元:直接继续流转
|
||||
// 只剩起点会走到这(结构件无调度):被指为目标时直通,不建实例
|
||||
await advanceFrom(record, pkg, node.id, payload);
|
||||
return;
|
||||
}
|
||||
@@ -122,15 +122,31 @@ export function createProcessService(deps: ProcessServiceDeps): ProcessService {
|
||||
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)也只对它生效。
|
||||
*/
|
||||
const boundTo = record.workGroup?.[spec.position];
|
||||
const bound = boundTo !== undefined && (await deps.org.isActive(boundTo)) ? boundTo : undefined;
|
||||
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];
|
||||
bound = boundTo !== undefined && (await deps.org.isActive(boundTo)) ? boundTo : undefined;
|
||||
}
|
||||
const resolution = resolveOwner(spec, { candidates, ...(bound === undefined ? {} : { bound }) });
|
||||
if (resolution.kind === 'vacant') throw new PositionVacantError(spec.position);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user