INNER CODE UNIT · Go
startAgent
VersusControl/versus-incident · cmd/main.go:299
func startAgent(ctx context.Context, app *fiber.App, cfg c.AgentConfig, gatewaySecret string, store storage.Provider, rdb redis.UniversalClient, toolAvailability *agent.ToolAvailabilityService, kubernetesService *kubernetes.Service, healthManager *servicehealth.Manager) (*agent.Catalog, <-chan struct{}, error) {
// On the Postgres backend, install the typed signal-table
// catalog store so the log catalog reads/writes the explicit
// vs_patterns/vs_logs/vs_services tables (searchable, indexed) instead of
// the whole-blob "patterns" path. Selected ONCE at boot by backend type —
// only the Postgres provider satisfies storage.SQLAccessor; the file
// backend (nil store) keeps the inline patterns.json whole-blob path
// byte-for-byte unchanged. OSS is single-instance, so instance_index = 0.
// Must run BEFORE LoadCatalog so the boot read routes through the store.
var pgCatalog agent.CatalogStore
if acc, ok := store.(storage.SQLAccessor); ok {
pgCatalog = agent.NewPostgresCatalogStore(acc.DB(), storage.DefaultOrgID, 0)
agent.SetCatalogStore(pgCatalog)
log.Printf("agent: postgres typed catalog store installed (instance 0)")
}
catalog, err := agent.LoadCatalog(store)
if err != nil {