数据目录阶段 0 前端:证据面板给不完整的指标标「结果不完整」并写明原因,截断切开的 Agent 字段标「已截断」,运行时间线说清指标不完整的原因和下一步

This commit is contained in:
ThearchyHelios
2026-10-03 09:36:40 +08:00
parent b0c36b5880
commit a007270536
7 changed files with 94 additions and 4 deletions
+4
View File
@@ -398,6 +398,10 @@ export type SourceTone = 'ok' | 'warn' | 'alert' | 'muted'
export function inputSource(input: EvidenceInput): { tone: SourceTone; text: string; reason?: string } {
const status = input.status ?? ''
if (input.via === 'agent_field') {
// 被截断切开的数组字段:取回的每一格都对得上,但字段只含取回的那部分行
if (status === 'verified' && input.truncated === true) {
return { tone: 'warn', text: `${EVIDENCE_TEXT.sourceVerified};${EVIDENCE_TEXT.inputTruncated}` }
}
if (status === 'verified') return { tone: 'ok', text: EVIDENCE_TEXT.sourceVerified }
if (status === 'mismatch') {
return { tone: 'warn', text: EVIDENCE_TEXT.sourceMismatch(evidenceValue(input.model_value), evidenceValue(input.value)) }
+5
View File
@@ -237,6 +237,11 @@ export const EVIDENCE_TEXT = {
unmatchedPlain: '无法追溯的数字:',
uncited: '该数字未使用引用标记,系统无法核对其来源',
missingValue: '缺少输入:口径卡本次未计算出该指标的值',
/** 指标拿截断的查询结果整组算出来(计数、求和……):值只算到了取回的那部分,出具按缺口降档 */
incomplete: '结果不完整',
incompleteFallback: '基于被截断的查询结果计算,结果不完整',
/** 输入是 Agent 交来、被截断切开的数组字段 */
inputTruncated: '查询结果已截断,该字段只含取回的部分行',
unshowable: (value: string) => `有值(${value}),但无法按口径卡的格式显示`,
chainPending: '正在加载算式和输入…',
/** 证据接口逐项复核出来的问题。正常时不说,出问题才醒目 */
+20 -4
View File
@@ -1106,12 +1106,21 @@ function MetricPart({ step, entry, inputs, runId, seal, pending, failed, resolve
const dash = rendered === NONE || entry?.rendered === NONE
const missing = entry?.status === 'missing_input' || (value == null && (dash || !resolved))
const unshowable = !missing && dash && value != null
// 拿截断的查询结果整组算出来的:值是真的算出来的,但只算到了取回的那部分,出具已按缺口降档
const incomplete = step?.incomplete === true || entry?.incomplete === true
const incompleteReason = step?.incomplete_reason || entry?.incomplete_reason || EVIDENCE_TEXT.incompleteFallback
return (
<Part title={EVIDENCE_TEXT.metric} data-ev-metric="">
<div className="flex flex-wrap items-baseline gap-x-2">
<span className="font-medium">{name}</span>
{resolved && rendered && <span className="mono tnum text-sm" data-ev-value="">{rendered}</span>}
{incomplete && (
<span className="chip" data-ev-incomplete="" title={incompleteReason}
style={{ color: 'var(--st-waiting)', borderColor: 'var(--st-waiting)' }}>
{EVIDENCE_TEXT.incomplete}
</span>
)}
</div>
{(caliber || version || artifact || from) && (
<div className="mt-0.5 flex flex-wrap items-center gap-x-2 text-2xs text-dim">
@@ -1127,6 +1136,9 @@ function MetricPart({ step, entry, inputs, runId, seal, pending, failed, resolve
)}
<Integrity step={step} seal={seal} />
{missing && <p className="mt-1" style={{ color: 'var(--st-waiting)' }} data-ev-missing="">{EVIDENCE_TEXT.missingValue}</p>}
{incomplete && (
<p className="mt-1" style={{ color: 'var(--st-waiting)' }} data-ev-incomplete-reason="">{incompleteReason}</p>
)}
{unshowable && (
<p className="mt-1" style={{ color: 'var(--st-waiting)' }} data-ev-unshowable="">
{EVIDENCE_TEXT.unshowable(valueText(value))}
@@ -1201,12 +1213,16 @@ function IntegrityList({ code, items }: { code: string; items: string[] }) {
function InputChip({ input, link }: { input: EvidenceInput; link?: InputLink }) {
const host = useEvidenceHost()
const missing = input.status === 'missing' || input.value == null
// Agent 交来、被截断切开的数组字段:对它计数、求和只算到了取回的那部分
const cut = !missing && input.truncated === true
const node = input.node_id ? host.nodeLabel?.(input.node_id) || input.node_id : ''
const via = input.via ? VIA_TEXT[input.via] ?? nodeTypeLabel(input.via) : ''
const from = [node && `来自节点「${node}」`, via && `(${via})`, input.role && ` · ${ROLE_TEXT[input.role] ?? input.role}`]
.filter(Boolean).join('')
const style = missing ? { color: 'var(--st-waiting)', borderColor: 'var(--st-waiting)' } : { color: 'var(--text)' }
const body = <span className="truncate">{valueText(input.value)} ← {input.path ?? NONE}{missing ? '(缺失)' : ''}</span>
const from = [node && `来自节点「${node}」`, via && `(${via})`, input.role && ` · ${ROLE_TEXT[input.role] ?? input.role}`,
cut && ` · ${EVIDENCE_TEXT.inputTruncated}`].filter(Boolean).join('')
const style = missing || cut ? { color: 'var(--st-waiting)', borderColor: 'var(--st-waiting)' } : { color: 'var(--text)' }
const body = (
<span className="truncate">{valueText(input.value)} ← {input.path ?? NONE}{missing ? '(缺失)' : cut ? '(已截断)' : ''}</span>
)
return (
<li className="max-w-full">
{link ? (
+11
View File
@@ -745,6 +745,17 @@ function explainLog(code: string | undefined, message: string): Pick<Step, 'titl
next: '模型给出的出处在查询结果中不存在。请让模型先查询到这些字段再提交,查询不到的字段记为空值',
}
}
case 'metric_incomplete': {
// 「指标「入园人次」基于被截断的查询结果计算(只取回了前 1000 行),结果不完整」(metrics.py _incomplete_reason)
const name = message.match(/^指标「(.+?)」/)?.[1]
return {
title: name ? `指标「${name}」结果不完整` : '指标结果不完整',
sub: message.match(/^指标「.+?」(.+?),结果不完整$/)?.[1],
next: '口径卡对截断的查询结果计数、求和,只算到了取回的部分,出具按缺口降档。'
+ '请在 SQL 中直接聚合(如 COUNT、SUM)或缩小查询范围后重新运行',
fix: 'canvas',
}
}
case 'judge_limit': {
// 「结论句裁判已到上限(这份报告的裁判金额上限 $0.05):3 句没判,记为未裁判;已判的保留」(judge.py run_request)
const n = message.match(/[::]\s*(\d+)\s*句(?:没判|未裁判)/)?.[1]
+6
View File
@@ -2036,6 +2036,8 @@ export interface EvidenceInput {
query?: string | null
/** 输入落在哪一格,全局编号(Q3.r5.amount) */
cell?: string
/** agent 的数组字段:引用的行段到了截断查询结果的末行,后面还有没取回的行(query 步骤上是快照本身截断了) */
truncated?: boolean | null
}
/** 口径卡钉在另一个已发布工作流某个版本里的口径卡上 */
@@ -2091,6 +2093,10 @@ export interface EvidenceStep extends Omit<EvidenceInput, 'status'> {
substituted?: string
recompute_ok?: boolean | null
status?: string
/** metric:表达式把截断的查询结果当成整组用了(计数、求和……),值只算到了取回的那部分 */
incomplete?: boolean
/** metric:不完整的原因(人话,「基于被截断的查询结果计算(只取回了前 1000 行),结果不完整」) */
incomplete_reason?: string
inputs?: EvidenceInput[]
/** 口径卡钉在哪个工作流的哪一版(metric;方案第 5 节的写法,接口实际给在 source 上) */
caliber_from?: EvidenceCaliberSource | null
+22
View File
@@ -1316,6 +1316,28 @@ await section('agent 字段按出处核对(可点击证据第二期):抽
&& !odd.some((s) => /undefined|NaN/.test(`${s.title}${s.sub ?? ''}`)), odd.map((s) => s.title).join(' | '))
})
await section('口径卡指标不完整(数据目录阶段 0):截断的查询结果整组拿来算的指标,警告说人话并指到 SQL', async () => {
const E = (seq, type, node_id, data = {}) => ({ seq, type, node_id, ts: 1790000000 + seq, data })
// 原话和 backend/app/engine/nodes/metrics.py 的 _incomplete_reason 同一个句式。先核对后端源码还是这么说的
const INCOMPLETE = '指标「入园人次」基于被截断的查询结果计算(只取回了前 1000 行),结果不完整'
const metricsPy = readFileSync(`${root}backend/app/engine/nodes/metrics.py`, 'utf8')
check('后端发指标不完整警告的格式还是夹具里这一种', metricsPy.includes('code="metric_incomplete"')
&& metricsPy.includes('message=f"指标「{m[\'name\']}」{m[\'incomplete_reason\']}"')
&& metricsPy.includes('f"基于被截断的查询结果计算(只取回了{fetched[0]}),结果不完整"'),
'改了 metrics.py 的说法就同步改 decode.ts 的 explainLog 和这里的夹具')
const all = flatten(mod.decodeRun([
E(1, 'node.started', 'card', { node_type: 'metrics' }),
E(2, 'log', 'card', { level: 'warn', code: 'metric_incomplete', metric: 'visits', message: INCOMPLETE }),
E(3, 'node.finished', 'card', { duration_ms: 3 }),
]))
const inc = all.find((s) => s.code === 'metric_incomplete')
check('metric_incomplete 说人话:标题点名哪个指标不完整', inc?.title === '指标「入园人次」结果不完整', inc?.title)
check('……原因放副标题,原话留在展开区', inc?.sub === '基于被截断的查询结果计算(只取回了前 1000 行)' && inc?.detail === INCOMPLETE,
`${inc?.sub} / ${inc?.detail}`)
check('……是提醒(warn),下一步指到 SQL,节点本身照样成功', inc?.level === 'warn' && !!inc?.next?.includes('SQL')
&& all.find((s) => s.kind === 'node')?.status === 'done', `${inc?.level} ${inc?.next}`)
})
await section('结论句裁判(可点击证据第四期):裁判调用单独成行、几条警告说人话、封存后按需裁判有记录', async () => {
const E = (seq, type, node_id, data = {}) => ({ seq, type, node_id, ts: 1790000000 + seq, data })
// 原话和后端同一个格式:engine/judge.py 的 run_request、engine/nodes/report.py 的改写一次。先核对后端源码还是这么说的
+26
View File
@@ -1010,6 +1010,32 @@ await section('caliber', '口径卡来源和升版处置', async () => {
await none.ctx.close()
})
await section('incomplete', '截断的查询结果整组算出来的指标:标「结果不完整」并写明原因,完整的指标不标', async () => {
await openQ(page, '45,678.5元', { wait: '[data-ev-expression]' })
check('完整的指标不出不完整标识', await panel(page).locator('[data-ev-incomplete], [data-ev-incomplete-reason]').count() === 0)
check('……输入也不标「已截断」', !(await panel(page).locator('[data-ev-input]').allInnerTexts()).some((t) => t.includes('已截断')))
await page.keyboard.press('Escape')
// 接口的形状:backend/app/api/evidence.py 的指标步骤带 incomplete / incomplete_reason,输入带 Agent 字段证据里的 truncated
const REASON = '基于被截断的查询结果计算(只取回了前 1000 行),结果不完整'
const cut = await probeQ((id, body) => ({ ...body, chain: (body.chain ?? []).map((st) => (st.step === 'metric'
? { ...st, incomplete: true, incomplete_reason: REASON } : st.step === 'input' ? { ...st, truncated: true } : st)) }))
await openQ(cut.page, '45,678.5元', { wait: '[data-ev-incomplete]' })
const p = cut.page.locator('[data-evidence-panel]')
const chip = p.locator('[data-ev-incomplete]')
check('指标名旁有「结果不完整」标识,悬停看原因', (await chip.innerText().catch(() => '')) === '结果不完整'
&& await chip.getAttribute('title') === REASON, await chip.innerText().catch(() => ''))
const why = await p.locator('[data-ev-incomplete-reason]').innerText().catch(() => '')
check('原因写在指标下面', why === REASON, why)
const warn = await tokenColor(cut.page, 'color', 'var(--st-waiting)')
check('用提醒色(不是失败色:值是真算出来的,只是不全)', await chip.evaluate((el) => getComputedStyle(el).color) === warn)
const inputs = await p.locator('[data-ev-input]').allInnerTexts()
check('被截断切开的 Agent 字段输入标「已截断」', inputs.some((t) => t.includes('(已截断)')), inputs.join('|'))
const source = await p.locator('[data-ev-sources]').innerText().catch(() => '')
check('……输入来源写明与快照一致、但只含取回的部分行', source.includes('与快照一致;查询结果已截断,该字段只含取回的部分行'),
source.replace(/\s+/g, ' ').slice(0, 160))
await cut.ctx.close()
})
await section('q-narrow', '查询步骤在 360px:栏内展开、底部抽屉都不横向滚动;减少动效', async () => {
const overflow = () => page.evaluate((sel) => {
const el = document.querySelector(sel)