mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-19 03:42:00 +00:00
账本前端补两样:答案身上的召回标记写到问数据的轮次和证据面板「口径」一步;对账结果卡上问「说明有用 / 看不懂」
复核 W4R-03(a×c):召回在原答案的运行上追加 ledger.recalled、ledger.basis_changed,以前只在运行时间线(decode)里,问数据的
轮次底部、证据面板「口径」一步、账本接口都不带——使用者被标了「依据有变」、或者口径升版后「已按 v2 核对,不影响」,重开对话
什么也看不到,得点开「过程」才翻得出来,而使用者进不了记录页。W4-a 已在账本接口加上 recall(ledger/recall.answer_marks:
checked / basis / tasks,几种 state 都带),这边照它画:
- typesLedger:RunLedger.recall(LedgerRecallMarks)
- run/LedgerStep 新增 RecallMarks(问数据的轮次和「口径」一步共用):「已按口径「X」vN 核对,不影响」(同一份口径核对过
几次只写最近那一版,数变了的不在这里写);依据有变按两类各一行——数据目录(catalog / values / catalog_edit)和表结构
(structure),认不出的种类只说「答案的依据有变」不猜,项数相加,按新目录新出现错误级问题的写几条;看的人手上有说的是
这个答案的召回待办时写一句(口径升到 vN、数变了 / 依据有变检查出新问题)并链到 /apps/inbox/{待办}
- LedgerTurn:比对过的卡里写在摘要下面;没比对、不比对的答案(state 不是 matched)只要带着标记就单独写一张小卡
- LedgerPart(证据面板「口径」一步):有标签的写在脚注前;没标签但答案带着标记的,这一步只写标记
复核 W4R-10(多包):细案 02 做法 10 的 E2「说明有用 / 看不懂」以前没有入口。W4-a 已加 POST /ledger/answers/{run}/reconcile/
{对账运行}/feedback({verdict: useful | unclear},记成对账运行上的封存后事件、统计 E2 数它),账本接口的 reconciled 每一项
带 feedback {mine, useful, unclear}。这边:
- api.caliberLedger.feedback;typesLedger 加 LedgerFeedback、LedgerFeedbackOut
- run/LedgerReconcile 的对账卡:做完的卡问一句「「差在哪」的说明有帮助吗?」,两个按钮,看的人选过的按下(aria-pressed),
写各几个人(服务端给的数),可以改主意;交回来的反馈先画上,账本再取一次让别处挂着的同一张卡跟着变;回收站里只看不反馈;
没做完的卡不问
- 问数据的轮次里卡片上方没有「差在哪」,卡里补写一份(showWhere),反馈问的就是它;证据面板里它本来就在卡片上方,不重复
检查(写请求都在浏览器层拦下):
- check-evidence 新一段 ledger-recall:比对过的答案「口径」一步写核对过(只写最近那一版)、依据有变(项数相加、新问题条数)、
链到待办;不比对的答案这一步只写依据有变
- check-chat 新一段 recall:轮次底部同上,另核对做完的对账卡写「差在哪」和反馈人数;不比对的答案单独一张小卡写表结构有变
- check-ledger 对账一段:没做完不问;点「看不懂」请求体只有 verdict、按下、写各几个人;改点「说明有用」再记一条、按下的换过来
- 共用夹具 ledger-fixtures 加 RECALL
把这几个文件的改动拿掉回跑:check-chat recall 6 项、check-evidence ledger-recall 4 项、check-ledger 对账反馈 2 项都不过;
放回去全过
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
*
|
||||
* - run:GET /api/runs/{id}/ledger,一次运行里每个数的口径标签、整题判断、能做的动作、出具过的正式运行、对过的账;
|
||||
* - issue:按口径正式出具(参数只由服务端从比对工件里取,这里只能选「按哪份口径」);
|
||||
* - reconcile:口径对账(点开才跑一次确定性派生的只读图);
|
||||
* - reconcile:口径对账(点开才跑一次确定性派生的只读图);feedback:对账结果上的「说明有用 / 看不懂」(记成对账运行上的
|
||||
* 封存后事件,统计 E2 数它);
|
||||
* - certifyQueue / dismiss:可沉淀的问题、「不是口径」(搭建者及以上);
|
||||
* - freeze:固化成口径草稿(/copilot/from-run 的 freeze 选项,报告引用的查询变成固定 SQL 的取数节点)。
|
||||
*
|
||||
@@ -11,7 +12,7 @@
|
||||
* 请求函数从 ./http 导入,不从 ./client 导入(client.ts 要导入这个文件,反过来就成了循环)。
|
||||
*/
|
||||
import type {
|
||||
CertifyQueue, FreezeOut, LedgerIssueOut, LedgerReconcileIn, LedgerReconcileOut, RunLedger,
|
||||
CertifyQueue, FreezeOut, LedgerFeedbackOut, LedgerFeedbackVerdict, LedgerIssueOut, LedgerReconcileIn, LedgerReconcileOut, RunLedger,
|
||||
} from '../typesLedger'
|
||||
import { get, post, type RequestOptions } from './http'
|
||||
|
||||
@@ -21,6 +22,8 @@ export const caliberLedger = {
|
||||
run: (runId: string, opts?: RequestOptions) => get<RunLedger>(`/runs/${encodeURIComponent(runId)}/ledger`, opts),
|
||||
issue: (runId: string, body: { workflow_id: string; version: number }) => post<LedgerIssueOut>(`${at(runId)}/issue`, body),
|
||||
reconcile: (runId: string, body: LedgerReconcileIn) => post<LedgerReconcileOut>(`${at(runId)}/reconcile`, body),
|
||||
feedback: (runId: string, reconcileId: string, verdict: LedgerFeedbackVerdict) =>
|
||||
post<LedgerFeedbackOut>(`${at(runId)}/reconcile/${encodeURIComponent(reconcileId)}/feedback`, { verdict }),
|
||||
certifyQueue: (opts?: RequestOptions) => get<CertifyQueue>('/ledger/certify-queue', opts),
|
||||
dismiss: (body: { item_id: string; kind?: string; note: string }) =>
|
||||
post<{ ok: boolean; item_id: string }>('/ledger/certify-queue/dismiss', body),
|
||||
|
||||
@@ -113,6 +113,34 @@ export const LEDGER_UI = {
|
||||
less: '收起',
|
||||
original: (text: string) => `原答案里写的是 ${text};对账时按同样的 SQL 重新取数,数据有变化时两者可能不同`,
|
||||
openRun: '打开对账运行',
|
||||
/** 「差在哪」的说明有没有帮人看懂(统计 E2 数它,衡量差异说明写得好不好) */
|
||||
feedback: {
|
||||
ask: '「差在哪」的说明有帮助吗?',
|
||||
useful: '说明有用',
|
||||
unclear: '看不懂',
|
||||
mine: (v: 'useful' | 'unclear') => `你选了「${v === 'useful' ? '说明有用' : '看不懂'}」,可以改`,
|
||||
counts: (useful: number, unclear: number) => [useful ? `${formatNumber(useful)} 人觉得有用` : '',
|
||||
unclear ? `${formatNumber(unclear)} 人看不懂` : ''].filter(Boolean).join(' · '),
|
||||
saved: '已记下你的反馈',
|
||||
readOnly: '对话在回收站中,恢复后才能反馈',
|
||||
},
|
||||
},
|
||||
|
||||
// ---- 答案身上的召回标记(问数据的轮次、证据面板「口径」一步) ----
|
||||
recall: {
|
||||
/** 口径升版后在同一份数据上重算过、数没变 */
|
||||
checked: (caliber: string) => `已按口径${caliber} 核对,不影响`,
|
||||
/** 依据有变:目录里影响数字的项被驳回或修改、出现新码值、处理变化时改了目录(目录类),表或列被删、类型变了(表结构) */
|
||||
basis: (what: 'catalog' | 'structure' | 'other', items: number) =>
|
||||
`${what === 'structure' ? '依据的表结构有变' : what === 'catalog' ? '依据的数据目录有变' : '答案的依据有变'}`
|
||||
+ `${items ? `(${formatNumber(items)} 项)` : ''}`,
|
||||
newErrors: (n: number) => `按新目录检查新出现 ${formatNumber(n)} 条错误级问题`,
|
||||
basisHint: '答案本身没有改:它依据的数据目录或表结构在答案之后有变化,请核对是否还能用',
|
||||
/** 看的这个人手上说的是这个答案的 recall 待办:口径升版后数变了的、依据有变检查出新问题的 */
|
||||
taskCaliber: (version: number | null | undefined) => `口径升到 ${version != null ? `v${version}` : '新版本'},这个答案用到的数变了`,
|
||||
taskBasis: '依据有变,按新目录检查出了新的问题',
|
||||
taskOther: '有一条召回待办',
|
||||
task: '去待办处理',
|
||||
},
|
||||
|
||||
// ---- 问数据:轮次底部的摘要 ----
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Scale } from 'lucide-react'
|
||||
import { ApiError, api } from '../api/client'
|
||||
@@ -9,8 +10,8 @@ import { LEDGER_UI } from '../lib/termsLedger'
|
||||
import { useAtLeast } from '../store/auth'
|
||||
import { useLedger } from '../store/ledger'
|
||||
import type {
|
||||
LedgerField, LedgerPairOptions, LedgerReconcileAction, LedgerReconcileIn, LedgerReconciled, LedgerReconcileGroup,
|
||||
LedgerRelated, RunLedger,
|
||||
LedgerFeedback, LedgerFeedbackVerdict, LedgerField, LedgerPairOptions, LedgerReconcileAction, LedgerReconcileIn, LedgerReconciled,
|
||||
LedgerReconcileGroup, LedgerRelated, RunLedger,
|
||||
} from '../typesLedger'
|
||||
import { BindingList, DiffList, caliberOf } from './LedgerStep'
|
||||
|
||||
@@ -26,6 +27,8 @@ import { BindingList, DiffList, caliberOf } from './LedgerStep'
|
||||
* - 结果(ReconcileResults):每一组对照写按你的问法、按口径、差值(另附相对差),每个数按
|
||||
* /runs/{对账运行}/evidence/metrics/{对账卡}/{指标} 取值,点一下打开它的出处链(apps/EvidenceDrawer,和应用页点数同一套)。
|
||||
* 哪几个指标是一组由服务端给(reconciled.groups),这里不按命名规则拼。
|
||||
* - 反馈(FeedbackRow):对账跑完之后问一句「差在哪」的说明有没有帮人看懂——「说明有用 / 看不懂」,记成对账运行上的封存后
|
||||
* 事件(服务端 ledger/feedback),统计 E2 数它。同一个人改主意只算最后一次;看的人选过哪个、各几个人都由服务端给。
|
||||
*/
|
||||
|
||||
const NEEDS_PAIRS = 'ledger_reconcile_needs_pairs'
|
||||
@@ -229,7 +232,55 @@ function GroupRow({ runId, card, group, onOpen }: {
|
||||
)
|
||||
}
|
||||
|
||||
function ReconcileCard({ item, data, original }: { item: LedgerReconciled; data?: RunLedger; original?: string }) {
|
||||
/**
|
||||
* 「差在哪」的说明有没有帮人看懂:说明有用 / 看不懂。按下的那个是看的人最后一次给的(服务端的 mine),可以改;回来的是这次
|
||||
* 对账现在的反馈,账本再取一次(别处挂着的同一张卡跟着变)
|
||||
*/
|
||||
function FeedbackRow({ runId, item, readOnly }: { runId: string; item: LedgerReconciled; readOnly: boolean }) {
|
||||
const refresh = useLedger((s) => s.refresh)
|
||||
const [fb, setFb] = useState<LedgerFeedback | undefined>(item.feedback)
|
||||
const [busy, setBusy] = useState<LedgerFeedbackVerdict | null>(null)
|
||||
useEffect(() => { setFb(item.feedback) }, [item.feedback])
|
||||
const F = LEDGER_UI.result.feedback
|
||||
const give = async (verdict: LedgerFeedbackVerdict) => {
|
||||
setBusy(verdict)
|
||||
try {
|
||||
const out = await api.caliberLedger.feedback(runId, item.run_id, verdict)
|
||||
setFb(out.feedback)
|
||||
toast.ok(F.saved)
|
||||
refresh(runId)
|
||||
} catch (e) {
|
||||
toast.error(e)
|
||||
} finally {
|
||||
setBusy(null)
|
||||
}
|
||||
}
|
||||
const counts = fb ? F.counts(fb.useful, fb.unclear) : ''
|
||||
return (
|
||||
<div className="mt-1.5 flex flex-wrap items-center gap-1.5 text-2xs" data-ledger-feedback={fb?.mine ?? ''}>
|
||||
<span className="text-dim">{F.ask}</span>
|
||||
{(['useful', 'unclear'] as const).map((v) => (
|
||||
<button key={v} type="button" className={clsx('btn btn-xs', fb?.mine === v ? 'btn-primary' : 'btn-ghost')}
|
||||
aria-pressed={fb?.mine === v} disabled={readOnly || busy != null}
|
||||
title={readOnly ? F.readOnly : undefined} onClick={() => void give(v)} data-ledger-feedback-give={v}>
|
||||
{busy === v ? <Spinner size={11} /> : null}{F[v]}
|
||||
</button>
|
||||
))}
|
||||
{fb?.mine && <span className="text-faint" data-ledger-feedback-mine="">{F.mine(fb.mine)}</span>}
|
||||
{counts && <span className="text-faint" data-ledger-feedback-counts="">{counts}</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 这张对账卡对照的那份相关口径「差在哪」(问数据的轮次里卡片上方没有这一段,反馈要有说的是什么) */
|
||||
function whereOf(data: RunLedger | undefined, item: LedgerReconciled): LedgerRelated | undefined {
|
||||
return (data?.queries ?? []).find((q) => q.artifact === item.query)?.candidates
|
||||
.find((c) => c.caliber === item.caliber && c.status === 'related')
|
||||
}
|
||||
|
||||
function ReconcileCard({ runId, item, data, original, readOnly, showWhere }: {
|
||||
runId: string; item: LedgerReconciled; data?: RunLedger; original?: string; readOnly: boolean; showWhere: boolean
|
||||
}) {
|
||||
const builder = useAtLeast('builder')
|
||||
const [all, setAll] = useState(false)
|
||||
const [target, setTarget] = useState<EvidenceTarget | null>(null)
|
||||
@@ -240,6 +291,7 @@ function ReconcileCard({ item, data, original }: { item: LedgerReconciled; data?
|
||||
const R = LEDGER_UI.result
|
||||
const state = item.status === 'succeeded' ? 'succeeded' : item.status === 'failed' ? 'failed'
|
||||
: item.status === 'cancelled' ? 'cancelled' : 'running'
|
||||
const where = showWhere ? whereOf(data, item) : undefined
|
||||
return (
|
||||
<div className="mt-1.5 rounded border px-2 py-1.5" data-ledger-reconciled={item.run_id} data-ledger-reconciled-state={state}>
|
||||
<div className="flex flex-wrap items-center gap-1.5 text-2xs">
|
||||
@@ -264,20 +316,33 @@ function ReconcileCard({ item, data, original }: { item: LedgerReconciled; data?
|
||||
{original && <p className="mt-1 text-2xs text-faint" data-ledger-original="">{R.original(original)}</p>}
|
||||
</>
|
||||
)}
|
||||
{state === 'succeeded' && showWhere && where && (
|
||||
<div className="mt-1 text-2xs" data-ledger-reconciled-where="">
|
||||
<div className="text-faint">{LEDGER_UI.step.where}</div>
|
||||
<DiffList related={where} />
|
||||
</div>
|
||||
)}
|
||||
{state === 'succeeded' && <FeedbackRow runId={runId} item={item} readOnly={readOnly} />}
|
||||
<EvidenceDrawer target={target} onClose={() => setTarget(null)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 对过的账(新的在前)。original:从证据面板打开时,正文里这个数写的是什么 */
|
||||
export function ReconcileResults({ items, data, original }: {
|
||||
runId: string; items: LedgerReconciled[]; data?: RunLedger; original?: string
|
||||
/**
|
||||
* 对过的账(新的在前)。runId 是答案的运行(反馈记在它名下的对账上);original:从证据面板打开时,正文里这个数写的是什么;
|
||||
* showWhere:卡片上方没有「差在哪」时(问数据的轮次)卡里写一份,反馈问的就是它;readOnly:对话在回收站里,只看不反馈
|
||||
*/
|
||||
export function ReconcileResults({ runId, items, data, original, showWhere = false, readOnly = false }: {
|
||||
runId: string; items: LedgerReconciled[]; data?: RunLedger; original?: string; showWhere?: boolean; readOnly?: boolean
|
||||
}) {
|
||||
const sorted = useMemo(() => items, [items])
|
||||
if (!sorted.length) return null
|
||||
return (
|
||||
<div data-ledger-reconciled-list="">
|
||||
{sorted.map((item) => <ReconcileCard key={item.run_id} item={item} data={data} original={original} />)}
|
||||
{sorted.map((item) => (
|
||||
<ReconcileCard key={item.run_id} runId={runId} item={item} data={data} original={original} readOnly={readOnly}
|
||||
showWhere={showWhere} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { BookMarked, RotateCw, Scale } from 'lucide-react'
|
||||
import { BookMarked, CircleCheck, Inbox, RotateCw, Scale, TriangleAlert } from 'lucide-react'
|
||||
import { ApiError, api } from '../api/client'
|
||||
import { Spinner, StatusBadge, toast } from '../components/ui'
|
||||
import { errorMessage } from '../lib/errors'
|
||||
@@ -9,7 +9,8 @@ import { LEDGER_UI, caliberName } from '../lib/termsLedger'
|
||||
import { useAtLeast } from '../store/auth'
|
||||
import { useLedger, useRunLedger, type LedgerSlot } from '../store/ledger'
|
||||
import type {
|
||||
LedgerBinding, LedgerIssueAction, LedgerIssued, LedgerLabel, LedgerReconcileAction, LedgerRelated, RunLedger, SegmentLedger,
|
||||
LedgerBinding, LedgerIssueAction, LedgerIssued, LedgerLabel, LedgerRecallMarks, LedgerReconcileAction, LedgerRelated, RunLedger,
|
||||
SegmentLedger,
|
||||
} from '../typesLedger'
|
||||
import { ReconcileDialog, ReconcileResults } from './LedgerReconcile'
|
||||
|
||||
@@ -19,7 +20,9 @@ import { ReconcileDialog, ReconcileResults } from './LedgerReconcile'
|
||||
* · 按口径正式出具;相关口径——差在哪 + 看差多少(口径对账:核对参数 → 发起 → 三个数各自点得开);这次的推理——
|
||||
* 写「没有相关的已发布口径」;没比对的写原因。比对还没出结果时写「正在比对口径」,store/ledger 按退避轮询,
|
||||
* 等满了还没结论照实说、给「再取一次」;
|
||||
* - 按口径正式出具那一项(IssueControl)和出具过的正式运行(IssuedList):问数据的轮次摘要用同一份。
|
||||
* - 按口径正式出具那一项(IssueControl)和出具过的正式运行(IssuedList):问数据的轮次摘要用同一份;
|
||||
* - 答案身上的召回标记(RecallMarks):「已按口径「X」vN 核对,不影响」、依据有变、说的是这个答案的召回待办(链到待办),
|
||||
* 「口径」一步和问数据的轮次底部用同一份。
|
||||
*
|
||||
* 界面层不放逻辑:标签、能不能出具、能不能自动、不能的原因、要不要先核对参数都是服务端给的(GET /runs/{id}/ledger),
|
||||
* 这里只照着画。比对在封存之后做,脚注写明「封存后比对,不在封存范围内」,事后补比的另写按哪种口径回看。
|
||||
@@ -93,6 +96,60 @@ export function LedgerWaiting({ slot, runId, compact = false }: { slot: LedgerSl
|
||||
)
|
||||
}
|
||||
|
||||
/** 依据有变的几种归成两类说:目录(目录里影响数字的项、新码值、处理变化时改了目录)和表结构;认不出的只说依据有变,不猜 */
|
||||
const BASIS_GROUP: Record<string, 'catalog' | 'structure'> = {
|
||||
catalog: 'catalog', values: 'catalog', catalog_edit: 'catalog', structure: 'structure',
|
||||
}
|
||||
|
||||
/** 有没有要画的召回标记 */
|
||||
export const hasRecallMarks = (recall: LedgerRecallMarks | undefined) =>
|
||||
!!(recall?.checked?.some((c) => !c.changed) || recall?.basis?.length || recall?.tasks?.length)
|
||||
|
||||
/**
|
||||
* 答案身上的召回标记(细案做法 7):「已按口径「X」v3 核对,不影响」、「依据的数据目录有变(2 项)」,看的这个人手上有说的
|
||||
* 是这个答案的 recall 待办时链到待办。标记是服务端从这次运行上封存后追加的 ledger.recalled、ledger.basis_changed 读出来的
|
||||
* (ledger/recall.answer_marks),这里只照着写;同一份口径核对过几次只写最近的那一版,依据有变按两类各写一行、项数相加
|
||||
*/
|
||||
export function RecallMarks({ recall }: { recall?: LedgerRecallMarks }) {
|
||||
if (!hasRecallMarks(recall)) return null
|
||||
const R = LEDGER_UI.recall
|
||||
const checked = new Map<string, NonNullable<LedgerRecallMarks['checked']>[number]>()
|
||||
for (const c of recall?.checked ?? []) if (!c.changed) checked.set(String(c.workflow_id ?? ''), c)
|
||||
const basis = new Map<'catalog' | 'structure' | 'other', { items: number; errors: number }>()
|
||||
for (const b of recall?.basis ?? []) {
|
||||
const group = BASIS_GROUP[String(b.kind ?? '')] ?? 'other'
|
||||
const cur = basis.get(group) ?? { items: 0, errors: 0 }
|
||||
basis.set(group, { items: cur.items + (b.items ?? 0), errors: cur.errors + (b.new_errors ?? 0) })
|
||||
}
|
||||
const tasks = recall?.tasks ?? []
|
||||
return (
|
||||
<ul className="space-y-0.5 text-2xs" data-ledger-recall="">
|
||||
{[...checked.values()].map((c) => (
|
||||
<li key={`c-${c.workflow_id ?? ''}`} className="flex items-start gap-1.5 text-dim" data-ledger-recall-checked={c.to_version ?? ''}>
|
||||
<CircleCheck size={11} className="mt-[2px] shrink-0 text-faint" aria-hidden />
|
||||
<span>{R.checked(caliberName(c.workflow_name, c.to_version))}</span>
|
||||
</li>
|
||||
))}
|
||||
{[...basis.entries()].map(([group, b]) => (
|
||||
<li key={`b-${group}`} className="flex items-start gap-1.5" data-ledger-recall-basis={group}>
|
||||
<TriangleAlert size={11} className="mt-[2px] shrink-0" style={{ color: 'var(--st-waiting)' }} aria-hidden />
|
||||
<span title={R.basisHint}>
|
||||
{R.basis(group, b.items)}
|
||||
{b.errors > 0 && <span className="text-dim"> · {R.newErrors(b.errors)}</span>}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
{tasks.map((t) => (
|
||||
<li key={`t-${t.id}`} className="flex flex-wrap items-start gap-1.5" data-ledger-recall-task={t.id}>
|
||||
<Inbox size={11} className="mt-[2px] shrink-0 text-faint" aria-hidden />
|
||||
<span>{t.reason === 'caliber' ? R.taskCaliber(t.to_version) : t.reason === 'catalog' ? R.taskBasis : R.taskOther}</span>
|
||||
<Link to={`/apps/inbox/${encodeURIComponent(t.id)}`} className="text-[var(--accent)] hover:underline">{R.task}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
/** 比对的来历:封存后比对,不在封存范围内;事后补比的写按哪种口径回看 */
|
||||
export function LedgerFootnote({ data }: { data: RunLedger }) {
|
||||
return (
|
||||
@@ -251,9 +308,14 @@ export function LedgerPart({ runId, runClass, report, segId, segText, segLedger,
|
||||
return (
|
||||
<Section title={LEDGER_UI.step.title} data-ev-ledger="unreadable">
|
||||
<p className="text-dim">{LEDGER_UI.step.unreadable(data.reason ?? '')}</p>
|
||||
<RecallMarks recall={data.recall} />
|
||||
</Section>
|
||||
)
|
||||
}
|
||||
// 没比对的答案照样可能被标依据有变:标记说的是整个答案,这一步只写它
|
||||
if (data && hasRecallMarks(data.recall)) {
|
||||
return <Section title={LEDGER_UI.step.title} data-ev-ledger="recall"><RecallMarks recall={data.recall} /></Section>
|
||||
}
|
||||
return null
|
||||
}
|
||||
const queries = label.queries ?? (label.query ? [label.query] : [])
|
||||
@@ -304,7 +366,7 @@ export function LedgerPart({ runId, runClass, report, segId, segText, segLedger,
|
||||
<Scale size={11} aria-hidden /> {LEDGER_UI.reconcile.button}
|
||||
</button>
|
||||
) : r.comparable === false ? <p className="mt-1 text-2xs text-faint">{r.reason || LEDGER_UI.step.notComparable}</p> : null}
|
||||
{!!done.length && <ReconcileResults runId={runId} items={done} data={data} original={segText} />}
|
||||
{!!done.length && <ReconcileResults runId={runId} items={done} data={data} original={segText} readOnly={readOnly} />}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
@@ -316,6 +378,7 @@ export function LedgerPart({ runId, runClass, report, segId, segText, segLedger,
|
||||
{label.kind === 'unknown' && (
|
||||
<p className="text-dim" data-ledger-unknown="">{LEDGER_TEXT.kind.unknown}{label.reason ? `:${label.reason}` : ''}</p>
|
||||
)}
|
||||
{hasRecallMarks(data?.recall) && <div className="mt-1.5"><RecallMarks recall={data?.recall} /></div>}
|
||||
{data && <LedgerFootnote data={data} />}
|
||||
{dialog && data && (
|
||||
<ReconcileDialog runId={runId} action={dialog.action} related={dialog.related} onClose={() => setDialog(null)} />
|
||||
|
||||
@@ -4,13 +4,17 @@ import { LEDGER_TEXT } from '../lib/terms'
|
||||
import { LEDGER_UI } from '../lib/termsLedger'
|
||||
import { useRunLedger } from '../store/ledger'
|
||||
import type { LedgerIssueAction, LedgerReconcileAction, LedgerRelated, RunLedger } from '../typesLedger'
|
||||
import { IssueControl, IssuedList, LedgerFootnote, LedgerWaiting, caliberOf, ledgerEnabled, ledgerErrorShown } from './LedgerStep'
|
||||
import {
|
||||
IssueControl, IssuedList, LedgerFootnote, LedgerWaiting, RecallMarks, caliberOf, hasRecallMarks, ledgerEnabled, ledgerErrorShown,
|
||||
} from './LedgerStep'
|
||||
import { ReconcileDialog, ReconcileResults } from './LedgerReconcile'
|
||||
|
||||
/**
|
||||
* 问数据轮次底部的口径账本(docs/design/next-round/02-口径账本.md 做法 11):一行摘要(「3 个数来自口径「周销售」v3,
|
||||
* 1 个数是这次的推理」)和对应的动作——整题等价时按口径正式出具(能自动的写正在自动出具),有相关口径时对账;
|
||||
* 正式出具的结果(自动的、一键的)挂在轮次下面、点开去运行;对过的账一张结果卡片,三个数各自点得开。
|
||||
* 正式出具的结果(自动的、一键的)挂在轮次下面、点开去运行;对过的账一张结果卡片,三个数各自点得开,卡里写「差在哪」、
|
||||
* 问说明有没有帮助(说明有用 / 看不懂)。答案身上的召回标记(「已按口径「X」vN 核对,不影响」、依据有变、说的是这个答案的
|
||||
* 召回待办)也写在这里:以前只在「过程」里点开才看得到,使用者又进不了记录页;没比对的答案照样可能带着,单独写一行。
|
||||
*
|
||||
* 比对在封存之后做:轮次刚交付时写「正在比对口径」,store/ledger 按退避再取,等满了还没结论照实说、给「再取一次」。
|
||||
* 不靠实时流(ledger.matched 追加时这次运行的事件总线已经关了)。界面层不放逻辑:每个数的标签、整题判断、能不能出具、
|
||||
@@ -62,12 +66,21 @@ export function LedgerTurn({ runId, runClass, done, readOnly = false }: {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (!data || data.state !== 'matched' || !summary) return null
|
||||
if (!data) return null
|
||||
// 召回标记(依据有变、已按 vN 核对)说的是整个答案:没比对过、不比对的答案照样可能带着,单独写一行
|
||||
const marked = hasRecallMarks(data.recall)
|
||||
if (data.state !== 'matched' || !summary) {
|
||||
return marked ? (
|
||||
<div className="w-full basis-full rounded-md border px-2.5 py-2 text-xs" data-ledger-turn="recall">
|
||||
<RecallMarks recall={data.recall} />
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
const issue = (data.actions ?? []).find((a): a is LedgerIssueAction => a.kind === 'issue')
|
||||
const reconciles = reconcileEntries(data)
|
||||
const issued = data.issued ?? []
|
||||
const reconciled = data.reconciled ?? []
|
||||
if (!summary.total && !issued.length && !reconciled.length) return null
|
||||
if (!summary.total && !issued.length && !reconciled.length && !marked) return null
|
||||
const whole = data.whole
|
||||
return (
|
||||
<div className="w-full basis-full space-y-1.5 rounded-md border px-2.5 py-2 text-xs" data-ledger-turn="matched">
|
||||
@@ -83,6 +96,7 @@ export function LedgerTurn({ runId, runClass, done, readOnly = false }: {
|
||||
{LEDGER_UI.turn.whole(caliberOf(whole), LEDGER_TEXT.how[whole.how === 'composed' ? 'composed' : 'independent'])}
|
||||
</p>
|
||||
)}
|
||||
<RecallMarks recall={data.recall} />
|
||||
{(issue || reconciles.length > 0) && (
|
||||
<div className="flex flex-wrap items-start gap-1.5" data-ledger-actions="">
|
||||
{issue && <IssueControl runId={runId} action={issue} slot={slot} readOnly={readOnly} />}
|
||||
@@ -96,7 +110,7 @@ export function LedgerTurn({ runId, runClass, done, readOnly = false }: {
|
||||
</div>
|
||||
)}
|
||||
<IssuedList data={data} />
|
||||
{reconciled.length > 0 && <ReconcileResults runId={runId} items={reconciled} data={data} />}
|
||||
{reconciled.length > 0 && <ReconcileResults runId={runId} items={reconciled} data={data} showWhere readOnly={readOnly} />}
|
||||
<LedgerFootnote data={data} />
|
||||
{dialog && <ReconcileDialog runId={runId} action={dialog.action} related={dialog.related} onClose={() => setDialog(null)} />}
|
||||
</div>
|
||||
|
||||
@@ -182,6 +182,44 @@ export interface LedgerReconciled {
|
||||
card?: string
|
||||
groups?: LedgerReconcileGroup[]
|
||||
created_at?: string | null
|
||||
/** 「说明有用 / 看不懂」(服务端 ledger/feedback.feedback_of):看的这个人最后一次给的、各几个人 */
|
||||
feedback?: LedgerFeedback
|
||||
}
|
||||
|
||||
export type LedgerFeedbackVerdict = 'useful' | 'unclear'
|
||||
|
||||
/** 对账结果上的反馈:mine 是看的这个人最后一次给的(没给过为空),useful / unclear 是各几个人(每人只算最后一次) */
|
||||
export interface LedgerFeedback {
|
||||
mine?: LedgerFeedbackVerdict | null
|
||||
useful: number
|
||||
unclear: number
|
||||
}
|
||||
|
||||
/** POST /api/ledger/answers/{run}/reconcile/{对账运行}/feedback 的答复 */
|
||||
export interface LedgerFeedbackOut {
|
||||
run_id: string
|
||||
feedback: LedgerFeedback
|
||||
}
|
||||
|
||||
/**
|
||||
* 答案身上的召回标记(GET /runs/{id}/ledger 的 recall,服务端 ledger/recall.answer_marks;细案做法 7「依据有变」「已按 vN
|
||||
* 核对,不影响」)。几种 state 都可能带:没比对过、不比对的答案照样可能被标依据有变。不放数、表名、取值
|
||||
*/
|
||||
export interface LedgerRecallMarks {
|
||||
/** 口径升版后召回重算、数没变:在这个答案上记的「已按 vN 核对,不影响」 */
|
||||
checked?: {
|
||||
workflow_id?: string | null
|
||||
workflow_name?: string | null
|
||||
from_version?: number | null
|
||||
to_version?: number | null
|
||||
recall_run?: string | null
|
||||
changed?: boolean
|
||||
at?: string | null
|
||||
}[]
|
||||
/** 依据有变:kind 是 catalog(目录里影响数字的项被驳回或修改)/ structure(表结构)/ values(新码值)/ catalog_edit */
|
||||
basis?: { kind?: string | null; items?: number; new_errors?: number; at?: string | null }[]
|
||||
/** 看的这个人手上、说的是这个答案的 recall 待办(还没处理的) */
|
||||
tasks?: { id: string; reason?: string; to_version?: number | null }[]
|
||||
}
|
||||
|
||||
export interface LedgerCaliber {
|
||||
@@ -220,6 +258,7 @@ export interface RunLedger {
|
||||
actions?: LedgerAction[]
|
||||
issued?: LedgerIssued[]
|
||||
reconciled?: LedgerReconciled[]
|
||||
recall?: LedgerRecallMarks
|
||||
}
|
||||
|
||||
/** 证据片段接口(GET /runs/{id}/evidence/segments/{seg})的 ledger 键:这个片段的标签和比对的来历 */
|
||||
|
||||
Reference in New Issue
Block a user