feat(library): 整库发布身份、写集合与收尾边界
build / build (push) Successful in 1m45s

执行时真实时钟与持久授权回读(撤销/过期即停并保留预备份)、写集合写前落盘、
租约与 attempt 身份、恢复队列与原发送身份分离、成功收尾必须释放维护后再登记终态。
This commit is contained in:
姚章浩
2026-11-01 11:35:10 +08:00
parent 5afd8c0140
commit 8d838d9cb4
82 changed files with 4809 additions and 551 deletions
+71 -48
View File
@@ -1,3 +1,4 @@
import { LegacySourceAssociation } from './LegacySourceAssociation'
import { useCallback, useEffect, useRef, useState } from 'react'
import {
createLibraryRestoreAuthorization,
@@ -1474,6 +1475,19 @@ export function ReleaseTargetsView(props: ViewProps) {
<dd>{target ? '完整快照' : '未接入'}</dd>
</div>
</dl>
{target?.source_identity ? (
<details className="rel-source-identity">
<summary>来源身份与完整摘要</summary>
<p>
来源实例:{target.source_identity.project} / {target.source_identity.app}
</p>
<p>
来源租户 / 知识库:{target.source_identity.tenant_id} / {target.source_identity.knowledge_base_id}
</p>
<p>来源身份:{target.source_id}</p>
<p>快照摘要:{target.snapshot_id}</p>
</details>
) : null}
<ul className="rel-checklist">
<li className={target ? 'ok' : 'unknown'}>
{target
@@ -1639,14 +1653,14 @@ export function ReleaseTargets() {
}
const startSync = async () => {
if (!targetSnapshot) {
setNotice('还没有可发布的测试封存')
if (!targetSnapshot || !current?.test_sealed?.source_id) {
setNotice('还没有与当前来源绑定的可发布封存,请刷新状态')
return
}
setPendingSync(true)
setNotice(null)
try {
const accepted = await enqueueLibrarySync(scope, targetSnapshot)
const accepted = await enqueueLibrarySync(scope, targetSnapshot, current?.test_sealed?.source_id ?? '')
setNotice(`已投递同步:${accepted.job_id}(先固定测试版本并生成预备份,再写目标)`)
await load()
} catch (syncError) {
@@ -1801,50 +1815,59 @@ export function ReleaseTargets() {
}, [pendingRecovery, maintenances, scope, load])
return (
<ReleaseTargetsView
page={page}
jobs={jobs}
overview={overviews[scope]}
loading={loading}
error={error}
notice={notice}
scope={scope}
onScope={(next) => {
setScope(next)
setExpandedSnapshot(null)
}}
drawerOpen={drawerOpen}
onDrawer={setDrawerOpen}
expandedSnapshot={expandedSnapshot}
onExpandSnapshot={setExpandedSnapshot}
pendingCapture={pendingCapture}
canCapture={canCapture}
canWrite={canWrite}
sync={{
canSign: canSignSync,
pendingGrant: pendingSyncGrant,
onGrant: () => void grantSync(),
canStart: current?.gate.sync_allowed === true,
pending: pendingSync,
onStart: () => void startSync(),
}}
baseline={{
canStart: canSignSync,
pending: pendingBaseline,
onStart: () => void startBaseline(),
}}
canRestore={canRestore}
restore={restore}
restoreNotice={restoreNotice}
pendingRestore={pendingRestore}
pendingGrant={pendingGrant}
onGrantRestore={() => void grantRestore()}
onRestore={() => void startRestore()}
maintenance={maintenances[scope]}
now={now}
onRefresh={() => void load()}
onCapture={() => void startCapture()}
onRecover={(windowJobID) => void recover(windowJobID)}
/>
<>
<ReleaseTargetsView
page={page}
jobs={jobs}
overview={overviews[scope]}
loading={loading}
error={error}
notice={notice}
scope={scope}
onScope={(next) => {
setScope(next)
setExpandedSnapshot(null)
}}
drawerOpen={drawerOpen}
onDrawer={setDrawerOpen}
expandedSnapshot={expandedSnapshot}
onExpandSnapshot={setExpandedSnapshot}
pendingCapture={pendingCapture}
canCapture={canCapture}
canWrite={canWrite}
sync={{
canSign: canSignSync,
pendingGrant: pendingSyncGrant,
onGrant: () => void grantSync(),
canStart: current?.gate.sync_allowed === true && Boolean(current?.test_sealed?.source_id),
pending: pendingSync,
onStart: () => void startSync(),
}}
baseline={{
canStart: canSignSync,
pending: pendingBaseline,
onStart: () => void startBaseline(),
}}
canRestore={canRestore}
restore={restore}
restoreNotice={restoreNotice}
pendingRestore={pendingRestore}
pendingGrant={pendingGrant}
onGrantRestore={() => void grantRestore()}
onRestore={() => void startRestore()}
maintenance={maintenances[scope]}
now={now}
onRefresh={() => void load()}
onCapture={() => void startCapture()}
onRecover={(windowJobID) => void recover(windowJobID)}
/>
<LegacySourceAssociation
key={scope}
scope={scope}
snapshots={page?.snapshots ?? []}
admin={role === 'admin'}
onBound={() => load()}
/>
</>
)
}