范式退役:活动只剩一种、只跑 Loop;审批活动可管;活动库重做
用户定的两件,一并落地。
**一、活动不再分 flow 和 loop —— 彻底退役 flow**
· `flow-engine` 模块整个删除(runner 379 行 + step-sequence 184 行 + 测试);
· `paradigm` 从清单身份、`activity_package`/`task` 两张表、任务卡与活动库一并退场;
`businessModel` 不再是判别联合 —— 只有案例模型(CMMN + 说明书 + DMN)一形;
· task 的引擎分派从「按 paradigm 取两个之一」收成**唯一的引擎**;
· `activities/` 四个 flow 活动(A1 受理 / A4 定价 / A6 议价 / A7 归档)各写了一份
案例模型:阶段照原来的步分,触达世界的项一律 manualActivationRule,
能算的交 DMN(A1 的三分类 P-03、A4 的 P-01/P-02)不交 Agent;
· 六个占位槽位的骨架从「机器步落台账 + 一张验收单」改成案例骨架,包版本 0.8.0 → 0.9.0。
**代价写在明处,不假装没有**:`turn-runner` 每一拍都要 `agent.decide` ——
环境里没有模型 key,案例活动一步也走不动。三套端到端(统一报价 / 新建流程包 / 测试台
Trace)整套跳过,文件头写明恢复条件:①有可用模型 ②走法改写成按 Enabled 集推进。
**不许把断言改松让它变绿** —— 绿得不诚实比红着更坏。debt.md 已记。
**二、审批活动可管**(新能力)
· `sys.approval_template`:审批点**可复用的那一半** —— 审批人看哪几项、按什么名字看、
怎么催、说什么话。谁来审不在里面(与活动点同口径,运营时轮值);驳回回哪个节点
也不在里面(那是每张图自己的事,留在节点上);
· 三条路由 + 引用反查:还被审批点引着就不许删(409),删了那些节点会**静默**退回旧行为;
· 运行时 `basisOf`:引了模板就按模板筛与改名,没引即旧行为(载荷全摊开)。
模板改了只影响新发出的审批单 —— 在途单的依据在发出那一刻已定形。
**三、活动库重做**:一区两格 —— 「活动(装进来的)」与「审批活动(配出来的)」,
都用流程卡那套两段式卡片(头 + 四格数据板),幽灵卡当入口(装入活动 / 新建审批活动);
「标准/案例」那一维随范式一起撤,业务分类成了唯一的一维,以行内小签呈现。
迁移 0020:两张表 drop paradigm、建 approval_template。已在开发库跑过并重播种。
实测(丁子乔账号):建「定价审批」模板 → 流程包 A5 属性里选得到 → 引用反查计数正确。
四闸绿(api:check 随本提交)。
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { activityManifestSchema } from '@contracts';
|
||||
import { evaluate, evaluateUnaryTest } from '@sfeel';
|
||||
import { evaluateUnaryTest } from '@sfeel';
|
||||
import { createMockHost } from '@sdk';
|
||||
import { manifest, P03_DMN } from '../src/manifest.ts';
|
||||
import activity from '../src/index.ts';
|
||||
@@ -31,46 +31,41 @@ describe('清单本身合规', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('步序声明(AM 12.3)', () => {
|
||||
describe('案例模型(AM 03/12.2)—— 双表示同版本', () => {
|
||||
const model = manifest.assets.businessModel;
|
||||
if (model.paradigm !== 'flow') throw new Error('A1 应是 flow 范式');
|
||||
const cmmn = parseCmmnLite(model.cmmnXml);
|
||||
|
||||
it('末步是验收工单 —— 完成只出自放行通过', () => {
|
||||
expect(model.steps.at(-1)).toMatchObject({ kind: 'human', workOrder: 'acceptance' });
|
||||
it('CMMN 与说明书同在,不允许分叉', () => {
|
||||
expect(model.cmmnXml).toContain('<casePlanModel');
|
||||
expect(model.narrative.length).toBeGreaterThan(80);
|
||||
});
|
||||
|
||||
it('每步六件齐备:步型 / 入参映射 / 出参写入 / 完成条件 / 失败策略', () => {
|
||||
for (const step of model.steps) {
|
||||
expect(step.name).not.toBe('');
|
||||
expect(step.failure.retry.times).toBeGreaterThanOrEqual(0);
|
||||
expect(step.failure.fallback.kind).toBeDefined();
|
||||
it('触达世界的项恒需人工激活(AM 4.1 原理一)', () => {
|
||||
// 解析归一、追问补全、查历史价 —— 三件都碰外界,一件也不许自动跑
|
||||
for (const id of ['T_normalize', 'T_ask_back', 'T_history']) {
|
||||
expect(cmmn.manualActivation, `${id} 应为人工激活`).toContain(id);
|
||||
}
|
||||
});
|
||||
|
||||
it('条件跳步是任务数据上的确定性谓词,由引擎求值', () => {
|
||||
const askBack = model.steps.find((s) => s.name === 'S2_ask_back');
|
||||
expect(askBack?.when).toBe('missing_key_fields > 0');
|
||||
// 谓词读的是**落表后的字段名** —— 作用域来自台账,不是模型出参的驼峰名
|
||||
expect(evaluate(askBack!.when!, { missing_key_fields: 2 })).toBe(true);
|
||||
expect(evaluate(askBack!.when!, { missing_key_fields: 0 })).toBe(false);
|
||||
it('末尾一张验收单 —— 完成只出自放行通过', () => {
|
||||
expect(model.cmmnXml).toContain('id="T_release"');
|
||||
});
|
||||
|
||||
it('人类工具步都配了时限 —— 无死等', () => {
|
||||
for (const step of model.steps) {
|
||||
if (step.kind === 'human') expect(step.deadline).toMatch(/^P/);
|
||||
}
|
||||
});
|
||||
|
||||
it('LLM 步的模板与出参 schema 随声明版本冻结', () => {
|
||||
const llm = model.steps.find((s) => s.kind === 'llm');
|
||||
expect(llm).toBeDefined();
|
||||
if (llm?.kind === 'llm') {
|
||||
expect(llm.template).toContain('{{rfqRef}}');
|
||||
expect(llm.outputSchema['type']).toBe('object');
|
||||
}
|
||||
it('能算的交 DMN,不交 Agent —— 打标是 decisionTask', () => {
|
||||
expect(model.cmmnXml).toContain('decisionRef="p03-type"');
|
||||
expect(P03_DMN.tables.some((t) => t.id === 'p03-type')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
/** 极小取值:只为断言用,不重实现引擎的解析器(那一份在 loop-engine 里有自己的测试) */
|
||||
function parseCmmnLite(xml: string): { manualActivation: string[] } {
|
||||
const ids: string[] = [];
|
||||
for (const m of xml.matchAll(/<humanTask id="([^"]+)"[\s\S]*?<\/humanTask>/g)) {
|
||||
if (m[0].includes('manualActivationRule')) ids.push(m[1]!);
|
||||
}
|
||||
return { manualActivation: ids };
|
||||
}
|
||||
|
||||
describe('三分类规则 P-03 —— 能算的不问 LLM', () => {
|
||||
const table = P03_DMN.tables[0]!;
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* A1 询价受理的案例模型 —— **双表示同版本**:CMMN XML(机器面)与案例说明书(叙事面)。
|
||||
*
|
||||
* 2026-07-29 由步序声明(flow)改写而来:活动不再分范式,一律案例模型 + Agent 临场调度。
|
||||
* 原来的六步在这里各归其位 —— 解析归一与追问补全同属「收料归一」阶段(常来回几轮,
|
||||
* 所以带 repetitionRule);查历史价与三分类打标属「定性分级」;末尾一张验收单。
|
||||
*/
|
||||
|
||||
export const CMMN_XML = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL">
|
||||
<case id="intake">
|
||||
<caseFileModel>
|
||||
<caseFileItem id="rfq" name="询价来函"/>
|
||||
<caseFileItem id="records" name="统一受理记录"/>
|
||||
<caseFileItem id="history" name="历史价格情报"/>
|
||||
<caseFileItem id="verdict" name="受理结论"/>
|
||||
</caseFileModel>
|
||||
<casePlanModel id="plan" name="询价受理" autoComplete="true">
|
||||
<sentry id="s_rfq">
|
||||
<onPart id="op_rfq" caseFileItemRef="rfq"><standardEvent>create</standardEvent></onPart>
|
||||
</sentry>
|
||||
<sentry id="s_incomplete">
|
||||
<onPart id="op_ic" caseFileItemRef="records"><standardEvent>update</standardEvent></onPart>
|
||||
<ifPart id="if_ic"><condition>missingKeyFields > 0</condition></ifPart>
|
||||
</sentry>
|
||||
<sentry id="s_complete">
|
||||
<onPart id="op_cp" caseFileItemRef="records"><standardEvent>update</standardEvent></onPart>
|
||||
<ifPart id="if_cp"><condition>missingKeyFields = 0</condition></ifPart>
|
||||
</sentry>
|
||||
<sentry id="s_typed">
|
||||
<onPart id="op_tp" caseFileItemRef="records"><standardEvent>update</standardEvent></onPart>
|
||||
<ifPart id="if_tp"><condition>untyped = 0</condition></ifPart>
|
||||
</sentry>
|
||||
|
||||
<stage id="S1" name="收料归一" autoComplete="true">
|
||||
<entryCriterion id="ec_s1" sentryRef="s_rfq"/>
|
||||
<humanTask id="T_normalize" name="人工逐条解析归一">
|
||||
<itemControl><manualActivationRule id="m_nm"/><repetitionRule id="r_nm"/></itemControl>
|
||||
</humanTask>
|
||||
<humanTask id="T_ask_back" name="人工追问补全信息">
|
||||
<entryCriterion id="ec_ask" sentryRef="s_incomplete"/>
|
||||
<itemControl><manualActivationRule id="m_ab"/><repetitionRule id="r_ab"/></itemControl>
|
||||
</humanTask>
|
||||
</stage>
|
||||
<milestone id="M_complete" name="八字段齐"/>
|
||||
|
||||
<stage id="S2" name="定性分级" autoComplete="true">
|
||||
<entryCriterion id="ec_s2" sentryRef="s_complete"/>
|
||||
<humanTask id="T_history" name="人工查历史价">
|
||||
<itemControl><manualActivationRule id="m_hi"/></itemControl>
|
||||
</humanTask>
|
||||
<decisionTask id="D_classify" name="逐条打标 A/B/C" decisionRef="p03-type"/>
|
||||
<planningTable id="pt_s2">
|
||||
<humanTask id="T_lifecycle" name="人工核生命周期"/>
|
||||
</planningTable>
|
||||
</stage>
|
||||
<milestone id="M_typed" name="全条已打标"/>
|
||||
|
||||
<humanTask id="T_release" name="人工受理结论验收放行">
|
||||
<entryCriterion id="ec_rel" sentryRef="s_typed"/>
|
||||
<itemControl><manualActivationRule id="m_rl"/></itemControl>
|
||||
</humanTask>
|
||||
|
||||
<timerEventListener id="TL_half" name="时限过半">
|
||||
<timerExpression>PT12H</timerExpression>
|
||||
</timerEventListener>
|
||||
<userEventListener id="UL_amend" name="客户改需求"/>
|
||||
</casePlanModel>
|
||||
</case>
|
||||
</definitions>`;
|
||||
|
||||
export const NARRATIVE = `§0 开案:一封询价来函即开案。信里是 RFQ 正文与 BOM 附件,条目从几条到上百条不等。
|
||||
受理这件事的成品只有一样:**一份能往下走的统一受理记录** —— 八字段齐、每条都打了标。
|
||||
|
||||
S1 收料归一:逐条把 BOM 解析成统一格式(PN / 厂牌 / EAU / 目标价 / 交期 / 包装 / 品质要求 / 备注)。
|
||||
解析不出的不许臆造 —— 缺关键字段(PN、EAU、交期为必要三要素)就追问客户,常要来回一两轮,
|
||||
所以这两件事都可重复做。**吃不准的宁可空着去问,也不许填一个看起来合理的值。**
|
||||
|
||||
S2 定性分级:先查历史价(同客户同料近一年有没有报过、隔了多久、行情稳不稳),
|
||||
再按三分类规则 P-03 逐条打标 —— A 类历史价直用、B 类需重新核价、C 类需选型或寻源。
|
||||
拿不准的一律降 B,不许臆断 A:错标 A 会让一条本该重新核价的料带着旧价一路走到报价单上。
|
||||
生命周期核查是裁量项 —— 遇到疑似 EOL 的料随手拉一次。
|
||||
|
||||
§Z 结案:八字段齐、每条都已打标、BD 签字放行,自动结案(CMMN AutoComplete)。
|
||||
结论只有两个去向要交出去:需不需要选型、需不需要寻源 —— 下游的两道网关读的就是这两面旗。`;
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
import type { ActivityManifest, DmnModel } from '@contracts';
|
||||
import { INTAKE_SKILLS } from './skills.ts';
|
||||
import { CMMN_XML, NARRATIVE } from './case-model.ts';
|
||||
import { activityIdSchema } from '@contracts';
|
||||
import { INTAKE_CLASSIFIED, INTAKE_OVERVIEW, INTAKE_RELEASE } from './views/report.ts';
|
||||
|
||||
@@ -44,7 +45,6 @@ export const manifest: ActivityManifest = {
|
||||
name: '客户RFQ受理',
|
||||
packageVersion: '0.1.8',
|
||||
category: '统一报价',
|
||||
paradigm: 'flow',
|
||||
sdkVersion: '0.1.0-m5',
|
||||
checksum: 'dev-checksum-quote-intake',
|
||||
},
|
||||
@@ -169,126 +169,11 @@ export const manifest: ActivityManifest = {
|
||||
|
||||
/* 资产初始版:flow = 步序声明 */
|
||||
assets: {
|
||||
/* 资产初始版:案例模型(2026-07-29 起活动只有这一种业务模型) */
|
||||
businessModel: {
|
||||
paradigm: 'flow',
|
||||
steps: [
|
||||
{
|
||||
kind: 'llm',
|
||||
name: 'S3_normalize',
|
||||
label: 'S3 逐条解析归一',
|
||||
input: { rfqRef: 'rfqRef', customerCode: 'customerCode', subject: 'subject', body: 'body' },
|
||||
/*
|
||||
* 出参路径要对得上**自己声明的 outputSchema**:模型回的是
|
||||
* `{ records: [...], missingKeyFields }`,不是一堆扁平字段。
|
||||
* MVP 逐条办的第一条 = `records.0`;`customerCode` 不在模型出参里,
|
||||
* 它来自起单入参,由作用域补上。
|
||||
*/
|
||||
output: {
|
||||
domain: INTAKE_DOMAIN,
|
||||
object: 'record',
|
||||
key: { customer_code: 'customerCode', pn: 'records.0.pn' },
|
||||
fields: {
|
||||
pn: 'records.0.pn',
|
||||
brand: 'records.0.brand',
|
||||
eau: 'records.0.eau',
|
||||
target_price: 'records.0.targetPrice',
|
||||
lead_time: 'records.0.leadTime',
|
||||
// 完整度判定要有据可依:D1 的谓词读的就是它
|
||||
missing_key_fields: 'missingKeyFields',
|
||||
},
|
||||
},
|
||||
model: 'quote-extractor',
|
||||
// 出参形状由网关按 outputSchema 统一附上,模板只讲**这件事本身**
|
||||
template:
|
||||
'按《询价受理规范》把下面这封询价拆解为逐条需求,逐条抄录 ' +
|
||||
'pn(型号)/ brand(厂牌)/ eau(年用量,整数)/ targetPrice(目标价,数字)/ leadTime(交期)。' +
|
||||
'原文没写的字段留空,不要编造;每缺一个关键字段(pn / eau / leadTime)就把 missingKeyFields 加一。\n\n' +
|
||||
'询价单号:{{rfqRef}}\n客户编码:{{customerCode}}\n主题:{{subject}}\n正文:\n{{body}}',
|
||||
outputSchema: {
|
||||
type: 'object',
|
||||
required: ['records'],
|
||||
properties: {
|
||||
records: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
required: ['pn'],
|
||||
properties: {
|
||||
pn: { type: 'string' },
|
||||
brand: { type: 'string' },
|
||||
eau: { type: 'integer' },
|
||||
targetPrice: { type: 'number' },
|
||||
leadTime: { type: 'string' },
|
||||
},
|
||||
},
|
||||
},
|
||||
missingKeyFields: { type: 'integer' },
|
||||
},
|
||||
},
|
||||
view: 'intake-overview',
|
||||
failure: { retry: { times: 2, backoff: 'PT30S' }, fallback: { kind: 'human', workOrder: 'execution' } },
|
||||
},
|
||||
{
|
||||
kind: 'human',
|
||||
name: 'S2_ask_back',
|
||||
label: 'S2 追问补全信息',
|
||||
// D1 判断完整度:缺 PN/数量/交期三要素才走补全 —— 条件必谓词,由引擎求值
|
||||
when: 'missing_key_fields > 0',
|
||||
input: {},
|
||||
workOrder: 'execution',
|
||||
card: { title: '缺关键字段,请向客户追问补全', fields: ['pn', 'eau', 'leadTime'] },
|
||||
deadline: 'P1D',
|
||||
failure: { retry: { times: 0, backoff: 'PT30S' }, fallback: { kind: 'blocked' } },
|
||||
},
|
||||
{
|
||||
kind: 'tool',
|
||||
name: 'S4_history',
|
||||
label: 'S4 查历史价',
|
||||
input: { pn: 'pn' },
|
||||
// 情报四件全部落表:S5 打标要的就是这三件,只落 hit 会让下一步无米下锅
|
||||
output: {
|
||||
domain: INTAKE_DOMAIN,
|
||||
object: 'type_table',
|
||||
key: { pn: 'pn' },
|
||||
fields: {
|
||||
history_hit: 'hit',
|
||||
history_days: 'historyDays',
|
||||
market_stable: 'marketStable',
|
||||
lifecycle: 'lifecycle',
|
||||
},
|
||||
},
|
||||
tool: 'crm.history-price-read',
|
||||
failure: { retry: { times: 2, backoff: 'PT1M' }, fallback: { kind: 'human', workOrder: 'execution' } },
|
||||
},
|
||||
{
|
||||
kind: 'pure-tool',
|
||||
name: 'S5_classify',
|
||||
label: 'S5 逐条打标(DMN · 三分类规则 P-03)',
|
||||
// 入参名 ← 作用域路径:作用域里是 S4 落表后的字段名
|
||||
input: { historyDays: 'history_days', marketStable: 'market_stable', lifecycle: 'lifecycle' },
|
||||
output: {
|
||||
domain: INTAKE_DOMAIN,
|
||||
object: 'type_table',
|
||||
key: { pn: 'pn' },
|
||||
fields: { type_tag: 'type', basis: 'play' },
|
||||
},
|
||||
tool: 'quote-intake.classify',
|
||||
view: 'intake-classified',
|
||||
failure: { retry: { times: 1, backoff: 'PT10S' }, fallback: { kind: 'blocked' } },
|
||||
},
|
||||
{
|
||||
kind: 'human',
|
||||
name: 'S6_release',
|
||||
label: 'S6 分流复核与派单 · 验收放行',
|
||||
input: {},
|
||||
workOrder: 'acceptance',
|
||||
card: { title: '统一受理记录(打标)请验收' },
|
||||
view: 'intake-release',
|
||||
deadline: 'P1D',
|
||||
failure: { retry: { times: 0, backoff: 'PT30S' }, fallback: { kind: 'blocked' } },
|
||||
},
|
||||
],
|
||||
parallelGroups: [],
|
||||
cmmnXml: CMMN_XML,
|
||||
narrative: NARRATIVE,
|
||||
dmn: P03_DMN,
|
||||
},
|
||||
skills: INTAKE_SKILLS,
|
||||
// 三张模版对应三种局面(事态全景 / 进展 / 成果预览),由步序声明按位置推送
|
||||
|
||||
Reference in New Issue
Block a user