mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-20 03:41:58 +00:00
Excel 导入改造期 4:证据下钻——报告里引用上传表格的数,点开能看到它来自原表格的哪一格;裁判核对时看得到来源、口径、接受理由和区域外文字
推断的来源(新 engine/direct_select、data/provenance、data/provenance_db;api/evidence 新增推断来源接口) - 只对直接引用一列的查询下钻:受限文法用和执行时相同的 SQLite 分词读法,别名互换、自连接、表达式、聚合、子查询、集合运算(含藏在注释、字符串、方括号、转义、BOM 之后的)一律只给表级来历;再用 EXPLAIN 字节码和授权回调兜底 - 结果带齐主键、值非空,按主键参数化回查只读快照、类型和值严格一致才给格子;不一致时整份重算库哈希,哈希不符标红 - 从导入清单和溯源找回格子:宽表、交叉表逆透视的长表(日期取自表头格、年份取自统计期、行标签、分段标题)、列表、合计表、按期累积的并集(换算到所属那一期);原文与规范写法不同时一并列出 - 清单读不到、登记哈希与清单不一致、快照已回收、遮罩列,都只给表级来历或不给,写明原因;原件已清除、接受已作废照实显示;未封存的运行照常推断并标明 - 相关核对:这一行、这一期的核对结论与接受理由 裁判摘录(engine/judge) - 带期 4 标记的报告,上传表格的查询旁加来源行、口径行、接受理由、可见单元格里的区域外文字和人工录入的统计期;限定语写明这些数未经系统核对,长度有上限、截断时写明 - 隐藏行列里的区域外文字不送;设了遮罩的源只写条数 前端证据面板(run/EvidenceProvenance;ManifestBody 从版本页抽出复用) - 「推断的来源」一节与已封存的证据分开标注:格子坐标、取自哪些格、年份来源、规范写法、回查、相关核对、数据版本与各期;标红与拒绝原因按状态显示 不变的部分 - 文档顶层加 provenance 标记,只有新报告走新路径;期 4 之前的运行、非上传源、手工源的面板、复核、裁判摘录逐字不变,由金样测试钉住 - 执行器给区域外文字记录是否在隐藏行列;不建「导入校验」系统表(D6)
This commit is contained in:
@@ -5,7 +5,7 @@ import type {
|
||||
} from '../types'
|
||||
import type {
|
||||
Approval, AutofixResult, Conversation, ConversationDetail, ConversationTurn, CustomTool, DataSource, EvidenceGraph,
|
||||
EvidenceAudit, EvidenceJudgeResult, EvidenceSegmentDetail, GraphSpec, KbDocument, MemoryItem, Provider, PublishCheck, PublishLevel, ReviewResult, Run,
|
||||
EvidenceAudit, EvidenceJudgeResult, EvidenceProvenance, EvidenceSegmentDetail, GraphSpec, KbDocument, MemoryItem, Provider, PublishCheck, PublishLevel, ReviewResult, Run,
|
||||
RunEvent, RunStatus, Skill, ToolChange, ToolInfo, ToolTrust, UpgradeResult, UploadDecision, UploadMixedColumn, UploadResult,
|
||||
UploadShapeReason, ValidationIssue, VarIssue, Variable, Workflow, WorkflowVersion,
|
||||
} from '../types'
|
||||
@@ -891,6 +891,15 @@ export const api = {
|
||||
*/
|
||||
judge: (runId: string, body: { units: string[]; report?: string }) =>
|
||||
post<EvidenceJudgeResult>(`/runs/${encodeURIComponent(runId)}/evidence/judge`, body),
|
||||
/**
|
||||
* 推断的来源(期 4):上传表格的一个单元格来自原表的哪一格、这次查询查的是哪一版数据、相关核对。按需算,
|
||||
* 推断不出来不是错误(200,结论在 status、reason、alert 里)。只在片段接口的查询步骤带 provenance: true 时请求;
|
||||
* 老服务端没有这个接口,回 404 且没有 code。report 同片段接口
|
||||
*/
|
||||
provenance: (runId: string, segmentId: string, opts?: RequestOptions & { report?: string }) =>
|
||||
get<EvidenceProvenance>(
|
||||
`/runs/${encodeURIComponent(runId)}/evidence/segments/${encodeURIComponent(segmentId)}/provenance${qs({ report: opts?.report })}`,
|
||||
opts),
|
||||
/**
|
||||
* 导出审计表:?format=json / csv 作为附件下载。回来的是文件本身和后端给的文件名
|
||||
* (Content-Disposition;没给就用 evidence-<运行号前 8 位>.<格式>)
|
||||
|
||||
@@ -30,6 +30,7 @@ import evidenceQuery from '../run/__tests__/evidence-query.json'
|
||||
import evidenceEntity from '../run/__tests__/evidence-entity.json'
|
||||
import evidenceJudge from '../run/__tests__/evidence-judge.json'
|
||||
import evidenceVerdict from '../run/__tests__/evidence-verdict.json'
|
||||
import evidenceProvenance from '../run/__tests__/evidence-provenance.json'
|
||||
import { EvidenceGuessView } from '../run/EvidenceGuess'
|
||||
import { IssuanceBanner } from '../run/AssistantStream'
|
||||
import mdPinned from '../run/__tests__/markdown-pinned.json'
|
||||
@@ -207,6 +208,11 @@ const EV_JUDGE_PLAIN = evidenceJudge.plain.doc as unknown as EvidenceDocData
|
||||
*/
|
||||
const EV_VERDICT = evidenceVerdict.formal.doc as unknown as EvidenceDocData
|
||||
const EV_VERDICT_EXPLORE = evidenceVerdict.explore.doc as unknown as EvidenceDocData
|
||||
/**
|
||||
* Excel 导入期 4:上传表格的单元格追到原表格子(evidence-provenance.json)。文档由 compose_doc 真跑、带文档标记;
|
||||
* 片段接口、推断来源接口、导入清单的工件都由 check-evidence 用 page.route 伪造(按 runId 认出这一份夹具)
|
||||
*/
|
||||
const EV_PROVENANCE = evidenceProvenance.doc as unknown as EvidenceDocData
|
||||
/** 同一份旧契约的出具,去掉位置:老运行就是这样,只能按字符串标 */
|
||||
const LEGACY_LOOSE = {
|
||||
matched: EV_LEGACY.matched.map(({ start: _s, end: _e, ...m }) => m),
|
||||
@@ -431,6 +437,20 @@ function EvidenceOnly() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{/*
|
||||
Excel 导入期 4:推断的来源。宽栏一份、360 宽的画布右栏一份(栏内展开,不出横向滚动)
|
||||
*/}
|
||||
<div className="flex flex-col gap-4" id="evidence-provenance-demo">
|
||||
<div id="evidence-provenance" className="rounded-lg border p-3">
|
||||
<div className="mb-1 text-2xs text-faint">上传表格的单元格:数据版本、推断的来源、相关核对</div>
|
||||
<EvidenceDoc doc={EV_PROVENANCE} artifact={evidenceProvenance.doc_artifact} runId={evidenceProvenance.run_id}
|
||||
label="answer" tally />
|
||||
</div>
|
||||
<div id="evidence-provenance-narrow" className="rounded-lg border bg-panel p-2.5" style={{ width: 360, maxWidth: '100%' }}>
|
||||
<EvidenceDoc doc={EV_PROVENANCE} artifact={evidenceProvenance.doc_artifact} runId={evidenceProvenance.run_id}
|
||||
label="answer" dense tally />
|
||||
</div>
|
||||
</div>
|
||||
<div id="evidence-long" className="rounded-lg border p-3">
|
||||
<div className="mb-1 text-2xs text-faint">长报告:{EV_LONG.blocks.length} 块,块级 content-visibility,超过 3000 字先折叠</div>
|
||||
<EvidenceDoc doc={EV_LONG} label="长报告" tally />
|
||||
|
||||
@@ -341,6 +341,78 @@ export const EVIDENCE_TEXT = {
|
||||
guessNone: '未找到数值相同的单元格',
|
||||
guessDiff: (d: string) => `相差 ${d}`,
|
||||
guessCandidates: '可能来自',
|
||||
|
||||
// ---- 期 4:推断的来源(上传表格的单元格追到原表格子,P4-SPEC 4.2)----
|
||||
// 用词同版本页:不写「快照」「构建」「并集」,写「数据版本」「这一期」「数据文件」;署名一律标「署名(未认证)」。
|
||||
// 不下钻的原因、标红的提示由服务端给原文(provenance_types.REASON_TEXT / ALERT_TEXT),界面原样显示,不在这里另写
|
||||
provenance: {
|
||||
version: '数据版本',
|
||||
/** 首行。每期替换只有一期,不写期数;导入模式的说法同版本页(VERSIONS_TEXT.modeLabel) */
|
||||
versionHead: (source: string, mode: string, n: number) => (mode === 'accumulate'
|
||||
? `数据源「${source}」· 按期累积 · 共 ${formatNumber(n)} 期`
|
||||
: `数据源「${source}」· 每期替换`),
|
||||
part: (seq: number, start: string, end: string) => `第 ${formatNumber(seq)} 次导入 · 统计期 ${start} 至 ${end}`,
|
||||
partNoPeriod: (seq: number) => `第 ${formatNumber(seq)} 次导入 · 统计期未记录`,
|
||||
/** sha 是原件 sha256 的前 12 位;清单没记哈希时只写文件名 */
|
||||
file: (name: string, sha: string) => (sha ? `文件「${name}」· sha256 ${sha}` : `文件「${name}」`),
|
||||
/** S9:回执里块内各区域的外接矩形和排除的行数。排除 0 行、没有记录时不写 */
|
||||
region: (region: string, excluded: number | null) =>
|
||||
(excluded ? `区域 ${region} · 排除 ${formatNumber(excluded)} 行` : `区域 ${region}`),
|
||||
excluded: (n: number) => `排除 ${formatNumber(n)} 行`,
|
||||
committedAt: (at: string) => `导入于 ${at}`,
|
||||
/** 查询用到的表(与冻结表结构的交集)。原表写明的合计表另注一句:它不能和明细相加 */
|
||||
tables: (names: string[]) => `涉及的表:${names.join('、')}`,
|
||||
totalTable: (name: string) => `${name}(原表写明的合计)`,
|
||||
hasRow: '这一格所在的一期',
|
||||
current: '当前状态',
|
||||
revoked: '这一期的接受已作废',
|
||||
/** 清除原件、作废接受的记录:时间 · 理由 · 署名(未认证)。缺的不写(时间没记时调用方传空串),署名没填写「未填写」 */
|
||||
stateDetail: (at: string, reason: string | null, name: string | null) =>
|
||||
[at, reason ? `理由:${reason}` : '', `署名(未认证):${name || '未填写'}`].filter(Boolean).join(' · '),
|
||||
/** 这一期写过的接受理由(导入清单里的,是当时的事实)。核对标题取不到时写核对编号 */
|
||||
acceptedLine: (check: string, reason: string, name: string | null) =>
|
||||
`已接受:${check} · ${reason} · 署名(未认证):${name || '未填写'}`,
|
||||
manifest: '查看导入清单',
|
||||
manifestMasked: '数据源设置了遮罩,导入清单请到数据源卡片上的「版本」查看',
|
||||
unsealed: '本次运行尚未封存或封存核对未通过,以下内容不计入已封存的证据',
|
||||
morePeriods: (n: number) => `另有 ${formatNumber(n)} 期`,
|
||||
title: '推断的来源',
|
||||
badge: '推断,不属于已封存的证据',
|
||||
cell: (sheet: string, ref: string) => `工作表「${sheet}」${ref}`,
|
||||
/** 多期时格子在哪一期的文件里:坐标是那一期原件的坐标,不是别的期的 */
|
||||
fromPart: (seq: number, file: string | null) =>
|
||||
(file ? `取自第 ${formatNumber(seq)} 次导入的文件「${file}」` : `取自第 ${formatNumber(seq)} 次导入`),
|
||||
axisHeader: (ref: string) => `日期取自表头格 ${ref}`,
|
||||
yearPeriod: (cells: string) => (cells ? `年份取自统计期(${cells})` : '年份取自统计期'),
|
||||
yearHuman: (name: string) => `年份取自人工录入的统计期(署名(未认证):${name})`,
|
||||
yearMixed: '这一块的日期表头有的是日期格(自带年份),有的是文本(年份取自统计期),无法确定这一格属于哪一种',
|
||||
/** 格子原文拿不到时(text 为 null)只写坐标,不拿规范写法冒充原文 */
|
||||
rowLabel: (ref: string, text?: string | null) => (text ? `行标签 ${ref}「${text}」` : `行标签 ${ref}`),
|
||||
/** 清单里没有分段标题格的原文,只有配方里的定位文字:照实说是「按配方中的标题定位」 */
|
||||
sectionTitle: (ref: string, title?: string | null) =>
|
||||
(title ? `分段标题 ${ref}(按配方中的标题「${title}」定位)` : `分段标题 ${ref}`),
|
||||
colHeader: (refs: string) => `列表头 ${refs}`,
|
||||
totalLabel: (ref: string, text?: string | null) => (text ? `合计标签 ${ref}「${text}」` : `合计标签 ${ref}`),
|
||||
canonical: (raw: string, canon: string) => `原文「${raw}」,按规范写法存为「${canon}」`,
|
||||
reportedTotal: '原表写明的合计:不要彼此相加,也不要与明细相加',
|
||||
rawPurged: '原件已清除:坐标来自导入时的记录,无法再对照原件',
|
||||
mergedFill: '这一块按合并单元格的左上格填充:如果这一格在合并区域内,值取自该区域的左上格',
|
||||
recheck: '已按主键回查数据文件,值一致',
|
||||
details: '技术细节',
|
||||
recheckSql: '回查 SQL',
|
||||
checks: '相关核对',
|
||||
row: { passed: '这一行成立', mismatch: '这一行不成立', unverifiable: '这一行含空值,未能核对' } as Record<string, string>,
|
||||
cellStatus: {
|
||||
ok: '这一格一致',
|
||||
unverifiable: '这一格未能核对',
|
||||
unknown: '本期有格子未能核对,这一格是否在其中无法确定',
|
||||
not_formula: '这一格是写死的数,不做公式引用核对',
|
||||
} as Record<string, string>,
|
||||
partStatus: { passed: '本期通过', mismatch: '本期不成立', unverifiable: '本期未能核对', info: '口径说明' } as Record<string, string>,
|
||||
accepted: (reason: string, name: string | null) => `已接受,理由:${reason}(署名(未认证):${name || '未填写'})`,
|
||||
loading: '正在推断来源…',
|
||||
failed: '未能获取推断的来源',
|
||||
},
|
||||
} as const
|
||||
|
||||
/** 结论句按裁判结论分成的几堆(lib/evidence 的 claimCounts 数出来的) */
|
||||
@@ -1074,7 +1146,8 @@ export const VERSIONS_TEXT = {
|
||||
/** tokens 是 formatTokens 的结果(带单位),cost 是 formatCost 的结果 */
|
||||
aiUsage: (calls: number, tokens: string, cost: string) => `调用模型 ${formatNumber(calls)} 次,共 ${tokens},约 ${cost}`,
|
||||
aiNone: '这次导入没有调用模型',
|
||||
outsideTextNote: '区域外文字只在这里显示,不提供给模型',
|
||||
/** 期 4 起,带来源标记的报告里,裁判摘录会带上可见单元格里的区域外文字(隐藏行列里的不送) */
|
||||
outsideTextNote: '区域外文字不导入数据表;核对报告时,裁判可以看到其中可见单元格的文字',
|
||||
revokedBadge: '接受已作废',
|
||||
/** 当前版本或回滚目标被别人改过(base_changed、revoke_target_changed):服务端原话说了变的是什么,这里只说列表已刷新 */
|
||||
refreshHint: '列表已刷新,请重新确认',
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import type { CheckResult, ImportAcceptance, ManifestOut } from '../../types'
|
||||
import { CopyButton, Notice } from '../../components/ui'
|
||||
import { formatBytes, formatCost, formatDateTime, formatTokens } from '../../lib/format'
|
||||
import { RAW_STATE_LABEL, RECIPE_ORIGIN_LABEL, RECIPE_TEXT, VERSIONS_TEXT as VT } from '../../lib/terms'
|
||||
import { CheckStatusChip } from './ImportReceipt'
|
||||
import { ReceiptSummary } from './ReceiptBlocks'
|
||||
|
||||
// ===========================================================================
|
||||
// 导入清单的渲染(P3-SPEC 7.3):文件、配方、统计期、核对、接受、确认清单、修改记录、说明、回执摘要、AI 用量,
|
||||
// 原始清单默认收起。
|
||||
//
|
||||
// 从版本页(VersionsDialog)抽出来,证据面板的「数据版本」一节也用它(P4-SPEC 4.1):面板里查看导入清单
|
||||
// 不能退回整份 JSON 输出——那样遮罩不起作用,64 KB 的清单也没法读。两处的行为必须一致,check-versions 守版本页,
|
||||
// check-evidence 的 provenance 段守面板
|
||||
// ===========================================================================
|
||||
|
||||
function Block({ id, title, children }: { id: string; title: string; children: ReactNode }) {
|
||||
return (
|
||||
<section className="space-y-1.5 rounded-lg border bg-bg p-3 text-xs" data-manifest-block={id}>
|
||||
<h4 className="font-semibold">{title}</h4>
|
||||
{children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
const short = (sha: unknown) => (typeof sha === 'string' && sha ? sha.slice(0, 8) : '')
|
||||
const cellsShort = (cells: string[]) => cells.map((c) => c.slice(c.lastIndexOf('!') + 1)).join('、')
|
||||
const list = <T,>(v: unknown): T[] => (Array.isArray(v) ? (v as T[]) : [])
|
||||
|
||||
/**
|
||||
* 导入清单的各块。content 是服务端存的原样(内容寻址,取回时复验了哈希),字段都按「可能缺」读:期 2 的清单
|
||||
* 没有修改记录,简单导入只有导入回执。
|
||||
*
|
||||
* 清单之外的三样(文件名兜底、原件状态、配方第几版)由调用方给:版本页取自导入记录,证据面板取自推断来源接口的
|
||||
* 那一期(PartView)。原件状态和配方版次是当前状态,不在清单里
|
||||
*/
|
||||
export function ManifestBody({ m, fileName, rawState, recipeSeq }: {
|
||||
m: ManifestOut
|
||||
/** 清单没记文件名时显示的名字 */
|
||||
fileName?: string | null
|
||||
/** 原件状态(kept / purged / absent),取不到为 null 时不显示 */
|
||||
rawState?: string | null
|
||||
/** 配方第几版,取不到为 null 时不显示 */
|
||||
recipeSeq?: number | null
|
||||
}) {
|
||||
const c = m.content ?? {}
|
||||
const B = VT.manifestBlocks
|
||||
const simple = m.kind === 'build_report'
|
||||
const receipt = simple ? c : c.receipt
|
||||
const checks = list<CheckResult>(c.checks)
|
||||
const titleOf = (id: string) => checks.find((x) => x.id === id)?.title
|
||||
const accepts: ImportAcceptance[] = [
|
||||
...list<ImportAcceptance>(c.acceptances?.overrides).map((a) => ({ ...a, kind: 'override' })),
|
||||
...list<ImportAcceptance>(c.acceptances?.waivers).map((a) => ({ ...a, kind: 'waiver' })),
|
||||
]
|
||||
const confirmations = list<{ id: string; label: string; at?: string }>(c.confirmations)
|
||||
const edits = Array.isArray(c.edits) ? list<Record<string, any>>(c.edits) : null
|
||||
const rendered = Object.entries((c.notes?.rendered ?? {}) as Record<string, { comment?: string; columns?: Record<string, string> }>)
|
||||
const usage = list<Record<string, any>>(c.ai?.usage)
|
||||
const tokens = usage.reduce((n, u) => n + (Number(u.input_tokens) || 0) + (Number(u.output_tokens) || 0), 0)
|
||||
const cost = usage.reduce((n, u) => n + (Number(u.cost_usd) || 0), 0)
|
||||
const period = c.period as { start?: string; end?: string; source?: string; cells?: string[]; signed_by?: string | null } | null
|
||||
const outside = list(receipt?.outside_text)
|
||||
|
||||
return (
|
||||
<div className="space-y-2.5" data-manifest={m.kind} data-verified={m.verified ? 'true' : 'false'}>
|
||||
{simple
|
||||
? <Notice tone="info">{VT.manifestSimple}</Notice>
|
||||
: !m.verified && <Notice tone="err" attr={{ 'data-manifest-unverified': '' }}>{VT.manifestUnverified}</Notice>}
|
||||
|
||||
{!simple && (
|
||||
<>
|
||||
<Block id="file" title={B.file}>
|
||||
<div className="flex flex-wrap items-baseline gap-x-3 gap-y-1">
|
||||
<span className="mono break-all">{c.file?.name || fileName}</span>
|
||||
{c.file?.size != null && <span className="tnum text-dim">{formatBytes(Number(c.file.size))}</span>}
|
||||
{short(c.file?.raw_sha256) && <span className="mono text-dim">{VT.sha(short(c.file?.raw_sha256))}</span>}
|
||||
{rawState != null && <span className="chip">{RAW_STATE_LABEL[rawState] ?? rawState}</span>}
|
||||
</div>
|
||||
{c.signed_by?.name && <div className="text-2xs text-faint">{VT.signedBy(c.signed_by.name)}</div>}
|
||||
</Block>
|
||||
|
||||
<Block id="recipe" title={B.recipe}>
|
||||
<div className="flex flex-wrap items-baseline gap-x-3 gap-y-1">
|
||||
{recipeSeq != null && <span>{VT.recipeSeq(recipeSeq)}</span>}
|
||||
{c.recipe?.origin && <span className="text-dim">{RECIPE_ORIGIN_LABEL[c.recipe.origin] ?? c.recipe.origin}</span>}
|
||||
{short(c.recipe?.sha256) && <span className="mono text-dim">{VT.sha(short(c.recipe?.sha256))}</span>}
|
||||
</div>
|
||||
{c.recipe?.canonical && <RawJson summary={VT.recipeJson} value={c.recipe.canonical} attr="data-recipe-json" />}
|
||||
</Block>
|
||||
|
||||
<Block id="period" title={B.period}>
|
||||
{period?.start && period?.end ? (
|
||||
<div className="space-y-0.5">
|
||||
<div className="tnum">{VT.period(period.start, period.end)}</div>
|
||||
<div className="text-2xs text-faint">
|
||||
{period.source === 'human'
|
||||
? `${VT.periodHuman},${VT.signedBy(period.signed_by || VT.unsigned)}`
|
||||
: period.cells?.length ? RECIPE_TEXT.periodFromCells(cellsShort(period.cells)) : ''}
|
||||
</div>
|
||||
</div>
|
||||
) : <p className="text-faint">{VT.periodUnknown}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="checks" title={B.checks}>
|
||||
{checks.length ? (
|
||||
<ul className="space-y-1.5">
|
||||
{checks.map((k) => (
|
||||
<li key={k.id} className="space-y-1 rounded-md border px-2.5 py-1.5" data-manifest-check={k.id} data-status={k.status}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<CheckStatusChip status={k.status} />
|
||||
<span className="mono text-faint">{k.id}</span>
|
||||
<span className="min-w-0 flex-1">{k.title}</span>
|
||||
{/* 计数照试运行回执的规则(ImportReceipt 的 CheckRow):「说明」类的 failed 是预期内的不相等个数,不写 */}
|
||||
{!!k.checked && k.status !== 'info' && (
|
||||
<span className="tnum text-2xs text-faint" data-check-counts="">
|
||||
{VT.checkCounts(k.checked, k.failed ?? 0, k.unverifiable ?? 0)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{/* 清单是当证据核对的,细节不截断:服务端每个核对最多逐条列 20 格,其余写成「另有 N 格不一致」
|
||||
「N 格无法核对:…」,截掉的正是这几行 */}
|
||||
{!!k.details?.length && (
|
||||
<ul className="space-y-0.5 text-2xs leading-relaxed text-dim" data-check-details={k.details.length}>
|
||||
{k.details.map((d, i) => <li key={i}>{d}</li>)}
|
||||
</ul>
|
||||
)}
|
||||
{k.sql && <RawJson summary={VT.sql} value={k.params?.length ? `${k.sql}\n-- ${JSON.stringify(k.params)}` : k.sql} attr="data-check-sql" />}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.checksNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="acceptances" title={B.acceptances}>
|
||||
{accepts.length ? (
|
||||
<ul className="space-y-1">
|
||||
{accepts.map((a, i) => (
|
||||
<li key={`${a.check_id}-${i}`} className="space-y-0.5 rounded-md border px-2.5 py-1.5" data-manifest-acceptance={a.check_id}>
|
||||
<div className="flex flex-wrap items-baseline gap-x-2">
|
||||
<span className="chip">{VT.acceptKind[a.kind] ?? VT.acceptKind.override}</span>
|
||||
<span className="min-w-0 flex-1 break-words">
|
||||
{VT.acceptRow(titleOf(a.check_id) ? `${a.check_id} ${titleOf(a.check_id)}` : a.check_id, a.reason)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-2 text-2xs text-faint">
|
||||
<span>{VT.signedBy(a.signed_by || VT.unsigned)}</span>
|
||||
{a.at && <span className="tnum">{formatDateTime(a.at)}</span>}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.acceptancesNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="confirmations" title={B.confirmations}>
|
||||
{confirmations.length ? (
|
||||
<ul className="list-inside list-disc space-y-0.5 text-dim">
|
||||
{confirmations.map((x, i) => <li key={`${x.id}-${i}`}>{x.label}</li>)}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.confirmationsNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="edits" title={B.edits}>
|
||||
{edits == null
|
||||
? <p className="text-faint">{VT.editsUnrecorded}</p>
|
||||
: edits.length ? (
|
||||
<ul className="space-y-1">
|
||||
{edits.map((e, i) => (
|
||||
<li key={`${e.seq ?? i}`} className={clsx('flex flex-wrap items-baseline gap-x-2 rounded-md border px-2.5 py-1.5', e.superseded && 'opacity-60')}
|
||||
data-manifest-edit={e.kind}>
|
||||
<span className="chip">{VT.editKind[e.kind] ?? VT.editKind.fix}</span>
|
||||
<span className="min-w-0 flex-1 break-words">{e.title}</span>
|
||||
{e.superseded && <span className="text-2xs text-faint">{VT.editSuperseded}</span>}
|
||||
<span className="text-2xs text-faint">{VT.signedBy(e.signed_by || VT.unsigned)}</span>
|
||||
{e.at && <span className="tnum text-2xs text-faint">{formatDateTime(e.at)}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.editsNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="notes" title={B.notes}>
|
||||
{rendered.length ? (
|
||||
<ul className="space-y-2">
|
||||
{rendered.map(([table, n]) => (
|
||||
<li key={table} className="space-y-0.5" data-manifest-note={table}>
|
||||
<div className="font-medium">{table}</div>
|
||||
{n.comment && <p className="leading-relaxed text-dim">{n.comment}</p>}
|
||||
{Object.entries(n.columns ?? {}).length > 0 && (
|
||||
<ul className="space-y-0.5 text-2xs text-dim">
|
||||
{Object.entries(n.columns ?? {}).map(([col, text]) => <li key={col}>{col}:{text}</li>)}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.notesNone}</p>}
|
||||
</Block>
|
||||
</>
|
||||
)}
|
||||
|
||||
<section className="space-y-1.5 rounded-lg border bg-bg p-3" data-manifest-block="receipt">
|
||||
<ReceiptSummary receipt={receipt} />
|
||||
{outside.length > 0 && <p className="text-2xs text-faint" data-outside-note="">{VT.outsideTextNote}</p>}
|
||||
</section>
|
||||
|
||||
{!simple && (
|
||||
<Block id="ai" title={B.ai}>
|
||||
<p className={usage.length ? 'text-dim' : 'text-faint'}>
|
||||
{usage.length ? VT.aiUsage(usage.length, formatTokens(tokens), formatCost(cost)) : VT.aiNone}
|
||||
</p>
|
||||
</Block>
|
||||
)}
|
||||
|
||||
<RawJson summary={VT.manifestRaw} value={c} attr="data-manifest-raw" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 等宽的原文(原始清单、配方 JSON、核对的 SQL),默认收起:给要逐字核对的人看,带复制 */
|
||||
function RawJson({ summary, value, attr }: { summary: string; value: unknown; attr: string }) {
|
||||
const text = typeof value === 'string' ? value : JSON.stringify(value, null, 2)
|
||||
return (
|
||||
<details className="text-2xs" {...{ [attr]: '' }}>
|
||||
<summary className="cursor-pointer select-none text-faint hover:text-dim">{summary}</summary>
|
||||
<div className="mt-1.5 flex items-start gap-1.5">
|
||||
<pre className="mono max-h-80 min-w-0 flex-1 overflow-auto whitespace-pre-wrap break-all rounded-md border bg-[var(--bg)] p-2 leading-relaxed text-dim">
|
||||
{text}
|
||||
</pre>
|
||||
<CopyButton text={text} />
|
||||
</div>
|
||||
</details>
|
||||
)
|
||||
}
|
||||
@@ -4,17 +4,16 @@ import { AlertTriangle, ArrowLeft, ChevronRight, FileText, Info, RotateCcw, Scis
|
||||
import clsx from 'clsx'
|
||||
import { ApiError, api } from '../../api/client'
|
||||
import type {
|
||||
CheckResult, DataSource, ImportAcceptance, ImportRecord, ManifestOut, PeriodRef, RevokePlan, SnapshotOut, SnapshotPart,
|
||||
DataSource, ImportAcceptance, ImportRecord, ManifestOut, PeriodRef, RevokePlan, SnapshotOut, SnapshotPart,
|
||||
} from '../../types'
|
||||
import {
|
||||
CopyButton, EmptyState, ErrorState, Modal, Notice, Skeleton, TabPanel, Tabs, promptDialog, toast,
|
||||
EmptyState, ErrorState, Modal, Notice, Skeleton, TabPanel, Tabs, promptDialog, toast,
|
||||
} from '../../components/ui'
|
||||
import { localActor } from '../../lib/actor'
|
||||
import { humanizeError } from '../../lib/errors'
|
||||
import { formatBytes, formatCost, formatDateTime, formatTime, formatTokens, parseServerTime } from '../../lib/format'
|
||||
import { RAW_STATE_LABEL, RECIPE_ORIGIN_LABEL, RECIPE_TEXT, VERSIONS_TEXT as VT } from '../../lib/terms'
|
||||
import { CheckStatusChip } from './ImportReceipt'
|
||||
import { ReceiptSummary } from './ReceiptBlocks'
|
||||
import { formatBytes, formatDateTime, formatTime, parseServerTime } from '../../lib/format'
|
||||
import { RAW_STATE_LABEL, VERSIONS_TEXT as VT } from '../../lib/terms'
|
||||
import { ManifestBody } from './ManifestBody'
|
||||
|
||||
// ===========================================================================
|
||||
// 版本页(数据源卡片上的「版本」,P3-SPEC 7.8):当前版本的各期、历史版本、全部导入记录三个页签,
|
||||
@@ -703,216 +702,7 @@ function ManifestView({ sourceId, rec, onBack }: { sourceId: string; rec: Import
|
||||
? <ErrorState error={error} onRetry={() => setNonce((n) => n + 1)} />
|
||||
: !m
|
||||
? <Skeleton rows={5} height={36} gap={8} />
|
||||
: <ManifestBody m={m} rec={rec} />}
|
||||
: <ManifestBody m={m} fileName={rec.file_name} rawState={rec.raw_state} recipeSeq={rec.recipe_seq} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Block({ id, title, children }: { id: string; title: string; children: ReactNode }) {
|
||||
return (
|
||||
<section className="space-y-1.5 rounded-lg border bg-bg p-3 text-xs" data-manifest-block={id}>
|
||||
<h4 className="font-semibold">{title}</h4>
|
||||
{children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
const short = (sha: unknown) => (typeof sha === 'string' && sha ? sha.slice(0, 8) : '')
|
||||
const cellsShort = (cells: string[]) => cells.map((c) => c.slice(c.lastIndexOf('!') + 1)).join('、')
|
||||
const list = <T,>(v: unknown): T[] => (Array.isArray(v) ? (v as T[]) : [])
|
||||
|
||||
/**
|
||||
* 导入清单的各块。content 是服务端存的原样(内容寻址,取回时复验了哈希),字段都按「可能缺」读:期 2 的清单
|
||||
* 没有修改记录,简单导入只有导入回执
|
||||
*/
|
||||
function ManifestBody({ m, rec }: { m: ManifestOut; rec: ImportRecord }) {
|
||||
const c = m.content ?? {}
|
||||
const B = VT.manifestBlocks
|
||||
const simple = m.kind === 'build_report'
|
||||
const receipt = simple ? c : c.receipt
|
||||
const checks = list<CheckResult>(c.checks)
|
||||
const titleOf = (id: string) => checks.find((x) => x.id === id)?.title
|
||||
const accepts: ImportAcceptance[] = [
|
||||
...list<ImportAcceptance>(c.acceptances?.overrides).map((a) => ({ ...a, kind: 'override' })),
|
||||
...list<ImportAcceptance>(c.acceptances?.waivers).map((a) => ({ ...a, kind: 'waiver' })),
|
||||
]
|
||||
const confirmations = list<{ id: string; label: string; at?: string }>(c.confirmations)
|
||||
const edits = Array.isArray(c.edits) ? list<Record<string, any>>(c.edits) : null
|
||||
const rendered = Object.entries((c.notes?.rendered ?? {}) as Record<string, { comment?: string; columns?: Record<string, string> }>)
|
||||
const usage = list<Record<string, any>>(c.ai?.usage)
|
||||
const tokens = usage.reduce((n, u) => n + (Number(u.input_tokens) || 0) + (Number(u.output_tokens) || 0), 0)
|
||||
const cost = usage.reduce((n, u) => n + (Number(u.cost_usd) || 0), 0)
|
||||
const period = c.period as { start?: string; end?: string; source?: string; cells?: string[]; signed_by?: string | null } | null
|
||||
const outside = list(receipt?.outside_text)
|
||||
|
||||
return (
|
||||
<div className="space-y-2.5" data-manifest={m.kind} data-verified={m.verified ? 'true' : 'false'}>
|
||||
{simple
|
||||
? <Notice tone="info">{VT.manifestSimple}</Notice>
|
||||
: !m.verified && <Notice tone="err" attr={{ 'data-manifest-unverified': '' }}>{VT.manifestUnverified}</Notice>}
|
||||
|
||||
{!simple && (
|
||||
<>
|
||||
<Block id="file" title={B.file}>
|
||||
<div className="flex flex-wrap items-baseline gap-x-3 gap-y-1">
|
||||
<span className="mono break-all">{c.file?.name || rec.file_name}</span>
|
||||
{c.file?.size != null && <span className="tnum text-dim">{formatBytes(Number(c.file.size))}</span>}
|
||||
{short(c.file?.raw_sha256) && <span className="mono text-dim">{VT.sha(short(c.file?.raw_sha256))}</span>}
|
||||
<span className="chip">{RAW_STATE_LABEL[rec.raw_state] ?? rec.raw_state}</span>
|
||||
</div>
|
||||
{c.signed_by?.name && <div className="text-2xs text-faint">{VT.signedBy(c.signed_by.name)}</div>}
|
||||
</Block>
|
||||
|
||||
<Block id="recipe" title={B.recipe}>
|
||||
<div className="flex flex-wrap items-baseline gap-x-3 gap-y-1">
|
||||
{rec.recipe_seq != null && <span>{VT.recipeSeq(rec.recipe_seq)}</span>}
|
||||
{c.recipe?.origin && <span className="text-dim">{RECIPE_ORIGIN_LABEL[c.recipe.origin] ?? c.recipe.origin}</span>}
|
||||
{short(c.recipe?.sha256) && <span className="mono text-dim">{VT.sha(short(c.recipe?.sha256))}</span>}
|
||||
</div>
|
||||
{c.recipe?.canonical && <RawJson summary={VT.recipeJson} value={c.recipe.canonical} attr="data-recipe-json" />}
|
||||
</Block>
|
||||
|
||||
<Block id="period" title={B.period}>
|
||||
{period?.start && period?.end ? (
|
||||
<div className="space-y-0.5">
|
||||
<div className="tnum">{VT.period(period.start, period.end)}</div>
|
||||
<div className="text-2xs text-faint">
|
||||
{period.source === 'human'
|
||||
? `${VT.periodHuman},${VT.signedBy(period.signed_by || VT.unsigned)}`
|
||||
: period.cells?.length ? RECIPE_TEXT.periodFromCells(cellsShort(period.cells)) : ''}
|
||||
</div>
|
||||
</div>
|
||||
) : <p className="text-faint">{VT.periodUnknown}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="checks" title={B.checks}>
|
||||
{checks.length ? (
|
||||
<ul className="space-y-1.5">
|
||||
{checks.map((k) => (
|
||||
<li key={k.id} className="space-y-1 rounded-md border px-2.5 py-1.5" data-manifest-check={k.id} data-status={k.status}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<CheckStatusChip status={k.status} />
|
||||
<span className="mono text-faint">{k.id}</span>
|
||||
<span className="min-w-0 flex-1">{k.title}</span>
|
||||
{/* 计数照试运行回执的规则(ImportReceipt 的 CheckRow):「说明」类的 failed 是预期内的不相等个数,不写 */}
|
||||
{!!k.checked && k.status !== 'info' && (
|
||||
<span className="tnum text-2xs text-faint" data-check-counts="">
|
||||
{VT.checkCounts(k.checked, k.failed ?? 0, k.unverifiable ?? 0)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{/* 清单是当证据核对的,细节不截断:服务端每个核对最多逐条列 20 格,其余写成「另有 N 格不一致」
|
||||
「N 格无法核对:…」,截掉的正是这几行 */}
|
||||
{!!k.details?.length && (
|
||||
<ul className="space-y-0.5 text-2xs leading-relaxed text-dim" data-check-details={k.details.length}>
|
||||
{k.details.map((d, i) => <li key={i}>{d}</li>)}
|
||||
</ul>
|
||||
)}
|
||||
{k.sql && <RawJson summary={VT.sql} value={k.params?.length ? `${k.sql}\n-- ${JSON.stringify(k.params)}` : k.sql} attr="data-check-sql" />}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.checksNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="acceptances" title={B.acceptances}>
|
||||
{accepts.length ? (
|
||||
<ul className="space-y-1">
|
||||
{accepts.map((a, i) => (
|
||||
<li key={`${a.check_id}-${i}`} className="space-y-0.5 rounded-md border px-2.5 py-1.5" data-manifest-acceptance={a.check_id}>
|
||||
<div className="flex flex-wrap items-baseline gap-x-2">
|
||||
<span className="chip">{VT.acceptKind[a.kind] ?? VT.acceptKind.override}</span>
|
||||
<span className="min-w-0 flex-1 break-words">
|
||||
{VT.acceptRow(titleOf(a.check_id) ? `${a.check_id} ${titleOf(a.check_id)}` : a.check_id, a.reason)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-2 text-2xs text-faint">
|
||||
<span>{VT.signedBy(a.signed_by || VT.unsigned)}</span>
|
||||
{a.at && <span className="tnum">{formatDateTime(a.at)}</span>}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.acceptancesNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="confirmations" title={B.confirmations}>
|
||||
{confirmations.length ? (
|
||||
<ul className="list-inside list-disc space-y-0.5 text-dim">
|
||||
{confirmations.map((x, i) => <li key={`${x.id}-${i}`}>{x.label}</li>)}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.confirmationsNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="edits" title={B.edits}>
|
||||
{edits == null
|
||||
? <p className="text-faint">{VT.editsUnrecorded}</p>
|
||||
: edits.length ? (
|
||||
<ul className="space-y-1">
|
||||
{edits.map((e, i) => (
|
||||
<li key={`${e.seq ?? i}`} className={clsx('flex flex-wrap items-baseline gap-x-2 rounded-md border px-2.5 py-1.5', e.superseded && 'opacity-60')}
|
||||
data-manifest-edit={e.kind}>
|
||||
<span className="chip">{VT.editKind[e.kind] ?? VT.editKind.fix}</span>
|
||||
<span className="min-w-0 flex-1 break-words">{e.title}</span>
|
||||
{e.superseded && <span className="text-2xs text-faint">{VT.editSuperseded}</span>}
|
||||
<span className="text-2xs text-faint">{VT.signedBy(e.signed_by || VT.unsigned)}</span>
|
||||
{e.at && <span className="tnum text-2xs text-faint">{formatDateTime(e.at)}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.editsNone}</p>}
|
||||
</Block>
|
||||
|
||||
<Block id="notes" title={B.notes}>
|
||||
{rendered.length ? (
|
||||
<ul className="space-y-2">
|
||||
{rendered.map(([table, n]) => (
|
||||
<li key={table} className="space-y-0.5" data-manifest-note={table}>
|
||||
<div className="font-medium">{table}</div>
|
||||
{n.comment && <p className="leading-relaxed text-dim">{n.comment}</p>}
|
||||
{Object.entries(n.columns ?? {}).length > 0 && (
|
||||
<ul className="space-y-0.5 text-2xs text-dim">
|
||||
{Object.entries(n.columns ?? {}).map(([col, text]) => <li key={col}>{col}:{text}</li>)}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-faint">{VT.notesNone}</p>}
|
||||
</Block>
|
||||
</>
|
||||
)}
|
||||
|
||||
<section className="space-y-1.5 rounded-lg border bg-bg p-3" data-manifest-block="receipt">
|
||||
<ReceiptSummary receipt={receipt} />
|
||||
{outside.length > 0 && <p className="text-2xs text-faint" data-outside-note="">{VT.outsideTextNote}</p>}
|
||||
</section>
|
||||
|
||||
{!simple && (
|
||||
<Block id="ai" title={B.ai}>
|
||||
<p className={usage.length ? 'text-dim' : 'text-faint'}>
|
||||
{usage.length ? VT.aiUsage(usage.length, formatTokens(tokens), formatCost(cost)) : VT.aiNone}
|
||||
</p>
|
||||
</Block>
|
||||
)}
|
||||
|
||||
<RawJson summary={VT.manifestRaw} value={c} attr="data-manifest-raw" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 等宽的原文(原始清单、配方 JSON、核对的 SQL),默认收起:给要逐字核对的人看,带复制 */
|
||||
function RawJson({ summary, value, attr }: { summary: string; value: unknown; attr: string }) {
|
||||
const text = typeof value === 'string' ? value : JSON.stringify(value, null, 2)
|
||||
return (
|
||||
<details className="text-2xs" {...{ [attr]: '' }}>
|
||||
<summary className="cursor-pointer select-none text-faint hover:text-dim">{summary}</summary>
|
||||
<div className="mt-1.5 flex items-start gap-1.5">
|
||||
<pre className="mono max-h-80 min-w-0 flex-1 overflow-auto whitespace-pre-wrap break-all rounded-md border bg-[var(--bg)] p-2 leading-relaxed text-dim">
|
||||
{text}
|
||||
</pre>
|
||||
<CopyButton text={text} />
|
||||
</div>
|
||||
</details>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import type {
|
||||
} from '../types'
|
||||
import { ArtifactViewer, ResultTable } from './AssistantStream'
|
||||
import { useEvidenceHost } from './evidenceHost'
|
||||
import { EvidenceProvenance } from './EvidenceProvenance'
|
||||
import { CopyChip } from './Markdown'
|
||||
|
||||
/**
|
||||
@@ -58,6 +59,9 @@ import { CopyChip } from './Markdown'
|
||||
* 裁判拆档(JR):证据不足的写明缺什么;裁判模型和写作模型相同、模型不在价格表里时在「模型的解释」下提醒;
|
||||
* 表名实体步骤列出字段清单;讲方法、讲结构的句子在「挂的依据」下直接列出 SQL 和字段清单。
|
||||
*
|
||||
* Excel 导入期 4:上传表格的单元格多三节——数据版本、推断的来源、相关核对(EvidenceProvenance)。只在片段是单元格
|
||||
* 引用、且片段接口的查询步骤带 provenance: true 时请求推断来源接口;推断来源的缓存只在面板开着期间有效。
|
||||
*
|
||||
* 四种摆法:side 从右侧弹出(宽屏),drawer 从底部抽出(窄屏),inline 在 360px 的
|
||||
* 画布右栏里直接栏内展开,dock 放进页面给的一块常驻位置(记录页的「证据」页签)。
|
||||
* 都不是模态的:开着面板照样能在正文里走。
|
||||
@@ -82,6 +86,10 @@ export function EvidencePanel({ id, mode, doc, artifact, runId, runClass, view,
|
||||
onViolations: () => void
|
||||
}) {
|
||||
const titleId = `${id}-title`
|
||||
// 推断的来源只在面板这次打开期间缓存:回答里有当前状态(原件已清除、接受已作废)和取决于数据文件现状的结论,
|
||||
// 关掉面板(卸载)或换了运行就作废,再打开重新取。同一次打开里来回点同一片段只取一次
|
||||
const holdProvenance = useEvidence((s) => s.holdProvenance)
|
||||
useEffect(() => (runId ? holdProvenance(runId) : undefined), [runId, holdProvenance])
|
||||
const found = useMemo(() => (view.kind === 'seg' ? findSeg(doc, view.id) : null), [doc, view])
|
||||
const claimAt = useMemo(() => (view.kind === 'unit' ? findUnit(doc, view.id) : null), [doc, view])
|
||||
const overlay = useVerdicts(runId, doc.node_id || undefined)
|
||||
@@ -247,6 +255,10 @@ function SegmentBody({ panelId, doc, artifact, runId, runClass, seg, unit, block
|
||||
&& (cite?.kind === 'cell' || entry?.kind === 'query' || !!queries.length)
|
||||
const bad = state === 'none' || state === 'suspect' || state === 'unverified'
|
||||
const closest = closestNames(detail?.closest ?? entityStep?.closest)
|
||||
// 期 4:推断的来源。条件写死成「片段是单元格引用、它的查询步骤带了提示」:期 4 之前的运行、手工源(查询步骤没有
|
||||
// 提示)、指标片段(cite.kind 是 metric,哪怕它链上的查询步骤误带了提示)一个请求都不多发。接口答的是另一份报告
|
||||
// (docForeign)时 detail 为空、链是空的,也就不请求
|
||||
const provenanceOn = !!runId && cite?.kind === 'cell' && queries.some((q) => q.provenance === true)
|
||||
|
||||
// 画布右栏:点开片段时把证据路径交给画布(产出证据的节点实线、报告虚线),链取回来后再补全
|
||||
const host = useEvidenceHost()
|
||||
@@ -386,6 +398,8 @@ function SegmentBody({ panelId, doc, artifact, runId, runClass, seg, unit, block
|
||||
<QueryPart key={`${q.artifact ?? ''}-${i}`} id={queryId(i)} step={q} seal={seal} masked={masked} />
|
||||
))}
|
||||
|
||||
{provenanceOn && runId && <EvidenceProvenance runId={runId} segId={seg.id} report={report} />}
|
||||
|
||||
{state === 'deterministic' && !isMetric && !isInput && !isCell && !isEntity && !isQuote && (
|
||||
<p className="text-dim">{sourceOf(seg, doc) || detail?.note}</p>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,489 @@
|
||||
import { useEffect, useId, useState, type ReactNode } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { AlertTriangle, ChevronRight, FileText } from 'lucide-react'
|
||||
import clsx from 'clsx'
|
||||
import { ApiError, api } from '../api/client'
|
||||
import { ErrorState, Modal, Skeleton } from '../components/ui'
|
||||
import { NONE, formatDateTime } from '../lib/format'
|
||||
import { EVIDENCE_TEXT, RAW_STATE_LABEL, VERSIONS_TEXT } from '../lib/terms'
|
||||
import { ManifestBody } from '../pages/import/ManifestBody'
|
||||
import { segmentKey, useEvidence } from '../store/evidence'
|
||||
import type {
|
||||
EvidenceProvenance as Provenance, ManifestOut, ProvenanceCellSource, ProvenanceCheck, ProvenanceFromCell, ProvenancePart,
|
||||
ProvenanceVersion,
|
||||
} from '../types'
|
||||
import { CopyChip } from './Markdown'
|
||||
|
||||
/**
|
||||
* 证据面板里的「数据版本」「推断的来源」「相关核对」三节(Excel 导入期 4,P4-SPEC 4.1–4.3)。
|
||||
*
|
||||
* 上传表格的单元格:这次查询查的是哪一版数据(各期的统计期、文件、原件状态、写过的接受理由),这一格来自原表的
|
||||
* 哪个工作表、哪一格(日期、年份、行标签、分段标题各取自哪里),以及这一行、这一格的核对结果。
|
||||
*
|
||||
* 数据都来自推断来源接口(按需算,面板打开那个片段时才算)。调用方只在片段是单元格引用、且片段接口的查询步骤
|
||||
* 带 provenance: true 时挂这个组件,所以期 4 之前的运行、手工源、指标片段一个请求都不多发。
|
||||
*
|
||||
* 三节分两种性质,界面分开标注:
|
||||
* - 数据版本来自封存链上的导入清单(内容寻址),不加「推断」标注;
|
||||
* - 推断的来源、相关核对是先按主键认出这一行再推出来的,挂「推断,不属于已封存的证据」,用虚线左边框和
|
||||
* 别的几节区分。封存那一行(verdict)不受它影响,推断的来源不计入「已封存 · 核对一致」。
|
||||
*
|
||||
* 标题用 <h4>(读屏按标题跳得到),视觉照抄面板里 Part 的小标题;Part 本身不动——改它会改变期 4 之前所有面板的
|
||||
* DOM。标红的提示用自己的属性 data-ev-prov-alert,不用 data-ev-integrity:现有断言数过后者的个数。
|
||||
* 折叠、展开不加动效(P4-SPEC 4.3)。
|
||||
*/
|
||||
|
||||
const P = EVIDENCE_TEXT.provenance
|
||||
|
||||
/** 小标题的样式:同 EvidencePanel 的 Part(mb-1 text-2xs font-medium text-faint),只是换成真正的标题元素 */
|
||||
const HEAD = 'text-2xs font-medium text-faint'
|
||||
|
||||
/** 期数多于这个数时折叠:只展开这一格所在的一期和最近一期 */
|
||||
const FOLD_AT = 3
|
||||
|
||||
/** 原件 sha256 显示前几位(P4-SPEC 4.1:前 12 位) */
|
||||
const SHA_PREFIX = 12
|
||||
|
||||
/**
|
||||
* 导入、清除、作废记录的时间。没记(契约里 at 可以是 null)或认不出时给空串,由调用方略去这一项:formatDateTime
|
||||
* 拿不到时间时返回「—」,它是真值,filter(Boolean) 去不掉,会在「原件已清除 · — · 理由:…」里留下一个孤立的「—」
|
||||
*/
|
||||
function stamp(at: string | null | undefined): string {
|
||||
const text = formatDateTime(at)
|
||||
return text === NONE ? '' : text
|
||||
}
|
||||
|
||||
export function EvidenceProvenance({ runId, segId, report }: { runId: string; segId: string; report?: string }) {
|
||||
const key = segmentKey(runId, segId, report)
|
||||
const slot = useEvidence((s) => s.provenance[key])
|
||||
const load = useEvidence((s) => s.loadProvenance)
|
||||
// 槽没了就再取:面板开着时不会被清(清缓存只在最后一个面板关掉以后),这里只是不让一节永远停在「正在推断」
|
||||
const missing = !slot
|
||||
useEffect(() => {
|
||||
if (missing) void load(runId, segId, report)
|
||||
}, [missing, runId, segId, report, load])
|
||||
|
||||
if (!slot || slot.status === 'loading') {
|
||||
// 取的过程中只画这一节的加载态,不先画三节空壳
|
||||
return (
|
||||
<SourceShell state="loading">
|
||||
<p className="text-dim" data-ev-prov-loading="">{P.loading}</p>
|
||||
</SourceShell>
|
||||
)
|
||||
}
|
||||
if (slot.status === 'error' || !slot.data || typeof slot.data !== 'object') {
|
||||
// 老服务端没有这个接口(404、405 且没有机读码):三节都不画,和期 4 之前一样
|
||||
if (oldServer(slot.error)) return null
|
||||
return (
|
||||
<SourceShell state="error">
|
||||
<p className="text-dim" data-ev-prov-failed="">{P.failed}</p>
|
||||
</SourceShell>
|
||||
)
|
||||
}
|
||||
// 按片段换实例:展开的「技术细节」「另有 n 期」是这一格的状态,点到别的格子时收起
|
||||
return <Answer key={key} d={slot.data} />
|
||||
}
|
||||
|
||||
function oldServer(error: unknown): boolean {
|
||||
return error instanceof ApiError && (error.status === 404 || error.status === 405) && !error.code
|
||||
}
|
||||
|
||||
/** 三节画不画、推断的来源那一节画什么(P4-SPEC 4.1 的渲染矩阵) */
|
||||
interface Plan {
|
||||
version: boolean
|
||||
source: 'none' | 'reason' | 'alert' | 'cell'
|
||||
checks: boolean
|
||||
}
|
||||
|
||||
const NOTHING: Plan = { version: false, source: 'none', checks: false }
|
||||
|
||||
/**
|
||||
* 渲染矩阵。表外的组合不该出现(服务端的契约检查会拦),出现时按「table_only、无 alert」画:给出数据版本(有的话)
|
||||
* 和一句原因。alert 只在矩阵里列出的组合下画成红色
|
||||
*/
|
||||
function planOf(d: Provenance): Plan {
|
||||
const code = d.reason?.code
|
||||
const alert = d.alert?.code
|
||||
if (d.status === 'none') {
|
||||
if (!alert && (code === 'legacy_doc' || code === 'not_upload' || code === 'not_cell')) return NOTHING
|
||||
if (!alert && (code === 'not_sealed' || code === 'simple_upload')) return { version: false, source: 'reason', checks: false }
|
||||
if (alert === 'manifest_unreadable' || alert === 'chain_mismatch') return { version: false, source: 'alert', checks: false }
|
||||
} else if (d.status === 'table_only') {
|
||||
if (alert === 'db_tampered' || alert === 'chain_mismatch') return { version: true, source: 'alert', checks: false }
|
||||
if (!alert) return { version: true, source: 'reason', checks: false }
|
||||
} else if (d.status === 'inferred') {
|
||||
if (!alert && d.cell_source) return { version: true, source: 'cell', checks: true }
|
||||
}
|
||||
return { version: true, source: 'reason', checks: false }
|
||||
}
|
||||
|
||||
function Answer({ d }: { d: Provenance }) {
|
||||
const plan = planOf(d)
|
||||
const version = plan.version && d.version ? d.version : null
|
||||
const [manifest, setManifest] = useState<ProvenancePart | null>(null)
|
||||
if (plan.source === 'none') return null
|
||||
return (
|
||||
<>
|
||||
{version && <VersionPart v={version} sealed={d.sealed !== false} onManifest={setManifest} />}
|
||||
<SourceShell state={d.status}>
|
||||
{plan.source === 'alert' && d.alert && (
|
||||
// 标红:样式同 IntegrityList(失败色的框),放在这一节最前面;有它时不再画 reason.text
|
||||
<p className="flex items-start gap-1.5 rounded border px-2 py-1 [overflow-wrap:anywhere]" data-ev-prov-alert={d.alert.code}
|
||||
style={{ color: 'var(--st-failed)', borderColor: 'var(--st-failed)', background: 'var(--st-failed-soft)' }}>
|
||||
<AlertTriangle size={12} aria-hidden className="mt-0.5 shrink-0" />
|
||||
<span>{d.alert.text}</span>
|
||||
</p>
|
||||
)}
|
||||
{plan.source === 'reason' && d.reason?.text && (
|
||||
<p className="text-dim [overflow-wrap:anywhere]" data-ev-prov-reason={d.reason.code}>{d.reason.text}</p>
|
||||
)}
|
||||
{plan.source === 'cell' && d.cell_source && <CellPart cs={d.cell_source} version={d.version} />}
|
||||
</SourceShell>
|
||||
{plan.checks && Array.isArray(d.checks) && d.checks.length > 0 && <ChecksPart checks={d.checks} />}
|
||||
{manifest && createPortal(
|
||||
// 弹窗挂到 body 上:侧边面板是 fixed 的一层,里面的遮罩盖不住整页(同「打开完整快照」)
|
||||
<ManifestDialog part={manifest} onClose={() => setManifest(null)} />,
|
||||
document.body,
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/** 「推断,不属于已封存的证据」:推断的来源、相关核对两节的标题旁都挂 */
|
||||
function Badge() {
|
||||
return (
|
||||
<span className="chip shrink-0 text-faint" data-ev-prov-badge=""
|
||||
style={{ borderColor: 'var(--border-strong)', borderStyle: 'dashed' }}>
|
||||
{P.badge}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/** 推断出来的一节:虚线左边框,标题旁挂「推断」标签 */
|
||||
function Inferred({ title, children, ...rest }: { title: string; children: ReactNode } & Record<`data-${string}`, string>) {
|
||||
return (
|
||||
<div className="border-l-2 border-dashed pl-2" style={{ borderColor: 'var(--border-strong)' }} {...rest}>
|
||||
<div className="mb-1 flex flex-wrap items-center gap-x-1.5 gap-y-0.5">
|
||||
<h4 className={HEAD}>{title}</h4>
|
||||
<Badge />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 推断的来源一节的外壳:data-ev-provenance 写这一节的状态(inferred / table_only / none,取的过程中 loading,出错 error) */
|
||||
function SourceShell({ state, children }: { state: string; children: ReactNode }) {
|
||||
return <Inferred title={P.title} data-ev-provenance={state}>{children}</Inferred>
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 数据版本
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function VersionPart({ v, sealed, onManifest }: {
|
||||
v: ProvenanceVersion; sealed: boolean; onManifest: (part: ProvenancePart) => void
|
||||
}) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const moreId = useId()
|
||||
const parts = Array.isArray(v.parts) ? v.parts : []
|
||||
// 多于 3 期:这一格所在的一期和最近一期展开,其余收进「另有 n 期」
|
||||
const fold = parts.length > FOLD_AT
|
||||
const latest = parts[parts.length - 1]
|
||||
const keep = parts.filter((p) => p.has_row || p === latest)
|
||||
const folded = fold ? parts.length - keep.length : 0
|
||||
const shown = fold && !open ? keep : parts
|
||||
const tables = (Array.isArray(v.tables) ? v.tables : []).filter((t) => t && t.name)
|
||||
return (
|
||||
<div data-ev-prov-version="">
|
||||
<h4 className={clsx('mb-1', HEAD)}>{P.version}</h4>
|
||||
{!sealed && (
|
||||
// 封存那一行已经照实说了状态,这里只是不让「来自封存链」的说法越界:dim 色,不标红
|
||||
<p className="mb-1 text-2xs text-dim" data-ev-prov-unsealed="">{P.unsealed}</p>
|
||||
)}
|
||||
<p className="[overflow-wrap:anywhere]" data-ev-prov-head="">{P.versionHead(v.source, v.mode, parts.length)}</p>
|
||||
{tables.length > 0 && (
|
||||
<p className="mt-0.5 text-2xs text-dim [overflow-wrap:anywhere]" data-ev-prov-tables="">
|
||||
{P.tables(tables.map((t) => (t.kind === 'reported_total' ? P.totalTable(t.name) : t.name)))}
|
||||
</p>
|
||||
)}
|
||||
<ul className="mt-1 space-y-1.5" id={moreId}>
|
||||
{shown.map((p) => (
|
||||
<PartRow key={`${p.import_id}-${p.seq}`} p={p} manifest={v.manifest_view !== false} onManifest={onManifest} />
|
||||
))}
|
||||
</ul>
|
||||
{fold && folded > 0 && (
|
||||
// 展开后按钮还在、焦点留在它上面(同一个元素),再按一次收起
|
||||
<button type="button" className="btn btn-xs btn-ghost -ml-1 mt-1" aria-expanded={open} aria-controls={moreId}
|
||||
data-ev-prov-more="" onClick={() => setOpen((x) => !x)}>
|
||||
<ChevronRight size={11} aria-hidden className={clsx(open && 'rotate-90')} />
|
||||
{P.morePeriods(folded)}
|
||||
</button>
|
||||
)}
|
||||
{v.manifest_view === false && (
|
||||
// 清单里有核对细节里的数、标签原文、区域外文字:数据源设了遮罩时面板自己的入口不多暴露
|
||||
<p className="mt-1 text-2xs text-dim" data-ev-prov-manifest-masked="">{P.manifestMasked}</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 当前状态(取自导入记录,不在封存范围内):作废、清除后面加这枚小字 */
|
||||
function Current() {
|
||||
return <span className="chip ml-1.5 text-faint" data-ev-prov-current="">{P.current}</span>
|
||||
}
|
||||
|
||||
function PartRow({ p, manifest, onManifest }: {
|
||||
p: ProvenancePart; manifest: boolean; onManifest: (part: ProvenancePart) => void
|
||||
}) {
|
||||
const period = p.period && p.period.start && p.period.end ? p.period : null
|
||||
const purged = p.raw_state === 'purged' || !!p.purged
|
||||
const sha = typeof p.raw_sha256 === 'string' ? p.raw_sha256.slice(0, SHA_PREFIX) : ''
|
||||
const committed = stamp(p.committed_at)
|
||||
const facts = [
|
||||
p.file_name ? P.file(p.file_name, sha) : '',
|
||||
p.region ? P.region(p.region, p.excluded_rows) : p.excluded_rows ? P.excluded(p.excluded_rows) : '',
|
||||
period?.source === 'human' ? `${VERSIONS_TEXT.periodHuman}(${VERSIONS_TEXT.signedBy(period.signed_by || VERSIONS_TEXT.unsigned)})` : '',
|
||||
// 清除过的另起一行写清除记录和「当前状态」,这里不重复
|
||||
!purged && p.raw_state ? RAW_STATE_LABEL[p.raw_state] ?? '' : '',
|
||||
committed ? P.committedAt(committed) : '',
|
||||
p.recipe_seq != null ? VERSIONS_TEXT.recipeSeq(p.recipe_seq) : '',
|
||||
p.signed_by ? VERSIONS_TEXT.signedBy(p.signed_by) : '',
|
||||
].filter(Boolean)
|
||||
const accepts = Array.isArray(p.acceptances) ? p.acceptances : []
|
||||
return (
|
||||
<li className="min-w-0" data-ev-prov-part={String(p.seq)} data-ev-prov-has-row={p.has_row ? '' : undefined}>
|
||||
<div className="flex flex-wrap items-baseline gap-x-2 gap-y-0.5">
|
||||
<span className="tnum font-medium">{period ? P.part(p.seq, period.start, period.end) : P.partNoPeriod(p.seq)}</span>
|
||||
{p.has_row && (
|
||||
<span className="chip" style={{ color: 'var(--accent)', borderColor: 'var(--accent)' }} data-ev-prov-here="">{P.hasRow}</span>
|
||||
)}
|
||||
</div>
|
||||
{facts.length > 0 && <p className="text-2xs text-dim [overflow-wrap:anywhere]">{facts.join(' · ')}</p>}
|
||||
{purged && (
|
||||
<p className="mt-0.5 text-2xs text-dim [overflow-wrap:anywhere]" data-ev-prov-purged="">
|
||||
{RAW_STATE_LABEL.purged}
|
||||
{p.purged ? ` · ${P.stateDetail(stamp(p.purged.at), p.purged.reason, p.purged.signed_by)}` : ''}
|
||||
<Current />
|
||||
</p>
|
||||
)}
|
||||
{p.revoked && (
|
||||
<p className="mt-0.5 text-2xs [overflow-wrap:anywhere]" style={{ color: 'var(--st-waiting)' }} data-ev-prov-revoked="">
|
||||
{P.revoked} · {P.stateDetail(stamp(p.revoked.at), p.revoked.reason, p.revoked.signed_by)}
|
||||
<Current />
|
||||
</p>
|
||||
)}
|
||||
{accepts.length > 0 && (
|
||||
// 接受理由在清单里,是当时的事实:作废之后照旧列出
|
||||
<ul className="ml-3 mt-0.5 space-y-0.5 text-2xs text-dim">
|
||||
{accepts.map((a, i) => (
|
||||
<li key={`${a.check_id}-${i}`} className="[overflow-wrap:anywhere]" data-ev-prov-acceptance={a.check_id}>
|
||||
{P.acceptedLine(a.title || a.check_id, a.reason, a.signed_by)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{manifest && p.manifest && (
|
||||
<button type="button" className="btn btn-xs btn-ghost -ml-1 mt-0.5" data-ev-prov-manifest={p.manifest}
|
||||
onClick={() => onManifest(p)}>
|
||||
<FileText size={11} aria-hidden /> {P.manifest}
|
||||
</button>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看导入清单:版本页的清单渲染(ManifestBody),内容按清单的工件 id 经工件接口取(内容寻址,取回时复验哈希)。
|
||||
* 不用 ArtifactViewer:它对非表格内容整份 JSON 输出,遮罩不起作用,64 KB 的清单也没法读
|
||||
*/
|
||||
function ManifestDialog({ part, onClose }: { part: ProvenancePart; onClose: () => void }) {
|
||||
const [state, setState] = useState<{ id: string; content?: unknown; error?: unknown } | null>(null)
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
setState({ id: part.manifest })
|
||||
api.artifact(part.manifest).then(
|
||||
(res) => { if (alive) setState({ id: part.manifest, content: res?.content }) },
|
||||
(error) => { if (alive) setState({ id: part.manifest, error }) },
|
||||
)
|
||||
return () => { alive = false }
|
||||
}, [part.manifest])
|
||||
const mine = state?.id === part.manifest ? state : null
|
||||
const m: ManifestOut | null = mine?.content && typeof mine.content === 'object'
|
||||
? { artifact_id: part.manifest, verified: true, kind: 'import_manifest', content: mine.content as Record<string, any> }
|
||||
: null
|
||||
return (
|
||||
<Modal open onClose={onClose} width={920} title={VERSIONS_TEXT.manifestTitle(part.seq)}>
|
||||
{mine?.error
|
||||
? <ErrorState error={mine.error} />
|
||||
: !m
|
||||
? <Skeleton rows={5} height={36} gap={8} />
|
||||
: (
|
||||
<div data-ev-prov-manifest-view={part.manifest}>
|
||||
<ManifestBody m={m} fileName={part.file_name} rawState={part.raw_state} recipeSeq={part.recipe_seq} />
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 推断的来源:格子与逐条
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function CellPart({ cs, version }: { cs: ProvenanceCellSource; version: ProvenanceVersion | null }) {
|
||||
const [tech, setTech] = useState(false)
|
||||
const techId = useId()
|
||||
const parts = version?.parts ?? []
|
||||
const part = parts.find((p) => p.has_row) ?? parts.find((p) => p.seq === cs.part_seq)
|
||||
const items = fromItems(cs)
|
||||
const recheck = cs.recheck
|
||||
const sql = recheck?.sql ? (recheck.params?.length ? `${recheck.sql}\n-- ${JSON.stringify(recheck.params)}` : recheck.sql) : ''
|
||||
return (
|
||||
<>
|
||||
<p className="text-sm font-semibold [overflow-wrap:anywhere]" data-ev-prov-cell="">{P.cell(cs.sheet, cs.cell)}</p>
|
||||
{parts.length > 1 && (
|
||||
// 多期时坐标是哪一期原件的坐标:同一个位置在别的期的文件里是另一个数
|
||||
<p className="text-2xs text-dim [overflow-wrap:anywhere]" data-ev-prov-from-part="">
|
||||
{P.fromPart(cs.part_seq, part?.file_name ?? null)}
|
||||
</p>
|
||||
)}
|
||||
{items.length > 0 && (
|
||||
<ul className="mt-1 space-y-0.5 [overflow-wrap:anywhere]" data-ev-prov-from="">
|
||||
{items.map((it) => <li key={it.key} data-ev-prov-item={it.kind}>{it.text}</li>)}
|
||||
</ul>
|
||||
)}
|
||||
{cs.merged_fill && (
|
||||
<p className="mt-1 text-2xs [overflow-wrap:anywhere]" style={{ color: 'var(--st-waiting)' }} data-ev-prov-merged="">{P.mergedFill}</p>
|
||||
)}
|
||||
{cs.raw_purged && (
|
||||
<p className="mt-1 text-2xs [overflow-wrap:anywhere]" style={{ color: 'var(--st-waiting)' }} data-ev-prov-raw="">{P.rawPurged}</p>
|
||||
)}
|
||||
{(recheck?.ok || sql) && (
|
||||
<div className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-2xs text-faint">
|
||||
{recheck?.ok && <span data-ev-prov-recheck="">{P.recheck}</span>}
|
||||
{sql && (
|
||||
<button type="button" className="inline-flex items-center gap-0.5 rounded px-1 transition-colors hover:bg-hover hover:text-fg"
|
||||
aria-expanded={tech} aria-controls={techId} data-ev-prov-details="" onClick={() => setTech((x) => !x)}>
|
||||
<ChevronRight size={10} aria-hidden className={clsx(tech && 'rotate-90')} />
|
||||
{P.details}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{sql && (
|
||||
// 收起时留在 DOM 里(hidden):按钮的 aria-controls 始终指得到它
|
||||
<div className="mt-1" id={techId} hidden={!tech} data-ev-prov-tech="">
|
||||
<div className="mb-0.5 flex items-center gap-2">
|
||||
<span className="min-w-0 flex-1 text-2xs font-medium text-faint">{P.recheckSql}</span>
|
||||
<CopyChip label={EVIDENCE_TEXT.copySql} text={() => sql} />
|
||||
</div>
|
||||
<pre className="mono max-h-28 overflow-auto whitespace-pre-wrap rounded bg-bg px-1.5 py-1 text-2xs leading-relaxed text-dim [overflow-wrap:anywhere]">
|
||||
{sql}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
interface Item { key: string; kind: string; text: string }
|
||||
|
||||
/**
|
||||
* 逐条:这一行其余键列各取自哪一格,加上年份、规范写法、合计口径。顺序照 4.1:日期 → 年份 → 行标签 → 分段标题 →
|
||||
* 规范写法。坐标和格子同一张工作表时只写坐标,不同时带上工作表名。列表的多行表头合成一条
|
||||
*/
|
||||
function fromItems(cs: ProvenanceCellSource): Item[] {
|
||||
const from: ProvenanceFromCell[] = Array.isArray(cs.from) ? cs.from.filter((f) => f && f.cell) : []
|
||||
const ref = (f: ProvenanceFromCell) => (f.sheet && f.sheet !== cs.sheet ? `${f.sheet}!${f.cell}` : f.cell)
|
||||
const year = yearItem(cs)
|
||||
const heads = from.filter((f) => f.role === 'col_header')
|
||||
const out: Item[] = []
|
||||
let yearDone = false
|
||||
from.forEach((f, i) => {
|
||||
const key = `${f.role}-${i}`
|
||||
if (f.role === 'axis_header') {
|
||||
out.push({ key, kind: f.role, text: P.axisHeader(ref(f)) })
|
||||
if (year && !yearDone) { out.push(year); yearDone = true }
|
||||
} else if (f.role === 'row_label') {
|
||||
out.push({ key, kind: f.role, text: P.rowLabel(ref(f), f.text) })
|
||||
} else if (f.role === 'section_title') {
|
||||
out.push({ key, kind: f.role, text: P.sectionTitle(ref(f), f.locate_title) })
|
||||
} else if (f.role === 'total_label') {
|
||||
out.push({ key, kind: f.role, text: P.totalLabel(ref(f), f.text) })
|
||||
} else if (f.role === 'col_header' && f === heads[0]) {
|
||||
out.push({ key, kind: f.role, text: P.colHeader(heads.map(ref).join('、')) })
|
||||
}
|
||||
})
|
||||
if (year && !yearDone) out.push(year)
|
||||
if (cs.canonical?.raw && cs.canonical.canonical) {
|
||||
out.push({ key: 'canonical', kind: 'canonical', text: P.canonical(cs.canonical.raw, cs.canonical.canonical) })
|
||||
}
|
||||
if (cs.kind === 'reported_total') out.push({ key: 'total', kind: 'reported_total', text: P.reportedTotal })
|
||||
return out
|
||||
}
|
||||
|
||||
function yearItem(cs: ProvenanceCellSource): Item | null {
|
||||
const y = cs.year
|
||||
if (!y) return null
|
||||
// mixed:清单只记每块的表头形式,逐格判断不了,照实说,不断言这一格属于哪一种
|
||||
const text = y.mixed ? P.yearMixed
|
||||
: y.source === 'human' ? P.yearHuman(y.signed_by || VERSIONS_TEXT.unsigned)
|
||||
: P.yearPeriod((Array.isArray(y.cells) ? y.cells : []).join('、'))
|
||||
return { key: 'year', kind: 'year', text }
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 相关核对
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** 状态的颜色只用令牌:成立 / 一致是 done,不成立是 failed,未能核对、无法确定是 waiting,其余中性 */
|
||||
const TONE: Record<string, string> = {
|
||||
passed: 'var(--st-done)',
|
||||
ok: 'var(--st-done)',
|
||||
mismatch: 'var(--st-failed)',
|
||||
unverifiable: 'var(--st-waiting)',
|
||||
unknown: 'var(--st-waiting)',
|
||||
}
|
||||
|
||||
function ChecksPart({ checks }: { checks: ProvenanceCheck[] }) {
|
||||
return (
|
||||
<Inferred title={P.checks} data-ev-prov-checks="">
|
||||
<ul className="space-y-1">
|
||||
{checks.map((c, i) => <CheckRow key={`${c.id}-${i}`} c={c} />)}
|
||||
</ul>
|
||||
</Inferred>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 一条核对:「编号 标题 — 这一行成立」(关系核对看行级结果,合计看格级结果,其余看本期结论)。本期结论不成立或未能
|
||||
* 核对时另起一行写出来,写过理由的接在后面:「本期不成立 · 已接受,理由:…」——行级成立、本期不成立(别的日子不成立、
|
||||
* 已接受)两件事都要看得到。口径不同(R2)不判行,本期结论就是「口径说明」,和别的核对同一种写法,扫读时对得齐
|
||||
*/
|
||||
function CheckRow({ c }: { c: ProvenanceCheck }) {
|
||||
const main: { code: string; text: string } | null = c.row_status
|
||||
? { code: c.row_status, text: P.row[c.row_status] ?? c.row_status }
|
||||
: c.cell_status ? { code: c.cell_status, text: P.cellStatus[c.cell_status] ?? c.cell_status }
|
||||
: null
|
||||
const partText = P.partStatus[c.part_status] ?? c.part_status
|
||||
// 没有行级、格级结果的(统计期、口径之外的核对)主行就写本期结论,理由接在同一行
|
||||
const lead = main ?? { code: c.part_status, text: partText }
|
||||
const accepted = c.acceptance ? P.accepted(c.acceptance.reason, c.acceptance.signed_by) : ''
|
||||
const showPart = !!main && (c.part_status === 'mismatch' || c.part_status === 'unverifiable')
|
||||
const second = main ? [showPart ? partText : '', accepted].filter(Boolean).join(' · ') : ''
|
||||
return (
|
||||
<li className="min-w-0 [overflow-wrap:anywhere]" data-ev-prov-check={c.id} data-ev-prov-part-status={c.part_status}
|
||||
data-ev-prov-row={c.row_status ?? undefined} data-ev-prov-cell-status={c.cell_status ?? undefined}>
|
||||
<p>
|
||||
<span className="mono mr-1 text-faint">{c.id}</span>
|
||||
<span>{c.title}</span>
|
||||
{' — '}
|
||||
<span style={{ color: TONE[lead.code] ?? 'var(--text-dim)' }} data-ev-prov-status="">{lead.text}</span>
|
||||
{!main && accepted && <span className="text-dim"> · {accepted}</span>}
|
||||
</p>
|
||||
{second && <p className="text-2xs text-dim" data-ev-prov-period="">{second}</p>}
|
||||
{c.detail && <p className="text-2xs text-faint" data-ev-prov-detail="">{c.detail}</p>}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,8 @@ import { create } from 'zustand'
|
||||
import { ApiError, api } from '../api/client'
|
||||
import { graphVerdicts, judgedVerdicts, sqlOf } from '../lib/evidence'
|
||||
import type {
|
||||
EvidenceDocData, EvidenceGraph, EvidenceJudgeResult, EvidenceSegmentDetail, EvidenceStats, EvidenceVerdict,
|
||||
EvidenceDocData, EvidenceGraph, EvidenceJudgeResult, EvidenceProvenance, EvidenceSegmentDetail, EvidenceStats,
|
||||
EvidenceVerdict,
|
||||
} from '../types'
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,11 @@ import type {
|
||||
* 四期:封存之后按需追加的结论句判定按 `runId@报告` 记在 judged 里(按需裁判接口、片段接口叠上的
|
||||
* 判定都记进来),正文的句末徽标、横幅的结论句计数据此盖过文档里的「未裁判 · 按需」。封存的文档本身
|
||||
* 一个字不改。同一句正在判的不重复发;判过的(判定不是未裁判)不再给按钮,也就不会再发
|
||||
*
|
||||
* Excel 导入期 4:推断的来源按片段的缓存键记在 provenance 里,但**只在面板开着期间有效**。回答里有当前状态
|
||||
* (原件已清除、接受已作废)和取决于数据文件现状的结论(被修改过、已回收),在版本页清除、作废、回滚之后,
|
||||
* 关掉面板再打开就要看到新结论。所以面板挂载时 holdProvenance,最后一个面板关掉(或换了运行)时清掉这次
|
||||
* 运行的槽;同一次打开里来回点同一片段只取一次
|
||||
*/
|
||||
|
||||
export interface Slot<T> {
|
||||
@@ -69,6 +75,14 @@ interface EvidenceState {
|
||||
asks: Record<string, Slot<EvidenceJudgeResult>>
|
||||
/** 运行类别(formal / exploratory):没开裁判的文档靠它认探索运行,按需取一次 */
|
||||
runClasses: Record<string, Slot<string | null>>
|
||||
/** 推断的来源(Excel 导入期 4),键同 segmentKey。只在面板开着期间有效,见 holdProvenance */
|
||||
provenance: Record<string, Slot<EvidenceProvenance>>
|
||||
loadProvenance: (runId: string, segmentId: string, report?: string) => Promise<void>
|
||||
/**
|
||||
* 证据面板挂载时调用,返回释放函数(面板卸载、换了运行时调)。这次运行最后一个面板释放后,清掉它的推断来源槽:
|
||||
* 关掉面板再打开会重新取
|
||||
*/
|
||||
holdProvenance: (runId: string) => () => void
|
||||
/** 记下几句封存后追加的判定(片段接口叠上的、证据图带来的) */
|
||||
noteVerdicts: (runId: string, report: string | undefined, verdicts: Record<string, EvidenceVerdict>) => void
|
||||
/** 请模型判断这几句(探索运行)。判定记进 judged;答复(含触顶、出错)记进 asks */
|
||||
@@ -101,12 +115,17 @@ export class NotADocError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 每次运行开着几个证据面板。放在模块里不放进 store:它只决定什么时候清缓存,界面不读它,变了也不该重渲染
|
||||
*/
|
||||
const provenanceHolds = new Map<string, number>()
|
||||
|
||||
export const useEvidence = create<EvidenceState>((set, get) => {
|
||||
/**
|
||||
* 取一次、记进 table[key];正在取或已经取到的不再发。取的途中这一格被清掉或换了(dropLatest 之后
|
||||
* 又起了一次),回来的结果作废:不能让早先发出的请求把后来那份盖掉
|
||||
*/
|
||||
async function fill<K extends 'docs' | 'graphs' | 'segments' | 'latest' | 'sqls'>(
|
||||
async function fill<K extends 'docs' | 'graphs' | 'segments' | 'latest' | 'sqls' | 'provenance'>(
|
||||
table: K, key: string, fetcher: () => Promise<NonNullable<EvidenceState[K][string]['data']>>, force = false,
|
||||
) {
|
||||
const cur = get()[table][key]
|
||||
@@ -190,6 +209,33 @@ export const useEvidence = create<EvidenceState>((set, get) => {
|
||||
mark({ status: 'error', error })
|
||||
}
|
||||
},
|
||||
provenance: {},
|
||||
loadProvenance: (runId, segmentId, report) =>
|
||||
fill('provenance', segmentKey(runId, segmentId, report), () => api.evidence.provenance(runId, segmentId, { report })),
|
||||
holdProvenance: (runId) => {
|
||||
provenanceHolds.set(runId, (provenanceHolds.get(runId) ?? 0) + 1)
|
||||
let released = false
|
||||
return () => {
|
||||
if (released) return
|
||||
released = true
|
||||
const left = (provenanceHolds.get(runId) ?? 1) - 1
|
||||
if (left > 0) {
|
||||
provenanceHolds.set(runId, left)
|
||||
return
|
||||
}
|
||||
provenanceHolds.delete(runId)
|
||||
// 推到这一轮之后再清:开发期 StrictMode 把挂载的 effect 先清理、紧接着再跑一遍(又 hold 回来),
|
||||
// 同一次提交里一个面板关、另一个面板开也是这样——这两种都不算「面板关了」
|
||||
queueMicrotask(() => {
|
||||
if (provenanceHolds.has(runId)) return
|
||||
const prefix = `${runId}:`
|
||||
const cur = get().provenance
|
||||
if (!Object.keys(cur).some((k) => k.startsWith(prefix))) return
|
||||
// 正在取的也清掉:fill 只在槽还是它自己放的那一份时才落结果,晚到的回包作废
|
||||
set({ provenance: Object.fromEntries(Object.entries(cur).filter(([k]) => !k.startsWith(prefix))) })
|
||||
})
|
||||
}
|
||||
},
|
||||
loadRunClass: (runId) => {
|
||||
const cur = get().runClasses[runId]
|
||||
if (cur && cur.status !== 'error') return Promise.resolve()
|
||||
|
||||
@@ -550,6 +550,11 @@ export interface OutsideText {
|
||||
text: string
|
||||
kind: 'text' | 'text_digits' | (string & {})
|
||||
period_source?: boolean
|
||||
/**
|
||||
* 期 4:所在行或列是否被隐藏(执行器写入)。true 在隐藏行列里;false 可见;null 或没有这个键:导入时没有记录
|
||||
* (期 4 之前的清单)。裁判摘录只送 false 的项,界面照常显示全部区域外文字
|
||||
*/
|
||||
hidden?: boolean | null
|
||||
}
|
||||
|
||||
/** 试运行回执(Extraction 去掉问题和核对之后给界面看的部分) */
|
||||
@@ -2117,6 +2122,11 @@ export interface EvidenceStep extends Omit<EvidenceInput, 'status'> {
|
||||
note?: string
|
||||
/** 数据源改名或删掉了、按查询当时记下的遮罩处理时的那句说明。行照样有 */
|
||||
mask_note?: string
|
||||
/**
|
||||
* 期 4:可以请求推断来源(GET …/segments/{sid}/provenance)。只有带文档标记的报告、单元格片段的查询步骤、
|
||||
* 查询快照来自上传的表格时才有,且恒为 true;其余一个键都不加。前端只在 seg.cite?.kind === 'cell' 且它为 true 时请求
|
||||
*/
|
||||
provenance?: boolean
|
||||
// ---- entity:表或字段(三期)----
|
||||
/** entity:table / column */
|
||||
kind?: string
|
||||
@@ -2237,3 +2247,227 @@ export interface EvidenceSegmentDetail {
|
||||
/** 可疑实体:最接近的已知名字(最多 3 个),给「是不是想写…」 */
|
||||
closest?: (string | { alias?: string; name?: string; table?: string; kind?: string })[]
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 期 4:推断的来源(GET /runs/{id}/evidence/segments/{sid}/provenance?report=…)
|
||||
// 契约照 backend/app/data/provenance_types.py(asdict 之后的 JSON,P4-SPEC 2.8.1)。这是期 4 新加的接口,
|
||||
// 答复里每个键都在(值可以是 null),所以这里不写成可选;老服务端没有这个接口时回 404 且没有 code,三节都不画。
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** inferred 给出格子;table_only 只给表级来历(version 非空);none 不画,或只画一句原因 / 红色提示 */
|
||||
export type ProvenanceStatus = 'inferred' | 'table_only' | 'none'
|
||||
|
||||
/** 不下钻的原因(provenance_types.ReasonCode)。界面不按它拼字,原样显示服务端给的 reason.text */
|
||||
export type ProvenanceReasonCode =
|
||||
| 'legacy_doc' | 'not_cell' | 'not_sealed' | 'not_upload' | 'simple_upload' | 'manifest_unreadable'
|
||||
| 'chain_mismatch' | 'expression' | 'alias' | 'multi_table' | 'unparsed' | 'no_pk' | 'pk_missing' | 'masked'
|
||||
| 'null_value' | 'null_pk' | 'snapshot_gone' | 'db_tampered' | 'recheck_missing' | 'recheck_multiple'
|
||||
| 'recheck_mismatch' | 'no_lineage'
|
||||
|
||||
/** 标红的提示:出现时 reason.code 与它相同,界面只画提示 */
|
||||
export type ProvenanceAlertCode = 'db_tampered' | 'chain_mismatch' | 'manifest_unreadable'
|
||||
|
||||
/** 附带的格:日期表头格、行标签、分段标题、列表头、合计标签 */
|
||||
export type ProvenanceFromRole = 'axis_header' | 'row_label' | 'section_title' | 'col_header' | 'total_label'
|
||||
|
||||
/** 本期结论(照搬清单里 CheckResult.status) */
|
||||
export type ProvenancePartStatus = 'passed' | 'mismatch' | 'unverifiable' | 'info'
|
||||
/** 这一行的关系核对结果(只给关系核对) */
|
||||
export type ProvenanceRowStatus = 'passed' | 'mismatch' | 'unverifiable'
|
||||
/** 这一格的合计核对结果(只给 K、G、T) */
|
||||
export type ProvenanceCellStatus = 'ok' | 'unverifiable' | 'unknown' | 'not_formula'
|
||||
|
||||
export interface ProvenanceReportRef {
|
||||
node_id: string
|
||||
doc_artifact: string
|
||||
}
|
||||
|
||||
/** 片段本身是单元格引用就给(与 status 无关),不是时为 null */
|
||||
export interface ProvenanceCellRef {
|
||||
/** 目录里的查询编号(Q3) */
|
||||
alias: string
|
||||
row: number
|
||||
column: string
|
||||
/** 查询快照的工件 id */
|
||||
artifact: string | null
|
||||
}
|
||||
|
||||
export interface ProvenanceReason {
|
||||
code: ProvenanceReasonCode
|
||||
/** 细分,给测试和日志用,界面不显示 */
|
||||
detail: string
|
||||
/** 界面原样显示 */
|
||||
text: string
|
||||
}
|
||||
|
||||
export interface ProvenanceAlert {
|
||||
code: ProvenanceAlertCode
|
||||
text: string
|
||||
}
|
||||
|
||||
export interface ProvenanceTableRef {
|
||||
name: string
|
||||
kind: 'data' | 'reported_total'
|
||||
}
|
||||
|
||||
export interface ProvenancePeriod {
|
||||
start: string
|
||||
end: string
|
||||
source: 'cells' | 'human'
|
||||
/** 解析出统计期的格子,带工作表名(「客流汇总!B2」) */
|
||||
cells: string[]
|
||||
/** 人工录入时的署名(未认证) */
|
||||
signed_by: string | null
|
||||
}
|
||||
|
||||
/** 一条接受理由(导入清单里的,内容寻址,是当时的事实) */
|
||||
export interface ProvenanceAcceptance {
|
||||
check_id: string
|
||||
title: string | null
|
||||
kind: 'override' | 'waiver'
|
||||
reason: string
|
||||
signed_by: string | null
|
||||
at: string | null
|
||||
}
|
||||
|
||||
/** 导入记录上的当前状态(清除原件、作废接受) */
|
||||
export interface ProvenanceStateNote {
|
||||
at: string | null
|
||||
signed_by: string | null
|
||||
reason: string | null
|
||||
}
|
||||
|
||||
/** 数据版本里的一期(按统计期升序)。raw_state、purged、revoked 是当前状态,界面标「当前状态」 */
|
||||
export interface ProvenancePart {
|
||||
import_id: string
|
||||
seq: number
|
||||
/** 导入清单的工件 id:「查看导入清单」按它经 /api/artifacts/{id} 取 */
|
||||
manifest: string
|
||||
/** 没有统计期时 null(「统计期未记录」) */
|
||||
period: ProvenancePeriod | null
|
||||
file_name: string | null
|
||||
raw_sha256: string | null
|
||||
/** 区域(「客流汇总!B4:AG30」,多张表用「、」连);取不到为 null */
|
||||
region: string | null
|
||||
/** 排除的行数之和;期 3 之前的回执没有记录时为 null */
|
||||
excluded_rows: number | null
|
||||
recipe_sha256: string | null
|
||||
/** 配方第几版(当前状态);取不到为 null */
|
||||
recipe_seq: number | null
|
||||
/** 导入时间(清单的 created_at) */
|
||||
committed_at: string | null
|
||||
/** 署名(未认证) */
|
||||
signed_by: string | null
|
||||
acceptances: ProvenanceAcceptance[]
|
||||
raw_state: 'kept' | 'purged' | 'absent' | null
|
||||
purged: ProvenanceStateNote | null
|
||||
revoked: ProvenanceStateNote | null
|
||||
/** 这一格所在的一期:inferred 时恰好一项为 true */
|
||||
has_row: boolean
|
||||
}
|
||||
|
||||
/** 数据版本(表级来历),来自封存链上的清单,不加「推断」标注 */
|
||||
export interface ProvenanceVersion {
|
||||
source: string
|
||||
snapshot_id: string
|
||||
mode: 'replace' | 'accumulate'
|
||||
union: boolean
|
||||
tables: ProvenanceTableRef[]
|
||||
/** false:数据源设有遮罩,不出「查看导入清单」 */
|
||||
manifest_view: boolean
|
||||
parts: ProvenancePart[]
|
||||
}
|
||||
|
||||
export interface ProvenanceFromCell {
|
||||
role: ProvenanceFromRole
|
||||
/** 这一格给出的是哪一列的值;宽表指标列的行标签(指标名取自哪一格)为 null */
|
||||
column: string | null
|
||||
sheet: string
|
||||
/** 不带工作表名的坐标(「G4」) */
|
||||
cell: string
|
||||
/** 格子原文;拿不到为 null */
|
||||
text: string | null
|
||||
/** 只给分段标题:配方中的定位文字 */
|
||||
locate_title: string | null
|
||||
}
|
||||
|
||||
export interface ProvenanceYear {
|
||||
source: 'period' | 'human'
|
||||
cells: string[]
|
||||
signed_by: string | null
|
||||
/** 这一块的日期表头有的是日期格、有的是文本,无法确定这一格属于哪一种 */
|
||||
mixed: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 这一行标签列(交叉表的维度、合计表的合计项)的原文与数据库里的规范写法不同时给出。被引用的是值列也给:
|
||||
* 合计表那一格是「18-22 时合计」→「18-22时合计」,全角标签那一期的值格是「8-9」→「8-9」
|
||||
*/
|
||||
export interface ProvenanceCanonical {
|
||||
raw: string
|
||||
canonical: string
|
||||
}
|
||||
|
||||
export interface ProvenanceRecheck {
|
||||
/** 占位符一律是 ?,按主键的顺序与 params 一一对应 */
|
||||
sql: string
|
||||
params: unknown[]
|
||||
ok: boolean
|
||||
}
|
||||
|
||||
/** 推断出的格子(只在 inferred 时有) */
|
||||
export interface ProvenanceCellSource {
|
||||
table: string
|
||||
column: string
|
||||
column_role: 'axis' | 'dim' | 'derive' | 'const' | 'measure' | 'value' | 'text' | (string & {})
|
||||
kind: 'data' | 'reported_total'
|
||||
pk: Record<string, unknown>
|
||||
/** 快照库的 rowid(累积时是合并后的行号) */
|
||||
rowid: number
|
||||
part_seq: number
|
||||
part_rowid: number
|
||||
sheet: string
|
||||
/** 不带工作表名的坐标(「G5」) */
|
||||
cell: string
|
||||
header: string | null
|
||||
unit: string | null
|
||||
from: ProvenanceFromCell[]
|
||||
year: ProvenanceYear | null
|
||||
canonical: ProvenanceCanonical | null
|
||||
raw_purged: boolean
|
||||
/** 列表这一块按合并单元格的左上格填充 */
|
||||
merged_fill: boolean
|
||||
recheck: ProvenanceRecheck
|
||||
}
|
||||
|
||||
/** 相关核对的一条(只在 inferred 时有) */
|
||||
export interface ProvenanceCheck {
|
||||
id: string
|
||||
kind: string
|
||||
title: string
|
||||
part_status: ProvenancePartStatus
|
||||
row_status: ProvenanceRowStatus | null
|
||||
cell_status: ProvenanceCellStatus | null
|
||||
acceptance: ProvenanceAcceptance | null
|
||||
/** K 无法核对时的原因摘要(可能带数字,系统呈现) */
|
||||
detail: string | null
|
||||
}
|
||||
|
||||
/** GET /runs/{id}/evidence/segments/{sid}/provenance:推断的来源 */
|
||||
export interface EvidenceProvenance {
|
||||
schema: 'agentlab.provenance/1' | (string & {})
|
||||
report: ProvenanceReportRef
|
||||
segment: string
|
||||
cell: ProvenanceCellRef | null
|
||||
status: ProvenanceStatus
|
||||
/** status 不是 inferred 时必有 */
|
||||
reason: ProvenanceReason | null
|
||||
/** 标红;有它时不再画 reason.text */
|
||||
alert: ProvenanceAlert | null
|
||||
/** 运行已封存且封存核对通过;false 时数据版本一节加一句未封存 */
|
||||
sealed: boolean
|
||||
/** status 为 none 时为 null */
|
||||
version: ProvenanceVersion | null
|
||||
cell_source: ProvenanceCellSource | null
|
||||
checks: ProvenanceCheck[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user