dcdc8d1ddd
全栈知识治理平台首次入库(P1-P10 + 发布链路模拟验证闭环): - 治理核心:源目录/变更集/人工审核/发布批次/发布执行(fail-closed 闸口) - 测试通道:WeKnora 测试 KB 上传/轮询/验收;poll 完成时写入 parser_generation/index_generation,修复 manual/seed 路径发布闸口永久拦截 - 发布适配器 v071(本地 source=测试角色 / 云端 target=生产角色 模拟验证通过): * ES 导出/导入 mapping 自适应(.keyword 子字段、可选 tenant_id) * OSS locator 支持嵌套 scheme;chunks.seq_id 由目标序列分配 * bundle 归档同身份重试原子替换;verifier 按 bundle chunk_type 计数 * 回滚 job payload 支持 prior_execution_id(strict 解码) - 三通道发布+回滚演练实测:publish 4/4 verified,检索命中, rollback 4/4 rolled_back,目标端 PG is_enabled=false、ES is_enabled=false - 前端 A·Data-console 风格全站统一,120 用例通过 - 门禁:go vet / go test 全包通过,gofmt 干净
286 lines
6.7 KiB
Go
286 lines
6.7 KiB
Go
package governance
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type SourceType string
|
|
|
|
const (
|
|
SourceTypePP SourceType = "pp"
|
|
SourceTypeAList SourceType = "alist"
|
|
SourceTypeDingTalk SourceType = "dingtalk"
|
|
SourceTypeManual SourceType = "manual"
|
|
)
|
|
|
|
func (sourceType SourceType) Valid() bool {
|
|
switch sourceType {
|
|
case SourceTypePP, SourceTypeAList, SourceTypeDingTalk, SourceTypeManual:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type ItemType string
|
|
|
|
const (
|
|
ItemTypeDocument ItemType = "document"
|
|
ItemTypeFile ItemType = "file"
|
|
ItemTypeLink ItemType = "link"
|
|
ItemTypeVideo ItemType = "video"
|
|
)
|
|
|
|
type Visibility string
|
|
|
|
const (
|
|
VisibilityInternal Visibility = "internal"
|
|
VisibilityExternal Visibility = "external"
|
|
VisibilityBoth Visibility = "both"
|
|
VisibilityBlocked Visibility = "blocked"
|
|
)
|
|
|
|
type VisibilityOrigin string
|
|
|
|
const (
|
|
VisibilityOriginPPPublicTag VisibilityOrigin = "pp_public_tag"
|
|
VisibilityOriginConfiguredScope VisibilityOrigin = "configured_scope"
|
|
VisibilityOriginManual VisibilityOrigin = "manual"
|
|
)
|
|
|
|
type SourceChange string
|
|
|
|
const (
|
|
SourceChangeUnchanged SourceChange = "unchanged"
|
|
SourceChangeAdded SourceChange = "added"
|
|
SourceChangeUpdated SourceChange = "updated"
|
|
SourceChangeDeleted SourceChange = "deleted"
|
|
SourceChangeUnavailable SourceChange = "unavailable"
|
|
)
|
|
|
|
func (state SourceChange) Valid() bool {
|
|
switch state {
|
|
case SourceChangeUnchanged, SourceChangeAdded, SourceChangeUpdated, SourceChangeDeleted, SourceChangeUnavailable:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type ReviewState string
|
|
|
|
const (
|
|
ReviewPending ReviewState = "pending"
|
|
ReviewApproved ReviewState = "approved"
|
|
ReviewRejected ReviewState = "rejected"
|
|
ReviewNotRequired ReviewState = "not_required"
|
|
)
|
|
|
|
func (state ReviewState) Valid() bool {
|
|
switch state {
|
|
case ReviewPending, ReviewApproved, ReviewRejected, ReviewNotRequired:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type ContentState string
|
|
|
|
const (
|
|
ContentUnknown ContentState = "unknown"
|
|
ContentDownloading ContentState = "downloading"
|
|
ContentVerified ContentState = "verified"
|
|
ContentInvalid ContentState = "invalid"
|
|
ContentOverLimit ContentState = "over_limit"
|
|
ContentFailed ContentState = "failed"
|
|
)
|
|
|
|
func (state ContentState) Valid() bool {
|
|
switch state {
|
|
case ContentUnknown, ContentDownloading, ContentVerified, ContentInvalid, ContentOverLimit, ContentFailed:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type IngestState string
|
|
|
|
const (
|
|
IngestPending IngestState = "pending"
|
|
IngestUploading IngestState = "uploading"
|
|
IngestUploaded IngestState = "uploaded"
|
|
IngestFailed IngestState = "failed"
|
|
)
|
|
|
|
func (state IngestState) Valid() bool {
|
|
switch state {
|
|
case IngestPending, IngestUploading, IngestUploaded, IngestFailed:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type ProcessingState string
|
|
|
|
const (
|
|
ProcessingPending ProcessingState = "pending"
|
|
ProcessingProcessing ProcessingState = "processing"
|
|
ProcessingFinalizing ProcessingState = "finalizing"
|
|
ProcessingCompleted ProcessingState = "completed"
|
|
ProcessingFailed ProcessingState = "failed"
|
|
ProcessingStalled ProcessingState = "stalled"
|
|
)
|
|
|
|
func (state ProcessingState) Valid() bool {
|
|
switch state {
|
|
case ProcessingPending, ProcessingProcessing, ProcessingFinalizing, ProcessingCompleted, ProcessingFailed, ProcessingStalled:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type RetrievalState string
|
|
|
|
const (
|
|
RetrievalUnpublished RetrievalState = "unpublished"
|
|
RetrievalEnabled RetrievalState = "enabled"
|
|
RetrievalDisabling RetrievalState = "disabling"
|
|
RetrievalDisabled RetrievalState = "disabled"
|
|
RetrievalEnabling RetrievalState = "enabling"
|
|
RetrievalFailed RetrievalState = "failed"
|
|
)
|
|
|
|
func (state RetrievalState) Valid() bool {
|
|
switch state {
|
|
case RetrievalUnpublished, RetrievalEnabled, RetrievalDisabling, RetrievalDisabled, RetrievalEnabling, RetrievalFailed:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type AcceptanceState string
|
|
|
|
const (
|
|
AcceptancePending AcceptanceState = "pending"
|
|
AcceptancePassed AcceptanceState = "passed"
|
|
AcceptanceFailed AcceptanceState = "failed"
|
|
AcceptanceManualRequired AcceptanceState = "manual_required"
|
|
)
|
|
|
|
func (state AcceptanceState) Valid() bool {
|
|
switch state {
|
|
case AcceptancePending, AcceptancePassed, AcceptanceFailed, AcceptanceManualRequired:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func ValidSHA256(value string) bool {
|
|
if len(value) != 64 {
|
|
return false
|
|
}
|
|
for _, character := range value {
|
|
if !((character >= '0' && character <= '9') || (character >= 'a' && character <= 'f')) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
type SourceConnection struct {
|
|
ID string
|
|
Type SourceType
|
|
Name string
|
|
BaseURL string
|
|
SecretRef string
|
|
Enabled bool
|
|
Schedule json.RawMessage
|
|
LastHealth json.RawMessage
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type SourceItem struct {
|
|
ID string
|
|
SourceConnectionID string
|
|
StableExternalID string
|
|
CanonicalURIHash string
|
|
ParentExternalID string
|
|
NormalizedPath string
|
|
Title string
|
|
ItemType ItemType
|
|
SizeBytes *int64
|
|
MIME string
|
|
Revision string
|
|
UpdatedAtSource *time.Time
|
|
Visibility Visibility
|
|
VisibilityOrigin VisibilityOrigin
|
|
LastSeenScanID string
|
|
SourceChange SourceChange
|
|
AbsenceStreak int
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type ContentObject struct {
|
|
ID string
|
|
SHA256 string
|
|
SizeBytes int64
|
|
MIME string
|
|
ValidatedFormat string
|
|
LocalSpoolRef string
|
|
State ContentState
|
|
FirstDiscoveredAt time.Time
|
|
LastDiscoveredAt time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type SourceItemVersion struct {
|
|
ID string
|
|
SourceItemID string
|
|
Revision string
|
|
ContentObjectID *string
|
|
ContentState ContentState
|
|
DownloadError string
|
|
RawRecordSummary json.RawMessage
|
|
SourceUpdatedAt *time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type Publication struct {
|
|
ID string
|
|
SourceItemVersionID string
|
|
TestKBID string
|
|
KnowledgeID string
|
|
IngestState IngestState
|
|
ProcessingState ProcessingState
|
|
RetrievalState RetrievalState
|
|
ParserGeneration string
|
|
IndexGeneration string
|
|
LastError string
|
|
RetryCount int
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type AcceptanceResult struct {
|
|
ID string
|
|
PublicationID string
|
|
RunID string
|
|
CheckType string
|
|
State AcceptanceState
|
|
PolicyVersion string
|
|
EvidenceSummary json.RawMessage
|
|
ObservedAt time.Time
|
|
CreatedAt time.Time
|
|
}
|