config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config loads, validates, and provides defaults for yaad's configuration (server, storage, embeddings, and related settings).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatErrors

func FormatErrors(errs []ConfigError) string

FormatErrors produces a human-readable summary of validation errors.

Types

type Config

type Config struct {
	Server     ServerConfig     `toml:"server"`
	Memory     MemoryConfig     `toml:"memory"`
	Search     SearchConfig     `toml:"search"`
	Embeddings EmbeddingsConfig `toml:"embeddings"`
	Decay      DecayConfig      `toml:"decay"`
	Git        GitConfig        `toml:"git"`
	LLM        LLMConfig        `toml:"llm"`
}

Config holds all Yaad configuration.

func Default

func Default() *Config

func Load

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

func (*Config) NewEmbeddingProvider

func (c *Config) NewEmbeddingProvider() embeddings.Provider

NewEmbeddingProvider creates the embedding provider specified in config. Falls back to local stub if the provider is unknown or disabled.

type ConfigError

type ConfigError struct {
	Field   string              // Dot-separated path to the offending field (e.g. "decay.half_life_days").
	Message string              // Human-readable explanation of the problem.
	Value   interface{}         // The offending value, or nil for missing-required errors.
	ErrType ValidationErrorType // Categorization of the error.
}

ConfigError is a single validation problem found in the configuration.

func ValidateConfig

func ValidateConfig(cfg *Config) []ConfigError

ValidateConfig runs all built-in validators against cfg and returns the aggregated list of ConfigErrors.

func (ConfigError) String

func (e ConfigError) String() string

type ConfigValidator

type ConfigValidator interface {
	Validate(cfg *Config) []ConfigError
}

ConfigValidator validates a Config and returns any errors found.

type DecayConfig

type DecayConfig struct {
	Enabled       bool    `toml:"enabled"`
	HalfLifeDays  int     `toml:"half_life_days"`
	MinConfidence float64 `toml:"min_confidence"`
	BoostOnAccess float64 `toml:"boost_on_access"`
}

type EmbeddingsConfig

type EmbeddingsConfig struct {
	Enabled  bool   `toml:"enabled"`
	Provider string `toml:"provider"`
	Model    string `toml:"model"`
}

type GitConfig

type GitConfig struct {
	Watch     bool `toml:"watch"`
	AutoStale bool `toml:"auto_stale"`
}

type LLMConfig

type LLMConfig struct {
	Enabled   bool   `toml:"enabled"`
	Provider  string `toml:"provider"`
	Model     string `toml:"model"`
	APIKeyEnv string `toml:"api_key_env"`
}

LLMConfig is optional. Yaad is a memory layer — it does NOT call LLMs directly. This config is reserved for future summarization hooks.

type MemoryConfig

type MemoryConfig struct {
	HotTokenBudget  int `toml:"hot_token_budget"`
	WarmTokenBudget int `toml:"warm_token_budget"`
	MaxMemories     int `toml:"max_memories"`
}

type SearchConfig

type SearchConfig struct {
	BM25Weight   float64 `toml:"bm25_weight"`
	VectorWeight float64 `toml:"vector_weight"`
	DefaultLimit int     `toml:"default_limit"`
}

type ServerConfig

type ServerConfig struct {
	Port     int    `toml:"port"`
	Host     string `toml:"host"`
	TLS      bool   `toml:"tls"`
	CertFile string `toml:"cert_file"`
	KeyFile  string `toml:"key_file"`
}

type ValidationErrorType

type ValidationErrorType int

ValidationErrorType categorizes the kind of validation problem.

const (
	MissingRequired    ValidationErrorType = iota // A required field is absent or zero-value.
	InvalidValue                                  // A field has an invalid or malformed value.
	OutOfRange                                    // A numeric field is outside its acceptable range.
	IncompatibleFields                            // Two or more fields conflict with each other.
	UnknownField                                  // A TOML key is not recognized.
)

func (ValidationErrorType) String

func (t ValidationErrorType) String() string

Jump to

Keyboard shortcuts

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