mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-25 02:22:22 +00:00
可点击证据第一期:报告里的每个数字都点得开出处
「引用即渲染」:写报告的模型只写引用标记([[m:指标id]]、[[i:输入字段]]、[[see:…]]),数值由系统按口径卡
填进去,每个数字都挂着一条能复算的证据链。本期是数字层闭环;实体、结论句的概率性证据放在后续几期。
内核(engine/evidence.py,口径卡、出具契约、表达式等)
- 口径卡记录每个指标的来源:原式、代入式(每个输入写成「值 ← 路径」)、复算结果、口径与版本
- 出具契约的数值匹配改为按位置标注;同一个值有几个出处时记为「出处不唯一」并列出候选,不再随便挑一个
- 证据 id 由内容派生,事后对不上就是被改过;零值、结构性数字(列表序号、代码块标签)单独处理
- 口径卡新增 on_missing:缺输入时默认仍是整个节点失败,可以改成记为空值、交给契约判档
报告撰写节点(report)与引用模式的出具契约
- 流式生成时 token 里就是真实数字,不会漏出原始标记;裸数字、不存在的引用当场判违规,交回去重写
(max_repairs,默认 1 次);仍不过时按 on_violation 失败(正式运行默认)或把违规标在报告里(探索运行默认)
- report.checked 事件记下核对结果,落在封存范围内;fail 模式下仍不过时带 failed,运行记录里画成失败
- 出具契约写了 report_from 就按引用核对:取回文档时复验哈希,独立重算一遍,全部带引用才判完整出具
- 成果字段逐字等于报告正文时标注 _evidence;复核只能加说明,不能改写带证据的答案(前后端各拦一道)
证据接口
- GET /api/runs/{id}/evidence 返回证据图;GET …/evidence/segments/{id} 返回一个片段的证据链
- 只认封存范围内的事件能追到的工件,不读 artifacts 表;封存被改过时不把任何一项标成已封存
- 没有报告的旧运行降级为 none 或 legacy_contract
界面
- EvidenceDoc 按块、句、片段渲染报告,片段是和正文一样的按钮;整份报告只占一个 Tab 位,
←/→ 在片段间移动、↑/↓ 按句、n/N 跳到下一处「无证据」、Enter 打开面板、Esc 关闭并把焦点还回去
- EvidencePanel:宽屏侧边、窄屏底部抽屉、360px 画布右栏里栏内展开;显示指标步骤、代入式、复算结果、
封存状态。正文不是封存的那份报告时明确说出来,不拿别的报告的封存画绿
- 出具横幅多一行「N/N 数字有出处 · 无证据 M」和「定位下一处」;没有 _evidence 的旧回答渲染一字不差
- 画布认得报告撰写节点;Copilot 手册补上口径卡、报告节点、出具契约的写法;新增模板「⑨ 可追溯周报」
验证(沙箱):tsc 干净,生产构建通过,pytest 1601 passed,check-all 16 项检查全绿(新增 check-evidence)。
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import type { RunEvent, TeamMember, TeamRound, TeamRun, ToolChange } from '../types'
|
||||
import type { NodeState, RunPhase } from './trace'
|
||||
import { formatDuration, formatNumber } from '../lib/format'
|
||||
import { TYPE_LABEL, issuanceLabel, nodeTypeLabel } from '../lib/terms'
|
||||
import { TYPE_LABEL, evidenceTally, issuanceLabel, nodeTypeLabel } from '../lib/terms'
|
||||
import { statsTally } from '../lib/evidence'
|
||||
|
||||
// 泳道数据画布也要用(supervisor 节点要展开成协作矩阵),所以类型放在
|
||||
// types.ts 里;这里再导出一遍,老引用不用改
|
||||
@@ -675,6 +676,16 @@ function explainLog(code: string | undefined, message: string): Pick<Step, 'titl
|
||||
fix: 'canvas',
|
||||
}
|
||||
}
|
||||
case 'report_repair': {
|
||||
// 「报告里有 3 处没通过核对(「12」「m:nope」),已要求写作者重写(第 1 次)」。没通过的
|
||||
// 不只是裸数字,还有解析不了的引用(m:nope),标题不能只说「没写引用」
|
||||
const n = message.match(/报告里有\s*(\d+)\s*处/)?.[1]
|
||||
const round = message.match(/第\s*(\d+)\s*次/)?.[1]
|
||||
return {
|
||||
title: `报告${n ? `有 ${n} 处` : ''}没通过核对,已让模型按清单重写${round ? `(第 ${round} 次)` : ''}`,
|
||||
sub: message.match(/没通过核对((.+?))/)?.[1],
|
||||
}
|
||||
}
|
||||
case 'repair_invented': {
|
||||
// 「第 1 次修复作废:修复时出现了原文没有的值:total_count=0」
|
||||
const values = message.match(/原文没有的值[::]\s*(.+)$/)?.[1]?.trim()
|
||||
@@ -1574,6 +1585,31 @@ export function decodeRun(events: RunEvent[], final?: RunFinal, opts?: DecodeOpt
|
||||
break
|
||||
}
|
||||
|
||||
case 'report.checked': {
|
||||
// 报告撰写节点核对完自己写的报告:几个数字有出处、哪些地方没有证据。说法和出具
|
||||
// 横幅那一行同一种(evidenceTally)。载荷缺字段(别的版本的后端)就只说核对过
|
||||
// 前半句只数数字(无证据 = 总数 − 有出处,算得平),不是数字的解析不了的引用另起一句
|
||||
const counts = statsTally(d.stats && typeof d.stats === 'object' ? d.stats : null)
|
||||
const none = counts ? counts.none + counts.other : 0
|
||||
const violations: any[] = Array.isArray(d.violations) ? d.violations : []
|
||||
const repairs = num(d.repairs) ?? 0
|
||||
const tally = counts ? evidenceTally(counts.cited, counts.total, counts.other) : ''
|
||||
const listed = violations.slice(0, 8)
|
||||
.map((v) => `· ${String(v?.message ?? v?.text ?? v?.code ?? '')}`).filter((x) => x.length > 2)
|
||||
const more = violations.length > listed.length ? [`…另有 ${violations.length - listed.length} 处`] : []
|
||||
// on_violation=fail 且重写后仍不过:节点接着就失败,这一步不能画成完成。老后端没有 failed 字段,照旧
|
||||
const failed = d.failed === true
|
||||
push({
|
||||
id: `rc-${seq}`, seq, kind: 'issuance', nodeId, status: failed ? 'failed' : 'done', code: 'report_checked',
|
||||
level: failed ? 'error' : none || violations.length ? 'warn' : 'info',
|
||||
title: tally ? `核对报告:${tally}` : '核对报告',
|
||||
...(listed.length ? { detail: [...listed, ...more].join('\n') } : {}),
|
||||
...(repairs ? { meta: `重写 ${repairs} 次` } : {}),
|
||||
...(typeof d.doc_artifact === 'string' && d.doc_artifact ? { artifact: d.doc_artifact } : {}),
|
||||
}, nodeId)
|
||||
break
|
||||
}
|
||||
|
||||
case 'caliber.upgrade':
|
||||
out.push({
|
||||
id: `cu-${seq}`, seq, kind: 'note', level: 'warn', status: 'done',
|
||||
|
||||
Reference in New Issue
Block a user