From cf833a0a77f705f12c23652f7fbbc814df74fa10 Mon Sep 17 00:00:00 2001 From: Zhero & Rin Date: Tue, 1 Dec 2026 12:30:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(reconciliation):=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=B9=E8=B4=A6=E5=B7=A5=E4=BD=9C=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为什么:T6b 需要把「解析监控」改成「导入对账」,让差异、证据、待确认与处置在同一页闭环,同时保留平台侧流水。 做什么:新增对账 API 客户端;差异清单(R1-R8、证据等级、待确认徽标、处置按钮);批次概览与队列状态条;平台侧流水页签沿用原表;详情抽屉实时读取 WeKnora 阶段与失败,503 降级;导航改名但保留 tasks 模块 id。 边界:只读角色不显示触发/处置;1440/1024/768 用现有表格滚动与新增响应式规则;不伪造 URL 路由。 验证:npx tsc --noEmit、npm test(646+)、npm run build、make verify 全绿。 --- internal/platform/postgres/monitor_tasks.go | 3 +- web/src/App.test.tsx | 6 +- web/src/App.tsx | 6 +- web/src/ReconciliationFindings.test.tsx | 106 +++++ web/src/ReconciliationFindings.tsx | 444 ++++++++++++++++++++ web/src/ReconciliationProgress.test.tsx | 64 +++ web/src/WeKnoraMonitor.test.tsx | 4 + web/src/WeKnoraMonitor.tsx | 260 ++++++++++-- web/src/monitor.ts | 19 + web/src/monitorTasks.ts | 1 + web/src/monitorWorkbench.css | 191 +++++++++ web/src/reconciliation.test.ts | 115 +++++ web/src/reconciliation.ts | 227 ++++++++++ 13 files changed, 1402 insertions(+), 44 deletions(-) create mode 100644 web/src/ReconciliationFindings.test.tsx create mode 100644 web/src/ReconciliationFindings.tsx create mode 100644 web/src/ReconciliationProgress.test.tsx create mode 100644 web/src/reconciliation.test.ts create mode 100644 web/src/reconciliation.ts diff --git a/internal/platform/postgres/monitor_tasks.go b/internal/platform/postgres/monitor_tasks.go index 3d88794..f359ae4 100644 --- a/internal/platform/postgres/monitor_tasks.go +++ b/internal/platform/postgres/monitor_tasks.go @@ -28,6 +28,7 @@ type MonitorTask struct { SourceName string `json:"source_name"` TargetScope string `json:"target_scope"` TargetKB string `json:"target_kb"` + DocumentID string `json:"document_id"` Action string `json:"action"` Stage string `json:"stage"` Status string `json:"status"` @@ -124,7 +125,7 @@ const monitorTasksCTE = `WITH history_publications AS ( ELSE 'waiting' END AS stage FROM base ), projected AS ( - SELECT id,title,path,parent_node_id,node_id,source_id,source_name,target_scope,target_kb,version_id,retry_count,updated_at,action,stage,status,failure_id, + SELECT id,title,path,parent_node_id,node_id,source_id,source_name,target_scope,target_kb,knowledge_id AS document_id,version_id,retry_count,updated_at,action,stage,status,failure_id, CASE WHEN status<>'attention' THEN '' WHEN action='remove' THEN CASE WHEN job_type='test.remove' AND job_state='failed' AND retrieval_state IN ('failed','disabling') AND policy_state='blocked' THEN 'remove' ELSE '' END WHEN failure_type='artifact.fetch' THEN 'fetch' diff --git a/web/src/App.test.tsx b/web/src/App.test.tsx index 61ae10e..51e7959 100644 --- a/web/src/App.test.tsx +++ b/web/src/App.test.tsx @@ -46,7 +46,7 @@ describe('WorkspaceShell', () => { ) expect(html).toContain('aria-label="功能导航"') - for (const label of ['来源与目录', '解析监控', '发布管理', '系统设置']) { + for (const label of ['来源与目录', '导入对账', '发布管理', '系统设置']) { expect(html).toContain(label) } expect(html).not.toContain('来源链接') @@ -66,10 +66,10 @@ describe('WorkspaceShell', () => { expect(html).not.toContain('class="tab-list"') expect(html).not.toContain('class="workspace-tab') expect(html).toContain('来源与目录') - expect(html).toContain('解析监控') + expect(html).toContain('导入对账') expect(html).toContain('发布管理') expect(html).toContain('aria-label="当前位置"') - expect(html).toContain('解析监控') + expect(html).toContain('导入对账') expect(html).toContain('class="nav-item active"') }) diff --git a/web/src/App.tsx b/web/src/App.tsx index 5c14c97..6446883 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -60,7 +60,7 @@ const workspaceStorageKey = 'knowledge-governance.workspace.v1' const modules: ReadonlyArray<{ id: ModuleId; label: string; icon: string }> = [ { id: 'dashboard', label: '来源与目录', icon: '◫' }, - { id: 'tasks', label: '解析监控', icon: '↻' }, + { id: 'tasks', label: '导入对账', icon: '↻' }, { id: 'qaops', label: '问答运营', icon: '▤' }, { id: 'releases', label: '发布管理', icon: '⇧' }, { id: 'settings', label: '系统设置', icon: '⚙' }, @@ -1330,7 +1330,7 @@ function releaseGuidance(props: ReleaseManagementProps, pending: number) { step: 2, title: '现在要做:确认测试结果', reason: '暂时不能继续:目前没有可以审核的已通过知识', - action: '前往“解析监控”查看处理结果,并核对搜索效果', + action: '前往“导入对账”查看处理结果,并核对搜索效果', after: '第 3 步,审核发布内容', impact: '只读查看,不会影响生产', href: '#review-actions', @@ -1512,7 +1512,7 @@ export function ReleaseManagement(props: ReleaseManagementProps) { ) : null} {!props.reviewLoading && publishReady.length === 0 ? (
- 没有待发布的已批准知识。到「来源与目录」标注后,在「解析监控」处理完成即可发布。 + 没有待发布的已批准知识。到「来源与目录」标注后,在「导入对账」处理完成即可发布。
) : null} {publishReady.length > 0 ? ( diff --git a/web/src/ReconciliationFindings.test.tsx b/web/src/ReconciliationFindings.test.tsx new file mode 100644 index 0000000..1830a54 --- /dev/null +++ b/web/src/ReconciliationFindings.test.tsx @@ -0,0 +1,106 @@ +import { renderToStaticMarkup } from 'react-dom/server' +import { describe, expect, it, vi } from 'vitest' +import { ReconciliationFindingsView } from './ReconciliationFindings' +import type { ReconciliationFinding, ReconciliationRun } from './reconciliation' + +const run: ReconciliationRun = { + id: 'run-1', + kb_id: 'kb-1', + state: 'succeeded', + trigger: 'manual', + started_at: '2026-12-01T02:00:00Z', + finished_at: '2026-12-01T02:01:00Z', + ledger_count: 12, + kb_count: 11, + counts: { R1: 1, R2: 0, R3: 2, R4: 0, R5: 0, R6: 0, R7: 0, R8: 0 }, + previous_counts: { R1: 0, R2: 0, R3: 2, R4: 0, R5: 0, R6: 0, R7: 0, R8: 0 }, + window_overlapped: true, + error_code: '', +} +const finding: ReconciliationFinding = { + id: 'f1', + run_id: 'run-1', + type: 'R1', + publication_id: 'pub-1', + document_id: 'doc-1', + title: '缺失文件.pdf', + path: '产品/缺失文件.pdf', + source: '技术资料', + target_scope: 'internal', + ledger_state: 'completed', + weknora_parse_status: '', + normalized_state: '', + ledger_sha256: '', + declared_sha256: '', + weknora_file_md5: '', + evidence_level: 'none', + confirmation_state: 'pending', + detail: '台账认为应在库,单条读取返回 404', + suggested_action: 'requeue_upload', + action_state: 'open', + weknora_url: '', +} +const props = { + overview: null, + runs: { items: [run], total: 1, limit: 20, offset: 0 }, + findings: { items: [finding], total: 1, limit: 20, offset: 0 }, + filters: { type: '', q: '' }, + selectedRunID: 'run-1', + selectedKB: 'kb-1', + kbOptions: [{ id: 'kb-1', name: '测试知识库' }], + loading: false, + busy: false, + canOperate: true, + canRemove: true, + error: '', + message: '', + onTab: vi.fn(), + onSelectRun: vi.fn(), + onSelectKB: vi.fn(), + onFilters: vi.fn(), + onPage: vi.fn(), + onRefresh: vi.fn(), + onCreate: vi.fn(), + onAction: vi.fn(), + onDetail: vi.fn(), +} +describe('reconciliation findings', () => { + it('shows batch counts, pending confirmation, evidence and actions', () => { + const html = renderToStaticMarkup() + for (const text of [ + '导入对账', + '差异清单', + '平台侧流水', + '立即对账', + 'R1 丢失', + '待确认', + '无', + '重排上传', + '缺失文件.pdf', + ]) + expect(html).toContain(text) + expect(html).toContain('当前筛选 1 项') + expect(html).toContain('保留最近 30 批') + }) + it('hides trigger and actions from a read-only role', () => { + const html = renderToStaticMarkup() + expect(html).not.toContain('立即对账') + expect(html).not.toContain('>重排上传') + expect(html).toContain('只读角色') + }) + it('renders loading, empty and error states', () => { + const loading = renderToStaticMarkup( + + ) + expect(loading).toContain('正在读取差异') + expect(loading).toContain('还没有对账批次') + const failed = renderToStaticMarkup() + expect(failed).toContain('读取对账批次失败') + }) +}) diff --git a/web/src/ReconciliationFindings.tsx b/web/src/ReconciliationFindings.tsx new file mode 100644 index 0000000..b072c18 --- /dev/null +++ b/web/src/ReconciliationFindings.tsx @@ -0,0 +1,444 @@ +import { useEffect, useRef, useState } from 'react' +import type { MonitorOverview } from './monitor' +import type { + ReconciliationFinding, + ReconciliationFindingPage, + ReconciliationFindingType, + ReconciliationProgress, + ReconciliationRunPage, +} from './reconciliation' +import { fetchReconciliationProgress, ReconciliationRequestError } from './reconciliation' +import './monitorWorkbench.css' + +const time = (value: string | null | undefined) => + value ? new Date(value).toLocaleString('zh-CN', { hour12: false }) : '—' +const typeLabels: Record = { + R1: 'R1 丢失', + R2: 'R2 孤儿', + R3: 'R3 非平台导入', + R4: 'R4 内容过期', + R5: 'R5 状态不一致', + R6: 'R6 应下架仍在', + R7: 'R7 卡住', + R8: 'R8 一对多', +} +const evidenceLabels = { independent: '独立证据', declared_only: '仅声明', none: '无' } +const actionLabels: Record = { + requeue_upload: '重排上传', + remove_from_test: '从测试库移除', + writeback_state: '以 WeKnora 为准回写', + enter_removal: '进入需下架流程', + none: '不处置', +} +const countKeys = ['R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8'] + +export interface FindingFilters { + type: string + q: string +} + +interface FindingsProps { + overview: MonitorOverview | null + runs: ReconciliationRunPage + findings: ReconciliationFindingPage + filters: FindingFilters + selectedRunID: string + selectedKB: string + kbOptions: { id: string; name: string }[] + loading: boolean + busy: boolean + canOperate: boolean + canRemove: boolean + error: string + message: string + onTab: (tab: 'findings' | 'platform') => void + onSelectRun: (id: string) => void + onSelectKB: (id: string) => void + onFilters: (value: FindingFilters) => void + onPage: (offset: number) => void + onRefresh: () => void + onCreate: () => void + onAction: (finding: ReconciliationFinding) => void + onDetail: (finding: ReconciliationFinding) => void +} + +export function ReconciliationFindingsView(p: FindingsProps) { + const run = p.runs.items.find((item) => item.id === p.selectedRunID) || p.runs.items[0] || null + const previous = run?.previous_counts || null + const pageCount = Math.max(1, Math.ceil(p.findings.total / p.findings.limit)) + const queue = p.overview?.weknora_queues + return ( +
+
+
+

导入对账

+

台账与测试 WeKnora 知识库的差异、证据与处置

+
+ {p.overview ? `快照 ${time(p.overview.observed_at)}` : '等待运行快照'} + +
+ + {p.error ? ( +
+ {p.error} +
+ ) : null} +
+ + WeKnora 队列: + {queue ? ( + + {queue.queues.reduce((sum, item) => sum + item.pending, 0)} 等待 ·{' '} + {queue.queues.reduce((sum, item) => sum + item.active, 0)} 运行 + + ) : ( + 未配置只读 Key 或队列不可用 + )} + + + 服务:{p.overview?.health.filter((item) => item.readiness === 'ready').length ?? 0} 可接单 + + 一期只对测试库;生产下架依赖测试移除 + 下一轮整库发布 +
+
+
+ + + {p.canOperate ? ( + + ) : ( + 只读角色:可查看差异,不能触发或处置 + )} +
+ {run ? ( + <> +

+ {time(run.started_at)} · {run.trigger === 'schedule' ? '定时' : '手动'} · 台账 {run.ledger_count} 条 · + 库内 {run.kb_count} 条{run.window_overlapped ? ' · 与整库作业重叠,R1/R2 待确认' : ''} + {run.error_code ? ` · 失败:${run.error_code}` : ''} +

+
+ {countKeys.map((key) => ( + + {run.counts[key] ?? 0} + {key} + {previous ? ( + + {run.counts[key] === previous[key] + ? '持平' + : `${run.counts[key] > (previous[key] || 0) ? '+' : ''}${run.counts[key] - (previous[key] || 0)}`} + + ) : null} + + ))} +
+ + ) : ( +

还没有对账批次。选择测试知识库后点「立即对账」。

+ )} + {p.message ? ( +
+ {p.message} +
+ ) : null} +
+
+
+
+

差异清单

+ + 当前筛选 {p.findings.total} 项 · 本页 {p.findings.items.length} 项 + +
+ 明细保留最近 30 批且不超过 90 天 +
+
+ p.onFilters({ ...p.filters, q: e.target.value })} + /> + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + {p.findings.items.map((finding) => ( + + + + + + + + + + + ))} + {!p.findings.items.length ? ( + + + + ) : null} + +
类型文件名称 / 目录来源台账 / WeKnora证据 / 建议确认说明操作
+ + {typeLabels[finding.type]} + + + {finding.title || '未命名文件'} + {finding.path || '未提供目录'} + + {finding.source || '—'} + + + 台账 {finding.ledger_state || '—'} → WeKnora {finding.normalized_state || '—'} + + + {evidenceLabels[finding.evidence_level]} + {actionLabels[finding.suggested_action]} + + {finding.confirmation_state === 'pending' ? ( + 待确认 + ) : ( + 已确认 + )} + + {finding.detail} + + + {p.canOperate && finding.action_state === 'open' && finding.suggested_action !== 'none' ? ( + + ) : null} + {finding.action_state === 'done' ? 已处置 : null} +
+ {p.loading ? '正在读取差异…' : run ? '该批次没有差异。' : '先选择一个对账批次。'} +
+
+
+ + 当前筛选共 {p.findings.total} 项 · 每页 {p.findings.limit} 项 + +
+ + + 第 {Math.floor(p.findings.offset / p.findings.limit) + 1} / {pageCount} 页 + + +
+
+
+
+ ) +} + +export function WeKnoraProgress({ documentID, compact = false }: { documentID: string; compact?: boolean }) { + const [progress, setProgress] = useState(null) + const [error, setError] = useState('') + const [loading, setLoading] = useState(true) + useEffect(() => { + if (!documentID) { + setLoading(false) + return + } + const controller = new AbortController() + setLoading(true) + setError('') + void fetchReconciliationProgress(documentID, controller.signal) + .then((value) => { + if (!controller.signal.aborted) setProgress(value) + }) + .catch((err) => { + if (controller.signal.aborted) return + setProgress(null) + if (err instanceof ReconciliationRequestError && err.code === 'runtime_read_unavailable') { + setError('未配置 WeKnora 只读 Key,无法读取实时处理详情。') + } else { + setError(err instanceof Error ? err.message : '读取 WeKnora 处理详情失败') + } + }) + .finally(() => { + if (!controller.signal.aborted) setLoading(false) + }) + return () => controller.abort() + }, [documentID]) + return ( +
+
+

WeKnora 处理详情

+ 实时读取,不落库 +
+ {loading ?

正在读取…

: null} + {error ?

{error}

: null} + {progress ? ( + <> +

+ {progress.parse_status || '—'} · 入库 {progress.ingestion_status || '—'} · Wiki{' '} + {progress.wiki_status || '—'} · 读取 {time(progress.observed_at)} +

+ {progress.stages.length ? ( +
    + {progress.stages.map((stage) => ( +
  1. + {stage.name} {stage.status} + {stage.error_code ? ` · ${stage.error_code}` : ''} + {stage.finished_at ? ` · ${time(stage.finished_at)}` : ''} +
  2. + ))} +
+ ) : ( +

还没有阶段记录。

+ )} + {progress.failures.length ? ( +
+ 历史失败 + {progress.failures.map((failure) => ( +

+ {failure.task_type} · 尝试 {failure.fail_count} · {time(failure.failed_at)} · {failure.last_error} +

+ ))} + {progress.has_more_failures ? 仅显示最近 50 条失败。 : null} +
+ ) : null} + + ) : null} +
+ ) +} + +export function FindingDetail({ finding, onClose }: { finding: ReconciliationFinding; onClose: () => void }) { + const ref = useRef(null) + useEffect(() => { + ref.current?.showModal() + }, []) + return ( + +
+

{typeLabels[finding.type]} · 处理详情

+ +
+

{finding.title || '未命名文件'}

+
+ {[ + ['目录', finding.path], + ['来源', finding.source], + ['发布标识', finding.publication_id], + ['远端文档', finding.document_id], + ['台账状态', finding.ledger_state], + ['WeKnora 状态', finding.weknora_parse_status], + ['归一状态', finding.normalized_state], + ['台账 SHA256', finding.ledger_sha256], + ['声明 SHA256', finding.declared_sha256], + ['WeKnora MD5', finding.weknora_file_md5], + ['证据等级', evidenceLabels[finding.evidence_level]], + ['确认状态', finding.confirmation_state === 'pending' ? '待确认' : '已确认'], + ['处置建议', actionLabels[finding.suggested_action]], + ['说明', finding.detail], + ].map(([label, value]) => ( +
+
{label}
+
{value || '—'}
+
+ ))} +
+ {finding.document_id ? : null} +
+ ) +} diff --git a/web/src/ReconciliationProgress.test.tsx b/web/src/ReconciliationProgress.test.tsx new file mode 100644 index 0000000..3cc0f6c --- /dev/null +++ b/web/src/ReconciliationProgress.test.tsx @@ -0,0 +1,64 @@ +// @vitest-environment jsdom +import { act } from 'react' +import { createRoot } from 'react-dom/client' +import type { Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { WeKnoraProgress } from './ReconciliationFindings' + +let container: HTMLDivElement +let root: Root +beforeEach(() => { + ;(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true + container = document.createElement('div') + document.body.appendChild(container) + root = createRoot(container) +}) +afterEach(() => { + act(() => root.unmount()) + container.remove() + vi.unstubAllGlobals() +}) +describe('WeKnora progress drawer block', () => { + it('degrades to a read-only key message on 503', async () => { + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue( + new Response(JSON.stringify({ error: 'runtime_read_unavailable', code: 'runtime_read_unavailable' }), { + status: 503, + }) + ) + ) + await act(async () => root.render()) + await act(async () => await Promise.resolve()) + expect(container.textContent).toContain('未配置 WeKnora 只读 Key') + }) + it('shows stages and failures when available', async () => { + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue( + new Response( + JSON.stringify({ + data: { + document_id: 'doc-1', + parse_status: 'failed', + ingestion_status: 'failed', + wiki_status: 'none', + stages: [{ name: 'parse', status: 'failed', error_code: 'E1', finished_at: '2026-12-01T00:00:00Z' }], + failures: [ + { task_type: 'parse', fail_count: 2, failed_at: '2026-12-01T00:00:00Z', last_error: '解析失败' }, + ], + has_more_failures: false, + observed_at: '2026-12-01T00:00:00Z', + }, + }), + { status: 200 } + ) + ) + ) + await act(async () => root.render()) + await act(async () => await Promise.resolve()) + expect(container.textContent).toContain('parse') + expect(container.textContent).toContain('解析失败') + expect(container.textContent).toContain('failed') + }) +}) diff --git a/web/src/WeKnoraMonitor.test.tsx b/web/src/WeKnoraMonitor.test.tsx index 10398c1..470b1b0 100644 --- a/web/src/WeKnoraMonitor.test.tsx +++ b/web/src/WeKnoraMonitor.test.tsx @@ -15,6 +15,7 @@ const page: MonitorTaskPage = { source_name: '技术资料', target_scope: 'internal', target_kb: 'test-kb', + document_id: 'doc-1', action: 'update', stage: 'parsing', status: 'attention', @@ -35,6 +36,7 @@ const page: MonitorTaskPage = { source_name: '技术资料', target_scope: 'external', target_kb: 'test-public', + document_id: 'doc-2', action: 'remove', stage: 'finished', status: 'completed', @@ -65,6 +67,8 @@ const props = { selected: [], busy: false, canOperate: true, + tab: 'platform' as const, + onTab: vi.fn(), onFilters: vi.fn(), onPage: vi.fn(), onSelection: vi.fn(), diff --git a/web/src/WeKnoraMonitor.tsx b/web/src/WeKnoraMonitor.tsx index 059bce7..9bbe23f 100644 --- a/web/src/WeKnoraMonitor.tsx +++ b/web/src/WeKnoraMonitor.tsx @@ -11,12 +11,25 @@ import { targetLabel, } from './monitorTasks' import type { MonitorFilters, MonitorTask, MonitorTaskPage } from './monitorTasks' -import { requeueJobFailure, retryPublicationsBatch } from './testPublications' +import { requeueJobFailure, retryPublicationsBatch, startPublicationRemoval } from './testPublications' import { fetchActiveUISettings, settingsRefreshDelays } from './uiSettings' import { useOptionalAuth } from './auth' import { WorkspaceContextTabsSetter } from './workspaceContext' +import { ReconciliationFindingsView, FindingDetail, WeKnoraProgress } from './ReconciliationFindings' +import type { FindingFilters } from './ReconciliationFindings' +import { + createReconciliationRun, + fetchReconciliationFindings, + fetchReconciliationRuns, + removeFinding, + requeueFinding, + writebackFinding, +} from './reconciliation' +import type { ReconciliationFinding, ReconciliationFindingPage, ReconciliationRunPage } from './reconciliation' import './monitorWorkbench.css' +const emptyRuns: ReconciliationRunPage = { items: [], total: 0, limit: 20, offset: 0 } +const emptyFindings: ReconciliationFindingPage = { items: [], total: 0, limit: 20, offset: 0 } const emptyPage: MonitorTaskPage = { items: [], total: 0, @@ -54,6 +67,10 @@ interface ViewProps { error: string message: string canOperate: boolean + tab: 'findings' | 'platform' + onTab: (tab: 'findings' | 'platform') => void + title?: string + subtitle?: string onFilters: (value: MonitorFilters) => void onPage: (offset: number) => void onSelection: (rows: MonitorTask[]) => void @@ -83,14 +100,22 @@ export function WeKnoraMonitorView(p: ViewProps) {
-

解析监控

-

运行概况与文件处理进度

+

{p.title || '平台侧流水'}

+

{p.subtitle || '上传、解析、移除与重试记录;不按对账口径过滤被顶替行'}

{overview ? `快照 ${time(overview.observed_at)}` : '等待运行快照'}
+ {p.error ? (
{p.error} @@ -580,6 +605,7 @@ function TaskDetail({ ))} ) : null} + {item.document_id ? : null}

新增、更新完成表示测试库处理完成;移除完成表示测试库内容移除,不代表生产发布。

{item.status === 'attention' ? (

@@ -601,6 +627,20 @@ export function WeKnoraMonitor({ } = {}) { const auth = useOptionalAuth() const canOperate = auth?.identity?.role === 'admin' || auth?.identity?.role === 'engineer' + const canRemove = auth?.identity?.role === 'admin' + const [tab, setTab] = useState<'findings' | 'platform'>(focus ? 'platform' : 'findings') + const [runs, setRuns] = useState(emptyRuns) + const [selectedRunID, setSelectedRunID] = useState('') + const [findings, setFindings] = useState(emptyFindings) + const [findingFilters, setFindingFilters] = useState({ type: '', q: '' }) + const [findingOffset, setFindingOffset] = useState(0) + const [selectedKB, setSelectedKB] = useState('') + const [findingDetail, setFindingDetail] = useState(null) + const [reconLoading, setReconLoading] = useState(true) + const [reconBusy, setReconBusy] = useState(false) + const [reconError, setReconError] = useState('') + const [reconMessage, setReconMessage] = useState('') + const [reconRev, setReconRev] = useState(0) const [overview, setOverview] = useState(null), [metrics, setMetrics] = useState(null) const [page, setPage] = useState(emptyPage), @@ -624,6 +664,7 @@ export function WeKnoraMonitor({ // 会遮蔽已完成文件的筛选;应用后由父消费掉,避免重挂载时旧请求再次覆盖手工筛选。 useEffect(() => { if (!focus) return + setTab('platform') setFilters({ ...defaultMonitorFilters, q: focus.q, source: focus.source, status: '' }) setOffset(0) setSelected([]) @@ -649,6 +690,10 @@ export function WeKnoraMonitor({ return () => clearTimeout(t) }, [resRev, delays.resourceMs]) useEffect(() => { + if (tab !== 'platform') { + setLoading(false) + return + } const c = new AbortController() setLoading(true) const timer = window.setTimeout(() => { @@ -678,7 +723,7 @@ export function WeKnoraMonitor({ clearTimeout(timer) c.abort() } - }, [filters, offset, docRev]) + }, [tab, filters, offset, docRev]) useEffect(() => { const c = new AbortController() void fetchMonitorOverview(c.signal) @@ -709,9 +754,110 @@ export function WeKnoraMonitor({ }) return () => c.abort() }, [resRev]) + useEffect(() => { + if (selectedKB || !overview?.knowledge_bases.length) return + setSelectedKB(overview.knowledge_bases[0].id) + }, [overview, selectedKB]) + useEffect(() => { + if (tab !== 'findings') return + const c = new AbortController() + setReconLoading(true) + void fetchReconciliationRuns(20, 0, selectedKB, c.signal) + .then((page) => { + if (c.signal.aborted) return + setRuns(page) + setReconError('') + const current = page.items.find((item) => item.id === selectedRunID) + if (!current && page.items[0]) setSelectedRunID(page.items[0].id) + }) + .catch((e) => { + if (!c.signal.aborted) { + setRuns(emptyRuns) + setReconError(e instanceof Error ? e.message : '读取对账批次失败') + } + }) + .finally(() => { + if (!c.signal.aborted) setReconLoading(false) + }) + return () => c.abort() + }, [tab, selectedKB, reconRev, selectedRunID]) + useEffect(() => { + if (tab !== 'findings' || !selectedRunID) { + setFindings(emptyFindings) + return + } + const c = new AbortController() + setReconLoading(true) + void fetchReconciliationFindings(selectedRunID, findingFilters.type, findingFilters.q, 20, findingOffset, c.signal) + .then((page) => { + if (!c.signal.aborted) { + setFindings(page) + setReconError('') + } + }) + .catch((e) => { + if (!c.signal.aborted) { + setFindings(emptyFindings) + setReconError(e instanceof Error ? e.message : '读取差异清单失败') + } + }) + .finally(() => { + if (!c.signal.aborted) setReconLoading(false) + }) + return () => c.abort() + }, [tab, selectedRunID, findingFilters, findingOffset, reconRev]) + const createRun = async () => { + if (reconBusy) return + const kbID = selectedKB || overview?.knowledge_bases[0]?.id || '' + if (!kbID) { + setReconMessage('请先选择测试知识库') + return + } + setReconBusy(true) + setReconMessage('') + try { + const run = await createReconciliationRun(kbID) + setSelectedRunID(run.id) + setReconMessage('已提交对账;扫描在后台执行,完成后刷新可见。') + setReconRev((x) => x + 1) + } catch (e) { + setReconMessage(e instanceof Error ? e.message : '触发对账失败') + } finally { + setReconBusy(false) + } + } + const actOnFinding = async (finding: ReconciliationFinding) => { + if (reconBusy) return + if ( + finding.suggested_action === 'remove_from_test' && + !window.confirm('从测试库删除该孤儿条目?不会删除来源文件或生产内容。') + ) + return + setReconBusy(true) + setReconMessage('') + try { + if (finding.suggested_action === 'enter_removal') { + if (!finding.publication_id) throw new Error('缺少发布标识,无法进入移除流程') + await startPublicationRemoval(finding.publication_id) + } else if (finding.suggested_action === 'writeback_state') { + await writebackFinding(finding.id) + } else if (finding.suggested_action === 'requeue_upload') { + await requeueFinding(finding.id) + } else if (finding.suggested_action === 'remove_from_test') { + await removeFinding(finding.id) + } + setReconMessage('处置已受理;状态以服务端读回为准。') + setReconRev((x) => x + 1) + } catch (e) { + setReconMessage(e instanceof Error ? e.message : '处置失败') + } finally { + setReconBusy(false) + } + } const refresh = () => { setDocRev((x) => x + 1) setResRev((x) => x + 1) + setReconRev((x) => x + 1) } const selectAll = async () => { if (busy) return @@ -796,40 +942,80 @@ export function WeKnoraMonitor({ } return ( <> - { - setFilters(v) - setOffset(0) - setSelected([]) - setMessage('') - setLoading(true) - }} - onPage={setOffset} - onSelection={setSelected} - onSelectAll={() => void selectAll()} - onRetry={(r) => void retry(r)} - onDetail={(row) => { - void fetchMonitorTasks({ id: row.id }, 0, 1) - .then((p) => { - if (p.items[0]) setDetail(p.items[0]) - else setMessage('该条记录已被新版本替换,请刷新列表') - }) - .catch((e) => setMessage(e instanceof Error ? e.message : '读取详情失败')) - }} - onRefresh={refresh} - onLocateSource={onLocateSource} - /> + {tab === 'findings' ? ( + ({ id: item.id, name: item.name }))} + loading={reconLoading} + busy={reconBusy} + canOperate={canOperate} + canRemove={canRemove} + error={reconError} + message={reconMessage} + onTab={setTab} + onSelectRun={(id) => { + setSelectedRunID(id) + setFindingOffset(0) + }} + onSelectKB={(id) => { + setSelectedKB(id) + setSelectedRunID('') + setFindingOffset(0) + }} + onFilters={(value) => { + setFindingFilters(value) + setFindingOffset(0) + }} + onPage={setFindingOffset} + onRefresh={refresh} + onCreate={() => void createRun()} + onAction={(finding) => void actOnFinding(finding)} + onDetail={setFindingDetail} + /> + ) : ( + { + setFilters(v) + setOffset(0) + setSelected([]) + setMessage('') + setLoading(true) + }} + onPage={setOffset} + onSelection={setSelected} + onSelectAll={() => void selectAll()} + onRetry={(r) => void retry(r)} + onDetail={(row) => { + void fetchMonitorTasks({ id: row.id }, 0, 1) + .then((p) => { + if (p.items[0]) setDetail(p.items[0]) + else setMessage('该条记录已被新版本替换,请刷新列表') + }) + .catch((e) => setMessage(e instanceof Error ? e.message : '读取详情失败')) + }} + onRefresh={refresh} + onLocateSource={onLocateSource} + /> + )} {detail ? setDetail(null)} onLocateSource={onLocateSource} /> : null} + {findingDetail ? setFindingDetail(null)} /> : null} ) } diff --git a/web/src/monitor.ts b/web/src/monitor.ts index 664fa44..948f132 100644 --- a/web/src/monitor.ts +++ b/web/src/monitor.ts @@ -57,6 +57,24 @@ export interface IngestionPipeline { fetch_missing: number concurrency: number } +export interface WeKnoraQueue { + name: string + pool: string + pending: number + active: number + scheduled: number + retry: number + archived: number + processed: number + failed: number +} +export interface WeKnoraQueues { + available: boolean + queues_error: boolean + workers_error: boolean + queues: WeKnoraQueue[] + timestamp: number +} export interface MonitorOverview { mode: string simulated: boolean @@ -66,6 +84,7 @@ export interface MonitorOverview { knowledge_bases: KnowledgeProgress[] pipeline?: IngestionPipeline health: ServiceHealth[] + weknora_queues?: WeKnoraQueues | null } export interface MonitorFile { name: string diff --git a/web/src/monitorTasks.ts b/web/src/monitorTasks.ts index dcd3e8e..95f8f98 100644 --- a/web/src/monitorTasks.ts +++ b/web/src/monitorTasks.ts @@ -9,6 +9,7 @@ export interface MonitorTask { source_name: string target_scope: string target_kb: string + document_id?: string action: string stage: string status: string diff --git a/web/src/monitorWorkbench.css b/web/src/monitorWorkbench.css index 2178ddd..9c9471a 100644 --- a/web/src/monitorWorkbench.css +++ b/web/src/monitorWorkbench.css @@ -593,3 +593,194 @@ padding: 18px; } } + +/* T6 导入对账:页签、批次概览、差异表与实时处理详情。沿用钴蓝/中性灰,不引入紫色。 */ +.monitor-tabs { + display: flex; + gap: 8px; + margin: 0 0 14px; + padding: 4px; + width: fit-content; + border: 1px solid var(--border-base); + border-radius: 999px; + background: var(--bg-soft); +} +.monitor-tabs button { + min-height: 32px; + padding: 0 16px; + border: 0; + border-radius: 999px; + background: transparent; + color: var(--ink-mute); + font-size: 13px; + font-weight: 600; + cursor: pointer; +} +.monitor-tabs button.active { + background: var(--bg-panel); + color: var(--ink-strong); + box-shadow: var(--shadow-card); +} +.monitor-service-strip { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 8px 22px; + margin-bottom: 14px; + padding: 10px 14px; + border: 1px solid var(--border-base); + border-radius: var(--r-lg); + background: var(--bg-panel); + font-size: 12px; + color: var(--ink-mute); +} +.monitor-service-strip b { + color: var(--ink-strong); +} +.monitor-recon-overview { + margin-bottom: 16px; + padding: 16px 18px; + border: 1px solid var(--border-base); + border-radius: var(--r-lg); + background: var(--bg-panel); + box-shadow: var(--shadow-card); +} +.monitor-recon-controls { + display: flex; + flex-wrap: wrap; + align-items: flex-end; + gap: 12px; +} +.monitor-recon-controls label { + display: flex; + flex-direction: column; + gap: 4px; + font-size: 11px; + color: var(--ink-mute); +} +.monitor-recon-controls select { + min-width: 180px; + max-width: 280px; +} +.monitor-diff-counts { + display: grid; + grid-template-columns: repeat(8, minmax(0, 1fr)); + gap: 8px; + margin-top: 14px; +} +.monitor-diff-counts > span { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; + padding: 8px 10px; + border: 1px solid var(--border-base); + border-radius: var(--r-md); + background: var(--bg-soft); +} +.monitor-diff-counts b { + font-size: 20px; + line-height: 1.2; + color: var(--ink-strong); + font-variant-numeric: tabular-nums; +} +.monitor-diff-counts small, +.monitor-diff-counts em { + font-size: 10px; + font-style: normal; + color: var(--ink-mute); + white-space: nowrap; +} +.monitor-diff-counts .has-diff { + border-color: color-mix(in srgb, var(--c-fail) 45%, var(--border-base)); +} +.monitor-diff-counts .has-diff b { + color: var(--c-fail); +} +.monitor-finding-type { + display: inline-block; + padding: 2px 8px; + border-radius: 999px; + background: var(--bg-soft); + border: 1px solid var(--border-base); + font-size: 11px; + font-weight: 600; + white-space: nowrap; +} +.monitor-finding-type.r1, +.monitor-finding-type.r2, +.monitor-finding-type.r4, +.monitor-finding-type.r7 { + border-color: color-mix(in srgb, var(--c-fail) 45%, var(--border-base)); + color: var(--c-fail); +} +.monitor-finding-type.r5, +.monitor-finding-type.r6 { + border-color: color-mix(in srgb, var(--c-warn, #b7791f) 45%, var(--border-base)); +} +.monitor-badge-pending { + display: inline-block; + padding: 2px 8px; + border-radius: 999px; + background: #fff7e6; + border: 1px solid #e6b450; + color: #8a5a00; + font-size: 11px; + font-weight: 600; + white-space: nowrap; +} +.monitor-progress { + margin-top: 16px; + padding-top: 14px; + border-top: 1px solid var(--border-base); +} +.monitor-progress.compact { + margin-top: 12px; +} +.monitor-progress h3 { + font-size: 13px; + margin: 0; +} +.monitor-stages { + margin: 10px 0 0; + padding-left: 18px; + display: grid; + gap: 6px; + font-size: 12px; + color: var(--ink-base); +} +.monitor-failures { + margin-top: 12px; + padding: 10px 12px; + border: 1px solid var(--border-base); + border-radius: var(--r-md); + background: var(--bg-soft); + font-size: 12px; +} +.monitor-failures p { + margin: 6px 0 0; + color: var(--ink-mute); + overflow-wrap: anywhere; +} +@media (max-width: 1024px) { + .monitor-diff-counts { + grid-template-columns: repeat(4, minmax(0, 1fr)); + } + .monitor-address-grid, + .monitor-metric-grid { + grid-template-columns: 1fr 1fr; + } +} +@media (max-width: 768px) { + .monitor-diff-counts { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + .monitor-recon-controls select { + min-width: 0; + width: 100%; + } + .monitor-service-strip { + display: grid; + gap: 6px; + } +} diff --git a/web/src/reconciliation.test.ts b/web/src/reconciliation.test.ts new file mode 100644 index 0000000..906eba3 --- /dev/null +++ b/web/src/reconciliation.test.ts @@ -0,0 +1,115 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { + createReconciliationRun, + fetchReconciliationFindings, + fetchReconciliationProgress, + ReconciliationRequestError, +} from './reconciliation' + +afterEach(() => vi.unstubAllGlobals()) +const run = { + id: 'run-1', + kb_id: 'kb-1', + state: 'running', + trigger: 'manual', + started_at: '2026-12-01T02:00:00Z', + finished_at: null, + ledger_count: 0, + kb_count: 0, + counts: {}, + previous_counts: null, + window_overlapped: false, + error_code: '', +} +describe('reconciliation API client', () => { + it('sends the write intent and kb_id when creating a run', async () => { + const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: run }), { status: 202 })) + vi.stubGlobal('fetch', fetchMock) + const created = await createReconciliationRun('kb-1') + expect(created.id).toBe('run-1') + const [, init] = fetchMock.mock.calls[0] + expect(init.headers['X-Governance-Action']).toBe('reconciliation-action') + expect(JSON.parse(String(init.body))).toEqual({ kb_id: 'kb-1' }) + }) + it('surfaces 409 run-in-progress code', async () => { + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue( + new Response( + JSON.stringify({ error: 'reconciliation_run_in_progress', code: 'reconciliation_run_in_progress' }), + { + status: 409, + } + ) + ) + ) + try { + await createReconciliationRun('kb-1') + throw new Error('expected 409') + } catch (error) { + expect(error).toBeInstanceOf(ReconciliationRequestError) + expect((error as ReconciliationRequestError).status).toBe(409) + expect((error as ReconciliationRequestError).code).toBe('reconciliation_run_in_progress') + } + }) + it('marks 503 progress as runtime_read_unavailable', async () => { + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue( + new Response(JSON.stringify({ error: 'runtime_read_unavailable', code: 'runtime_read_unavailable' }), { + status: 503, + }) + ) + ) + await expect(fetchReconciliationProgress('doc-1')).rejects.toMatchObject({ + code: 'runtime_read_unavailable', + }) + }) + it('parses findings and rejects an unknown type', async () => { + const finding = { + id: 'f1', + run_id: 'run-1', + type: 'R1', + publication_id: 'pub-1', + document_id: 'doc-1', + title: 't', + path: 'p', + source: 's', + target_scope: 'internal', + ledger_state: 'completed', + weknora_parse_status: '', + normalized_state: '', + ledger_sha256: '', + declared_sha256: '', + weknora_file_md5: '', + evidence_level: 'none', + confirmation_state: 'pending', + detail: 'd', + suggested_action: 'requeue_upload', + action_state: 'open', + weknora_url: '', + } + vi.stubGlobal( + 'fetch', + vi + .fn() + .mockResolvedValue( + new Response(JSON.stringify({ data: { items: [finding], total: 1, limit: 20, offset: 0 } }), { status: 200 }) + ) + ) + const page = await fetchReconciliationFindings('run-1') + expect(page.items[0].confirmation_state).toBe('pending') + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue( + new Response( + JSON.stringify({ data: { items: [{ ...finding, type: 'R9' }], total: 1, limit: 20, offset: 0 } }), + { + status: 200, + } + ) + ) + ) + await expect(fetchReconciliationFindings('run-1')).rejects.toThrow('对账差异响应无效') + }) +}) diff --git a/web/src/reconciliation.ts b/web/src/reconciliation.ts new file mode 100644 index 0000000..a60f5a4 --- /dev/null +++ b/web/src/reconciliation.ts @@ -0,0 +1,227 @@ +export type ReconciliationFindingType = 'R1' | 'R2' | 'R3' | 'R4' | 'R5' | 'R6' | 'R7' | 'R8' +export type ReconciliationEvidence = 'independent' | 'declared_only' | 'none' +export type ReconciliationConfirmation = 'confirmed' | 'pending' +export type ReconciliationAction = 'requeue_upload' | 'remove_from_test' | 'writeback_state' | 'enter_removal' | 'none' + +export interface ReconciliationRun { + id: string + kb_id: string + state: 'running' | 'succeeded' | 'failed' + trigger: 'schedule' | 'manual' + started_at: string + finished_at: string | null + ledger_count: number + kb_count: number + counts: Record + previous_counts: Record | null + window_overlapped: boolean + error_code: string +} +export interface ReconciliationRunPage { + items: ReconciliationRun[] + total: number + limit: number + offset: number +} +export interface ReconciliationFinding { + id: string + run_id: string + type: ReconciliationFindingType + publication_id: string + document_id: string + title: string + path: string + source: string + target_scope: string + ledger_state: string + weknora_parse_status: string + normalized_state: string + ledger_sha256: string + declared_sha256: string + weknora_file_md5: string + evidence_level: ReconciliationEvidence + confirmation_state: ReconciliationConfirmation + detail: string + suggested_action: ReconciliationAction + action_state: 'open' | 'done' + weknora_url: string +} +export interface ReconciliationFindingPage { + items: ReconciliationFinding[] + total: number + limit: number + offset: number +} +export interface ReconciliationStage { + name: string + status: string + error_code: string + finished_at: string | null +} +export interface ReconciliationFailure { + task_type: string + fail_count: number + failed_at: string + last_error: string +} +export interface ReconciliationProgress { + document_id: string + parse_status: string + ingestion_status: string + wiki_status: string + stages: ReconciliationStage[] + failures: ReconciliationFailure[] + has_more_failures: boolean + observed_at: string +} + +const record = (value: unknown): value is Record => typeof value === 'object' && value !== null +const count = (value: unknown) => typeof value === 'number' && Number.isInteger(value) && value >= 0 +const text = (value: unknown) => (typeof value === 'string' ? value : '') + +export class ReconciliationRequestError extends Error { + status: number + code: string + constructor(message: string, status: number, code: string) { + super(message) + this.status = status + this.code = code + } +} + +async function request(path: string, init: RequestInit, signal?: AbortSignal): Promise { + const response = await fetch(path, { + ...init, + headers: { + Accept: 'application/json', + ...(init.body ? { 'Content-Type': 'application/json' } : {}), + ...(init.headers || {}), + }, + signal, + }) + const payload = await response.json().catch(() => null) + if (!response.ok) { + const body = record(payload) ? payload : {} + throw new ReconciliationRequestError( + text(body.error) || `请求失败(HTTP ${response.status})`, + response.status, + text(body.code) + ) + } + return payload +} + +function parseRun(value: unknown): ReconciliationRun { + if ( + !record(value) || + typeof value.id !== 'string' || + typeof value.kb_id !== 'string' || + !['running', 'succeeded', 'failed'].includes(String(value.state)) || + !['schedule', 'manual'].includes(String(value.trigger)) || + typeof value.started_at !== 'string' || + !count(value.ledger_count) || + !count(value.kb_count) || + !record(value.counts) || + typeof value.window_overlapped !== 'boolean' + ) + throw new Error('对账批次响应无效') + return value as unknown as ReconciliationRun +} + +function parseFinding(value: unknown): ReconciliationFinding { + if ( + !record(value) || + typeof value.id !== 'string' || + !['R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8'].includes(String(value.type)) || + !['independent', 'declared_only', 'none'].includes(String(value.evidence_level)) || + !['confirmed', 'pending'].includes(String(value.confirmation_state)) || + !['requeue_upload', 'remove_from_test', 'writeback_state', 'enter_removal', 'none'].includes( + String(value.suggested_action) + ) || + !['open', 'done'].includes(String(value.action_state)) + ) + throw new Error('对账差异响应无效') + return value as unknown as ReconciliationFinding +} + +export async function fetchReconciliationRuns( + limit = 20, + offset = 0, + kbID = '', + signal?: AbortSignal +): Promise { + const query = new URLSearchParams({ limit: String(limit), offset: String(offset) }) + if (kbID) query.set('kb_id', kbID) + const payload = await request(`/api/v1/reconciliation/runs?${query}`, { method: 'GET' }, signal) + if (!record(payload) || !record(payload.data) || !Array.isArray(payload.data.items)) + throw new Error('对账批次列表响应无效') + return { + items: payload.data.items.map(parseRun), + total: Number(payload.data.total) || 0, + limit: Number(payload.data.limit) || limit, + offset: Number(payload.data.offset) || offset, + } +} + +export async function fetchReconciliationFindings( + runID: string, + type = '', + q = '', + limit = 20, + offset = 0, + signal?: AbortSignal +): Promise { + const query = new URLSearchParams({ limit: String(limit), offset: String(offset) }) + if (type) query.set('type', type) + if (q) query.set('q', q) + const payload = await request( + `/api/v1/reconciliation/runs/${encodeURIComponent(runID)}/findings?${query}`, + { method: 'GET' }, + signal + ) + if (!record(payload) || !record(payload.data) || !Array.isArray(payload.data.items)) + throw new Error('对账差异列表响应无效') + return { + items: payload.data.items.map(parseFinding), + total: Number(payload.data.total) || 0, + limit: Number(payload.data.limit) || limit, + offset: Number(payload.data.offset) || offset, + } +} + +export async function createReconciliationRun(kbID: string): Promise { + const payload = await request('/api/v1/reconciliation/runs', { + method: 'POST', + headers: { 'X-Governance-Action': 'reconciliation-action' }, + body: JSON.stringify({ kb_id: kbID }), + }) + if (!record(payload) || !record(payload.data)) throw new Error('触发对账响应无效') + return parseRun(payload.data) +} + +async function findingAction(id: string, action: 'writeback' | 'requeue' | 'remove'): Promise { + const payload = await request(`/api/v1/reconciliation/findings/${encodeURIComponent(id)}/${action}`, { + method: 'POST', + headers: { 'X-Governance-Action': 'reconciliation-action' }, + }) + if (!record(payload) || !record(payload.data)) throw new Error('对账处置响应无效') + return parseFinding(payload.data) +} + +export const writebackFinding = (id: string) => findingAction(id, 'writeback') +export const requeueFinding = (id: string) => findingAction(id, 'requeue') +export const removeFinding = (id: string) => findingAction(id, 'remove') + +export async function fetchReconciliationProgress( + documentID: string, + signal?: AbortSignal +): Promise { + const payload = await request( + `/api/v1/reconciliation/documents/${encodeURIComponent(documentID)}/progress`, + { method: 'GET' }, + signal + ) + if (!record(payload) || !record(payload.data) || typeof payload.data.document_id !== 'string') + throw new Error('WeKnora 处理详情响应无效') + return payload.data as unknown as ReconciliationProgress +}