config

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Storage       StorageConfig       `mapstructure:"storage"`
	Embedding     EmbeddingConfig     `mapstructure:"embedding"`
	Summarization SummarizationConfig `mapstructure:"summarization"`
	Conversation  ConversationConfig  `mapstructure:"conversation"`
	Knowledge     KnowledgeConfig     `mapstructure:"knowledge"`
	Context       ContextConfig       `mapstructure:"context"`
	Entity        EntityConfig        `mapstructure:"entity"`
	Retention     RetentionConfig     `mapstructure:"retention"`
	Namespace     NamespaceConfig     `mapstructure:"namespace"`
	Server        ServerConfig        `mapstructure:"server"`
}

Config holds all configuration for Cortex.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with default values.

func Load

func Load(configPath string) (*Config, error)

Load loads configuration from file and environment variables.

func (*Config) Validate added in v1.0.0

func (c *Config) Validate() error

Validate checks required fields and value ranges, returning an error that lists every violation with its config key and an actionable message. It is invoked after loading so bad values fail at startup with a clear message instead of late and opaquely (e.g. a time.NewTicker panic on a non-positive interval, or a pgvector backend without database_url).

type ContextConfig

type ContextConfig struct {
	TTLCleanupInterval   time.Duration `mapstructure:"ttl_cleanup_interval"`
	HistoryRetentionDays int           `mapstructure:"history_retention_days"`
}

ContextConfig configures workflow context.

type ConversationConfig

type ConversationConfig struct {
	AutoSummarizeThreshold int  `mapstructure:"auto_summarize_threshold"`
	DefaultHistoryLimit    int  `mapstructure:"default_history_limit"`
	SemanticSearchEnabled  bool `mapstructure:"semantic_search_enabled"`
}

ConversationConfig configures conversation memory.

type EmbeddingConfig

type EmbeddingConfig struct {
	Provider   string        `mapstructure:"provider"`
	Model      string        `mapstructure:"model"`
	Dimensions int           `mapstructure:"dimensions"`
	BatchSize  int           `mapstructure:"batch_size"`
	CacheSize  int           `mapstructure:"cache_size"`
	Timeout    time.Duration `mapstructure:"timeout"`
}

EmbeddingConfig configures embedding generation.

type EntityConfig

type EntityConfig struct {
	ExtractionMode               string        `mapstructure:"extraction_mode"` // "off", "sampled", "whitelist", "full"
	ExtractionModel              string        `mapstructure:"extraction_model"`
	ExtractionBatchSize          int           `mapstructure:"extraction_batch_size"`
	ExtractionInterval           time.Duration `mapstructure:"extraction_interval"`
	SampleRate                   float64       `mapstructure:"sample_rate"`
	WhitelistKeywords            []string      `mapstructure:"whitelist_keywords"`
	SummaryRegenerationThreshold int           `mapstructure:"summary_regeneration_threshold"`
	MinConfidence                float64       `mapstructure:"min_confidence"`
	MinMentionsToKeep            int           `mapstructure:"min_mentions_to_keep"`
	AliasFuzzyThreshold          float64       `mapstructure:"alias_fuzzy_threshold"`
	ExtractionMaxAttempts        int           `mapstructure:"extraction_max_attempts"`
	ExtractionBackoff            string        `mapstructure:"extraction_backoff"`            // "fixed", "exponential"
	ExtractionDeadLetterPolicy   string        `mapstructure:"extraction_dead_letter_policy"` // "retain", "drop"
	ExtractionTimeout            time.Duration `mapstructure:"extraction_timeout"`
}

EntityConfig configures entity memory.

type KnowledgeConfig

type KnowledgeConfig struct {
	DefaultChunkStrategy  string `mapstructure:"default_chunk_strategy"`
	DefaultChunkMaxTokens int    `mapstructure:"default_chunk_max_tokens"`
	DefaultChunkOverlap   int    `mapstructure:"default_chunk_overlap"`
	DefaultSearchTopK     int    `mapstructure:"default_search_top_k"`
}

KnowledgeConfig configures the knowledge store.

type NamespaceConfig

type NamespaceConfig struct {
	AllowedNamespaces []string `mapstructure:"allowed_namespaces"`
}

NamespaceConfig configures namespace isolation.

type RetentionConfig

type RetentionConfig struct {
	ConversationRetentionDays int           `mapstructure:"conversation_retention_days"`
	EntityStaleDays           int           `mapstructure:"entity_stale_days"`
	ContextRunRetentionDays   int           `mapstructure:"context_run_retention_days"`
	GCInterval                time.Duration `mapstructure:"gc_interval"`
}

RetentionConfig configures data lifecycle.

type ServerConfig

type ServerConfig struct {
	LogLevel          string        `mapstructure:"log_level"`
	MetricsEnabled    bool          `mapstructure:"metrics_enabled"`
	MetricsPort       int           `mapstructure:"metrics_port"`
	StructuredLogging bool          `mapstructure:"structured_logging"`
	RequestIDHeader   string        `mapstructure:"request_id_header"`
	ShutdownTimeout   time.Duration `mapstructure:"shutdown_timeout"`
}

ServerConfig configures the server.

type StorageConfig

type StorageConfig struct {
	Backend     string `mapstructure:"backend"`      // "sqlite" or "pgvector"
	DataDir     string `mapstructure:"data_dir"`     // For SQLite
	DatabaseURL string `mapstructure:"database_url"` // For pgvector

	// Pool sizing for pgvector. 0 = unset: the database URL's
	// pool_max_conns/pool_min_conns query params apply, falling back to
	// built-in defaults. Explicit values take precedence over the URL.
	// int32 matches pgxpool's native field type so no conversion is needed.
	PoolMaxConns int32 `mapstructure:"pool_max_conns"`
	PoolMinConns int32 `mapstructure:"pool_min_conns"`
}

StorageConfig configures the storage backend.

type SummarizationConfig

type SummarizationConfig struct {
	Provider  string        `mapstructure:"provider"`
	Model     string        `mapstructure:"model"`
	MaxTokens int           `mapstructure:"max_tokens"`
	Timeout   time.Duration `mapstructure:"timeout"`
}

SummarizationConfig configures LLM summarization.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL