4528a55e6a
为什么: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/零写/失败整批/动作/运行时/密钥权限测试。
139 lines
4.6 KiB
Go
139 lines
4.6 KiB
Go
package governance
|
|
|
|
import "time"
|
|
|
|
// ReconciliationCounts is keyed by R1..R8. Normalize keeps every key present so
|
|
// the API and page never have to distinguish "absent" from "zero".
|
|
type ReconciliationCounts map[string]int
|
|
|
|
func (counts ReconciliationCounts) Normalize() ReconciliationCounts {
|
|
out := make(ReconciliationCounts, 8)
|
|
for _, key := range []string{"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8"} {
|
|
out[key] = counts[key]
|
|
}
|
|
return out
|
|
}
|
|
|
|
type ReconciliationRun struct {
|
|
ID string `json:"id"`
|
|
KBID string `json:"kb_id"`
|
|
State string `json:"state"`
|
|
Trigger string `json:"trigger"`
|
|
StartedAt time.Time `json:"started_at"`
|
|
FinishedAt *time.Time `json:"finished_at"`
|
|
LedgerCount int `json:"ledger_count"`
|
|
KBCount int `json:"kb_count"`
|
|
Counts ReconciliationCounts `json:"counts"`
|
|
PreviousCounts ReconciliationCounts `json:"previous_counts"`
|
|
WindowOverlapped bool `json:"window_overlapped"`
|
|
ErrorCode string `json:"error_code"`
|
|
}
|
|
|
|
type ReconciliationFinding struct {
|
|
ID string `json:"id"`
|
|
RunID string `json:"run_id"`
|
|
Type string `json:"type"`
|
|
PublicationID string `json:"publication_id"`
|
|
DocumentID string `json:"document_id"`
|
|
Title string `json:"title"`
|
|
Path string `json:"path"`
|
|
Source string `json:"source"`
|
|
TargetScope string `json:"target_scope"`
|
|
LedgerState string `json:"ledger_state"`
|
|
WeKnoraParseState string `json:"weknora_parse_status"`
|
|
NormalizedState string `json:"normalized_state"`
|
|
LedgerSHA256 string `json:"ledger_sha256"`
|
|
DeclaredSHA256 string `json:"declared_sha256"`
|
|
WeKnoraFileMD5 string `json:"weknora_file_md5"`
|
|
EvidenceLevel string `json:"evidence_level"`
|
|
ConfirmationState string `json:"confirmation_state"`
|
|
Detail string `json:"detail"`
|
|
SuggestedAction string `json:"suggested_action"`
|
|
ActionState string `json:"action_state"`
|
|
WeKnoraURL string `json:"weknora_url"`
|
|
}
|
|
|
|
type ReconciliationLedgerRow struct {
|
|
PublicationID string
|
|
KnowledgeID string
|
|
ProcessingState string
|
|
RetrievalState string
|
|
TargetScope string
|
|
ProcessingStartedAt *time.Time
|
|
UpdatedAt time.Time
|
|
UploadMD5 string
|
|
SourceItemID string
|
|
Title string
|
|
Path string
|
|
SourceName string
|
|
PolicyState string
|
|
SHA256 string
|
|
}
|
|
|
|
type ReconciliationRunFilter struct {
|
|
KBID string
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
type ReconciliationRunPage struct {
|
|
Items []ReconciliationRun `json:"items"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|
|
|
|
type ReconciliationFindingFilter struct {
|
|
RunID string
|
|
Type string
|
|
Query string
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
type ReconciliationFindingPage struct {
|
|
Items []ReconciliationFinding `json:"items"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|
|
|
|
type ReconciliationStage struct {
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
ErrorCode string `json:"error_code"`
|
|
FinishedAt *time.Time `json:"finished_at"`
|
|
}
|
|
|
|
type ReconciliationFailure struct {
|
|
TaskType string `json:"task_type"`
|
|
FailCount int `json:"fail_count"`
|
|
FailedAt time.Time `json:"failed_at"`
|
|
LastError string `json:"last_error"`
|
|
}
|
|
|
|
type ReconciliationProgress struct {
|
|
DocumentID string `json:"document_id"`
|
|
ParseStatus string `json:"parse_status"`
|
|
IngestionStatus string `json:"ingestion_status"`
|
|
WikiStatus string `json:"wiki_status"`
|
|
Stages []ReconciliationStage `json:"stages"`
|
|
Failures []ReconciliationFailure `json:"failures"`
|
|
HasMoreFailures bool `json:"has_more_failures"`
|
|
ObservedAt time.Time `json:"observed_at"`
|
|
}
|
|
|
|
// ReconciliationActionView is the minimum row an action needs to re-check that
|
|
// the scan snapshot is still true. Actions must never trust the finding alone.
|
|
type ReconciliationActionView struct {
|
|
Finding ReconciliationFinding
|
|
TestKBID string
|
|
RunStartedAt time.Time
|
|
CurrentExists bool
|
|
CurrentProcessingState string
|
|
CurrentKnowledgeID string
|
|
CurrentSuperseded bool
|
|
CurrentRetrievalState string
|
|
CurrentTargetScope string
|
|
}
|