根因:生产可恢复性只有 PRODUCTION_BACKUP_RESTORE_VERIFIED 这个手填 env 开关, 页面没有任何入口去真跑一次恢复;CLI(librarydrill)又不是 worker 能复用的实现, 所以"已验证"既证明不了跑过、也证明不了跑的是当前目标。 改动: - 共享实现 internal/libraryverify(维护隔离→捕获→基线校验→canary→恢复→复核→关窗口), cmd/librarydrill 改为薄封装,CLI 与 worker 只允许一份执行体。 - verify 成为独立业务作业:kind + VerifyStages(capture/verify/canary/restore/finalize), 与 sync/restore/baseline 共用同一把写互斥;迁移 79 加 kind 约束、重建部分唯一索引、 新建 library_restore_verifications(按 target_id 绑定,换库/索引/桶旧证据自动失效, 同 target+scope+job 幂等)。 - worker:admitLibraryJob + runOwnedLibraryAttempt 之后调用共享实现,阶段实时写 library_job_stages,结束后写真实终态;通过写 passed 证据,失败写 failed+原因(不伪成功); 中断接管按同一作业 id 收掉维护窗口。 - API:POST/GET /api/v1/library/verifications(管理员;闸口关闭/维护中拒绝;返回完整 整库目标、最近证据、失败原因),OpenAPI 同步。 - 闸口:同步/恢复/续作的证据判断改为读当前目标证据;历史 env 仅在证据缺失时兜底, 证据存在时以证据为准。 - 页面:生产保护与恢复面板加「恢复验证」块(完整 KB/索引/桶、状态、最近证据、失败原因、 管理员按钮、5s 轮询),作业类型补 verify 文案。 测试:make verify 16/16 全绿(go 1387 例 + web 454 例 + 契约/迁移/密钥/依赖锁定); 新增用例覆盖证据四条件、闸口证据优先、页面无证据/失败/通过三种呈现与管理员可见性。
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
||||
} from './librarySnapshots'
|
||||
import { useOptionalAuth } from './auth'
|
||||
import './releaseTargets.css'
|
||||
import { RestoreVerificationSection } from './RestoreVerificationSection'
|
||||
|
||||
// 发布管理:按已确认稿实现——顶部两个知识库页签,下面是**一个**作业区。
|
||||
//
|
||||
@@ -260,6 +261,7 @@ export function jobKindText(kind?: string): string {
|
||||
if (kind === 'sync') return '生产同步'
|
||||
if (kind === 'restore') return '按版本恢复'
|
||||
if (kind === 'baseline') return '建立目标基线'
|
||||
if (kind === 'verify') return '恢复验证'
|
||||
return kind ? kind : '—'
|
||||
}
|
||||
|
||||
@@ -281,7 +283,9 @@ export function publishStateText(job?: LibraryJobRecord): string {
|
||||
? '恢复进行中(目标在维护中)'
|
||||
: job.kind === 'baseline'
|
||||
? '建立基线进行中(只读捕获目标,不写内容)'
|
||||
: '同步进行中(目标在维护中)'
|
||||
: job.kind === 'verify'
|
||||
? '恢复验证进行中(目标在维护中)'
|
||||
: '同步进行中(目标在维护中)'
|
||||
}
|
||||
if (job.state === 'succeeded') return `${jobKindText(job.kind)}已完成 · ${stamp(job.finished_at ?? job.updated_at)}`
|
||||
if (job.state === 'failed') return `${jobKindText(job.kind)}失败 · ${stamp(job.finished_at ?? job.updated_at)}`
|
||||
@@ -718,6 +722,7 @@ function ProtectionCard({
|
||||
targetSealed,
|
||||
sync,
|
||||
baseline,
|
||||
scope,
|
||||
onOpen,
|
||||
}: {
|
||||
production: LibraryOverview['production'] | null
|
||||
@@ -730,6 +735,7 @@ function ProtectionCard({
|
||||
targetSealed: boolean
|
||||
sync: ReleaseSyncActions
|
||||
baseline: ReleaseBaselineActions
|
||||
scope: Scope
|
||||
onOpen: () => void
|
||||
}) {
|
||||
const backupKnown = prebackup.state === 'known' && prebackup.version
|
||||
@@ -798,6 +804,7 @@ function ProtectionCard({
|
||||
<dt>恢复条件</dt>
|
||||
<dd>{gate.reasons.length === 0 ? '已满足' : `缺 ${gate.reasons.length} 项`}</dd>
|
||||
</dl>
|
||||
<RestoreVerificationSection scope={scope} isAdmin={sync.canSign} />
|
||||
{gate.reasons.length > 0 ? (
|
||||
<ul className="rel-gate" aria-label="恢复与启动条件">
|
||||
{gate.reasons.map((reason) => (
|
||||
@@ -880,6 +887,7 @@ function ReadyBody({
|
||||
targetSealed={Boolean(snapshot)}
|
||||
sync={sync}
|
||||
baseline={baseline}
|
||||
scope={view.scope}
|
||||
onOpen={onOpen}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user