feat(library): 真实差异比对 + 孤儿作业回收 + 验收矩阵与台账
build / build (push) Successful in 1m18s

为什么:发布管理的差异一直显示"未接入",业务作业也可能因队列丢作业而永久占锁;
本轮把这两件做成真实实现,并把 30 个验收项与 CI/版本身份落成可审计文档。

- internal/librarydiff:稳定文档 ID + 排除易变列的整行摘要做增改撤销;overview 在
  生产权威版本与测试封存都在时给出 computed 差异并标注两侧快照,缺一侧仍是 unknown。
- 发布管理"本次变更"列文档身份与比对版本;无差异时明确写"没有文档差异"。
- ReconcileLibraryJobs:worker 启动清理队列已无对应作业的孤儿,避免永久互斥。
- docs/library-acceptance-matrix.md 与 docs/release-ledger.md 固定证据与版本事实。
This commit is contained in:
姚章浩
2026-10-28 14:39:17 +08:00
parent e3db157ba8
commit e313ae12f2
12 changed files with 490 additions and 1 deletions
+22
View File
@@ -195,6 +195,28 @@ describe('ReleaseTargetsView(确认稿布局)', () => {
expect(html).toContain('没有当前作业证据时不会把历史封存当作阶段完成')
})
it('差异已计算时按文档身份列增改撤销,并标注比对的两个版本', () => {
const html = render({
overview: {
...overview,
diff: {
state: 'computed',
added: [{ id: 'doc-new-0001', title: '新增的说明', digest: 'a'.repeat(64) }],
updated: [{ id: 'doc-upd-0002', title: '改过的说明', digest: 'b'.repeat(64) }],
removed: [{ id: 'doc-del-0003', title: '撤销的说明', digest: 'c'.repeat(64) }],
base_snapshot: 'prod00000000',
target_snapshot: 'test00000000',
},
},
})
expect(html).toContain('3 条')
expect(html).toContain('新增的说明 · doc-new-')
expect(html).toContain('改过的说明 · doc-upd-')
expect(html).toContain('撤销的说明 · doc-del-')
expect(html).toContain('生产 prod00000000 → 测试 test00000000')
expect(html).not.toContain('变更清单来自生产与测试版本对比')
})
it('准备信息注明快照时间与范围,不声称实时测试库已就绪', () => {
const html = render()
expect(html).toContain('依据 10/28 11:34 封存的测试库全库快照,不代表实时测试库已就绪')
+20 -1
View File
@@ -248,6 +248,20 @@ function StageBar({ view }: { view: ScopeView }) {
)
}
// 差异行是 {id,title,digest} 对象;只展示人能核对的身份,不摊开内部摘要。
function diffLabel(item: unknown): string {
if (typeof item === 'string') return item
if (item && typeof item === 'object') {
const record = item as Record<string, unknown>
const title = typeof record.title === 'string' ? record.title : ''
const id = typeof record.id === 'string' ? record.id : ''
if (title && id) return `${title} · ${id.slice(0, 8)}`
if (title) return title
if (id) return id
}
return JSON.stringify(item)
}
function ChangeTable({ diff }: { diff: LibraryOverview['diff'] }) {
const computed = diff.state === 'computed'
const rows = computed
@@ -266,6 +280,11 @@ function ChangeTable({ diff }: { diff: LibraryOverview['diff'] }) {
</div>
<span className={`rel-pill ${computed ? 'green' : 'gray'}`}>{computed ? `${rows.length} 条` : '未接入'}</span>
</header>
{computed && diff.base_snapshot && diff.target_snapshot ? (
<p className="rel-scope-note">
生产 {diff.base_snapshot.slice(0, 12)} → 测试 {diff.target_snapshot.slice(0, 12)}
</p>
) : null}
<table>
<thead>
<tr>
@@ -286,7 +305,7 @@ function ChangeTable({ diff }: { diff: LibraryOverview['diff'] }) {
rows.map((row, index) => (
<tr key={`${row.action}-${index}`}>
<td>{row.action}</td>
<td>{typeof row.item === 'string' ? row.item : JSON.stringify(row.item)}</td>
<td>{diffLabel(row.item)}</td>
</tr>
))
)}
+3
View File
@@ -247,6 +247,9 @@ export interface LibraryDiff {
added: unknown[]
updated: unknown[]
removed: unknown[]
/** 这次比对用的两个整库版本(生产 → 测试),避免把历史差异当成当前。 */
base_snapshot?: string
target_snapshot?: string
}
export interface LibraryStageRow {
+15
View File
@@ -598,3 +598,18 @@
overflow-x: auto;
}
}
/* 准备信息 / 差异行的范围说明:让人一眼看出依据的是哪次封存,而不是"现在"。 */
.rel-scope,
.rel-scope-note {
display: block;
margin: 2px 0 0;
font-style: normal;
font-size: 11px;
color: var(--rel-muted, #7b8d9a);
}
.rel-scope-note {
padding: 6px 14px 0;
font-variant-numeric: tabular-nums;
}