口径召回前端(W4-a):版本用量加问数回答和召回、发布弹窗预告召回规模、版本历史看召回批次、recall 待办卡、时间线认两个新事件

为什么:前三波召回只有接口;这一波收口,口径升版之后谁的答案受影响、重算了几组、数变没变、怎么处置都要在界面上走得通。

- canvas/versionUsage:使用情况那一行加问数回答、导出、定时任务、召回(老服务端不给就不写)
- canvas/RecallPanel(新):发布弹窗「召回」一行——旧版本被谁用过、按参数去重几组、发布后自动重算几组、超出上限几组(可在
  版本历史接着算)、上限为 0 时只列不算、不能重算的原因;版本历史展开一版——每组结论(数变了 / 没变 / 无法重算:原因 /
  重算失败 / 正在重算 / 未重算)、变了的指标、开了几条待办、召回运行链接,「另有 M 组未重算」+ 接着算
- run/RecallTask(新)+ TaskCard:recall 待办卡——旧口径、新口径、两版之差一行一个指标,每个数点得开召回卡的指标链;每个答案
  当时的值点得开(正式运行的口径卡、问数回答的查询快照),问数回答链回对话;「按新版重新出具」(不能时停用并写服务端给的
  原因)、「知道了」;遮罩值写已遮罩、点不开;目录有变、表结构变了两种只有「知道了」
- run/decode:ledger.recalled(已按 vN 核对,不影响;召回核对数变没变;试算结果)、ledger.basis_changed(依据有变、依据的
  表结构已变);缺字段不猜
- 文案进 lib/termsRecall.ts;接口 api/recall.ts、形状 typesRecall.ts;TaskKind 加 recall
- 检查:check-inbox 加 recall 卡两段,check-publish 加召回预告和召回批次两段(版本历史、发布弹窗都在这里测;check-versions
  测的是上传表格的版本页,和召回无关),check-decode 加两个新事件的夹具,check-capabilities 的可订阅事件跟上 ledger.recall
This commit is contained in:
ThearchyHelios
2026-10-16 20:05:24 +08:00
parent 77fc0efa10
commit 35583ba1d8
18 changed files with 1236 additions and 16 deletions
+8 -6
View File
@@ -332,7 +332,7 @@ await section('设置:身份、通知、审计', async () => {
await section('设置 → 通知:可订阅的事件照服务端登记列(总方案 X6)', async () => {
// 列表从真后端的 GET /api/notify/events 来(GET 放行):这种范围的渠道收得到的才列;从来推不到的(以前列着、一勾就 422
// 的「待办升级」「动作已生效」……)和登记了还没推送的(召回、待办汇总……)都不列
// 的「待办升级」「动作已生效」……)和登记了还没推送的(数据源变化……)都不列
const { page, errors } = await open('/settings/notify')
await page.getByRole('button', { name: '添加渠道' }).first().click()
const dlg = page.locator('[role="dialog"]')
@@ -343,21 +343,23 @@ await section('设置 → 通知:可订阅的事件照服务端登记列(总
}
const every = ['task.opened', 'run.finished', 'run.failed', 'action.unknown']
// 第 3 波起:定时评测的两个事件只推全局渠道(评测是搭建者们共用的一把尺,不归哪个人;服务端 notify/service.notify_eval);
// 访问密钥快到期推给全局渠道(服务账号的密钥)和个人渠道(个人密钥),每天的待办汇总只推个人渠道
// 访问密钥快到期推给全局渠道(服务账号的密钥)和个人渠道(个人密钥),每天的待办汇总只推个人渠道。第 4 波:口径召回
// 数变了的推全局渠道和答案主人的个人渠道(notify_recall),不归哪个应用
check('全局渠道:推给全局渠道的几项', await waitFor(page, async () => await dlg.locator('[data-notify-events="global"]').count() === 1)
&& JSON.stringify(await listed()) === JSON.stringify([...every, 'review.done', 'eval.regressed', 'eval.failed', 'key.expiring']),
&& JSON.stringify(await listed()) === JSON.stringify([...every, 'review.done', 'ledger.recall', 'eval.regressed', 'eval.failed',
'key.expiring']),
JSON.stringify(await listed()))
const text = await dlg.innerText()
// 只推定时发起的评测:叫法照实带「定时」,勾上的人不会以为手动发起的那次也推
check('评测的两个事件照实说是定时的', ['定时评测有退步', '定时评测没有评完'].every((t) => text.includes(t)), text)
check('从来推不到的不列', !['待办升级', '待办超时', '待办处理完', '动作失败', '动作已生效'].some((t) => text.includes(t)), text)
check('登记了还没推送的不列', !['数据源有变化要处理', '口径升版,答案的数变了']
check('登记了还没推送的不列', !['数据源有变化要处理']
.some((t) => text.includes(t)), text)
check('只推个人渠道的「每天的待办汇总」全局渠道不列', !text.includes('每天的待办汇总'), text)
check('应用的渠道:不列只发给提交人的「我提交审核的应用有结果」', await scope('app')
check('应用的渠道:不列只发给提交人的「我提交审核的应用有结果」,也不列口径召回', await scope('app')
&& JSON.stringify(await listed()) === JSON.stringify(every), JSON.stringify(await listed()))
check('个人渠道:连同待办汇总、密钥快到期都列', await scope('user')
&& JSON.stringify(await listed()) === JSON.stringify([...every, 'review.done', 'task.digest', 'key.expiring']),
&& JSON.stringify(await listed()) === JSON.stringify([...every, 'review.done', 'ledger.recall', 'task.digest', 'key.expiring']),
JSON.stringify(await listed()))
check('没有运行时报错', errors.length === 0, errors.slice(0, 2).join(' | '))
})
+46
View File
@@ -1888,6 +1888,52 @@ await section('口径账本:封存后比对已发布口径(ledger.matched)
check('不改相位:运行照旧是结束了', phase.phase === 'succeeded', phase.phase)
})
await section('口径召回:封存后的核对结论与依据有变(ledger.recalled、ledger.basis_changed)', async () => {
// next-round 02 做法 7:口径发布新版本后召回运行在同一份数据上重算两版,数没变的在原答案上记「已按 vN 核对,不影响」,
// 召回运行自己记结论;目录事实被驳回或修改、表结构变了的在答案上记「依据有变」。都在封存之后,事件里不带数
const E = (seq, type, node_id, data = {}) => ({ seq, type, node_id, ts: 1790000000 + seq, data })
const base = [E(1, 'run.started', null, {}), E(2, 'node.started', 'q', { node_type: 'tool' }), E(3, 'node.finished', 'q', {}),
E(4, 'run.finished', null, { status: 'succeeded' })]
const run = (...more) => flatten(mod.decodeRun([...base, ...more]))
const answer = run(E(5, 'ledger.recalled', null, { role: 'answer', changed: false, recall_run: 'rc-1', workflow_id: 'wf-week',
from_version: 1, to_version: 2, post_seal: true }))
check('认得它们:不是「未识别的事件」', !answer.some((s) => s.title === '未识别的事件'))
const ok = answer.find((s) => s.code === 'ledger_recalled')
check('原答案上:已按 v2 核对,不影响;写明封存后追加', ok?.title === '已按 v2 核对,不影响'
&& ok?.sub === '封存后追加,不在封存范围内' && ok?.level === 'info' && ok?.kind === 'note', `${ok?.title} / ${ok?.sub}`)
const changed = run(E(5, 'ledger.recalled', null, { role: 'recall', outcome: 'changed', changed: true, from_version: 1,
to_version: 2, answers: 2, tasks: ['t1', 't2'], metrics: [{ k: 0, name: '销售额', changed: true }] }))
.find((s) => s.code === 'ledger_recalled')
check('召回运行上:数变了是提醒,写开了几条待办,不带数', changed?.title === '召回核对(v1 → v2):数变了'
&& changed?.level === 'warn' && changed?.meta === '开了 2 条待办' && !/\d+\.\d/.test(`${changed?.title}${changed?.detail ?? ''}`),
`${changed?.title} / ${changed?.meta}`)
const same = run(E(5, 'ledger.recalled', null, { role: 'recall', outcome: 'unchanged', changed: false, from_version: 1, to_version: 2 }))
.find((s) => s.code === 'ledger_recalled')
check('……数没变的是一般说明', same?.title === '召回核对(v1 → v2):数没变' && same?.level === 'info', same?.title)
const failedRun = run(E(5, 'ledger.recalled', null, { role: 'recall', outcome: 'failed', changed: null, error: '数据源已停用' }))
.find((s) => s.code === 'ledger_recalled')
check('……重算失败照实写原因', failedRun?.title === '召回重算失败' && failedRun?.detail === '数据源已停用' && failedRun?.level === 'warn',
`${failedRun?.title} / ${failedRun?.detail}`)
const probe = run(E(5, 'ledger.recalled', null, { role: 'recall', probe: true, outcome: 'failed', error: 'no such column' }))
.find((s) => s.code === 'ledger_recalled')
check('表结构变了之后的口径试算:没有算出来', probe?.title === '表结构变了之后试算口径:没有算出来', probe?.title)
const basis = run(E(5, 'ledger.basis_changed', null, { kind: 'catalog', source: 'shop', table: 'orders',
items: [{ path: 'columns.amount.measure', label: '列 amount 的度量类型', change: 'changed' }], new_errors: 1 }))
.find((s) => s.code === 'ledger_basis_changed')
check('目录事实被改:依据有变,列出哪几项、新出现几条错误级问题', basis?.title === '依据有变:数据目录里影响数字的项被驳回或修改'
&& basis?.meta === 'shop · orders' && basis?.detail === '列 amount 的度量类型\n按新目录检查新出现 1 条错误级问题'
&& basis?.level === 'warn', `${basis?.title} / ${basis?.detail}`)
const structure = run(E(5, 'ledger.basis_changed', null, { kind: 'structure', table: 'orders', column: 'amount', items: [] }))
.find((s) => s.code === 'ledger_basis_changed')
check('表结构变了:依据的表结构已变', structure?.title === '依据的表结构已变' && structure?.level === 'warn', structure?.title)
const odd = run(E(5, 'ledger.recalled', null, {}), E(6, 'ledger.basis_changed', null, { kind: 'x', items: 'y' }))
check('缺字段:不出 undefined、不瞎填数', !odd.some((s) => /undefined|NaN/.test(`${s.title}${s.sub ?? ''}${s.detail ?? ''}${s.meta ?? ''}`)),
odd.map((s) => s.title).join(' | '))
const phase = [E(4, 'run.finished', null, {}), E(5, 'ledger.recalled', null, {}), E(6, 'ledger.basis_changed', null, {})]
.reduce((s, ev) => mod.nextPhase(s, ev), { phase: 'running', awaiting: false })
check('不改相位:运行照旧是结束了', phase.phase === 'succeeded', phase.phase)
})
await section('口径账本:问数据的助手选用已发布口径(use_caliber 操作)', async () => {
// next-round 02 做法 4:取数节点和口径卡由服务端按那一版生成(ledger/compose.py),不另转 add_node。过程里一行说清选用了
// 哪一版、生成了几个节点;拒收的照实写原因(同样交回了模型去改)
+136
View File
@@ -17,6 +17,10 @@
// - 审核个人应用(kind=review,payload 同服务端 blueprints/personal.review_payload):写提交人(显示名)、目的、说明;没有
// 「同意」——「取副本,去发布」调 POST /api/blueprints/{id}/copy 后进副本蓝图;取过的给「打开我的副本」(只认自己取的那
// 一份,别人取的不算);「退回」可以写原因,走待办接口 decision=reject。
// - 口径召回(kind=recall,payload 同服务端 ledger/recall.task_payload,next-round 02 做法 7):旧口径、新口径、两版之差
// 一行一个指标,每个数点得开出处(召回卡的指标链);每个答案当时的值也点得开(正式运行的口径卡、问数回答的查询快照);
// 问数回答链回那段对话;「按新版重新出具」decision=reissue、「知道了」decision=ack;服务端说不能重新出具时按钮停用、
// 写原因;使用者看到的遮罩值写「已遮罩」、点不开;目录有变那一种只有「知道了」,列出变了的目录项和新出现的问题。
//
// 接口全部在浏览器层答掉(/api/tasks/**),数据是这里虚构的;写请求记在探针里。
//
@@ -134,6 +138,53 @@ const TASKS = {
{ id: 'bp_daily_mine', owner: '审批人甲', status: 'trialed', app_id: null }] },
people: { zhangsan: '张三' },
},
// 口径召回:口径升到 v2,这一组答案的数变了(payload 同服务端 ledger/recall.task_payload)
recall: {
...base, id: 'recall', kind: 'recall', title: '口径「周销售」升到 v2,答案的数变了', node_id: null, app_id: null,
app_name: null, app_version: null, workflow_name: '口径召回:周销售 v1 → v2', run_id: 'rc_1',
assignments: [assignment('rc1', '审批人甲', 'pending', null, { source: 'recall' })],
payload: { kind: 'recall', reason: 'caliber', recall_run: 'rc_1', workflow_id: 'wf_week', workflow_name: '周销售',
from_version: 1, to_version: 2,
binding: [{ field: 'end', value: '2026-09-08', masked: false }, { field: 'start', value: '2026-09-01', masked: false }],
metrics: [{ k: 0, name: '销售额', unit: '元', changed: true, card: 'card', metric: 'gmv',
old: { value: 170.5, text: '170.50元', masked: false, metric: 'old_0' },
new: { value: 208.5, text: '208.50元', masked: false, metric: 'new_0' },
diff: { value: 38, text: '38.00元', masked: false, metric: 'diff_0' } }],
answers: [
{ kind: 'answer', kind_text: '问数回答', run_id: 'run_ans_1', version: 1, conversation_id: 'conv_1', turn_id: 'turn_1',
at: ago(86400_000), original: [{ k: 0, value: 170.5, text: '170.50元', masked: false, query: 'snap_1', column: '销售额' }] },
{ kind: 'schedule', kind_text: '定时任务', run_id: 'run_fm_1', version: 1, schedule_id: 'sch_1', at: ago(3 * 86400_000),
original: [{ k: 0, value: 165, text: '165.00元', masked: false, node: 'card', metric: 'gmv' }] },
],
actions: [{ decision: 'reissue', available: true }, { decision: 'ack', available: true }] },
},
// 使用者看的:遮罩值写「已遮罩」、点不开;没有被他能用的应用固定,服务端说不能重新出具
recallUser: {
...base, id: 'recallUser', kind: 'recall', title: '口径「客户分层」升到 v3,答案的数变了', node_id: null, app_id: null,
app_name: null, app_version: null, workflow_name: '口径召回:客户分层 v2 → v3', run_id: 'rc_2',
assignments: [assignment('rc2', 'zhangsan', 'pending', null, { source: 'recall' })],
payload: { kind: 'recall', reason: 'caliber', recall_run: 'rc_2', workflow_id: 'wf_tier', workflow_name: '客户分层',
from_version: 2, to_version: 3, binding: [{ field: 'phone', value: null, masked: true }],
metrics: [{ k: 0, name: '消费额', unit: '元', changed: true, card: 'card', metric: 'spend',
old: { value: null, text: '已遮罩', masked: true, metric: 'old_0' },
new: { value: 90, text: '90元', masked: false, metric: 'new_0' },
diff: { value: null, text: '已遮罩', masked: true, metric: 'diff_0' } }],
answers: [{ kind: 'answer', kind_text: '问数回答', run_id: 'run_ans_2', version: 2, conversation_id: 'conv_2',
original: [{ k: 0, value: null, text: null, masked: false, missing: '原答案里没有单独的这个数' }] }],
actions: [{ decision: 'reissue', available: false,
reason: '这份口径没有被你能使用的应用固定,不能由你按口径出具,请搭建者出具' }, { decision: 'ack', available: true }] },
},
// 答案依据的目录有变、按新目录检查出了新的错误级问题:只有「知道了」
recallCatalog: {
...base, id: 'recallCatalog', kind: 'recall', title: '答案依据的数据目录有变:按新目录检查出了新的问题', node_id: null,
app_id: null, app_name: null, app_version: null, workflow_name: '', run_id: 'run_ans_3',
assignments: [assignment('rc3', '审批人甲', 'pending', null, { source: 'recall' })],
payload: { kind: 'recall', reason: 'catalog', recall_run: 'run_ans_3',
basis: { kind: 'catalog', source: 'shop', table: 'orders', new_errors: 1,
items: [{ path: 'columns.amount.measure', label: '列 amount 的度量类型', change: 'changed' }],
checks: [{ code: 'stock_summed', message: '对存量列 amount 求和,分组里没有业务日期' }] },
actions: [{ decision: 'ack', available: true }] },
},
// 补充输入里选复核人(选人控件):使用者按这条待办的候选池选
pick: {
...base, id: 'pick', approval_id: 'ap8', kind: 'input', title: '指定复核人',
@@ -403,6 +454,89 @@ await section('审核个人应用:取副本去发布、打开我的副本、
check('退回不取副本', !s3.writes.some((w) => w.path.endsWith('/copy')))
})
await section('口径召回:三个值和差值、原答案当时的值、两个动作', async () => {
const state = { writes: [] }
const page = await open(state)
const asked = []
page.on('request', (r) => { if (r.url().includes('/api/')) asked.push(new URL(r.url()).pathname) })
await page.goto(`${WEB}/apps/inbox/recall`)
const box = page.locator('[data-task-recall="caliber"]')
await box.waitFor({ timeout: 15000 })
check('写明口径从 v1 升到 v2、同一份数据上两版各算一次', (await box.innerText()).includes('口径「周销售」从 v1 升到了 v2')
&& (await box.innerText()).includes('同一份数据'), (await box.innerText()).slice(0, 80))
check('这一组的参数', (await box.locator('[data-recall-binding-field="start"]').innerText()) === 'start=2026-09-01')
const row = box.locator('[data-recall-metric="gmv"]')
check('旧口径、新口径、两版之差一行,标「变了」', await row.getAttribute('data-changed') === 'true'
&& (await row.locator('[data-recall-cell="old"]').innerText()) === '170.50元'
&& (await row.locator('[data-recall-cell="new"]').innerText()) === '208.50元'
&& (await row.locator('[data-recall-cell="diff"]').innerText()) === '38.00元', (await row.innerText()).replace(/\s+/g, ' '))
const head = await box.locator('[data-recall-metrics] thead').innerText()
check('表头写旧口径 v1、新口径 v2、两版之差', head.includes('旧口径 v1') && head.includes('新口径 v2') && head.includes('两版之差'), head)
check('两个答案各一行,写原答案当时的值', await box.locator('[data-recall-answer]').count() === 2
&& (await box.locator('[data-recall-answer="run_ans_1"] [data-recall-original="0"]').innerText()) === '170.50元'
&& (await box.locator('[data-recall-answer="run_fm_1"] [data-recall-original="0"]').innerText()) === '165.00元')
check('问数回答链回那段对话', (await box.locator('[data-recall-answer="run_ans_1"] [data-recall-answer-link="chat"]')
.getAttribute('href')) === '/chat/conv_1')
check('正式运行(搭建者)链到记录页', (await box.locator('[data-recall-answer="run_fm_1"] [data-recall-answer-link="run"]')
.getAttribute('href')) === '/runs/run_fm_1')
const wait = (part) => page.waitForRequest((r) => r.url().includes(part), { timeout: 5000 }).then(() => true, () => false)
let hit = wait('/api/runs/rc_1/evidence/metrics/recall/diff_0')
await row.locator('[data-recall-cell="diff"]').click()
check('点差值:取召回卡上这个指标的出处链', await hit, asked.slice(-3).join(' , '))
await page.keyboard.press('Escape')
hit = wait('/api/runs/run_fm_1/evidence/metrics/card/gmv')
await box.locator('[data-recall-answer="run_fm_1"] [data-recall-original="0"]').click()
check('点定时任务那次当时的值:取那次正式运行口径卡的指标链', await hit, asked.slice(-3).join(' , '))
await page.keyboard.press('Escape')
hit = wait('snap_1')
await box.locator('[data-recall-answer="run_ans_1"] [data-recall-original="0"]').click()
check('点问数回答当时的值:打开那条查询快照', await hit, asked.slice(-3).join(' , '))
await page.keyboard.press('Escape')
await page.locator('[data-recall-reissue]').click()
await page.waitForTimeout(300)
const sent = state.writes.find((w) => w.path === '/api/tasks/recall/respond')
check('「按新版重新出具」走待办接口,decision 是 reissue', sent?.body?.decision === 'reissue', JSON.stringify(sent?.body))
check('……提示已按新版发起正式出具', await page.getByText('已按新版发起正式出具').first().waitFor({ timeout: 3000 }).then(() => true, () => false))
check('不给审批那一套按钮', await page.locator('[data-task-approve], [data-task-reject]').count() === 0)
check('没有未捕获的运行时错误', page.errors.length === 0, page.errors[0] ?? '')
const s2 = { writes: [] }
const p2 = await open(s2)
await p2.goto(`${WEB}/apps/inbox/recall`)
await p2.locator('[data-recall-ack]').waitFor({ timeout: 15000 })
await p2.locator('[data-recall-ack]').click()
await p2.waitForTimeout(300)
check('「知道了」decision 是 ack', s2.writes.find((w) => w.path === '/api/tasks/recall/respond')?.body?.decision === 'ack',
JSON.stringify(s2.writes))
})
await section('口径召回:使用者看到的遮罩值、不能重新出具的原因;目录有变那一种', async () => {
const state = { writes: [], me: { mode: 'local', username: 'zhangsan', display_name: '张三', role: 'user', groups: [], verified: true } }
const page = await open(state)
await page.goto(`${WEB}/apps/inbox/recallUser`)
const box = page.locator('[data-task-recall="caliber"]')
await box.waitFor({ timeout: 15000 })
const row = box.locator('[data-recall-metric="spend"]')
check('遮罩值写「已遮罩」、点不开', (await row.locator('[data-recall-cell="old"]').innerText()) === '已遮罩'
&& await row.locator('[data-recall-cell="old"]').isDisabled() && (await row.locator('[data-recall-cell="new"]').innerText()) === '90元')
check('参数里的遮罩值同样遮住', (await box.locator('[data-recall-binding-field="phone"]').innerText()) === 'phone=已遮罩')
check('原答案里没有单独这个数:写「—」不给链接', (await box.locator('[data-recall-answer="run_ans_2"]').innerText()).includes('—')
&& await box.locator('[data-recall-answer="run_ans_2"] [data-recall-original]').count() === 0)
check('不能重新出具:按钮停用,写服务端给的原因', await page.locator('[data-recall-reissue]').isDisabled()
&& (await page.locator('[data-recall-reissue-reason]').innerText()).includes('请搭建者出具'))
check('使用者不给记录页的链接', await box.locator('[data-recall-answer-link="run"]').count() === 0)
const p2 = await open({ writes: [] })
await p2.goto(`${WEB}/apps/inbox/recallCatalog`)
const basis = p2.locator('[data-recall-basis="catalog"]')
await basis.waitFor({ timeout: 15000 })
const text = await basis.innerText()
check('目录有变:写变了的目录项和新出现的问题', text.includes('列 amount 的度量类型(改了)') && text.includes('新出现的错误级问题 1 条')
&& text.includes('分组里没有业务日期'), text.replace(/\s+/g, ' '))
check('……只有「知道了」', await p2.locator('[data-recall-ack]').count() === 1 && await p2.locator('[data-recall-reissue]').count() === 0)
check('没有未捕获的运行时错误', page.errors.length === 0 && p2.errors.length === 0, page.errors[0] ?? p2.errors[0] ?? '')
})
await section('待办箱:列表和徽标', async () => {
const page = await open({ writes: [] })
await page.goto(`${WEB}/apps?tab=inbox`)
@@ -410,6 +544,8 @@ await section('待办箱:列表和徽标', async () => {
check('每条待办一行,链到详情', (await page.locator('[data-inbox-task]').count()) === Object.keys(TASKS).length)
check('审核个人应用的一行写种类「审核个人应用」', (await page.locator('[data-inbox-task="review"]').innerText()).includes('审核个人应用')
&& (await page.locator('[data-inbox-task="review"]').getAttribute('data-task-kind')) === 'review')
check('口径召回的一行写种类「口径召回」', (await page.locator('[data-inbox-task="recall"]').innerText()).includes('口径召回')
&& (await page.locator('[data-inbox-task="recall"]').getAttribute('data-task-kind')) === 'recall')
check('「应用」导航上的徽标数应用里的待办', (await page.locator('[data-apps-badge]').innerText()).trim() === String(Object.keys(TASKS).length))
check('页签上带数', /\d/.test(await page.getByRole('tab', { name: /待办/ }).innerText()))
})
+145
View File
@@ -2075,6 +2075,151 @@ await section('应用平台:发布成功做成应用;已发布版本的使
}
})
// 口径召回(next-round 02 做法 7、8):发布弹窗按这一版预告召回的规模(旧版本被谁用过、预计自动重算几组、超出上限几组、
// 不能重算的原因),版本用量加问数回答、导出、召回;版本历史里看口径升到这一版之后的召回批次(每组的结论),「另有 M 组未
// 重算」能手动接着算。预告、批次、接着算全在浏览器层伪造,写请求拦下核对
const PREVIEW = { workflow_id: 'pf-hard', version: 3, limit: 50, caliber: true, problem: null, groups: 60, recomputable: 58,
not_recomputable: 2, already: 0, will_recompute: 50, over_limit: 8, truncated: false,
versions: [{ version: 2, answers: 3, exports: 1, schedules: 1, apps: 2, formal: 4, pinned: 0, truncated: false }],
reasons: [{ reason: '新版 v3 的入口要的参数这一组里没有或不合规:「区域」必填', groups: 2 }] }
const BATCHES = { workflow_id: 'pf-lib', workflow_name: '__publish_check_lib__', version: 4, limit: 50, batch_size: 50,
problem: null, caliber: true, truncated: false, remaining: 1, can_continue: true,
counts: { changed: 1, unchanged: 1, failed: 1, running: 0, pending: 1, not_recomputable: 1 },
groups: [
{ id: '3-a', from_version: 3, to_version: 4, binding: [{ field: 'week', value: '2026-W38' }],
uses: [{ kind: 'answer', kind_text: '问数回答', count: 2 }], latest: '2026-10-01T02:00:00Z', state: 'changed',
run_id: 'rc-a', batch: 'auto', tasks: 2, changed_metrics: ['销售额'] },
{ id: '3-b', from_version: 3, to_version: 4, binding: [{ field: 'week', value: '2026-W37' }],
uses: [{ kind: 'schedule', kind_text: '定时任务', count: 1 }], latest: '2026-09-24T02:00:00Z', state: 'unchanged',
run_id: 'rc-b', batch: 'auto', tasks: 0, changed_metrics: [] },
{ id: '3-c', from_version: 3, to_version: 4, binding: [], uses: [{ kind: 'formal', kind_text: '正式运行', count: 1 }],
latest: '2026-09-20T02:00:00Z', state: 'failed', reason: '重算失败:数据源「shop」已停用', run_id: 'rc-c', batch: 'auto' },
{ id: '2-d', from_version: 2, to_version: 4, binding: [{ field: 'week', value: '2026-W30' }],
uses: [{ kind: 'answer', kind_text: '问数回答', count: 1 }], latest: '2026-08-01T02:00:00Z', state: 'not_recomputable',
reason: '新版 v4 的入口要的参数这一组里没有或不合规:「区域」必填' },
{ id: '3-e', from_version: 3, to_version: 4, binding: [{ field: 'week', value: '2026-W20' }],
uses: [{ kind: 'answer', kind_text: '问数回答', count: 1 }], latest: '2026-07-01T02:00:00Z', state: 'pending' },
] }
await section('口径召回:发布弹窗预告召回规模、版本用量加问数回答和召回', async () => {
const usage = { apps: [], effects: 0, formal_runs: 4, answers: 5, exports: 2, schedules: 1,
recall: { groups: 1, changed: 1, recalled_from: 0 } }
for (const variant of ['over', 'zero', 'none', 'not-caliber']) {
const { page, errors } = await open({ id: 'pf-hard' })
const asked = []
const body = variant === 'over' ? PREVIEW : variant === 'zero' ? { ...PREVIEW, limit: 0, will_recompute: 0, over_limit: 58 }
: variant === 'none' ? { ...PREVIEW, groups: 0, recomputable: 0, not_recomputable: 0, will_recompute: 0, over_limit: 0,
versions: [], reasons: [] }
: { ...PREVIEW, caliber: false, groups: 0, recomputable: 0, not_recomputable: 0, will_recompute: 0, over_limit: 0,
versions: [], reasons: [] }
await page.route(/\/api\/workflows\/pf-hard\/recall-preview(\?.*)?$/, (route) => {
asked.push(new URL(route.request().url()).search)
return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(body) })
})
await page.route(/\/api\/ledger\/workflow-versions\/.+$/, (route) =>
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(usage) }))
await openDialog(page)
const row = dialog(page).locator('[data-publish-recall]')
if (variant === 'not-caliber') {
await waitFor(page, async () => asked.length > 0)
await page.waitForTimeout(300)
check('旧版本里没有口径、也没有用过的答案:不画召回那一行', await row.count() === 0)
continue
}
check(`预告(${variant}):按要发布的这一版问(version=3)`, await waitFor(page, async () => asked.length > 0)
&& asked[0].includes('version=3'), asked.join(','))
await waitFor(page, async () => (await row.getAttribute('data-publish-recall').catch(() => '')) !== 'loading')
const text = await row.innerText().catch(() => '')
if (variant === 'over') {
check('写旧版本被谁用过', text.includes('旧版本被 3 次问数回答、1 次导出、1 个定时任务、2 个应用、4 次正式运行用过'), text)
check('写去重后几组、发布后自动重算几组', text.includes('按参数去重共 60 组,发布后自动重算 50 组')
&& await row.locator('[data-publish-recall-will="50"]').count() === 1, text)
check('超出上限的写明可以手动接着算', (await row.locator('[data-publish-recall-over="8"]').innerText())
.includes('另有 8 组超出每次 50 组的上限'))
check('不能重算的写几组和原因', (await row.locator('[data-publish-recall-unrecomputable="2"]').innerText())
.includes('「区域」必填'))
check('写明重算只运行口径的数据部分、不调用模型', text.includes('不调用模型'), text)
const line = await dialog(page).locator('[data-publish-usage] [data-version-usage-ledger]').innerText().catch(() => '')
check('使用情况加上问数回答、导出、召回', line.includes('问数回答 5 次') && line.includes('导出 2 次')
&& line.includes('召回 1 组(数变了 1 组)'), line)
await shoot(page, 'publish-recall-preview', dialog(page))
} else if (variant === 'zero') {
check('上限是 0:写明发布后不自动重算、只列出受影响的答案', await row.locator('[data-publish-recall-zero]').count() === 1
&& await row.locator('[data-publish-recall-over]').count() === 0, text)
} else {
check('是口径但旧版本没被用过:写不需要召回', await row.getAttribute('data-publish-recall') === 'none'
&& text.includes('不需要召回'), text)
}
check(`没有运行时报错(${variant})`, errors.length === 0, errors.join(' | '))
}
})
await section('口径召回:版本历史看召回批次、另有 M 组未重算、接着算', async () => {
const { page, errors } = await open({ id: 'pf-lib' })
const versions = [4, 3, 2].map((n) => ({ id: `v${n}`, version: n, note: '', created_at: '2026-09-26T02:00:00Z',
published: n === 4, level: 'published', retired_at: null, retired_by: null }))
await page.route(/\/api\/workflows\/pf-lib\/versions(\/\d+)?$/, (route) => {
const v = Number(new URL(route.request().url()).pathname.split('/')[5])
const body = v ? { ...versions.find((x) => x.version === v), workflow_id: 'pf-lib', graph: FAKES['pf-lib'].graph, graph_hash: 'x' } : versions
return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(body) })
})
await page.route(/\/api\/ledger\/workflow-versions\/.+$/, (route) => route.fulfill({ status: 200, contentType: 'application/json',
body: JSON.stringify({ apps: [], effects: 0, formal_runs: 3, answers: 4, exports: 0, schedules: 1,
recall: { groups: 4, changed: 1, recalled_from: 0 } }) }))
const continued = []
await page.route(/\/api\/ledger\/recall\/pf-lib\/(\d+)(\/continue)?$/, (route) => {
const req = route.request()
const v = Number(new URL(req.url()).pathname.split('/')[5])
if (v !== 4) return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ...BATCHES, version: v,
groups: [], remaining: 0, can_continue: false, counts: { changed: 0, unchanged: 0, failed: 0, running: 0, pending: 0,
not_recomputable: 0 } }) })
if (req.method() === 'POST') {
continued.push(new URL(req.url()).pathname)
const groups = BATCHES.groups.map((g) => (g.state === 'pending' ? { ...g, state: 'running', run_id: 'rc-e', batch: 'manual' } : g))
return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ...BATCHES, groups, remaining: 0,
can_continue: false, launched: ['rc-e'], counts: { ...BATCHES.counts, pending: 0, running: 1 } }) })
}
return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(BATCHES) })
})
await page.evaluate(() => document.activeElement?.blur?.())
await page.keyboard.press('Alt+KeyH')
const sheet = page.locator('[role="dialog"][aria-label="版本历史"]')
await sheet.waitFor()
await waitFor(page, async () => await sheet.locator('ol button', { hasText: 'v4' }).count() > 0)
await sheet.locator('ol button', { hasText: 'v4' }).first().click()
const box = sheet.locator('[data-version-recall="5"]')
check('展开 v4:列出口径升到这一版之后的召回批次', await waitFor(page, async () => await box.count() === 1))
const summary = await box.locator('[data-version-recall-summary]').innerText().catch(() => '')
check('……一句总的:数变了、没变、重算失败、无法重算各几组', summary === '数变了 1 组,没变 1 组,重算失败 1 组,无法重算 1 组', summary)
const state = async (id) => (await box.locator(`[data-version-recall-group="${id}"] .chip`).first().innerText().catch(() => ''))
check('每组写结论', await state('3-a') === '数变了' && await state('3-b') === '没变' && await state('3-c') === '重算失败'
&& await state('2-d') === '无法重算' && await state('3-e') === '未重算')
check('数变了的写变了的指标、开了几条待办,能看召回运行', (await box.locator('[data-version-recall-group="3-a"]').innerText())
.includes('变了的指标:销售额') && (await box.locator('[data-version-recall-group="3-a"]').innerText()).includes('开了 2 条待办')
&& (await box.locator('[data-version-recall-run="rc-a"]').getAttribute('href')) === '/runs/rc-a')
check('无法重算照实写原因', (await box.locator('[data-version-recall-group="2-d"] [data-version-recall-reason]').innerText())
=== '无法重算:新版 v4 的入口要的参数这一组里没有或不合规:「区域」必填')
check('重算失败写原因', (await box.locator('[data-version-recall-group="3-c"] [data-version-recall-reason]').innerText())
.includes('数据源「shop」已停用'))
const usageLine = await sheet.locator('[data-version-lifecycle="4"] [data-version-usage-ledger]').innerText().catch(() => '')
check('版本用量加上问数回答、召回', usageLine.includes('问数回答 4 次') && usageLine.includes('召回 4 组(数变了 1 组)'), usageLine)
check('另有 1 组未重算', (await box.locator('[data-version-recall-remaining="1"]').innerText()).includes('另有 1 组未重算'))
const go = box.locator('[data-version-recall-continue]')
check('给「接着算」,写每次几组', (await go.innerText()).includes('接着算(每次 50 组)'))
await shoot(page, 'versions-recall', sheet)
await go.click()
check('接着算:POST /api/ledger/recall/pf-lib/4/continue', await waitFor(page, async () => continued.length === 1)
&& continued[0] === '/api/ledger/recall/pf-lib/4/continue', continued.join(','))
check('……之后照服务端交回的批次画:没有未重算的、刚发起的那组正在重算', await waitFor(page, async () =>
await box.locator('[data-version-recall-remaining]').count() === 0 && await state('3-e') === '正在重算'))
check('……提示已发起几组', await page.getByText('已发起 1 组召回').first().waitFor({ timeout: 3000 }).then(() => true, () => false))
await sheet.locator('ol button', { hasText: 'v3' }).first().click()
await sheet.locator('[data-version-lifecycle="3"]').waitFor()
await page.waitForTimeout(300)
check('没有召回过的版本不画召回那一块', await sheet.locator('[data-version-lifecycle="3"] [data-version-recall]').count() === 0)
check('没有运行时报错', errors.length === 0, errors.join(' | '))
})
// 开了登录:发布记的是登录的人(服务端写 published_by,不看署名),不给署名框、不说「未署名」;受管级只给管理员,
// 搭建者那一档当场置灰、写明原因,不等点了发布才被拒(V1-21、V1-22)。受管工作流的新版本不论哪一档都只有管理员能发:
// 降成「已发布」会让此后的正式运行不再过治理门禁,和以受管级发布同一级(Q8,服务端同样拦)——搭建者两档都锁住