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
+6 -4
View File
@@ -13,7 +13,7 @@ import (
var ErrInvalidUISettings = errors.New("invalid UI settings")
const uiSettingsColumns = `id,state,document_refresh_seconds,resource_refresh_seconds,stalled_after_seconds,finalizing_after_seconds,updated_by,created_at,activated_at,retired_at,error_code`
const uiSettingsColumns = `id,state,document_refresh_seconds,resource_refresh_seconds,stalled_after_seconds,finalizing_after_seconds,ingestion_concurrency,updated_by,created_at,activated_at,retired_at,error_code`
const getActiveUISettingsSQL = `
SELECT ` + uiSettingsColumns + `
@@ -24,8 +24,8 @@ WHERE state = 'active'
const createUISettingsCandidateSQL = `
INSERT INTO ui_setting_revisions(
id,state,document_refresh_seconds,resource_refresh_seconds,
stalled_after_seconds,finalizing_after_seconds,updated_by,created_at
) VALUES($1,'validated',$2,$3,$4,$5,$6,$7)
stalled_after_seconds,finalizing_after_seconds,ingestion_concurrency,updated_by,created_at
) VALUES($1,'validated',$2,$3,$4,$5,$6,$7,$8)
RETURNING ` + uiSettingsColumns + `
`
@@ -63,7 +63,8 @@ func (s *Store) CreateUISettingsCandidate(ctx context.Context, request governanc
}
return scanUISettings(s.db.QueryRow(ctx, createUISettingsCandidateSQL,
id, request.DocumentRefreshSeconds, request.ResourceRefreshSeconds,
request.StalledAfterSeconds, request.FinalizingAfterSeconds, request.UpdatedBy, request.Now.UTC()))
request.StalledAfterSeconds, request.FinalizingAfterSeconds, request.IngestionConcurrency,
request.UpdatedBy, request.Now.UTC()))
}
func (s *Store) ActivateUISettings(ctx context.Context, revisionID string, now time.Time) (governance.UISettings, error) {
@@ -124,6 +125,7 @@ func scanUISettings(row interface{ Scan(...any) error }) (governance.UISettings,
var settings governance.UISettings
if err := row.Scan(&settings.ID, &settings.State, &settings.DocumentRefreshSeconds,
&settings.ResourceRefreshSeconds, &settings.StalledAfterSeconds, &settings.FinalizingAfterSeconds,
&settings.IngestionConcurrency,
&settings.UpdatedBy, &settings.CreatedAt, &settings.ActivatedAt, &settings.RetiredAt, &settings.ErrorCode); err != nil {
return governance.UISettings{}, fmt.Errorf("scan UI settings: %w", err)
}