package main import ( "context" "github.com/jackc/pgx/v5/pgxpool" "knowledge-governance/internal/dobotaiops" "knowledge-governance/internal/httpapi" "knowledge-governance/internal/qaopsmirror" "strings" ) // API serving never constructs or probes a production-source client. The worker // alone synchronizes the explicitly authorized local copy; this is not a fallback. func openQAOperations(_ context.Context, getenv func(string) string, governanceDSN string, pool *pgxpool.Pool) (httpapi.QAOpsReader, dobotaiops.Settings) { settings := dobotaiops.LoadSettings(getenv, governanceDSN) if !settings.Enabled { return nil, settings } if settings.TenantKey == "" || len(settings.TenantKey) > 128 || strings.ContainsRune(settings.TenantKey, 0) { settings.Problem = "local_mirror_tenant_invalid" return nil, settings } // Missing/offline source credentials stop synchronization, not last-good local reads. settings.Problem = "" return qaopsmirror.NewStore(pool, settings.TenantKey), settings }