范式退役:活动只剩一种、只跑 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:
2026-07-29 23:53:51 +08:00
co-authored by Claude Opus 5
parent 18c3e3fd09
commit 1fd215cf40
88 changed files with 1319 additions and 2966 deletions
+5 -73
View File
@@ -7,6 +7,7 @@
*/
import type { ActivityManifest, DmnModel } from '@contracts';
import { PRICING_SKILLS } from './skills.ts';
import { CMMN_XML, NARRATIVE } from './case-model.ts';
import { activityIdSchema } from '@contracts';
import { PRICING_BASIS, PRICING_PRICED, PRICING_RELEASE } from './views/report.ts';
@@ -63,7 +64,6 @@ export const manifest: ActivityManifest = {
name: 'A4 · 成本定价',
packageVersion: '0.1.5',
category: '统一报价',
paradigm: 'flow',
sdkVersion: '0.1.0-m5',
checksum: 'dev-checksum-quote-pricing',
},
@@ -161,79 +161,11 @@ export const manifest: ActivityManifest = {
},
assets: {
/* 资产初始版:案例模型(2026-07-29 起活动只有这一种业务模型) */
businessModel: {
paradigm: 'flow',
steps: [
{
kind: 'tool',
name: 'S1_basis',
label: 'S1 取价基准',
// Type A 取历史价近期价;B/C 取供应商底价表(C 类参考替代对标表)
input: { pn: 'pn' },
// 取回来的是**基准价**;偏离率要等 S2 定出拟报价才算得出来(见 S2B)
output: { domain: DOMAIN, object: 'draft', key: { pn: 'pn' }, fields: { last_price: 'lastPrice' } },
tool: 'crm.history-price-read',
view: 'pricing-basis',
failure: { retry: { times: 2, backoff: 'PT1M' }, fallback: { kind: 'human', workOrder: 'execution' } },
},
{
kind: 'pure-tool',
name: 'S2_price',
label: 'S2 逐条定价(DMN · 利润模型 P-01)',
input: { customerGrade: 'customerGrade', materialType: 'materialType', volumeTier: 'volumeTier' },
output: {
domain: DOMAIN,
object: 'draft',
key: { pn: 'pn' },
fields: { margin: 'marginLow', quoted_price: 'quotedPrice' },
},
tool: 'quote-pricing.margin',
failure: { retry: { times: 1, backoff: 'PT10S' }, fallback: { kind: 'blocked' } },
},
{
kind: 'pure-tool',
name: 'S2B_deviation',
label: 'S2B 算偏离率(基准价 ↔ 拟报价)',
input: { lastPrice: 'last_price', quotedPrice: 'quoted_price' },
output: { domain: DOMAIN, object: 'draft', key: { pn: 'pn' }, fields: { deviation: 'deviation' } },
tool: 'quote-pricing.basis',
failure: { retry: { times: 1, backoff: 'PT10S' }, fallback: { kind: 'blocked' } },
},
{
kind: 'pure-tool',
name: 'S3_floor_gate',
label: 'S3 底价自检(DMN · 底价门禁 P-02)',
input: { deviation: 'deviation' },
output: { domain: DOMAIN, object: 'draft', key: { pn: 'pn' }, fields: { disposition: 'disposition' } },
tool: 'quote-pricing.floor-gate',
view: 'pricing-priced',
failure: { retry: { times: 1, backoff: 'PT10S' }, fallback: { kind: 'blocked' } },
},
{
kind: 'human',
name: 'S4_decide_breach',
label: '超限条目:调人决策(回调还是注明理由)',
// 只有门禁不过才调人 —— 条件必谓词,零 LLM
when: 'breached > 0',
input: {},
workOrder: 'execution',
card: { title: '有条目低于底价 20% 以上,请裁决', fields: ['disposition', 'reason'] },
deadline: 'PT4H',
failure: { retry: { times: 0, backoff: 'PT30S' }, fallback: { kind: 'blocked' } },
},
{
kind: 'human',
name: 'S5_release',
label: 'S5 报价草案验收放行',
input: {},
workOrder: 'acceptance',
card: { title: '报价草案(全条目带偏离度)请验收', deliverable: 'quote-draft' },
deadline: 'P1D',
view: 'pricing-release',
failure: { retry: { times: 0, backoff: 'PT30S' }, fallback: { kind: 'blocked' } },
},
],
parallelGroups: [],
cmmnXml: CMMN_XML,
narrative: NARRATIVE,
dmn: P01_DMN,
},
skills: PRICING_SKILLS,
viewTemplates: [