mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-25 02:52:43 +00:00
结论句裁判改造:「不支持」拆成「证据相矛盾」和「证据不足」,补全交给裁判的证据,旧判定可按新规则重判
- 判定取值改为:支持 / 部分支持 / 证据相矛盾 / 证据不足 / 不是结论。只有证据和句子冲突才判相矛盾; 证据里没有相关信息判证据不足,并写明缺什么(比如 SQL、字段清单) - 出具判档不变松:证据相矛盾按 on_unsupported 降档或不予出具;证据不足记一条缺口,最多降档、不能判完整出具; 改造前的「证据不支持」照旧当相矛盾处理 - 补全证据摘录:表名附字段清单和类型(最多 60 个,快照不全时注明,遮罩列不列);口径卡指标附上每个输入 取自哪次查询、哪一格,以及那次查询的 SQL;一律只读封存范围内的工件 - 理由上限从 60 字放宽到 120 字,在句子边界截断,不再截在半句中间 - 裁判模型:按需裁判也判断是否和写作模型相同、是否在价格表里,证据面板里醒目提示; 设置页没配裁判模型时写明「未单独配置,将使用助手的模型」 - 新判定带规则版本:改造前的判定在界面上标「按旧规则判定」,可以请模型按当前规则重新判断 - 界面:证据相矛盾用红色;证据不足用中性色和 ○,写明缺什么;讲方法、讲结构的句子在证据面板里直接列出 对应的 SQL 和字段清单;出具横幅、审计表、报告节点印章的计数都分开这两档 - 顺带写稳 check-publish 里一条等按钮状态的断言(并行时偶发)
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
} from './decode'
|
||||
import { CODE_COLUMN, CopyChip, LEADING_ZERO, Markdown, type MarkSpec } from './Markdown'
|
||||
import { ClaimTally, EvidenceField, type EvidenceDocHandle } from './EvidenceDoc'
|
||||
import { EVIDENCE_STATE, docTally, evidenceFields, issuanceMarks, type EvidenceTally } from '../lib/evidence'
|
||||
import { EVIDENCE_STATE, claimProblems, docTally, evidenceFields, issuanceMarks, type EvidenceTally } from '../lib/evidence'
|
||||
import type { EvidenceDocData } from '../types'
|
||||
import { useRunClock } from './useRunClock'
|
||||
import type { ReviewResult } from '../types'
|
||||
@@ -2289,7 +2289,7 @@ export function IssuanceBanner({ issuance, runClass, evidence }: {
|
||||
{meta.hint && <div className="mt-1 text-2xs leading-relaxed text-dim">{meta.hint}</div>}
|
||||
{counts && (counts.total > 0 || counts.other > 0 || suspect > 0 || uncitedClaims > 0 || !!claims) && (
|
||||
// 逐段证据的计数:和报告核对那一行、证据条同一种说法。可疑名字、没挂依据的结论句不是数字,
|
||||
// 各自另起一句。有无证据的数字、可疑名字、证据不支持(或部分支持)的结论句时才给「定位下一处」——
|
||||
// 各自另起一句。有无证据的数字、可疑名字、证据有问题(相矛盾、部分有依据、证据不足)的结论句时才给「定位下一处」——
|
||||
// 结论句靠句末徽标定位;只是没挂依据的结论句没有徽标,定位不到
|
||||
<div className="mt-1 flex flex-wrap items-center gap-2 text-2xs" data-evidence-line="">
|
||||
{numbers && (
|
||||
@@ -2307,7 +2307,7 @@ export function IssuanceBanner({ issuance, runClass, evidence }: {
|
||||
{numbers || suspect > 0 || claims ? '· ' : ''}{EVIDENCE_TEXT.uncitedClaimsTag} {formatNumber(uncitedClaims)}
|
||||
</span>
|
||||
)}
|
||||
{(counts.none > 0 || counts.other > 0 || suspect > 0 || !!claims?.unsupported || !!claims?.partial) && evidence?.onNext && (
|
||||
{(counts.none > 0 || counts.other > 0 || suspect > 0 || claimProblems(claims) > 0) && evidence?.onNext && (
|
||||
<button type="button" className="btn btn-xs" data-evidence-next="" onClick={evidence.onNext}>
|
||||
{EVIDENCE_TEXT.locateNext}
|
||||
</button>
|
||||
|
||||
@@ -8,8 +8,9 @@ import { ListChecks } from 'lucide-react'
|
||||
import clsx from 'clsx'
|
||||
import { rovingTarget } from '../components/ui'
|
||||
import {
|
||||
EVIDENCE_STATE, claimCounts, claimLabel, docTally, segmentKind, segmentLabel, segmentState, tallySummary, unitText,
|
||||
isJudged, limitOf, unitVerdict, verdictState, withVerdicts, type EvidenceStateCode, type EvidenceTally as Tally,
|
||||
EVIDENCE_STATE, alertTier, claimCounts, claimLabel, claimProblems, conflicting, docTally, segmentKind, segmentLabel,
|
||||
segmentState, tallySummary, unitText, isJudged, limitOf, unitVerdict, verdictMissing, verdictState, withVerdicts,
|
||||
type EvidenceStateCode, type EvidenceTally as Tally,
|
||||
} from '../lib/evidence'
|
||||
import { formatNumber } from '../lib/format'
|
||||
import { EVIDENCE_STATE_LABEL, EVIDENCE_TEXT, JUDGE_TEXT, claimTally, evidenceTally, type ClaimTallyCounts } from '../lib/terms'
|
||||
@@ -26,13 +27,13 @@ import { BlockView, Markdown, StyledSlice, inlineStyles, numericColumns, type In
|
||||
* BlockView,和普通答案长得一模一样;有出处的数字画细实线,没有出处的画点状线、
|
||||
* 句末挂「无证据」。
|
||||
*
|
||||
* 结论句的判定(四期)只在句末挂一枚小徽标(◆ ◇ ! ?),整句不画线;证据不支持的整句铺一层浅底。
|
||||
* 徽标也是按钮:点开是这一句的「模型的解释」。判定是模型给的,颜色一律不用确定性的绿。
|
||||
* 结论句的判定(四期)只在句末挂一枚小徽标(◆ ◇ ! ○ ?),整句不画线;证据相矛盾(和旧的证据不支持)的整句
|
||||
* 铺一层浅底。徽标也是按钮:点开是这一句的「模型的解释」。判定是模型给的,颜色一律不用确定性的绿。
|
||||
*
|
||||
* 键盘:整份报告只占一个 Tab 位(roving tabindex)。←/→ 在有状态的片段、句末徽标间走,↑/↓ 按
|
||||
* 句子走(表格里按列走到上一行 / 下一行,出了表格接着按句子走),n / N 跳到下一处 /
|
||||
* 上一处无证据、证据不支持的地方,回车打开证据面板,Esc 关掉并留在原片段;面板开着时方向键走到哪、
|
||||
* 面板跟到哪,Tab 进面板。
|
||||
* 上一处有问题的地方(无证据、可疑名称、证据相矛盾、部分有依据;证据不足的排在这些之后),回车打开证据面板,
|
||||
* Esc 关掉并留在原片段;面板开着时方向键走到哪、面板跟到哪,Tab 进面板。
|
||||
*
|
||||
* 长报告:事件都挂在容器上(片段只带 data-seg),块用 memo,外加
|
||||
* content-visibility: auto;超过 TEXT_CAP 的部分先折叠,跳转到折叠里的片段时自动展开。
|
||||
@@ -66,8 +67,13 @@ interface Model {
|
||||
/** 每个有可点片段的句子里第一个可点片段,按正文顺序(↑/↓ 用) */
|
||||
unitFirst: string[]
|
||||
unitOf: Map<string, number>
|
||||
/** 无证据的片段,按正文顺序(n / N 用) */
|
||||
/**
|
||||
* 有问题的片段和句末徽标(n / N 用):先第 1 轮(无证据、可疑名称、证据相矛盾、部分有依据),再第 2 轮
|
||||
* (证据不足),每一轮里按正文顺序
|
||||
*/
|
||||
alerts: string[]
|
||||
/** alerts 里每一处在第几轮 */
|
||||
tier: Map<string, 1 | 2>
|
||||
/** 每块到它为止的累计字数(折叠用) */
|
||||
chars: number[]
|
||||
/** 表格里的片段在第几行第几列(表头 row = -1 不进来);↑/↓ 在表格里按列走 */
|
||||
@@ -83,7 +89,7 @@ function buildModel(blocks: EvidenceBlock[], overlay?: Record<string, EvidenceVe
|
||||
const badge = new Map<string, Badge>()
|
||||
const unitFirst: string[] = []
|
||||
const unitOf = new Map<string, number>()
|
||||
const alerts: string[] = []
|
||||
const tiered: [string, 1 | 2][] = []
|
||||
const chars: number[] = []
|
||||
const cell = new Map<string, { block: number; row: number; col: number }>()
|
||||
const grid = new Map<string, string>()
|
||||
@@ -101,14 +107,15 @@ function buildModel(blocks: EvidenceBlock[], overlay?: Record<string, EvidenceVe
|
||||
order.push(s.id)
|
||||
if (first) { unitFirst.push(s.id); first = false }
|
||||
unitOf.set(s.id, unitFirst.length - 1)
|
||||
if (EVIDENCE_STATE[state].alert) alerts.push(s.id)
|
||||
const t = alertTier(state)
|
||||
if (t) tiered.push([s.id, t])
|
||||
if (loc) {
|
||||
cell.set(s.id, { block: b, row: loc.row, col: loc.col })
|
||||
const key = `${b}:${loc.row}:${loc.col}`
|
||||
if (!grid.has(key)) grid.set(key, s.id)
|
||||
}
|
||||
}
|
||||
// 句末徽标排在这一句的片段后面:←/→ 走到句尾就是它,证据不支持的也进 n / N
|
||||
// 句末徽标排在这一句的片段后面:←/→ 走到句尾就是它,证据相矛盾、部分有依据、证据不足的也进 n / N
|
||||
const verdict = unitVerdict(unit, overlay)
|
||||
const state = verdictState(verdict)
|
||||
if (verdict && state) {
|
||||
@@ -118,12 +125,16 @@ function buildModel(blocks: EvidenceBlock[], overlay?: Record<string, EvidenceVe
|
||||
order.push(key)
|
||||
if (first) { unitFirst.push(key); first = false }
|
||||
unitOf.set(key, unitFirst.length - 1)
|
||||
if (EVIDENCE_STATE[state].alert) alerts.push(key)
|
||||
const t = alertTier(state)
|
||||
if (t) tiered.push([key, t])
|
||||
}
|
||||
}
|
||||
chars.push(total)
|
||||
})
|
||||
return { order, index, seg, badge, unitFirst, unitOf, alerts, chars, cell, grid }
|
||||
// 按(轮次、正文顺序)排:tiered 本来就是正文顺序,稳定排序只按轮次挪
|
||||
const sorted = [...tiered].sort((a, b) => a[1] - b[1])
|
||||
return { order, index, seg, badge, unitFirst, unitOf, alerts: sorted.map(([k]) => k), tier: new Map(sorted), chars, cell,
|
||||
grid }
|
||||
}
|
||||
|
||||
/** 片段或徽标在第几块 */
|
||||
@@ -311,11 +322,17 @@ export const EvidenceDoc = forwardRef<EvidenceDocHandle, {
|
||||
if (refocus && back) requestAnimationFrame(() => segEl(back)?.focus())
|
||||
}, [view, current, segEl])
|
||||
|
||||
/**
|
||||
* n / N 的下一处:按(轮次、正文位置)排的一圈,走到头接回开头。当前位置不是问题(普通片段、有依据的徽标)时
|
||||
* 按第 1 轮算——第 1 轮里它后面没有了,就接着走第 2 轮(证据不足)
|
||||
*/
|
||||
const step = useCallback((list: string[], from: string | null, dir: 1 | -1): string | null => {
|
||||
if (!list.length) return null
|
||||
const pos = from ? model.index.get(from) ?? -1 : -1
|
||||
if (dir > 0) return list.find((id) => (model.index.get(id) ?? 0) > pos) ?? list[0]
|
||||
for (let i = list.length - 1; i >= 0; i--) if ((model.index.get(list[i]) ?? 0) < pos) return list[i]
|
||||
const rank = (id: string | null): [number, number] => [id ? model.tier.get(id) ?? 1 : 1, id ? model.index.get(id) ?? -1 : -1]
|
||||
const cmp = (a: [number, number], b: [number, number]) => a[0] - b[0] || a[1] - b[1]
|
||||
const cur = rank(from)
|
||||
if (dir > 0) return list.find((id) => cmp(rank(id), cur) > 0) ?? list[0]
|
||||
for (let i = list.length - 1; i >= 0; i--) if (cmp(rank(list[i]), cur) < 0) return list[i]
|
||||
return list[list.length - 1]
|
||||
}, [model])
|
||||
|
||||
@@ -510,7 +527,7 @@ export function EvidenceTally({ counts, onNext, onList }: {
|
||||
}) {
|
||||
const suspect = counts.suspect ?? 0
|
||||
const claims = counts.claims
|
||||
const clean = !counts.none && !counts.other && !suspect && !claims?.unsupported && !claims?.partial
|
||||
const clean = !counts.none && !counts.other && !suspect && !claimProblems(claims)
|
||||
const numbers = evidenceTally(counts.cited, counts.total, counts.other)
|
||||
return (
|
||||
<div className="mb-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs" data-evidence-tally="">
|
||||
@@ -541,13 +558,14 @@ export function EvidenceTally({ counts, onNext, onList }: {
|
||||
}
|
||||
|
||||
/**
|
||||
* 「结论 4 句(支持 3 · 不支持 1)」:和数字那一段同一种说法。判定是模型给的:全都支持也不用确定性的绿,
|
||||
* 有不支持、部分支持、没挂依据的用提醒色,其余用暗字色(它是概率性的,不该和「有出处」一样笃定)
|
||||
* 「结论 4 句(有依据 3 · 证据相矛盾 1)」:和数字那一段同一种说法。判定是模型给的:全都支持也不用确定性的绿,
|
||||
* 有问题(证据相矛盾、旧的证据不支持、部分有依据、证据不足)、没挂依据的用提醒色,其余用暗字色(它是概率性的,
|
||||
* 不该和「有出处」一样笃定)
|
||||
*/
|
||||
export function ClaimTally({ claims, lead }: { claims: ClaimTallyCounts; lead: boolean }) {
|
||||
const text = claimTally(claims)
|
||||
if (!text) return null
|
||||
const warn = claims.unsupported > 0 || claims.partial > 0 || claims.uncited > 0
|
||||
const warn = claimProblems(claims) > 0 || claims.uncited > 0
|
||||
return (
|
||||
<span className="tnum" style={{ color: warn ? 'var(--st-waiting)' : 'var(--text-dim)' }} data-evidence-claims=""
|
||||
title={JUDGE_TEXT.badge(null)}>
|
||||
@@ -655,7 +673,7 @@ const DocBlock = memo(function DocBlock({ block, dense, doc, visual, current, ac
|
||||
/**
|
||||
* 一句话:文字按行内 Markdown 渲染(整句算一次样式,跨片段的 `code`、**粗体** 不会
|
||||
* 被切坏),有状态的片段包成按钮。含无证据片段的句子末尾挂「? 无证据」;有判定的结论句末尾挂
|
||||
* 一枚徽标(也是按钮),证据不支持的整句铺浅底——字本身不画线
|
||||
* 一枚徽标(也是按钮),证据相矛盾(和旧的证据不支持)的整句铺浅底——字本身不画线
|
||||
*/
|
||||
function UnitView({ unit, doc, current, active, panelId, code, tag, badge }: {
|
||||
unit: EvidenceUnit; doc: EvidenceDocData; current: string | null; active: string | null; panelId: string
|
||||
@@ -702,8 +720,8 @@ function UnitView({ unit, doc, current, active, panelId, code, tag, badge }: {
|
||||
const open = !!badge && active === key
|
||||
return (
|
||||
<>
|
||||
{badge?.state === 'unsupported'
|
||||
// 证据不支持:整句铺一层浅底(折行时每行各自带圆角),字色、字重都不动,也不画线
|
||||
{conflicting(badge?.state)
|
||||
// 证据相矛盾(和旧的证据不支持):整句铺一层浅底(折行时每行各自带圆角),字色、字重都不动,也不画线
|
||||
? <span className="ev-claim" data-ev-claim-shade={unit.id} style={{ '--ev-soft': meta!.soft } as CSSProperties}>{nodes}</span>
|
||||
: nodes}
|
||||
{tag && [...alerts].map((state) => (
|
||||
@@ -722,10 +740,11 @@ function UnitView({ unit, doc, current, active, panelId, code, tag, badge }: {
|
||||
aria-label={claimLabel(unit, badge.verdict)}
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? panelId : undefined}
|
||||
// 模型判过的写明谁判的、非确定;模型没判过的(按需还没点、到上限、没跑成)只说这是什么状态——
|
||||
// 到上限没判的也记着裁判模型,但不能写成「(模型 · 非确定)」,像是它判过一样
|
||||
// 模型判过的写明谁判的、非确定(证据不足的接着写缺什么);模型没判过的(按需还没点、到上限、没跑成)只说
|
||||
// 这是什么状态——到上限没判的也记着裁判模型,但不能写成「(模型 · 非确定)」,像是它判过一样
|
||||
title={isJudged(badge.verdict)
|
||||
? `${meta.label}${badge.verdict.post_seal ? ` · ${JUDGE_TEXT.postSeal}` : ''}(${badge.verdict.judge || JUDGE_TEXT.judgeModel} · 非确定)`
|
||||
? `${meta.label}${badge.verdict.post_seal ? ` · ${JUDGE_TEXT.postSeal}` : ''}(${badge.verdict.judge || JUDGE_TEXT.judgeModel} · 非确定)${
|
||||
verdictMissing(badge.verdict) ? `。${JUDGE_TEXT.missing(verdictMissing(badge.verdict))}` : ''}`
|
||||
: limitOf(badge.verdict) ? `${meta.label}:${JUDGE_TEXT.limitNotJudged}` : `${meta.label}:${meta.hint}`}
|
||||
style={segStyle(badge.state)}
|
||||
>
|
||||
|
||||
@@ -4,16 +4,17 @@ import {
|
||||
} from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { ArrowLeft, CornerDownRight, ListChecks, Scale, ShieldCheck, X } from 'lucide-react'
|
||||
import { AlertTriangle, ArrowLeft, CornerDownRight, ListChecks, Scale, ShieldCheck, X } from 'lucide-react'
|
||||
import clsx from 'clsx'
|
||||
import { ApiError } from '../api/client'
|
||||
import { Spinner, StatusBadge, isComposing } from '../components/ui'
|
||||
import {
|
||||
EVIDENCE_KIND_STYLE, EVIDENCE_STATE, caliberSourceText, caliberUpgradeText, closestNames, docForeign, entitySources,
|
||||
evidenceTrace, evidenceValue as valueText, graphDoc, inputSource, integrityFailures, isJudged, isJudgeLimit, judgeLimitWords,
|
||||
judgeable, limitOf, pointsToSettings,
|
||||
EVIDENCE_KIND_STYLE, EVIDENCE_STATE, caliberSourceText, caliberUpgradeText, claimBasis, closestNames, docForeign,
|
||||
entitySources, evidenceTrace, evidenceValue as valueText, graphDoc, inputSource, integrityFailures, isJudged,
|
||||
isJudgeLimit, judgeFlags, judgeLimitWords, judgeable, judgedVerdicts, limitOf, pointsToSettings,
|
||||
locatable, locatorText, notableInput, queryOf, queryWindow, quoteWhere, quoteWindow, reasonOf, rewriteOf, sealVerdict,
|
||||
segName, segmentKind, segmentState, sourceOf, unitText, unitVerdict, verdictState, type SealStatus, type SourceTone,
|
||||
segName, segmentKind, segmentState, sourceOf, unitText, unitVerdict, verdictMissing, verdictState, type ClaimBasis as Basis,
|
||||
type SealStatus, type SourceTone,
|
||||
} from '../lib/evidence'
|
||||
import { humanizeError } from '../lib/errors'
|
||||
import { formatDateTime, formatNumber, NONE, shortId } from '../lib/format'
|
||||
@@ -54,6 +55,9 @@ import { CopyChip } from './Markdown'
|
||||
* 的徽标,封存之后按需追加的另写「封存后追加」。探索运行里还没判过的句子给「请模型判断这句」;到了上限
|
||||
* 写明是哪个上限、到哪里调。点句末徽标打开的是整句(kind: 'unit'):句子、模型的解释、挂的依据、封存。
|
||||
*
|
||||
* 裁判拆档(JR):证据不足的写明缺什么;裁判模型和写作模型相同、模型不在价格表里时在「模型的解释」下提醒;
|
||||
* 表名实体步骤列出字段清单;讲方法、讲结构的句子在「挂的依据」下直接列出 SQL 和字段清单。
|
||||
*
|
||||
* 四种摆法:side 从右侧弹出(宽屏),drawer 从底部抽出(窄屏),inline 在 360px 的
|
||||
* 画布右栏里直接栏内展开,dock 放进页面给的一块常驻位置(记录页的「证据」页签)。
|
||||
* 都不是模态的:开着面板照样能在正文里走。
|
||||
@@ -387,7 +391,7 @@ function SegmentBody({ panelId, doc, artifact, runId, runClass, seg, unit, block
|
||||
)}
|
||||
|
||||
<JudgePart doc={doc} unit={unit} block={block} runId={runId} runClass={runClass}
|
||||
onDemand={detail?.unit?.on_demand} pending={pending} />
|
||||
onDemand={detail?.unit?.on_demand} answered={detail?.unit?.verdict} pending={pending} />
|
||||
|
||||
{host.onNode && (trace.producers.length > 0 || trace.consumers.length > 0) && (
|
||||
// 画布右栏:这段证据经过的节点,点一下在画布上选中并对准
|
||||
@@ -465,6 +469,8 @@ function ClaimBody({ doc, artifact, runId, runClass, unit, block }: {
|
||||
const sealLabel = sealed.status !== 'done' ? sealed.label
|
||||
: verdict && !late && isJudged(verdict) ? JUDGE_TEXT.sealedWithDoc : JUDGE_TEXT.sealedDoc
|
||||
const cites = (unit.cites ?? []).map((alias) => ({ alias, label: doc.catalog?.[alias]?.label as string | undefined }))
|
||||
// 讲方法、讲结构的句子:SQL 和字段清单直接列在挂的依据下面。正文不是封存的那份时不列(链是另一份报告的)
|
||||
const basis = useMemo(() => (foreign ? null : claimBasis(unit, doc)), [foreign, unit, doc])
|
||||
return (
|
||||
<>
|
||||
{foreign && (
|
||||
@@ -476,6 +482,7 @@ function ClaimBody({ doc, artifact, runId, runClass, unit, block }: {
|
||||
</Part>
|
||||
<JudgePart doc={doc} unit={unit} block={block} runId={runId} runClass={runClass}
|
||||
onDemand={foreign ? undefined : answered?.unit?.on_demand}
|
||||
answered={foreign ? undefined : answered?.unit?.verdict}
|
||||
pending={!!runId && !!first && (!slot || slot.status === 'loading')} />
|
||||
<Part title={JUDGE_TEXT.cites} data-ev-cites="">
|
||||
{cites.length ? (
|
||||
@@ -488,6 +495,7 @@ function ClaimBody({ doc, artifact, runId, runClass, unit, block }: {
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="text-dim">{JUDGE_TEXT.noCites}</p>}
|
||||
{basis && <BasisPart basis={basis} doc={doc} runId={runId} />}
|
||||
</Part>
|
||||
<Part title={EVIDENCE_TEXT.seal} data-ev-seal="">
|
||||
<SealLine status={sealed.status} label={sealLabel} />
|
||||
@@ -508,13 +516,15 @@ function ClaimBody({ doc, artifact, runId, runClass, unit, block }: {
|
||||
* 另写「封存后追加」;到上限没判的写明哪个上限、到哪里调;改写过一次的写明原句。探索运行里还没判过的
|
||||
* (没有判定、未裁判)给「请模型判断这句」。什么都说不上的(正式运行、没开裁判的文档)不画这一节
|
||||
*/
|
||||
function JudgePart({ doc, unit, block, runId, runClass, onDemand, pending }: {
|
||||
function JudgePart({ doc, unit, block, runId, runClass, onDemand, answered, pending }: {
|
||||
doc: EvidenceDocData; unit: EvidenceUnit; block: EvidenceBlock; runId?: string; runClass?: string
|
||||
/**
|
||||
* 片段接口答的「这句能不能请模型判断」:有它就照它(运行还没跑完封存、封存被改过这些前端认不出来);
|
||||
* 老后端没有时按运行类别和文档自己认
|
||||
*/
|
||||
onDemand?: EvidenceOnDemand
|
||||
/** 片段接口答这句时的判定:接口说它「早于当前规则」(outdated),指的就是这一条 */
|
||||
answered?: EvidenceVerdict
|
||||
/** 片段接口还在取:先不按运行类别另取一次 */
|
||||
pending?: boolean
|
||||
}) {
|
||||
@@ -532,7 +542,10 @@ function JudgePart({ doc, unit, block, runId, runClass, onDemand, pending }: {
|
||||
const late = !!verdict?.post_seal
|
||||
const rewrite = rewriteOf(doc, unit.id)
|
||||
const judgeDoc = !!doc.judge
|
||||
const canAsk = !!runId && !isJudged(verdict) && (known ? !!known.available : eligible && explore === true)
|
||||
// 片段接口说这句封存后追加的判定早于当前的裁判规则(旧取值、改造前判的):照常给按钮,旧判定旁边注明「按旧规则判定」。
|
||||
// 这一页里已经按当前规则重判过(眼前的判定不再是接口答的那一条)就不算了;重判没判成时答复交回的还是那条旧判定
|
||||
const outdated = known?.reason === 'outdated' && !!known.available && isJudged(verdict) && sameVerdict(verdict, answered)
|
||||
const canAsk = !!runId && (outdated || (!isJudged(verdict) && (known ? !!known.available : eligible && explore === true)))
|
||||
// 探索运行里暂时判不了(还没跑完封存、封存被改过、升级前的运行):照接口的原话说为什么没有按钮
|
||||
const blocked = known && !known.available && BLOCKED.has(known.reason ?? '') ? known.message || '' : ''
|
||||
// 这一次按需裁判的答复里没有这一句的判定:接口说了为什么(跳过了、触顶)就照说
|
||||
@@ -542,6 +555,16 @@ function JudgePart({ doc, unit, block, runId, runClass, onDemand, pending }: {
|
||||
: (Array.isArray(res?.limits_hit) && res.limits_hit.find((l) => typeof l === 'string')) || null
|
||||
const shownLimit = limit ?? resLimit
|
||||
const judged = isJudged(verdict)
|
||||
const missing = verdictMissing(verdict)
|
||||
// 裁判模型的两条提醒(和写作模型相同、不在价格表里):封存后追加的看这一次的答复(答复里有这一句时)、再看证据图里
|
||||
// 最近一次按需裁判;节点里当场判的看文档的裁判摘要
|
||||
const replied = res && judgedVerdicts(res)[unit.id] ? res : null
|
||||
const graph = useEvidence((s) => (runId ? s.graphs[runId] : undefined))
|
||||
const loadGraph = useEvidence((s) => s.loadGraph)
|
||||
const needMeta = !!runId && judged && late && !replied && !graph
|
||||
useEffect(() => { if (needMeta && runId) void loadGraph(runId) }, [needMeta, runId, loadGraph])
|
||||
const meta0 = (graph?.data?.reports ?? []).find((r) => !report || !r?.node_id || r.node_id === report)?.judge_meta
|
||||
const flags = judgeFlags(verdict, { doc: doc.judge, reply: replied, meta: meta0 })
|
||||
// 这一次答复的那句话(message):判定之外接口还想说的,照原话写出来。最要紧的是「运行已经接着跑了,这次的
|
||||
// 判定没有记进运行记录」——判定照样交回来、也标着封存后追加,只看徽标会以为它记进去了。已经由别处说过的不重复:
|
||||
// 跳过的那一行就是它、上限的那一框说的就是它、和判定里写的理由一字不差
|
||||
@@ -573,11 +596,43 @@ function JudgePart({ doc, unit, block, runId, runClass, onDemand, pending }: {
|
||||
</div>
|
||||
)}
|
||||
{verdict && (
|
||||
<p className="font-medium" style={{ color: meta?.color ?? 'var(--text-dim)' }} data-ev-verdict={verdict.status}>
|
||||
{meta?.glyph && <span aria-hidden className="mr-1">{meta.glyph}</span>}
|
||||
{meta ? meta.label : JUDGE_TEXT.notClaim}
|
||||
<div className="flex flex-wrap items-center gap-x-1.5 gap-y-0.5">
|
||||
<p className="font-medium" style={{ color: meta?.color ?? 'var(--text-dim)' }} data-ev-verdict={verdict.status}>
|
||||
{meta?.glyph && <span aria-hidden className="mr-1">{meta.glyph}</span>}
|
||||
{meta ? meta.label : JUDGE_TEXT.notClaim}
|
||||
</p>
|
||||
{outdated && (
|
||||
<span className="chip text-2xs text-faint" data-ev-judge-outdated="" title={known?.message ?? undefined}>
|
||||
{JUDGE_TEXT.outdated}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{missing && (
|
||||
// 证据不足:裁判写明缺的是什么(「SQL」「字段清单」)。说的是证据,不是结论错了:中性字色
|
||||
<p className="mt-0.5 [overflow-wrap:anywhere]" data-ev-missing="">
|
||||
<span className="text-faint">{JUDGE_TEXT.missingLead}</span>{missing}
|
||||
</p>
|
||||
)}
|
||||
{(flags.sameModel || flags.unpriced) && (
|
||||
// 判定照常给出,但读的人要知道它的分量:左侧一道提醒色的竖线加图标,字用正文色——醒目,不刺眼
|
||||
<div className="mt-1 space-y-0.5 border-l-2 py-px pl-2 text-2xs leading-relaxed" role="note" data-ev-judge-caution=""
|
||||
style={{ borderColor: 'var(--st-waiting)' }}>
|
||||
{flags.sameModel && (
|
||||
<p className="flex items-start gap-1" data-ev-judge-same=""
|
||||
title={flags.model ? JUDGE_TEXT.sameModelTitle(flags.writer ?? flags.model) : undefined}>
|
||||
<AlertTriangle size={11} aria-hidden className="mt-0.5 shrink-0" style={{ color: 'var(--st-waiting)' }} />
|
||||
<span>{JUDGE_TEXT.sameModel}</span>
|
||||
</p>
|
||||
)}
|
||||
{flags.unpriced && (
|
||||
<p className="flex items-start gap-1" data-ev-judge-unpriced="" title={JUDGE_TEXT.noPriceTitle}>
|
||||
<AlertTriangle size={11} aria-hidden className="mt-0.5 shrink-0" style={{ color: 'var(--st-waiting)' }} />
|
||||
<span>{JUDGE_TEXT.noPrice}</span>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{showMessage && (
|
||||
<p className="mb-1 mt-0.5 text-2xs leading-relaxed" role="note" style={{ color: 'var(--st-waiting)' }} data-ev-judge-message="">
|
||||
{resMessage}
|
||||
@@ -588,8 +643,9 @@ function JudgePart({ doc, unit, block, runId, runClass, onDemand, pending }: {
|
||||
<p className="mt-0.5 text-2xs text-faint" data-ev-judge-model="">{JUDGE_TEXT.notJudgedBy(verdict.judge)}</p>
|
||||
)}
|
||||
{verdict?.rationale && !shownLimit && (
|
||||
// 理由是模型写的话:斜体,和系统给的说明分开
|
||||
<p className="mt-0.5 italic text-dim" data-ev-rationale=""><em>{verdict.rationale}</em></p>
|
||||
// 理由是模型写的话:斜体,和系统给的说明分开。最长 120 字、可能夹着 SQL 片段和长的字段名:照原样折行,
|
||||
// 不截断,长串也在栏内断开
|
||||
<p className="mt-0.5 whitespace-pre-line italic text-dim [overflow-wrap:anywhere]" data-ev-rationale=""><em>{verdict.rationale}</em></p>
|
||||
)}
|
||||
{shownLimit && (
|
||||
<div className="mt-1 rounded border px-2 py-1" role="note" data-ev-judge-limit={shownLimit}
|
||||
@@ -656,6 +712,9 @@ function JudgePart({ doc, unit, block, runId, runClass, onDemand, pending }: {
|
||||
{asking ? <Spinner size={10} /> : <Scale size={11} aria-hidden />}
|
||||
{asking ? JUDGE_TEXT.asking : verdict && verdict.reason !== 'on_demand' ? JUDGE_TEXT.askAgain : JUDGE_TEXT.ask}
|
||||
</button>
|
||||
{outdated && known?.message && (
|
||||
<span className="basis-full text-2xs text-dim" data-ev-judge-outdated-why="">{known.message}</span>
|
||||
)}
|
||||
<span className="basis-full text-2xs text-faint">{JUDGE_TEXT.askHint}</span>
|
||||
</div>
|
||||
)}
|
||||
@@ -663,6 +722,13 @@ function JudgePart({ doc, unit, block, runId, runClass, onDemand, pending }: {
|
||||
)
|
||||
}
|
||||
|
||||
/** 两条判定是不是同一条(片段接口答的、页面上叠着的):按取值、理由、裁判模型、规则版本比,不按对象引用 */
|
||||
function sameVerdict(a: EvidenceVerdict | undefined, b: EvidenceVerdict | undefined): boolean {
|
||||
if (!a || !b) return false
|
||||
const sig = (v: EvidenceVerdict) => [v.status, v.rationale ?? '', v.judge ?? '', v.rule_version ?? ''].join('\u0001')
|
||||
return sig(a) === sig(b)
|
||||
}
|
||||
|
||||
/** 接口说这句暂时判不了、值得告诉人为什么的几种(正式运行、判过了、不是结论句不用说) */
|
||||
const BLOCKED = new Set(['unsealed', 'seal_broken', 'legacy'])
|
||||
|
||||
@@ -735,6 +801,9 @@ function EntityPart({ step, entry, cite, seal, pending, failed, catalog }: {
|
||||
<span className="text-2xs text-dim">{EVIDENCE_TEXT.tableColumns((step as any).columns, !!step?.is_view)}</span>
|
||||
)}
|
||||
</div>
|
||||
{kind === 'table' && !!step?.fields?.length && (
|
||||
<FieldList fields={step.fields} more={step.fields_more} masked={step.fields_masked === true} />
|
||||
)}
|
||||
{step?.comment && <p className="mt-0.5 text-2xs text-dim">{step.comment}</p>}
|
||||
{owners.length > 1 && <p className="mt-0.5 text-2xs text-dim">{EVIDENCE_TEXT.ownerTables(owners)}</p>}
|
||||
{step?.types && !step.type && Object.keys(step.types).length > 0 && (
|
||||
@@ -769,6 +838,125 @@ function EntityPart({ step, entry, cite, seal, pending, failed, catalog }: {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 表的字段清单:证据接口给的 fields(封存范围内的表结构快照,最多 60 个,遮罩的列不列入),多出来的写「另有 N 个」,
|
||||
* 快照只存了部分表时注明(partial,实体步骤那一节另有这句时不重复)。长名字、长类型都在栏内折行,不截断
|
||||
*/
|
||||
function FieldList({ fields, more, partial, masked, label }: {
|
||||
fields: NonNullable<EvidenceStep['fields']>; more?: number; partial?: boolean; masked?: boolean; label?: (n: number) => string
|
||||
}) {
|
||||
const list = fields.filter((f) => f && typeof f.name === 'string' && f.name)
|
||||
const extra = typeof more === 'number' && Number.isFinite(more) && more > 0 ? more : 0
|
||||
const total = list.length + extra
|
||||
return (
|
||||
<div className="mt-1.5" data-ev-fields="">
|
||||
<div className="mb-0.5 text-2xs font-medium text-faint">{label ? label(total) : EVIDENCE_TEXT.fields(total)}</div>
|
||||
<ul className="grid max-h-44 grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] gap-x-3 gap-y-px overflow-y-auto rounded bg-bg px-1.5 py-1 text-2xs">
|
||||
{list.map((f) => (
|
||||
<li key={f.name} className="min-w-0 [overflow-wrap:anywhere]" data-ev-field={f.name}>
|
||||
<span className="mono">{f.name}</span>
|
||||
{f.type && <>{' '}<span className="mono ml-1 text-faint" data-ev-field-type="">{f.type}</span></>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{extra > 0 && <p className="mt-0.5 text-2xs text-dim" data-ev-fields-more="">{EVIDENCE_TEXT.fieldsMore(extra)}</p>}
|
||||
{masked && <p className="mt-0.5 text-2xs text-dim" data-ev-fields-masked="">{EVIDENCE_TEXT.fieldsMasked}</p>}
|
||||
{partial && (
|
||||
<p className="mt-0.5 text-2xs" style={{ color: 'var(--st-waiting)' }} data-ev-fields-partial="">{EVIDENCE_TEXT.snapshotPartial}</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 讲方法、讲结构的句子挂的依据:表的字段清单、字段的类型(取句中那个名字片段的证据链:封存范围内的表结构快照)、
|
||||
* 对应的 SQL(查询快照工件,取回时后端复验哈希)。直接摆出来,不用再点开句中的名字
|
||||
*/
|
||||
function BasisPart({ basis, doc, runId }: { basis: Basis; doc: EvidenceDocData; runId?: string }) {
|
||||
const report = doc.node_id || undefined
|
||||
const segments = useEvidence((s) => s.segments)
|
||||
const sqls = useEvidence((s) => s.sqls)
|
||||
const loadSegment = useEvidence((s) => s.loadSegment)
|
||||
const loadSql = useEvidence((s) => s.loadSql)
|
||||
const entities = [...basis.tables, ...basis.columns]
|
||||
const artifacts = basis.queries.map((q) => {
|
||||
const a = doc.catalog?.[q]?.artifact
|
||||
return typeof a === 'string' && a ? a : ''
|
||||
})
|
||||
const segKey = entities.map((e) => e.seg ?? '').join(',')
|
||||
const artKey = artifacts.join(',')
|
||||
useEffect(() => {
|
||||
if (!runId) return
|
||||
for (const e of entities) if (e.seg) void loadSegment(runId, e.seg, report)
|
||||
for (const a of artifacts) if (a) void loadSql(a)
|
||||
// 按内容比:同一句不重复取
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [runId, report, segKey, artKey, loadSegment, loadSql])
|
||||
if (!runId) return <p className="mt-1.5 text-2xs text-faint" data-ev-basis="none">{JUDGE_TEXT.basisNoRun}</p>
|
||||
const stepOf = (seg?: string) => {
|
||||
const slot = seg ? segments[segmentKey(runId, seg, report)] : undefined
|
||||
const step = slot?.status === 'ok' ? (slot.data?.chain ?? []).find((c) => c?.step === 'entity') : undefined
|
||||
return { step, pending: !!seg && (!slot || slot.status === 'loading') }
|
||||
}
|
||||
return (
|
||||
<div className="mt-2 space-y-2 border-t pt-2" data-ev-basis="">
|
||||
{basis.tables.map((t) => {
|
||||
const { step, pending } = stepOf(t.seg)
|
||||
return (
|
||||
<div key={t.alias} data-ev-basis-table={t.alias}>
|
||||
{step?.fields?.length ? (
|
||||
<FieldList fields={step.fields} more={step.fields_more} partial={step.snapshot_truncated === true}
|
||||
masked={step.fields_masked === true} label={(n) => JUDGE_TEXT.basisFieldsCount(t.name, n)} />
|
||||
) : (
|
||||
<p className="text-2xs text-faint">
|
||||
{JUDGE_TEXT.basisFields(t.name)}:{pending ? JUDGE_TEXT.basisPending : JUDGE_TEXT.fieldsMissing}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{basis.columns.length > 0 && (
|
||||
<div data-ev-basis-columns="">
|
||||
<div className="mb-0.5 text-2xs font-medium text-faint">{JUDGE_TEXT.basisColumns}</div>
|
||||
<ul className="space-y-px text-2xs">
|
||||
{basis.columns.map((c) => {
|
||||
const { step, pending } = stepOf(c.seg)
|
||||
const type = step?.type ?? (step?.types ? Object.values(step.types)[0] : undefined)
|
||||
return (
|
||||
<li key={c.alias} className="min-w-0 [overflow-wrap:anywhere]" data-ev-basis-column={c.alias}>
|
||||
<span className="mono">{c.name}</span>{' '}
|
||||
<span className="mono ml-1 text-faint">{type || (pending ? '…' : NONE)}</span>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{basis.queries.map((q, i) => {
|
||||
const slot = artifacts[i] ? sqls[artifacts[i]] : undefined
|
||||
const sql = slot?.status === 'ok' ? slot.data?.sql ?? null : null
|
||||
return (
|
||||
<div key={q} data-ev-basis-sql={q}>
|
||||
<div className="mb-0.5 flex items-center gap-2">
|
||||
<span className="min-w-0 flex-1 text-2xs font-medium text-faint">{JUDGE_TEXT.basisSql(q)}</span>
|
||||
{sql && <CopyChip label={EVIDENCE_TEXT.copySql} text={() => sql} />}
|
||||
</div>
|
||||
{sql ? (
|
||||
<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]"
|
||||
data-ev-sql="">
|
||||
{sql}
|
||||
</pre>
|
||||
) : (
|
||||
<p className="text-2xs text-faint">{artifacts[i] && (!slot || slot.status === 'loading') ? JUDGE_TEXT.basisPending : JUDGE_TEXT.sqlMissing}</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{basis.more > 0 && <p className="text-2xs text-faint" data-ev-basis-more="">{JUDGE_TEXT.basisMoreQueries(basis.more)}</p>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 逐字引文:原文所在的文档和片段,引文在原文里的位置高亮(前后带一截上下文)。检索快照哈希对不上时
|
||||
* 不摆原文——那一段不能当证据。原话对不上的引文也画这一节,只写目录里记着的是哪次检索
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -1,8 +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, claimTally, evidenceTally, issuanceLabel, nodeTypeLabel } from '../lib/terms'
|
||||
import { statsTally } from '../lib/evidence'
|
||||
import { JUDGE_TEXT, TYPE_LABEL, claimTally, evidenceTally, issuanceLabel, nodeTypeLabel } from '../lib/terms'
|
||||
import { claimCountsOf, isJudged, statsTally } from '../lib/evidence'
|
||||
|
||||
// 泳道数据画布也要用(supervisor 节点要展开成协作矩阵),所以类型放在
|
||||
// types.ts 里;这里再导出一遍,老引用不用改
|
||||
@@ -647,16 +647,13 @@ function queryTitle(sql: string, source: string): string {
|
||||
/** agent 开了 cite_fields 时循环结束后那次结构化抽取 */
|
||||
const EXTRACT_TITLE = '按出处抽取字段'
|
||||
/**
|
||||
* report.checked 带的裁判摘要 → 「结论 4 句(支持 1 · 不支持 1 · 未裁判 2)」,和出具横幅同一种说法。
|
||||
* 「不是结论句」不算;没有摘要(没开裁判、老后端)返回空串
|
||||
* report.checked 带的裁判摘要 → 「结论 4 句(有依据 1 · 证据相矛盾 1 · 未裁判 2)」,和出具横幅同一种说法。
|
||||
* 「不是结论句」不算,旧数据的 unsupported 照样计入;没有摘要(没开裁判、老后端)返回空串
|
||||
*/
|
||||
function judgeTally(judge: unknown): string {
|
||||
const c = judge && typeof judge === 'object' ? (judge as { counts?: Record<string, unknown> }).counts : undefined
|
||||
if (!c || typeof c !== 'object') return ''
|
||||
const n = (k: string) => (typeof c[k] === 'number' && Number.isFinite(c[k] as number) ? c[k] as number : 0)
|
||||
const counts = { supported: n('supported'), partial: n('partial'), unsupported: n('unsupported'), unjudged: n('unjudged'),
|
||||
uncited: 0 }
|
||||
return claimTally({ ...counts, total: counts.supported + counts.partial + counts.unsupported + counts.unjudged })
|
||||
return claimTally(claimCountsOf(c))
|
||||
}
|
||||
|
||||
/** 报告撰写节点请裁判模型判断结论句(四期,claims: judge):units 是这一批几句 */
|
||||
@@ -1785,14 +1782,17 @@ export function decodeRun(events: RunEvent[], final?: RunFinal, opts?: DecodeOpt
|
||||
case 'evidence.judged': {
|
||||
// 探索运行跑完、封存之后,有人点开结论句请模型判断:判定追加在封存之后,不改封存的报告
|
||||
const verdicts = d.verdicts && typeof d.verdicts === 'object' ? Object.values(d.verdicts as Record<string, any>) : []
|
||||
const judged = verdicts.filter((v) => ['supported', 'partial', 'unsupported', 'not_a_claim'].includes(v?.status)).length
|
||||
const judged = verdicts.filter((v) => isJudged(v)).length
|
||||
const hit: string[] = Array.isArray(d.limits_hit) ? d.limits_hit : []
|
||||
push({
|
||||
id: `ej-${seq}`, seq, kind: 'note', nodeId, status: 'done', code: 'evidence_judged',
|
||||
level: hit.length || (Array.isArray(d.gaps) && d.gaps.length) ? 'warn' : 'info',
|
||||
title: `封存后按需裁判了 ${formatNumber(judged)} 句结论${hit.length ? ',部分因达到上限未裁判' : ''}`,
|
||||
sub: '封存后追加 · 模型判断,非确定',
|
||||
...(d.model ? { detail: [`模型:${d.model}`, ...(Array.isArray(d.gaps) ? d.gaps.map(String) : [])].join('\n') } : {}),
|
||||
// 裁判模型和写作模型相同、模型不在价格表里:和证据面板「模型的解释」同样的两句提醒
|
||||
...(d.model ? { detail: [`模型:${d.model}`, ...(d.same_model === true ? [JUDGE_TEXT.sameModel] : []),
|
||||
...(d.priced === false ? [JUDGE_TEXT.noPrice] : []),
|
||||
...(Array.isArray(d.gaps) ? d.gaps.map(String) : [])].join('\n') } : {}),
|
||||
}, nodeId)
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user