feat(governance): policy-driven ingestion from catalog annotations

Annotation in 来源与目录 is now the only import decision surface:
- migration 000033: catalog_import_intents (durable, rescan-proof per-file
  intent with locator snapshot + fetch lifecycle), source_items.policy_state,
  planned publication state, ui_setting_revisions.ingestion_concurrency
- marking fans a folder decision out to per-file intents, materializes
  versioned items, reuses already-verified local bytes (compare, don't pull),
  and plans one publication per routed KB; blocked retires planned rows
  while live publications stay untouched (需下架 shows in the KB diff)
- artifact.fetch worker lane (scripts/artifact_fetch.py): DingTalk export
  tree/live box API, AList /api/fs/get direct download with SSO-redirect
  fail-closed, PP ledger via locator hash; content-level dedupe on sha256
- 开始处理 promotes planned->pending inside the claim-time concurrency budget
  from system settings; claims enforce it in SQL
- monitor overview rebuilt as knowledge-base diff: planned/needs_removal per
  KB + fetch pipeline summary; frontend lanes 待入库/需下架 replace the
  deprecated snapshot change-set confirmation
- spool: images (png/jpg/gif/bmp/webp) accepted, ppt/pptx rejected in favour
  of PDF twins; DingTalk PPT resolves its converted PDF pair
This commit is contained in:
姚章浩
2026-09-13 22:17:12 +08:00
parent f6cb90cd70
commit 63f3b2c503
38 changed files with 1597 additions and 307 deletions
+13
View File
@@ -51,12 +51,24 @@ type KnowledgeBaseProgress struct {
Finalizing int `json:"finalizing"`
Failed int `json:"failed"`
Cancelled int `json:"cancelled"`
Planned int `json:"planned"`
NeedsRemoval int `json:"needs_removal"`
StalePlanned int `json:"stale_planned"`
InternalImported int `json:"internal_imported"`
InternalCompleted int `json:"internal_completed"`
ExternalImported int `json:"external_imported"`
ExternalCompleted int `json:"external_completed"`
}
// IngestionPipeline summarizes the artifact-fetch lane that sits in front of
// 待入库 so operators can see why planned items are not uploadable yet.
type IngestionPipeline struct {
FetchPending int `json:"fetch_pending"`
FetchFailed int `json:"fetch_failed"`
FetchMissing int `json:"fetch_missing"`
Concurrency int `json:"concurrency"`
}
// JobWindowMetrics reports a frozen statistical window; insufficient samples
// stay null and are never rendered as 0.
type JobWindowMetrics struct {
@@ -95,6 +107,7 @@ type MonitorOverview struct {
Host MonitorHost `json:"host"`
Services []MonitorService `json:"services"`
KnowledgeBases []KnowledgeBaseProgress `json:"knowledge_bases"`
Pipeline IngestionPipeline `json:"pipeline"`
Health []ServiceHealth `json:"health"`
}
+22 -8
View File
@@ -94,15 +94,29 @@ type CatalogRouteRequest struct {
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.
// 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"`
RoutableFiles int `json:"routable_files"`
UnboundFiles int `json:"unbound_files"`
HashUnknownFiles int `json:"hash_unknown_files"`
UnavailableFiles int `json:"unavailable_files"`
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 {
+3
View File
@@ -12,6 +12,7 @@ type UISettings struct {
ResourceRefreshSeconds int `json:"resource_refresh_seconds"`
StalledAfterSeconds int `json:"stalled_after_seconds"`
FinalizingAfterSeconds int `json:"finalizing_after_seconds"`
IngestionConcurrency int `json:"ingestion_concurrency"`
UpdatedBy string `json:"updated_by"`
CreatedAt time.Time `json:"created_at"`
ActivatedAt *time.Time `json:"activated_at"`
@@ -24,6 +25,7 @@ type CreateUISettingsCandidateRequest struct {
ResourceRefreshSeconds int
StalledAfterSeconds int
FinalizingAfterSeconds int
IngestionConcurrency int
UpdatedBy string
Now time.Time
}
@@ -33,6 +35,7 @@ func (request CreateUISettingsCandidateRequest) Valid() bool {
oneOfInt(request.ResourceRefreshSeconds, 30, 60) &&
oneOfInt(request.StalledAfterSeconds, 1800, 3600) &&
oneOfInt(request.FinalizingAfterSeconds, 7200, 14400) &&
request.IngestionConcurrency >= 1 && request.IngestionConcurrency <= 16 &&
validSettingsActor(request.UpdatedBy) && !request.Now.IsZero()
}