fix(release): 修复发布管理F01-F11资源闭包与状态呈现
build / build (push) Successful in 1m44s

F01:捕获、写前镜像、指纹和恢复后内容校验共用按目标精确绑定的资源闭包:
从已限定范围的 resource_bindings 与正文 handle 一次提取,再按索引取资源,
不再对每个租户资源扫描全部正文表。无绑定正文引用仍保留,缺失资源仍失败。

F02/F03:恢复验证使用 capture/verify/canary/restore/finalize 自己的阶段,登记
证据不再叫新版本生效;顶部优先在飞作业;已验证且 API reason 为空时不再同屏
显示未读到状态,报告可展开。

F04-F11:显示实际目标实例/项目/库;运行中主按钮查看当前任务并禁止重复启动;
快照历史默认已登记、可筛选分页并定位所选;无真实下次计划时显示未读取;各
scope 独立 overview;新操作清旧通知;存储行按文档/分块/资源/绑定及 Wiki
页面/目录/日志分项。高影响恢复验证/恢复增加一次影响确认。

验证:隔离 PG 20k 无关资源夹具旧扫描 683ms→新导出 41ms,资源 ID 闭包相等;
Go/前端全量及 make verify 17 项通过。未部署、未做 8088 UI 验收。
This commit is contained in:
姚章浩
2026-11-05 12:50:11 +08:00
parent 7675e2cd88
commit 1a0f99e346
18 changed files with 835 additions and 86 deletions
@@ -25,17 +25,34 @@ func exportLibraryBeforeImage(ctx context.Context, db librarySnapshotDB, identit
return PostgresSnapshot{}, errors.New("before-image schema contract mismatch")
}
exporter := PostgresExporter{db: tx}
snapshot := PostgresSnapshot{}
rowsByTable := map[string][]json.RawMessage{}
var bodies, bindings []json.RawMessage
for _, table := range productionLibraryTables {
if table == "resources" {
continue
}
rows, err := exporter.queryRows(ctx, fmt.Sprintf(`SELECT to_jsonb(%s) FROM %s WHERE %s ORDER BY (%s)::text`, table, table, scopeWhere(table), identityExpr(table)), identity.TenantID, identity.KnowledgeBaseID)
if err != nil {
return PostgresSnapshot{}, err
}
snapshot.Tables = append(snapshot.Tables, newTableSnapshot(table, rows))
rowsByTable[table] = rows
if table != "resource_bindings" && table != "knowledge_tag_relations" {
bodies = append(bodies, rows...)
}
if table == "resource_bindings" {
bindings = rows
}
}
var bodies []json.RawMessage
for _, table := range snapshot.Tables {
bodies = append(bodies, table.Rows...)
// F01: the before-image needs exact rollback rows, including deleted
// resources, but must not rescan every tenant resource per body table.
resources, err := scopedResourceRows(ctx, &exporter, identity, true, bodies, bindings)
if err != nil {
return PostgresSnapshot{}, err
}
rowsByTable["resources"] = resources
snapshot := PostgresSnapshot{}
for _, table := range productionLibraryTables {
snapshot.Tables = append(snapshot.Tables, newTableSnapshot(table, rowsByTable[table]))
}
handles, err := libraryResourceHandles(bodies)
if err != nil {