Files
knowledge-governance/internal/governance/source_catalog.go
T
zheromiku dcdc8d1ddd feat: 知识治理平台(含已验证发布/回滚契约)
全栈知识治理平台首次入库(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 干净
2026-09-30 10:54:06 +08:00

155 lines
5.4 KiB
Go

package governance
import "time"
type CatalogSource struct {
ConnectionID string `json:"connection_id"`
SourceType SourceType `json:"source_type"`
Name string `json:"name"`
RootNodeID string `json:"root_node_id"`
FolderCount int `json:"folder_count"`
FileCount int `json:"file_count"`
ObservedAt time.Time `json:"observed_at"`
SnapshotOnly bool `json:"snapshot_only"`
SnapshotStatus string `json:"snapshot_status"`
LastRefreshDurationMS int64 `json:"last_refresh_duration_ms"`
}
type CatalogBreadcrumb struct {
NodeID string `json:"node_id"`
Name string `json:"name"`
}
type CatalogNode struct {
NodeID string `json:"node_id"`
ParentNodeID string `json:"parent_node_id,omitempty"`
NodeType string `json:"node_type"`
Name string `json:"name"`
DirectChildCount int `json:"direct_child_count"`
SubtreeFileCount int `json:"subtree_file_count"`
SubtreeBytes int64 `json:"subtree_bytes"`
SizeBytes *int64 `json:"size_bytes,omitempty"`
ModifiedAt *time.Time `json:"modified_at,omitempty"`
ContentSHA256 *string `json:"content_sha256,omitempty"`
Visibility string `json:"visibility"`
ImportedCount int `json:"imported_count"`
ParsedCount int `json:"parsed_count"`
ActiveCount int `json:"active_count"`
FailedCount int `json:"failed_count"`
RoutableCount int `json:"routable_count"`
}
type CatalogNodeFilter struct {
ConnectionID string
ParentNodeID string
Limit int
Offset int
}
type CatalogNodePage struct {
Current CatalogNode `json:"current"`
Breadcrumbs []CatalogBreadcrumb `json:"breadcrumbs"`
Items []CatalogNode `json:"items"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
type CatalogSnapshot struct {
SnapshotID string `json:"snapshot_id"`
ConnectionID string `json:"connection_id"`
RootNodeID string `json:"root_node_id"`
SourceName string `json:"source_name"`
NodeCount int `json:"node_count"`
FolderCount int `json:"folder_count"`
FileCount int `json:"file_count"`
ObservedAt time.Time `json:"observed_at"`
CreatedAt time.Time `json:"created_at"`
IsHead bool `json:"is_head"`
}
type CatalogSnapshotPage struct {
Items []CatalogSnapshot `json:"items"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
type CatalogSnapshotNodeFilter struct {
ConnectionID string
SnapshotID string
ParentNodeID string
Limit int
Offset int
}
type CatalogRouteRequest struct {
ConnectionID string
NodeIDs []string
Visibility Visibility
TargetKnowledgeBaseID string
TargetKnowledgeBaseIDs []string
OperatorRef string
Reason string
Now time.Time
}
// CatalogRouteResult describes the desired-state write only. S7 guarantees the
// annotation never creates publications or jobs; counts explain what the
// subsequent ChangeSet/P3 pipeline will be able to act on.
type CatalogRouteResult struct {
SelectedFiles int `json:"selected_files"`
RoutableFiles int `json:"routable_files"`
UnboundFiles int `json:"unbound_files"`
HashUnknownFiles int `json:"hash_unknown_files"`
UnavailableFiles int `json:"unavailable_files"`
}
type CatalogChangeSetFilter struct {
ConnectionID string
Action string
Limit int
Offset int
}
type CatalogChangeSet struct {
ID string `json:"id"`
ConnectionID string `json:"connection_id"`
SourceName string `json:"source_name"`
State string `json:"state"`
AddCount int `json:"add_count"`
UpdateCount int `json:"update_count"`
MoveCount int `json:"move_count"`
MoveScopeCount int `json:"move_scope_count"`
DeleteCount int `json:"delete_count"`
NoChangeCount int `json:"no_change_count"`
CreatedAt time.Time `json:"created_at"`
}
type CatalogChangeItem struct {
Action string `json:"action"`
Title string `json:"title"`
OldPath string `json:"old_path,omitempty"`
NewPath string `json:"new_path,omitempty"`
OldSizeBytes *int64 `json:"old_size_bytes,omitempty"`
NewSizeBytes *int64 `json:"new_size_bytes,omitempty"`
OldModified *time.Time `json:"old_modified_at,omitempty"`
NewModified *time.Time `json:"new_modified_at,omitempty"`
OldContentSHA256 string `json:"old_content_sha256,omitempty"`
NewContentSHA256 string `json:"new_content_sha256,omitempty"`
ReasonCode string `json:"reason_code"`
Seq int64 `json:"seq"`
OldScope string `json:"old_scope,omitempty"`
NewScope string `json:"new_scope,omitempty"`
OldVersionID string `json:"old_version_id,omitempty"`
NewVersionID string `json:"new_version_id,omitempty"`
}
type CatalogChangeSetDetail struct {
CatalogChangeSet
Items []CatalogChangeItem `json:"items"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}