Files
ssw-mvp/docs/e2e/dag-data.mjs
T
数苏苏 e877e2df8c feat(e2e): DAG 业务时序图演示面板 v7
docs/e2e/dag-{panel.html,panel.mjs,data.mjs,panel.sh}
- 端口 7789,复用 lib/{exec,env,dsl,cipher}.mjs
- 5 张图共 71 节点全部跑通,真实业务链路+上下文传递
- Actions 引擎:pickSpace/search/openCreate/fillForm/save/toast/rowAction
- 节点 mode 徽章 + step 数徽章 + 侧栏 4 块详情(入参/产出/ctx/Chrome DOM)
- 每节点 actions 序列真实执行+每步截图,42 action-step/图1 全部 pass
- Business flowCtx: demandId→contractId→sandboxId→settlementId→auditId
- 签约 signCostMs=2ms, 满足 ≤1s SLA
- 新增 docs/e2e/DAG演示.command Finder 双击入口
- 清理废弃 web/nax_e2e_smoke.cjs / web/verify_new_pages.cjs

memory 2026-08-08: 记录 v1~v7 全部迭代与踩坑
2026-08-08 22:26:17 +08:00

375 lines
27 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 5 张业务时序图 → DAG 数据模型(带数据流可视化 metadata)
*
* 依据 docs/sequence_diagrams.md 把时序图拍平成节点-边图:
* participants : 泳道(每个参与者占一列)
* stages : 阶段(在背景上分色块)
* nodes : 节点(每个时序图步骤一个;带泳道、阶段、图标、数据预览、对应用例)
* edges : 边(节点之间的箭头;按时序图自上而下;带数据标签 + 类型)
*
* 节点对应的真实用例来自 docs/e2e/cases/ 下已存在的脚本(meta.tc 一致即可关联);
* 这里不绑死用例文件存在与否——节点缺脚本时前端会显示「无脚本」徽标,不影响 DAG 渲染。
*
* 数据流 metadata 约定:
* node.icon - 节点左侧小图标(emoji 或 svg glyph)
* node.data - { name:'订单', preview:'订单#20260808-001\n¥1,200 · 待付款' }
* edge.label - 边上显示的数据标签(例:订单、合约哈希、密文、凭证)
* edge.kind - 边的数据种类 → 决定标签色与流光
* request | contract | cipher | voucher | notify | response | callback
*/
const SWIMLANES = {
user: { label: '数据使用方', color: '#58a6ff', bg: '#0d2944' },
ops: { label: '平台运营方', color: '#a371f7', bg: '#23193d' },
provider: { label: '数据提供方', color: '#3fb950', bg: '#0f2b18' },
server: { label: '数据服务方', color: '#d29922', bg: '#2b230c' },
regulator: { label: '监管方', color: '#f78166', bg: '#3b1d12' },
tee: { label: 'TEE 硬件', color: '#ff7b72', bg: '#3b1216' },
psi: { label: '集中式 PSI', color: '#79c0ff', bg: '#0d2944' },
fl: { label: '联邦学习', color: '#7ee787', bg: '#0f2b18' },
mpc: { label: '多方安全计算', color: '#ffa657', bg: '#2b230c' }
}
/** 边种类 → 颜色(用于标签/流光) */
const EDGE_KINDS = {
request: { label: 'request', color: '#58a6ff', glow: 'rgba(88,166,255,.45)', text: '#9cc8ff' },
contract: { label: 'contract', color: '#a371f7', glow: 'rgba(163,113,247,.45)', text: '#c8b0ff' },
cipher: { label: 'cipher', color: '#7ee787', glow: 'rgba(126,231,135,.45)', text: '#b6f0bc' },
voucher: { label: 'voucher', color: '#d29922', glow: 'rgba(210,153,34,.45)', text: '#f0c878' },
notify: { label: 'notify', color: '#9aa7b4', glow: 'rgba(154,167,180,.35)', text: '#cfd6df' },
response: { label: 'response', color: '#3fb950', glow: 'rgba(63,185,80,.45)', text: '#7ed084' },
callback: { label: 'callback', color: '#f78166', glow: 'rgba(247,129,102,.45)', text: '#ffb098' }
}
// ───────── 图1:沙盒交付(两方/标准) ─────────
const seq1 = {
id: 'seq-1',
no: 1,
title: '沙盒交付(两方/标准)',
subtitle: '数据使用方 ↔ 数据提供方,端到端 5 阶段',
participants: ['user', 'ops', 'provider', 'server', 'regulator'],
stages: [
{ id: 's1-1', name: '阶段1:需求与撮合', color: 'rgba(88,166,255,.07)' },
{ id: 's1-2', name: '阶段2:合约签订', color: 'rgba(163,113,247,.07)' },
{ id: 's1-3', name: '阶段3:算法开发与调试', color: 'rgba(210,153,34,.07)' },
{ id: 's1-4', name: '阶段4:交付与执行', color: 'rgba(63,185,80,.07)' },
{ id: 's1-5', name: '阶段5:结算与审计', color: 'rgba(247,129,102,.07)' }
],
nodes: [
{ id: 'n1-1', lane: 'user', stage: 's1-1', icon: '📝', label: '提交数据需求', sub: '门户·资源目录', data: { name: '需求单', preview: '客群画像 · 25-35岁\n精度:城市级 · 周期:30天' } , route: '/tds/market' , mode: 'create', apiKey: 'demand_create',
actions: [
{ type: 'pickSpace' },
{ type: 'search', keyword: (ctx) => `E2E业务链-${ctx.runId}` },
{ type: 'shot', seq: 1, desc: '查看列表里本次提交的需求' }
]
},
{ id: 'n1-2', lane: 'ops', stage: 's1-1', icon: '🤝', label: '交易撮合', sub: '人工 + AI 助手' , route: '/tds/orders' },
{ id: 'n1-3', lane: 'ops', stage: 's1-1', icon: '📤', label: '推送匹配订单', sub: '→ 提供方' , route: '/tds/orders' },
{ id: 'n1-4', lane: 'provider', stage: 's1-1', icon: '✅', label: '确认接单' , route: '/tds/orders' , mode: 'status', apiKey: 'demand_accept',
actions: [
{ type: 'search', keyword: (ctx) => `E2E业务链-${ctx.runId}` },
{ type: 'shot', seq: 1, desc: '在订单页看本次的需求订单' }
] },
{ id: 'n1-5', lane: 'server', stage: 's1-1', icon: '⚙️', label: '挂出算法服务' , route: '/tds/products' },
{ id: 'n1-6', lane: 'user', stage: 's1-2', icon: '🖋️', label: '使用方订单签约', case: 'TC-CONTRACT-007', data: { name: '签约', preview: '数字签名 ed25519\n指纹 a3f9…c12d' } , route: '/tds/contracts' },
{ id: 'n1-7', lane: 'provider', stage: 's1-2', icon: '🖋️', label: '提供方订单签约' , route: '/tds/contracts' },
{ id: 'n1-8', lane: 'ops', stage: 's1-2', icon: '📜', label: '生成合作协议 & 数字合约' , route: '/tds/contracts' , mode: 'create', apiKey: 'contract_create',
actions: [
{ type: 'search', keyword: (ctx) => `E2E-CON-${ctx.runId}` },
{ type: 'shot', seq: 1, desc: '查看本次新建的合约在列表' }
] },
{ id: 'n1-9', lane: 'regulator',stage: 's1-2', icon: '⛓️', label: '上链 / 存证', case: 'TC-CONTRACT_API-006', data: { name: '合约哈希', preview: 'sha256:7f3a…b91e\nFISCO-BCOS group0' } , route: '/tds/chain' , mode: 'status', apiKey: 'contract_sign',
actions: [
{ type: 'pickSpace' },
{ type: 'shot', seq: 1, desc: '查看区块链存证列表(本次签约记录)' }
]
},
{ id: 'n1-10', lane: 'server', stage: 's1-3', icon: '💻', label: '交付算法代码' , route: '/tds/dev-center' },
{ id: 'n1-11', lane: 'provider', stage: 's1-3', icon: '🧪', label: '提供样例数据' , route: '/tdc/datasources' , route: '/tdc/datasources' },
{ id: 'n1-12', lane: 'user', stage: 's1-3', icon: '🛠️', label: '沙盒开发调试', case: 'TC-HOSTING-001', data: { name: '调试日志', preview: 'shap≈0.42 · AUC=0.87\n耗时 12s · 8/12 步骤' } , route: '/tdc/sandbox' , mode: 'create', apiKey: 'sandbox_create',
actions: [
{ type: 'pickSpace' },
{ type: 'search', keyword: (ctx) => `E2E-DT-${ctx.runId}` },
{ type: 'shot', seq: 1, desc: '查看沙盒托管任务列表' }
]
},
{ id: 'n1-13', lane: 'ops', stage: 's1-3', icon: '🔍', label: '算法审核' , route: '/tdc/hosting-job' , mode: 'status', apiKey: 'sandbox_upload',
actions: [
{ type: 'pickSpace' },
{ type: 'shot', seq: 1, desc: '查看托管任务当前状态' }
] },
{ id: 'n1-14', lane: 'user', stage: 's1-3', icon: '👍', label: '审核通过' , route: '/tds/dev-center' },
{ id: 'n1-15', lane: 'provider', stage: 's1-4', icon: '🔐', label: '灌入数据到沙盒' , route: '/tdc/hosting-job' , route: '/tdc/hosting-job' , mode: 'status', apiKey: 'sandbox_audit',
actions: [
{ type: 'pickSpace' },
{ type: 'shot', seq: 1, desc: '查看任务审核前状态' }
] },
{ id: 'n1-16', lane: 'user', stage: 's1-4', icon: '🚀', label: '安全沙盒交付执行', case: 'TC-DELIVERY-001', data: { name: '交付结果', preview: 'AES-256-GCM · 1.2MB\nsha256:c12f…dd09' } , route: '/tdc/delivery' , mode: 'execute', apiKey: 'sandbox_deliver',
actions: [
{ type: 'pickSpace' },
{ type: 'search', keyword: (ctx) => `E2E-DT-${ctx.runId}` },
{ type: 'shot', seq: 1, desc: '执行前的任务状态' }
]
},
{ id: 'n1-17', lane: 'user', stage: 's1-4', icon: '📨', label: '回传交付凭证' , route: '/tdc/delivery' },
{ id: 'n1-18', lane: 'user', stage: 's1-5', icon: '💰', label: '订单支付(线下)' , route: '/tds/billing' },
{ id: 'n1-19', lane: 'ops', stage: 's1-5', icon: '🧾', label: '生成结算凭证' , route: '/tds/billing' , mode: 'create', apiKey: 'settlement_create' },
{ id: 'n1-20', lane: 'regulator',stage: 's1-5', icon: '📤', label: '提交交易凭证' , route: '/tds/evidence' },
{ id: 'n1-21', lane: 'regulator',stage: 's1-5', icon: '🛡️', label: '审计核验', case: 'TC-EVIDENCE-001', data: { name: '审计结果', preview: '✔ 链上存证匹配\n✔ 调用频次合规' } , route: '/tds/audit' , mode: 'query', apiKey: 'auditlog_search',
actions: [
{ type: 'search', keyword: (ctx) => `E2E-CON-${ctx.runId}` },
{ type: 'shot', seq: 1, desc: '审计页搜索本次合约记录' }
]
},
],
edges: [
{ from: 'n1-1', to: 'n1-2', label: '需求单', kind: 'request' },
{ from: 'n1-2', to: 'n1-3', label: '匹配订单', kind: 'request' },
{ from: 'n1-3', to: 'n1-4', label: '订单推送', kind: 'request' },
{ from: 'n1-4', to: 'n1-2', label: '确认回执', kind: 'callback' },
{ from: 'n1-5', to: 'n1-2', label: '算法挂出', kind: 'notify' },
{ from: 'n1-2', to: 'n1-6', label: '订单', kind: 'request' },
{ from: 'n1-2', to: 'n1-7', label: '订单', kind: 'request' },
{ from: 'n1-6', to: 'n1-8', label: '签名', kind: 'contract' },
{ from: 'n1-7', to: 'n1-8', label: '签名', kind: 'contract' },
{ from: 'n1-8', to: 'n1-9', label: '合约哈希', kind: 'contract' },
{ from: 'n1-9', to: 'n1-10', label: '存证回执', kind: 'callback' },
{ from: 'n1-10', to: 'n1-11', label: '代码', kind: 'request' },
{ from: 'n1-11', to: 'n1-12', label: '样例数据', kind: 'cipher' },
{ from: 'n1-12', to: 'n1-13', label: '算法', kind: 'request' },
{ from: 'n1-13', to: 'n1-14', label: '审核结果', kind: 'response' },
{ from: 'n1-14', to: 'n1-15', label: '投产通知', kind: 'notify' },
{ from: 'n1-15', to: 'n1-16', label: '密态灌入', kind: 'cipher' },
{ from: 'n1-16', to: 'n1-17', label: '交付结果', kind: 'cipher' },
{ from: 'n1-17', to: 'n1-18', label: '结算请求', kind: 'request' },
{ from: 'n1-18', to: 'n1-19', label: '支付回执', kind: 'voucher' },
{ from: 'n1-19', to: 'n1-20', label: '结算凭证', kind: 'voucher' },
{ from: 'n1-20', to: 'n1-21', label: '凭证', kind: 'voucher' }
]
}
// ───────── 图2:沙盒交付(三方) ─────────
const seq2 = {
id: 'seq-2',
no: 2,
title: '沙盒交付(三方)',
subtitle: '服务方多一节签约 + 算法开发',
participants: ['user', 'ops', 'provider', 'server', 'regulator'],
stages: [
{ id: 's2-1', name: '阶段1:发现与撮合', color: 'rgba(88,166,255,.07)' },
{ id: 's2-2', name: '阶段2:合约签订', color: 'rgba(163,113,247,.07)' },
{ id: 's2-3', name: '阶段3:算法开发与调试', color: 'rgba(210,153,34,.07)' },
{ id: 's2-4', name: '阶段4:正式交付与执行', color: 'rgba(63,185,80,.07)' },
{ id: 's2-5', name: '阶段5:结算与审计', color: 'rgba(247,129,102,.07)' }
],
nodes: [
{ id: 'n2-1', lane: 'user', stage: 's2-1', icon: '📝', label: '数据需求 / 资源目录下单', case: 'TC-TRADE-003', data: { name: '需求', preview: '三方联合建模\n画像×风控×消费' } , route: '/tds/market' , mode: 'create', apiKey: 'demand_create' },
{ id: 'n2-2', lane: 'ops', stage: 's2-1', icon: '🤝', label: '交易撮合' , route: '/tds/orders' },
{ id: 'n2-3', lane: 'ops', stage: 's2-1', icon: '🧐', label: '订单审核' , route: '/tds/orders' },
{ id: 'n2-4', lane: 'provider', stage: 's2-1', icon: '📦', label: '提供数据资源' , route: '/tds/products' },
{ id: 'n2-5', lane: 'server', stage: 's2-1', icon: '⚙️', label: '提供算法服务' , route: '/tds/products' },
{ id: 'n2-6', lane: 'user', stage: 's2-2', icon: '🖋️', label: '使用方签约' , route: '/tds/contracts' },
{ id: 'n2-7', lane: 'provider', stage: 's2-2', icon: '🖋️', label: '提供方签约' , route: '/tds/contracts' },
{ id: 'n2-8', lane: 'server', stage: 's2-2', icon: '🖋️', label: '服务方签约' , route: '/tds/contracts' },
{ id: 'n2-9', lane: 'ops', stage: 's2-2', icon: '📜', label: '生成合作协议 & 数字合约' , route: '/tds/contracts' , mode: 'create', apiKey: 'contract_create' },
{ id: 'n2-10', lane: 'regulator',stage: 's2-2', icon: '⛓️', label: '上链 / 存证', data: { name: '合约哈希', preview: '三方合约 0xa3…91f\nFISCO-BCOS group0' } , route: '/tds/chain' , mode: 'status', apiKey: 'contract_sign' },
{ id: 'n2-11', lane: 'provider', stage: 's2-3', icon: '🧪', label: '提供样例数据' , route: '/tdc/datasources' , route: '/tdc/datasources' },
{ id: 'n2-12', lane: 'server', stage: 's2-3', icon: '💻', label: '编写算法代码', case: 'TC-HOSTING-001', data: { name: '算法', preview: 'XGBoost · lr=0.05\n树深 6 · 迭代 200' } , route: '/tds/dev-center' , mode: 'create', apiKey: 'sandbox_create' },
{ id: 'n2-13', lane: 'server', stage: 's2-3', icon: '📤', label: '提交算法审核' , route: '/tds/dev-center' },
{ id: 'n2-14', lane: 'ops', stage: 's2-3', icon: '🔍', label: '算法审核' , route: '/tds/dev-center' , mode: 'status', apiKey: 'sandbox_audit' },
{ id: 'n2-15', lane: 'server', stage: 's2-3', icon: '👍', label: '审核通过' , route: '/tds/dev-center' },
{ id: 'n2-16', lane: 'provider', stage: 's2-4', icon: '🔐', label: '灌入数据到沙盒' , route: '/tdc/hosting-job' , route: '/tdc/hosting-job' },
{ id: 'n2-17', lane: 'user', stage: 's2-4', icon: '🚀', label: '安全沙盒交付执行', case: 'TC-DELIVERY-001', data: { name: '三方联合', preview: 'MPC·SPDZ 协议\n128MB 中间碎片' } , route: '/tdc/delivery' , mode: 'execute', apiKey: 'sandbox_deliver' },
{ id: 'n2-18', lane: 'user', stage: 's2-4', icon: '📨', label: '回传交付凭证' , route: '/tdc/delivery' },
{ id: 'n2-19', lane: 'user', stage: 's2-5', icon: '💰', label: '订单付款(线下)' , route: '/tds/billing' },
{ id: 'n2-20', lane: 'ops', stage: 's2-5', icon: '🧾', label: '生成结算凭证' , route: '/tds/billing' , mode: 'create', apiKey: 'settlement_create' },
{ id: 'n2-21', lane: 'regulator',stage: 's2-5', icon: '📤', label: '提交交易凭证' , route: '/tds/evidence' },
{ id: 'n2-22', lane: 'regulator',stage: 's2-5', icon: '🛡️', label: '审计核验', case: 'TC-EVIDENCE-001', data: { name: '审计', preview: '三方交付均留痕\n✔ 数据不跨境' } , route: '/tds/audit' , mode: 'query', apiKey: 'auditlog_search' },
],
edges: [
{ from: 'n2-1', to: 'n2-2', label: '需求', kind: 'request' },
{ from: 'n2-2', to: 'n2-3', label: '订单', kind: 'request' },
{ from: 'n2-3', to: 'n2-4', label: '撮合', kind: 'request' },
{ from: 'n2-3', to: 'n2-5', label: '撮合', kind: 'request' },
{ from: 'n2-4', to: 'n2-6', label: '资源', kind: 'request' },
{ from: 'n2-5', to: 'n2-6', label: '服务', kind: 'request' },
{ from: 'n2-5', to: 'n2-7', label: '服务', kind: 'request' },
{ from: 'n2-5', to: 'n2-8', label: '服务', kind: 'request' },
{ from: 'n2-6', to: 'n2-9', label: '签名', kind: 'contract' },
{ from: 'n2-7', to: 'n2-9', label: '签名', kind: 'contract' },
{ from: 'n2-8', to: 'n2-9', label: '签名', kind: 'contract' },
{ from: 'n2-9', to: 'n2-10', label: '合约哈希', kind: 'contract' },
{ from: 'n2-10', to: 'n2-11', label: '存证', kind: 'callback' },
{ from: 'n2-11', to: 'n2-12', label: '样例数据', kind: 'cipher' },
{ from: 'n2-12', to: 'n2-13', label: '算法', kind: 'request' },
{ from: 'n2-13', to: 'n2-14', label: '审核请求', kind: 'request' },
{ from: 'n2-14', to: 'n2-15', label: '审核结果', kind: 'response' },
{ from: 'n2-15', to: 'n2-16', label: '投产', kind: 'notify' },
{ from: 'n2-16', to: 'n2-17', label: '密态灌入', kind: 'cipher' },
{ from: 'n2-17', to: 'n2-18', label: '交付结果', kind: 'cipher' },
{ from: 'n2-18', to: 'n2-19', label: '结算', kind: 'request' },
{ from: 'n2-19', to: 'n2-20', label: '支付回执', kind: 'voucher' },
{ from: 'n2-20', to: 'n2-21', label: '结算凭证', kind: 'voucher' },
{ from: 'n2-21', to: 'n2-22', label: '凭证', kind: 'voucher' }
]
}
// ───────── 图3:机构会员注册与资源发布 ─────────
const seq3 = {
id: 'seq-3',
no: 3,
title: '机构会员注册与资源发布',
subtitle: '机构入驻 → 资源上架 → 浏览购买',
participants: ['user', 'ops', 'provider', 'server'],
stages: [
{ id: 's3-1', name: '机构会员注册', color: 'rgba(88,166,255,.07)' },
{ id: 's3-2', name: '数据资源发布', color: 'rgba(63,185,80,.07)' },
{ id: 's3-3', name: '数据资源购买', color: 'rgba(163,113,247,.07)' },
{ id: 's3-4', name: '算法产品发布', color: 'rgba(210,153,34,.07)' }
],
nodes: [
{ id: 'n3-1', lane: 'user', stage: 's3-1', icon: '🏢', label: '注册机构会员、发布数据需求', case: 'TC-IDENTITY-004', data: { name: '机构注册', preview: '营业执照 OCR 通过\n法人:张三 · 信用:A级' } , route: '/tds/market' , mode: 'create', apiKey: 'connector_create' },
{ id: 'n3-2', lane: 'provider', stage: 's3-1', icon: '🏢', label: '注册机构会员、申请入驻' , route: '/tdc/members' , route: '/tdc/members' },
{ id: 'n3-3', lane: 'server', stage: 's3-1', icon: '🏢', label: '注册机构会员、发布算法产品' , route: '/tdc/members' },
{ id: 'n3-4', lane: 'provider', stage: 's3-2', icon: '📦', label: '提交数据资源、上架目录', case: 'TC-CATALOG-001', data: { name: '资源目录', preview: '「一线消费力指数」\n样本 120万 · 30 字段' } , route: '/tdc/datasources' , route: '/tdc/datasources' , mode: 'create', apiKey: 'product_create' },
{ id: 'n3-5', lane: 'user', stage: 's3-3', icon: '🛒', label: '浏览资源目录、下单购买' , route: '/tds/catalog' },
{ id: 'n3-6', lane: 'user', stage: 's3-3', icon: '🔌', label: '连接器注册', case: 'TC-CONNECTOR-001', data: { name: '连接器', preview: '[email protected]\nSNP 已签发 · v3.2' } , route: '/tds/connectors' , mode: 'create', apiKey: 'connector_register' },
{ id: 'n3-7', lane: 'server', stage: 's3-4', icon: '🛠️', label: '发布算法 / 服务产品' , route: '/tds/products' , mode: 'create', apiKey: 'product_create' },
],
edges: [
{ from: 'n3-1', to: 'n3-4', label: '需求', kind: 'request' },
{ from: 'n3-2', to: 'n3-4', label: '入驻申请', kind: 'request' },
{ from: 'n3-4', to: 'n3-5', label: '资源目录', kind: 'notify' },
{ from: 'n3-5', to: 'n3-6', label: '购买订单', kind: 'request' },
{ from: 'n3-3', to: 'n3-7', label: '机构认证', kind: 'notify' }
]
}
// ───────── 图4:隐私计算沙盒执行链路(TEE) ─────────
const seq4 = {
id: 'seq-4',
no: 4,
title: '隐私计算沙盒执行链路',
subtitle: 'TEE 硬件:用后即焚,仅结果出域',
participants: ['ops', 'tee', 'provider', 'user', 'server'],
stages: [
{ id: 's4-1', name: '触发:合约达成 → 创建沙盒', color: 'rgba(163,113,247,.07)' },
{ id: 's4-2', name: '数据灌入(加密通道)', color: 'rgba(255,123,114,.07)' },
{ id: 's4-3', name: '内存加工(按算法)', color: 'rgba(210,153,34,.07)' },
{ id: 's4-4', name: '结果出域', color: 'rgba(63,185,80,.07)' },
{ id: 's4-5', name: '用后即焚 → 凭证回传', color: 'rgba(247,129,102,.07)' }
],
nodes: [
{ id: 'n4-1', lane: 'ops', stage: 's4-1', icon: '📜', label: '合约签 → 创建安全沙盒', data: { name: '沙盒元数据', preview: 'policy:deny-all\ntflavor:kata-qemu-snp' } , route: '/tdc/sandbox' , mode: 'create', apiKey: 'sandbox_create' },
{ id: 'n4-2', lane: 'ops', stage: 's4-1', icon: '📣', label: '通知数据导入', case: 'TC-HOSTING-001' , route: '/tdc/hosting-job' },
{ id: 'n4-3', lane: 'provider', stage: 's4-2', icon: '🔐', label: '密态传输数据', data: { name: '加密数据', preview: 'AES-256-GCM\n12 MB · nonce 8e3…' } , route: '/tdc/hosting-job' , route: '/tdc/hosting-job' , mode: 'status', apiKey: 'sandbox_upload' },
{ id: 'n4-4', lane: 'tee', stage: 's4-2', icon: '🛡️', label: '接收加密数据' , route: '/tdc/sandbox' },
{ id: 'n4-5', lane: 'tee', stage: 's4-3', icon: '🧠', label: '计算执行', case: 'TC-DELIVERY-001', data: { name: 'TEE 内运行', preview: 'CDH 远程证明通过\nSNP report OK' } , route: '/tdc/sandbox' , mode: 'execute', apiKey: 'sandbox_deliver' },
{ id: 'n4-6', lane: 'user', stage: 's4-4', icon: '📥', label: '接收计算结果', case: 'TC-USAGE-001', data: { name: '结果', preview: '联合模型 v1.2\nAUC 0.91 · 1.2 MB' } , route: '/tdc/delivery' },
{ id: 'n4-7', lane: 'tee', stage: 's4-5', icon: '🔥', label: '数据销毁、环境清零' , route: '/tdc/destroy-log' , mode: 'status', apiKey: 'sandbox_destroy' },
{ id: 'n4-8', lane: 'tee', stage: 's4-5', icon: '📨', label: '沙盒释放、凭证回传', case: 'TC-EVIDENCE-001', data: { name: '执行凭证', preview: 'attest:sha256:c12…\n执行时间 8m12s' } , route: '/tdc/destroy-log' },
{ id: 'n4-9', lane: 'ops', stage: 's4-5', icon: '✔️', label: '收到释放回执' , route: '/tds/evidence' },
],
edges: [
{ from: 'n4-1', to: 'n4-2', label: '创建事件', kind: 'notify' },
{ from: 'n4-2', to: 'n4-3', label: '导入通知', kind: 'notify' },
{ from: 'n4-3', to: 'n4-4', label: '加密数据', kind: 'cipher' },
{ from: 'n4-4', to: 'n4-5', label: '解密入内存', kind: 'cipher' },
{ from: 'n4-5', to: 'n4-6', label: '结果加密出域', kind: 'cipher' },
{ from: 'n4-6', to: 'n4-7', label: 'ACK', kind: 'callback' },
{ from: 'n4-7', to: 'n4-8', label: '销毁完成', kind: 'notify' },
{ from: 'n4-8', to: 'n4-9', label: '释放凭证', kind: 'voucher' }
]
}
// ───────── 图5:三种隐私计算模式对比 ─────────
const seq5 = {
id: 'seq-5',
no: 5,
title: '三种隐私计算模式对比',
subtitle: '集中式 PSI · 联邦学习 · 多方安全计算(并行调度)',
participants: ['ops', 'psi', 'fl', 'mpc'],
stages: [
{ id: 's5-1', name: '场景:按需求选择计算模式', color: 'rgba(88,166,255,.07)' },
{ id: 's5-2', name: '部署沙盒', color: 'rgba(163,113,247,.07)' },
{ id: 's5-3', name: '计算加工', color: 'rgba(210,153,34,.07)' },
{ id: 's5-4', name: '结果回传', color: 'rgba(63,185,80,.07)' }
],
nodes: [
{ id: 'n5-1', lane: 'ops', stage: 's5-1', icon: '🧭', label: '按场景选择模式', data: { name: '选型', preview: '按"是否可集中"\n选 PSI / FL / MPC' } , route: '/tds/policies' , route: '/tds/policies' },
{ id: 'n5-2', lane: 'psi', stage: 's5-2', icon: '🏗️', label: '部署 1 个集中沙盒' , route: '/flow/projects' , route: '/flow/projects' , mode: 'create', apiKey: 'sandbox_create' },
{ id: 'n5-3', lane: 'fl', stage: 's5-2', icon: '🏗️', label: '各参与方本地部署(N 个)' , route: '/flow/projects' , mode: 'create', apiKey: 'sandbox_create' },
{ id: 'n5-4', lane: 'mpc', stage: 's5-2', icon: '🏗️', label: '各参与方本地部署(N 个)' , route: '/flow/projects' , route: '/flow/projects' , mode: 'create', apiKey: 'sandbox_create' },
{ id: 'n5-5', lane: 'psi', stage: 's5-3', icon: '🔐', label: '数据加密出域 → 集中融合', data: { name: 'PSI 协议', preview: 'OPRF + 加密求交\n隐私集合 ≈ 5w' } , route: '/tdc/privacy' , route: '/tdc/privacy' },
{ id: 'n5-6', lane: 'fl', stage: 's5-3', icon: '🖥️', label: '数据不出域 → 本地明文训练' , route: '/tdc/privacy' },
{ id: 'n5-7', lane: 'fl', stage: 's5-3', icon: '🔁', label: '沙盒间传输加密模型参数', data: { name: '梯度', preview: 'ΔW · 0.8 MB\n加噪 ε=0.1' } , route: '/tdc/privacy' },
{ id: 'n5-8', lane: 'mpc', stage: 's5-3', icon: '✂️', label: '数据不出域 → 秘密分享成碎片' , route: '/tdc/privacy' , route: '/tdc/privacy' },
{ id: 'n5-9', lane: 'mpc', stage: 's5-3', icon: '🔁', label: '沙盒间传输加密中间碎片', data: { name: '秘密分享', preview: '3-of-5 Shamir\n碎片 24 KB ×5' } , route: '/tdc/privacy' , route: '/tdc/privacy' },
{ id: 'n5-10', lane: 'psi', stage: 's5-4', icon: '📥', label: '返回求交结果', case: 'TC-USAGE-001', data: { name: '结果', preview: '交集 ID 数 4872\n用时 32s' } , route: '/tdc/privacy' , route: '/tdc/privacy' },
{ id: 'n5-11', lane: 'fl', stage: 's5-4', icon: '📥', label: '返回联合模型' , route: '/tdc/privacy' },
{ id: 'n5-12', lane: 'mpc', stage: 's5-4', icon: '📥', label: '返回联合统计结果', case: 'TC-USAGE-022', data: { name: '结果', preview: '均值 μ=124.7\nσ=8.3 · 用时 5m' } , route: '/tds/policy-conflict' , route: '/tds/policy-conflict' },
],
edges: [
{ from: 'n5-1', to: 'n5-2', label: '模式 PSI', kind: 'request' },
{ from: 'n5-1', to: 'n5-3', label: '模式 FL', kind: 'request' },
{ from: 'n5-1', to: 'n5-4', label: '模式 MPC', kind: 'request' },
{ from: 'n5-2', to: 'n5-5', label: '沙盒就绪', kind: 'notify' },
{ from: 'n5-5', to: 'n5-10', label: '求交结果', kind: 'cipher' },
{ from: 'n5-3', to: 'n5-6', label: '沙盒就绪', kind: 'notify' },
{ from: 'n5-6', to: 'n5-7', label: '梯度', kind: 'cipher' },
{ from: 'n5-7', to: 'n5-11', label: '聚合模型', kind: 'cipher' },
{ from: 'n5-4', to: 'n5-8', label: '沙盒就绪', kind: 'notify' },
{ from: 'n5-8', to: 'n5-9', label: '碎片', kind: 'cipher' },
{ from: 'n5-9', to: 'n5-12', label: '聚合统计', kind: 'cipher' }
]
}
/**
* 把"老格式"边(数组 [from,to,dashed])平滑成新格式(对象);调用方放心传老数据
*/
function normalizeEdges(edges) {
return edges.map((e) => {
if (Array.isArray(e)) {
const [from, to, dashed] = e
return { from, to, label: '', kind: dashed ? 'callback' : 'request' }
}
return e
})
}
const graphs = [seq1, seq2, seq3, seq4, seq5].map((g) => ({
...g,
edges: normalizeEdges(g.edges)
}))
export const DAG = {
swimlanes: SWIMLANES,
edgeKinds: EDGE_KINDS,
graphs
}
/** 收集一张图里所有节点关联到的真实 TC 编号(用于点「启动」时直接喂给 runner) */
export function collectTcs(graph) {
const set = new Set()
for (const n of graph.nodes) if (n.case) set.add(n.case)
return [...set]
}