feat(reconciliation): 实现导入对账后端

为什么:T6a 需要一张批次/差异表、全量只读扫描、R1-R8 判定和 finding 级处置;现有解析监控只转述台账状态,无法回答库内是否一致。
做什么:迁移 000084(upload_md5、runs/findings/actions、共享 removal_candidates 视图);WeKnora 字段与 1000/页扫描;runtime 只读客户端(0400 Key、503 降级);扫描/矩阵/动作/定时/僵死回收;9 条接口与 RBAC;overview 队列与删两张常量卡。
边界:只对测试库;对账零写请求;R1/R2 单条确认;R6 复用 /removal;R2 只管理员;生产链路未改。
验证:make verify 全绿(17 项);新增矩阵/扫描 R1-R8/零写/失败整批/动作/运行时/密钥权限测试。
This commit is contained in:
Zhero & Rin
2026-12-01 12:19:54 +08:00
committed by 姚章浩
parent 580695ca2e
commit 4528a55e6a
43 changed files with 3661 additions and 122 deletions
+10 -2
View File
@@ -11,8 +11,16 @@ func TestEmbeddedMigrationsAreVersionSorted(t *testing.T) {
if err != nil {
t.Fatalf("loadMigrations() error = %v", err)
}
if len(migrations) != 83 {
t.Fatalf("migration count = %d, want 83", len(migrations))
if len(migrations) != 84 {
t.Fatalf("migration count = %d, want 84", len(migrations))
}
// 84 是导入对账:台账 upload_md5、runs/findings/actions 与共享需下架视图。
if reconciliation := migrations[83]; reconciliation.Version != 84 ||
!strings.Contains(reconciliation.UpSQL, "CREATE TABLE IF NOT EXISTS reconciliation_runs") ||
!strings.Contains(reconciliation.UpSQL, "CREATE OR REPLACE VIEW removal_candidates") ||
!strings.Contains(reconciliation.UpSQL, "upload_md5") ||
!strings.Contains(reconciliation.DownSQL, "DROP VIEW IF EXISTS removal_candidates") {
t.Fatalf("migration 84 = %#v", reconciliation)
}
// 83 是密钥保存审计的来源列:只追加取证字段,来源解析不出时留空。
if source := migrations[82]; source.Version != 83 ||