转抄口径卡指标的出处跨卡往下追,对账、召回运行按追到底的结果判档

对账卡的「口径」、召回卡的「旧版 / 新版」写成 nodes.<口径卡>.metrics[i].value,出处停在「来自口径卡指标」,对账运行、
召回运行一律降档出具(「输入没追到原始数据」);口径卡自己的指标明明追得到取数查询。

- engine/lineage:metric_copy 认出转抄一个指标的值的写法;traced() 对 via=metric 的输入看 upstream.traced;
  MAX_COPY_DEPTH = 8。
- engine/nodes/metrics:转抄的输入记 upstream {metric, artifact, depth, traced}——那张卡的指标集落了工件、那个指标的输入
  都追到了原始数据(它自己转抄的已经一层层追过,记在它的输入上)、层数没超上限才算追到;超了就算没追到(防环:循环里
  抄自己上一轮的卡每一轮多一层)。那个指标不完整、所依据的查询没通过 SQL 检查的,转抄出来的同样不完整、存疑,出具照样
  降档:信任按追到底的结果给,不多给。
- api/evidence:转抄的输入后面接一步 upstream(那张卡的那个指标:值、原式、代入式、它的输入、追没追到,取值按同一套遮罩),
  转抄的转抄接着追(同一个指标只接一次、最多 8 层),它的输入落在查询快照上的照常给查询步骤;出处链里遮着的列把这几步
  的输入也算上。reconcile.py、recall.py 生成的式子不用改。
- 前端证据面板:新的一节「转抄的口径卡指标」,输入来源里转抄的那一项写清追没追到、点一下跳到那一步,那一步的输入点一下
  跳到口径的取数查询(文案进 lib/terms.ts)。check-ledger 加一段:对账结果里点「按口径」的数,一路点到口径的取数查询。

测试:tests/test_metric_copy_lineage.py(转抄、转抄的转抄完整出具;转抄没追到的照样停在那张卡;上游不完整的转抄也不完整;
层数上限;真跑对账、召回都完整出具,出处链接上口径卡那一步、给出口径的取数查询)。去掉 upstream 再跑,5 条失败。
This commit is contained in:
ThearchyHelios
2026-10-17 12:05:12 +08:00
parent 12439b5305
commit c3123e3818
10 changed files with 597 additions and 26 deletions
+49 -1
View File
@@ -8,6 +8,8 @@
// - 口径对账:核对参数(推断的参数要先核对)→ 发起(认不出列怎么配时照 409 带回的选项选对照的指标,再发起)→ 结果卡片:
// 这次 / 口径 / 差值 / 相对差四个数各自取值、点开是出处链;请求体逐项核对;做完的卡片上问「差在哪」的说明有没有帮助
// (说明有用 / 看不懂,统计 E2):请求体只有 verdict,选过的按下、写各几个人,能改主意;没做完的不问;
// - 「按口径」那个数转抄口径卡的指标:出处链跨卡接上口径卡那个指标的一步,输入来源里点一下跳到那一步,那一步的输入
// 点一下跳到口径的取数查询;
// - 可沉淀的问题:工作流列表弹窗里的抽屉,三类来源分开写;「固化成口径草稿」走 from-run 的 freeze(带同组的别的运行)、
// 打开画布;聚类按人挑的那一轮固化;「不是口径」要写理由;
// - 使用者看到的入口照服务端的动作:不能出具的写原因(请搭建者出具)、不摆出具按钮,能对账的照样对账;出具过的正式运行
@@ -22,7 +24,7 @@
import { readFileSync } from 'node:fs'
import { chromium } from '../frontend/node_modules/playwright-core/index.mjs'
import {
ISSUE, QUEUE, RECONCILE, RECONCILE_VALUES, WHOLE, WHOLE_LABELS, ledgerOf, metricDetail, reconciledOf,
ISSUE, QUEUE, RECONCILE, RECONCILE_VALUES, WHOLE, WHOLE_LABELS, copiedMetricDetail, ledgerOf, metricDetail, reconciledOf,
} from './ledger-fixtures.mjs'
const WEB = process.env.AGENTLAB_WEB ?? 'http://localhost:5273'
@@ -278,6 +280,52 @@ await section('口径对账:核对参数 → 发起 → 选对照的指标 →
check('没有运行时报错', errors.length === 0, errors.join(' | '))
})
// ---------------------------------------------------------------- 「按口径」那个数的出处跨卡追到取数查询
await section('对账结果里「按口径」那个数:出处跨卡追到口径的取数查询', async () => {
const extra = (method, p) => {
const m = p.match(/^\/runs\/run-rec-1\/evidence\/metrics\/reconcile\/([^/]+)$/)
if (method === 'GET' && m) {
return { json: m[1] === 'cal_0' ? copiedMetricDetail('run-rec-1', m[1]) : metricDetail('run-rec-1', m[1]) }
}
return null
}
const { page, errors } = await open('/ui-harness.html?evidence=1', {
reply: evidenceReply(() => ledgerOf(RUN, { reconciled: [reconciledOf('succeeded')] }), extra) })
await page.waitForSelector('#evidence-wide [data-seg="s8"]', { timeout: 10000 })
await openSeg(page, 's8')
const card = page.locator('[data-evidence-panel] [data-ledger-reconciled="run-rec-1"]')
await card.waitFor({ timeout: 6000 })
await until(async () => (await card.innerText()).includes(RECONCILE_VALUES.cal_0), 5000)
await card.locator('[data-ledger-value="cal_0"]').click()
const drawer = page.locator('[data-evidence-panel="side"]').last()
const up = drawer.locator('[data-ev-upstream="card"]')
const shown = await up.waitFor({ timeout: 5000 }).then(() => true, () => false)
const upText = shown ? (await up.innerText()).replace(/\s+/g, ' ') : ''
check('点「按口径」:出处链接上口径卡的那个指标(转抄的口径卡指标)', shown && upText.includes('转抄的口径卡指标')
&& upText.includes('取自口径卡「口径卡」的指标「订单数」') && upText.includes('1,180单'), upText)
check('……写那个指标的原式、它的输入追到了原始数据', upText.includes("cell(nodes.fetch, 0, 'orders')")
&& await up.locator('[data-ev-upstream-origin="traced"]').count() === 1, upText)
check('指标这一步:输入都追到了原始数据,不挂「未追到原始数据」', await drawer.locator('[data-ev-untraced-chip]').count() === 0
&& await drawer.locator('[data-ev-metric] [data-ev-origin="traced"]').count() === 1)
const src = drawer.locator('[data-ev-source="nodes.card.metrics[0].value"]')
const srcText = await src.innerText().catch(() => '')
check('输入来源:转抄的那一项说清取自另一张口径卡、那个指标的输入都追到了原始数据',
srcText.includes('取自另一张口径卡的指标,那个指标的输入都追到了原始数据')
&& srcText.includes('查看口径卡「口径卡」的这个指标'), srcText)
await src.locator('[data-ev-goto]').click()
const focused = await until(() => page.evaluate(() => document.activeElement?.hasAttribute('data-ev-upstream-head') === true), 3000)
check('点「查看口径卡「口径卡」的这个指标」:焦点落到那一步、描一下边', focused
&& await up.getAttribute('data-flash') === 'focus')
await up.locator(`[data-ev-input="cell(nodes.fetch, 0, 'orders')"]`).click()
const query = drawer.locator('[data-ev-query="q-cal-fetch"]')
const jumped = await until(async () => await query.getAttribute('data-flash') === 'focus', 3000)
check('那个指标的输入点一下:跳到口径的取数查询(SQL、被引用的那一格都在)', jumped
&& (await query.innerText()).includes('SELECT COUNT(*) AS orders FROM orders')
&& await query.locator('td[data-highlight="cell"]').count() === 1)
check('没有运行时报错', errors.length === 0, errors.join(' | '))
})
// ---------------------------------------------------------------- 可沉淀的问题
const WF = { id: 'wf-led-check', name: '检查用工作流', description: '', version: 1, status: 'draft', tags: [], is_template: false,
+25
View File
@@ -112,6 +112,31 @@ export const metricDetail = (runId, metric) => ({
seal: { sealed: true, ok: true, covered: true }, redacted: { columns: [] },
})
/**
* 对账卡上「按口径」那个数的出处(服务端 api/evidence._upstream_steps 的形状):它转抄口径卡的指标
* (nodes.card.metrics[0].value),出处跨卡接上口径卡「订单数」那一步,再到口径的取数查询(q-cal-fetch)
*/
export const copiedMetricDetail = (runId, metric) => ({
run_id: runId, node: 'reconcile', metric, rendered: RECONCILE_VALUES[metric] ?? '—', eid: `ev:metric:${metric}`,
chain: [
{ step: 'metric', alias: 'm', metric, name: '订单数 · 口径', value: 1180, rendered: RECONCILE_VALUES[metric], node_id: 'reconcile',
caliber: '口径对账', version: 'v1', expression: 'nodes.card.metrics[0].value', substituted: '1180', recompute_ok: true,
sealed: true, hash_ok: true, untraced: [],
inputs: [{ path: 'nodes.card.metrics[0].value', value: 1180, node_id: 'card', via: 'metric', field: 'metrics[0].value',
status: 'ok', upstream: { metric: 'orders', artifact: 'ms-card', depth: 1, traced: true } }] },
{ step: 'upstream', of: 'nodes.card.metrics[0].value', node_id: 'card', label: '口径卡', artifact: 'ms-card', metric: 'orders',
traced: true, depth: 1, hash_ok: true, sealed: true, name: '订单数', value: 1180, unit: '单', rendered: '1,180单',
caliber: '订单口径', version: 'v1', expression: "cell(nodes.fetch, 0, 'orders')", substituted: '1180', recompute_ok: true,
status: 'ok', untraced: [],
inputs: [{ step: 'input', path: "cell(nodes.fetch, 0, 'orders')", value: 1180, node_id: 'fetch', via: 'tool_cell',
status: 'verified', artifact: 'q-cal-fetch', locator: { row: 0, column: 'orders' }, eid: 'ev:cell:q-cal-fetch' }] },
{ step: 'query', alias: null, artifact: 'q-cal-fetch', node_id: 'fetch', tool: 'db_query__shop', source: 'shop',
sql: "SELECT COUNT(*) AS orders FROM orders WHERE status = 'paid'", columns: ['orders'], rows: [[1180]], row_offset: 0,
row_index: [0], total_rows: 1, highlight: { rows: [0], cols: ['orders'], cells: [[0, 'orders']] }, sealed: true, hash_ok: true },
],
seal: { sealed: true, ok: true, covered: true }, redacted: { columns: [] },
})
/** 认证队列:三类来源各一项 */
export const QUEUE = {
items: [