fix(reconciliation): R6 改用 removal_candidates 视图,定时批每日只占一个名额
build / build (push) Successful in 2m28s
build / build (push) Successful in 2m28s
白盒补充复核提出的三项: - P1 R6 与 /monitor/overview「需下架」计数口径不一致:R6 原先只在扫描结果里存在 且上游 parse_status=completed 时才生成,上游仍在 processing/finalizing 或单条读取 失败导致扫描缺行时,总览有数、对账无记录(陷阱 15)。改为直接由 removal_candidates 视图行生成,台账细节按 publication 回填,计数与总览同一来源;补单测覆盖 「上游 processing」「扫描未见」两种差异。 - P2 定时批失败后每个 tick 都重建:每日占位只排除 running/succeeded,failed 不占位, 一次失败当天会每分钟刷批。占位条件加入 failed,重跑改为显式手动触发;补 PG 集成用例。 - P2 队列不可用时前端显示 0 等待 · 0 运行:改为按 available 判定并显示不可用文案; 补组件用例。
This commit is contained in:
@@ -278,11 +278,7 @@ func (s *Service) buildFindings(ctx context.Context, run governance.Reconciliati
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
removalByPublication := make(map[string]bool, len(removal))
|
||||
for _, row := range removal {
|
||||
removalByPublication[row.PublicationID] = true
|
||||
}
|
||||
|
||||
// 「需下架」的台账细节沿用上面按 publication 建的台账索引。
|
||||
for _, row := range ledger {
|
||||
if !expectedLive(row) {
|
||||
continue
|
||||
@@ -305,15 +301,6 @@ func (s *Service) buildFindings(ctx context.Context, run governance.Reconciliati
|
||||
if finding, ok := s.r4Finding(row, item, normalized); ok {
|
||||
add(finding)
|
||||
}
|
||||
if removalByPublication[row.PublicationID] && item.ParseStatus == "completed" {
|
||||
add(governance.ReconciliationFinding{
|
||||
Type: "R6", PublicationID: row.PublicationID, DocumentID: row.KnowledgeID,
|
||||
Title: row.Title, Path: row.Path, Source: row.SourceName, TargetScope: row.TargetScope,
|
||||
LedgerState: row.ProcessingState, WeKnoraParseState: item.ParseStatus, NormalizedState: normalized,
|
||||
LedgerSHA256: row.SHA256, EvidenceLevel: "none", SuggestedAction: "enter_removal",
|
||||
Detail: "来源已判禁止导入,条目仍在测试库可检索",
|
||||
})
|
||||
}
|
||||
if row.ProcessingState == "cancelled" {
|
||||
if normalized != "cancelled" && ageFromPointer(run.StartedAt, row.ProcessingStartedAt, row.UpdatedAt) >= s.grace {
|
||||
add(r5Finding(row, item, normalized, "none", "台账已取消,WeKnora 仍有活动状态"))
|
||||
@@ -355,6 +342,51 @@ func (s *Service) buildFindings(ctx context.Context, run governance.Reconciliati
|
||||
}
|
||||
}
|
||||
|
||||
// R6: 应下架仍在。判定口径 = removal_candidates 视图(与 /monitor/overview 的
|
||||
// 「需下架」共用同一实现,陷阱 15)。这里直接由视图行生成,不再附加「本轮扫描
|
||||
// 见到该条目」「上游 parse_status=completed」这类只有对账侧才有的条件——上游仍在
|
||||
// processing/finalizing、或单条读取失败导致扫描缺行时,两处数字就会永久不一致。
|
||||
for _, row := range removal {
|
||||
finding := governance.ReconciliationFinding{
|
||||
Type: "R6", PublicationID: row.PublicationID, DocumentID: row.KnowledgeID,
|
||||
Title: row.Title, Path: row.Path, Source: row.SourceName, TargetScope: row.TargetScope,
|
||||
// 视图只收录 processing_state='completed' 的台账行。
|
||||
LedgerState: "completed", EvidenceLevel: "none", SuggestedAction: "enter_removal",
|
||||
Detail: "来源已判禁止导入,条目仍在测试库可检索",
|
||||
}
|
||||
if own, ok := ledgerByPublication[row.PublicationID]; ok {
|
||||
if finding.DocumentID == "" {
|
||||
finding.DocumentID = own.KnowledgeID
|
||||
}
|
||||
if finding.Title == "" {
|
||||
finding.Title = own.Title
|
||||
}
|
||||
if finding.Path == "" {
|
||||
finding.Path = own.Path
|
||||
}
|
||||
if finding.Source == "" {
|
||||
finding.Source = own.SourceName
|
||||
}
|
||||
if finding.TargetScope == "" {
|
||||
finding.TargetScope = own.TargetScope
|
||||
}
|
||||
if own.ProcessingState != "" {
|
||||
finding.LedgerState = own.ProcessingState
|
||||
}
|
||||
finding.LedgerSHA256 = own.SHA256
|
||||
}
|
||||
if item, ok := byID[finding.DocumentID]; ok {
|
||||
if normalized, known := normalizeParseStatus(item.ParseStatus); known {
|
||||
finding.NormalizedState = normalized
|
||||
}
|
||||
finding.WeKnoraParseState = item.ParseStatus
|
||||
finding.WeKnoraFileMD5 = normalizeMD5(item.FileHash)
|
||||
} else if finding.DocumentID != "" {
|
||||
finding.Detail = "来源已判禁止导入;本轮扫描未见该条目,计数仍与总览「需下架」一致"
|
||||
}
|
||||
add(finding)
|
||||
}
|
||||
|
||||
// R8: one publication id maps to more than one live row.
|
||||
grouped := make(map[string][]weknora.Knowledge)
|
||||
for _, item := range items {
|
||||
|
||||
Reference in New Issue
Block a user