Files
knowledge-governance/internal/governance/source_catalog.go
T
2026-10-26 18:42:47 +08:00

187 lines
6.6 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"`
// ScanProgress / ScanMessage 只在 SnapshotStatus == "scanning" 时有值:新来源在首次扫描
// 完成前也出现在「来源与目录」里,带着百分比与进度文案,不必等到快照落地才看得见。
ScanProgress int `json:"scan_progress"`
ScanMessage string `json:"scan_message,omitempty"`
}
// CatalogScanProgress 是「已登记、但还没有快照」的来源的首次扫描进度(来自 worker 写在
// 任务载荷里的进度,非另起一套计数)。
type CatalogScanProgress struct {
ConnectionID string
SourceType SourceType
Name string
Progress int
Message string
ScannedDirectories int
DiscoveredDirectories int
ScannedFiles int
StartedAt time.Time
}
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
}
// CatalogRouteFile is one selected file plus the metadata snapshot the policy
// fulfillment path needs to materialize and fetch it later.
type CatalogRouteFile struct {
NodeID string
Name string
RelativePath string
SizeBytes *int64
ModifiedAt *time.Time
ContentSHA256 *string
LocatorHash string
Direct bool
}
// CatalogRouteResult describes the desired-state write only. Policy fulfillment
// records intents, queues artifact fetches and plans publications; counts tell
// the operator what will show up in 解析监控.
type CatalogRouteResult struct {
SelectedFiles int `json:"selected_files"`
IntentsRecorded int `json:"intents_recorded"`
FetchQueued int `json:"fetch_queued"`
PlannedPublications int `json:"planned_publications"`
BlockedItems int `json:"blocked_items"`
UnboundFiles int `json:"unbound_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"`
}