fix(library): 打通恢复验证的正常恢复与页面联动
build / build (push) Successful in 1m35s

B1/B2:演练在同一维护切点做两次真实捕获(写前镜像与来源身份),
写集合在写第一笔之前落盘并登记;恢复走限定范围的 RestoreDrill,
复用同一份 DS01 身份合同与 Apply 原语整段回放,不再让同快照必被拒绝。
worker 接治理维护生命周期(实例+scope 行、真实入口状态、成功才释放),
held 保留行并由同 job 的 library.recover 收口(kind 过滤贯通 verify)。
B3:证据优先,failed/invalid 与读取错误即使 env=true 也拒绝。
B4/B5:GET 投影在飞作业,子面板回调父页面轮询;观测绑定 scope 与代次,
刷新失败明确过期,不再显示旧的"已验证"。
迁移 79 不自动 down;未部署、未调用业务目标。
This commit is contained in:
姚章浩
2026-11-03 11:14:27 +08:00
parent 5e1482e349
commit f9457fab52
22 changed files with 1145 additions and 136 deletions
+22 -6
View File
@@ -35,6 +35,8 @@ export interface LibraryVerificationView {
history: LibraryVerificationRecord[]
running?: boolean
job_id?: string
state?: string
stage?: string
}
function record(value: unknown): value is Record<string, unknown> {
@@ -97,19 +99,29 @@ export function parseVerificationView(value: unknown): LibraryVerificationView |
history,
running: bool(value.running),
job_id: text(value.job_id) || undefined,
state: text(value.state) || undefined,
stage: text(value.stage) || undefined,
}
}
export async function fetchLibraryVerification(
scope: string,
signal?: AbortSignal
): Promise<LibraryVerificationView | null> {
// fetchLibraryVerification 只返回**这份 scope** 的观测:
// HTTP 非 2xx、响应不可解析、或响应 scope 与请求不一致都抛错。
// 调用方据此把"读失败"和"没有证据"分开显示,不能拿旧绿色遮住失败(审核 B5)。
export async function fetchLibraryVerification(scope: string, signal?: AbortSignal): Promise<LibraryVerificationView> {
const response = await fetch(`/api/v1/library/verifications?scope=${encodeURIComponent(scope)}`, {
headers: { Accept: 'application/json' },
signal,
})
const value = (await response.json().catch(() => null)) as unknown
return parseVerificationView(value)
if (!response.ok) {
if (record(value) && text(value.reason)) throw new Error(`读取验证状态失败:${text(value.reason)}`)
throw new Error(`读取验证状态失败(HTTP ${response.status})`)
}
const parsed = parseVerificationView(value)
if (!parsed) throw new Error('读取验证状态失败:响应不可解析')
if (parsed.scope !== scope)
throw new Error(`读取验证状态失败:响应 scope=${parsed.scope || '空'} 与请求 ${scope} 不一致`)
return parsed
}
export interface LibraryVerificationAccepted {
@@ -150,8 +162,12 @@ export function verificationTargetLines(target: LibraryVerificationTarget, scope
]
}
export function verificationStatusText(view: LibraryVerificationView | null): string {
// verificationStatusText 只在**当前 scope 的新鲜观测**上允许说"已验证"。
// stale 表示这次刷新失败、显示的是上一次结果:它既不是当前结论,也不能是绿灯。
export function verificationStatusText(view: LibraryVerificationView | null, stale = false): string {
if (!view) return '还没有读到验证状态'
if (stale) return '上次观测已过期(刷新失败)'
if (view.running) return '验证执行中'
if (view.verified) return '已验证(当前目标)'
if (view.latest) return view.latest.status === 'failed' ? '最近一次未通过' : '未通过'
return '还没有验证记录'