Files
knowledge-governance/internal/governance/ui_settings.go
T
姚章浩 63f3b2c503 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
2026-09-30 10:54:07 +08:00

55 lines
1.8 KiB
Go

package governance
import (
"strings"
"time"
)
type UISettings struct {
ID string `json:"id"`
State string `json:"state"`
DocumentRefreshSeconds int `json:"document_refresh_seconds"`
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"`
RetiredAt *time.Time `json:"retired_at"`
ErrorCode string `json:"error_code"`
}
type CreateUISettingsCandidateRequest struct {
DocumentRefreshSeconds int
ResourceRefreshSeconds int
StalledAfterSeconds int
FinalizingAfterSeconds int
IngestionConcurrency int
UpdatedBy string
Now time.Time
}
func (request CreateUISettingsCandidateRequest) Valid() bool {
return oneOfInt(request.DocumentRefreshSeconds, 15, 30, 60) &&
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()
}
func oneOfInt(value int, allowed ...int) bool {
for _, candidate := range allowed {
if value == candidate {
return true
}
}
return false
}
func validSettingsActor(value string) bool {
trimmed := strings.TrimSpace(value)
return trimmed == value && len(trimmed) >= 2 && len(trimmed) <= 128 && !strings.ContainsAny(trimmed, "\x00\r\n\t")
}