口径账本的轮次摘要只数四种标签(来自口径、相关口径、这次的推理、没比对):认不出种类的标签(不是对象、没有种类、不是这四种)不计、也不算进总数,摘要那一句说得平、不出 NaN。分析结论的数不和口径比对,服务端不给它们标签(00-总方案 D11),这里是防着以后多出别的种类。check-ledger 的使用者一节混进两个认不出种类的标签

This commit is contained in:
ThearchyHelios
2026-10-21 18:24:18 +08:00
parent 84e6c2e13f
commit ce5ef5e5f0
2 changed files with 16 additions and 4 deletions
+12 -3
View File
@@ -21,13 +21,22 @@ import { ReconcileDialog, ReconcileResults } from './LedgerReconcile'
* 能不能自动、不能的原因都是服务端给的;摘要只是把主报告里服务端标好的数按标签数一数、写出是哪份口径。
*/
/** 摘要的几个数:主报告里服务端标好的标签按种类数,来自口径的写出是哪几份口径(按出现的先后) */
/** 摘要认的四种标签。服务端不给别的标签(分析结论的数不和口径比对,00-总方案 D11),以后多了也不计、不出 NaN */
const COUNTED_KINDS = ['caliber', 'related', 'reasoning', 'unknown'] as const
type CountedKind = (typeof COUNTED_KINDS)[number]
const counted = (kind: unknown): kind is CountedKind => (COUNTED_KINDS as readonly unknown[]).includes(kind)
/**
* 摘要的几个数:主报告里服务端标好的标签按种类数,来自口径的写出是哪几份口径(按出现的先后)。认不出种类的标签(不是对象、
* 没有 kind、不是四种之一)不计,也不算进总数:总数要等于四种之和,摘要那一句才说得平
*/
function summaryOf(data: RunLedger) {
const labels = Object.values((data.primary ? data.reports?.[data.primary]?.labels : undefined) ?? {})
const counts = { caliber: 0, related: 0, reasoning: 0, unknown: 0 }
.filter((l) => !!l && typeof l === 'object' && counted(l.kind))
const counts: Record<CountedKind, number> = { caliber: 0, related: 0, reasoning: 0, unknown: 0 }
const calibers: string[] = []
for (const l of labels) {
counts[l.kind] += 1
counts[l.kind as CountedKind] += 1
if (l.kind === 'caliber') {
const name = caliberOf(l)
if (!calibers.includes(name)) calibers.push(name)
+4 -1
View File
@@ -458,7 +458,9 @@ await section('使用者看到的入口照服务端的动作:不能出具的
meta: { v: 1, runId: RUN_U, runClass: 'exploratory', runStatus: 'succeeded', evidence: true } }
const refused = { ...ISSUE, available: false, auto: false, reason: '这份口径没有被你能使用的应用固定,不能由你按口径出具,请搭建者出具' }
delete refused.auto_reason
const LED = ledgerOf(RUN_U, { labels: WHOLE_LABELS, whole: WHOLE, actions: [refused, RECONCILE],
// 摘要只认四种标签(分析结论的数不和口径比对,服务端不给它们标签):混进来认不出的种类,不计、不出 NaN
const LED = ledgerOf(RUN_U, { labels: { ...WHOLE_LABELS, s40: { kind: 'analysis' }, s42: { reason: '没有种类' } },
whole: WHOLE, actions: [refused, RECONCILE],
// 出具过的是另一份口径(订单口径):周报口径这一项还没出具过,照服务端的原因写为什么不能出具
issued: [{ run_id: 'run-iss-u', status: 'succeeded', workflow_id: 'wf-orders', version: 1, tier: 'degraded', tier_text: '降档出具', auto: true }] })
const reply = (method, p) => {
@@ -478,6 +480,7 @@ await section('使用者看到的入口照服务端的动作:不能出具的
const shown = await box.waitFor({ timeout: 12000 }).then(() => true, () => false)
const text = shown ? (await box.innerText()).replace(/\s+/g, ' ') : ''
check('使用者也看到摘要', text.includes('3 个数来自口径「周报口径」v2(受管)'), text)
check('……认不出种类的标签不计、不出 NaN', !text.includes('NaN') && !text.includes('undefined'), text)
check('不能出具:照服务端的原因写「请搭建者出具」,不摆出具按钮', text.includes('请搭建者出具')
&& await page.locator('[data-ledger-issue-button]').count() === 0, text)
check('能对账:照样摆对账按钮', await page.locator('[data-ledger-turn-reconcile]').count() === 1)