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
+46 -2
View File
@@ -117,6 +117,12 @@ interface ViewProps {
sync: ReleaseSyncActions
// 目标非空又没有生效版本时,唯一入口是"建立目标权威基线"(管理员)。
baseline: ReleaseBaselineActions
// 恢复验证(真实作业)的接受/终态要回到父页面:父级据此启动轮询并在终态读回
// overview/维护/闸口,不能只在子面板里刷新自己。
verification: {
onAccepted: (jobId: string) => void
onComplete: (jobId: string) => void
}
// 按版本恢复是管理员动作:工程师看得到条件,但拿不到恢复入口。
canRestore: boolean
restore: LibraryRestoreAvailability | null
@@ -724,6 +730,7 @@ function ProtectionCard({
baseline,
scope,
onOpen,
verification,
}: {
production: LibraryOverview['production'] | null
// 没有目标观测时显示的原因(加载中 / 整体读取失败 / 当前范围没数据)。
@@ -737,6 +744,10 @@ function ProtectionCard({
baseline: ReleaseBaselineActions
scope: Scope
onOpen: () => void
verification: {
onAccepted: (jobId: string) => void
onComplete: (jobId: string) => void
}
}) {
const backupKnown = prebackup.state === 'known' && prebackup.version
// 基线入口只在"目标非空、却没有生效版本"时才是答案;空库走首次同步(预备份+登记),
@@ -804,7 +815,12 @@ function ProtectionCard({
<dt>恢复条件</dt>
<dd>{gate.reasons.length === 0 ? '已满足' : `缺 ${gate.reasons.length} 项`}</dd>
</dl>
<RestoreVerificationSection scope={scope} isAdmin={sync.canSign} />
<RestoreVerificationSection
scope={scope}
isAdmin={sync.canSign}
onAccepted={verification.onAccepted}
onComplete={verification.onComplete}
/>
{gate.reasons.length > 0 ? (
<ul className="rel-gate" aria-label="恢复与启动条件">
{gate.reasons.map((reason) => (
@@ -853,6 +869,10 @@ interface ReadyProps {
onOpen: () => void
sync: ReleaseSyncActions
baseline: ReleaseBaselineActions
verification: {
onAccepted: (jobId: string) => void
onComplete: (jobId: string) => void
}
}
function ReadyBody({
@@ -866,6 +886,7 @@ function ReadyBody({
authorization,
sync,
baseline,
verification,
canCapture,
canWrite,
pendingCapture,
@@ -889,6 +910,7 @@ function ReadyBody({
baseline={baseline}
scope={view.scope}
onOpen={onOpen}
verification={verification}
/>
</div>
<div className="rel-panel rel-jobbar">
@@ -1412,6 +1434,7 @@ export function ReleaseTargetsView(props: ViewProps) {
canWrite,
sync,
baseline,
verification,
canRestore,
restore,
restoreNotice,
@@ -1635,6 +1658,7 @@ export function ReleaseTargetsView(props: ViewProps) {
authorization={authorization}
sync={sync}
baseline={baseline}
verification={verification}
canCapture={canCapture}
canWrite={canWrite}
pendingCapture={pendingCapture}
@@ -1793,6 +1817,9 @@ export function ReleaseTargets() {
// 只靠 jobs/overview 判断会让页面在投递后立刻停止轮询,恢复完成也停在旧状态(F12)。
const [pendingRecovery, setPendingRecovery] = useState(false)
const recoveryStartedAt = useRef(0)
// 恢复验证是独立业务作业:投递后父页面必须自己轮询 overview/维护/闸口,
// 只在子面板刷新证据会让页面停在点击前的状态(审核 B4)。
const [activeVerifyJob, setActiveVerifyJob] = useState('')
const [pendingGrant, setPendingGrant] = useState(false)
// 轮询覆盖"投递 → 终态读回":投递中的动作也算在跑(点完到 worker 落库之间
// 有一次空窗,只看已有作业会让页面停在"尚未启动")。终态(成功/失败/取消)
@@ -1800,7 +1827,14 @@ export function ReleaseTargets() {
const polling = libraryPollingActive({
captures: jobs,
overviews,
pending: pendingCapture || pendingSync || pendingBaseline || pendingRestore || pendingSyncGrant || pendingGrant,
pending:
pendingCapture ||
pendingSync ||
pendingBaseline ||
pendingRestore ||
pendingSyncGrant ||
pendingGrant ||
activeVerifyJob !== '',
recoveryPending: pendingRecovery,
maintenances,
})
@@ -1949,6 +1983,16 @@ export function ReleaseTargets() {
pending: pendingBaseline,
onStart: () => void startBaseline(),
}}
verification={{
onAccepted: (jobId) => {
setActiveVerifyJob(jobId)
void load()
},
onComplete: () => {
setActiveVerifyJob('')
void load()
},
}}
canRestore={canRestore}
restore={restore}
restoreNotice={restoreNotice}