config

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config holds LadyM's runtime configuration.

All values have sensible defaults so the engine works out-of-the-box with no env vars and no network. Anything that needs a key/model is an opt-in override.

Configuration sources (highest precedence first):

  1. cli_overrides passed to Load (e.g. from CLI flags).
  2. Environment variables (LADYM_*).
  3. The project file ./ladym.toml.
  4. The global file ~/.ladym/config.toml.
  5. The defaults (offline: hashing embedding, llm_provider == "none").

Secret literals (api_key/*_key/token/secret/password) found in TOML are rejected with a warning and dropped — operators must use <name>_env indirection (e.g. llm.api_key_env = "MY_LLM_KEY") so secrets never land on disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTomlSafely

func ParseTomlSafely(text string, source string) (map[string]any, error)

ParseTomlSafely parses TOML text, stripping secret literals (with a stderr warning per drop).

Types

type ActivationWeights

type ActivationWeights struct {
	Similarity       float64
	Recency          float64
	Frequency        float64
	Graph            float64
	TypeBoost        float64
	RecencyHalfLifeS float64
}

ActivationWeights are the weights for the ACT-R-inspired activation function.

type AttentionConfig

type AttentionConfig struct {
	DedupWindowS float64
	NoiseWords   []string
}

AttentionConfig holds pre-write attention gate knobs.

type AuthConfig added in v0.4.0

type AuthConfig struct {
	Enabled bool
}

AuthConfig mirrors the flat auth_* fields (populated by the loader) — the HTTP data-plane's Basic-auth master switch (`ladym serve --http`).

type CodeIndexConfig

type CodeIndexConfig struct {
	MaxBodyLinesPerSymbol int
	RespectGitignore      bool
	ExtraIgnoreGlobs      []string
	Languages             []string // nil = all supported
}

CodeIndexConfig holds knobs for codebase indexing.

type Config

type Config struct {
	DBPath          string
	Workspace       string
	PreferSQLiteVec bool
	EnableWAL       bool

	// store backend (flat — source of truth for storage.OpenStore)
	StoreBackend string // "sqlite" (default) or "postgres"
	StoreDSN     string // postgres DSN; may be written directly (not a secret literal)
	StoreDSNEnv  string // env var name to read the DSN from (secrets-off-disk pattern)
	Store        StoreConfig

	// HTTP server auth (flat — source of truth for api.NewHandler)
	AuthEnabled bool // [auth] enabled: users-table Basic auth; default false = allow all
	Auth        AuthConfig

	// embedding (flat — source of truth for make_provider)
	EmbeddingProvider         string
	EmbeddingModel            string
	EmbeddingDim              int
	EmbeddingBaseURL          string
	EmbeddingAPIKeyEnv        string
	EmbeddingFallback         string
	EmbeddingQueryCacheSize   int
	EmbeddingTimeoutS         float64
	EmbeddingAllowDimChange   bool
	EmbeddingHTTPRequest      string
	EmbeddingHTTPResponsePath string
	Embedding                 EmbeddingConfig

	// CJK tokenizer dictionary (flat — source of truth for storage's dict
	// directory). "" = default ~/.ladyM/dict. Set to a shared volume mount
	// (LADYM_DICT_DIR / dict_dir) in microservice deployments so every
	// instance reads the dictionary one download provisioned.
	CJKDictDir string

	// llm (flat — source of truth for make_agent)
	LLMProvider           string // "none" = heuristic / offline mode
	LLMBaseURL            string
	LLMModel              string
	LLMAPIKeyEnv          string
	LLMMaxTokens          int
	LLMTemperature        float64
	LLMStructuredMethod   string
	LLMReasoningEffort    string // "low" | "medium" | "high" for OpenAI reasoning models; "" = provider default
	LLMTimeoutS           float64
	LLMAPIKey             string // plaintext LLM key (only when allow_plaintext_secrets)
	AllowPlaintextSecrets bool   // DEV/testing escape hatch; default stays secure
	LLM                   LLMConfig

	AgentsOverrides map[string]map[string]any
	Activation      ActivationWeights
	Recall          RecallConfig
	Consolidate     ConsolidateConfig
	CodeIndex       CodeIndexConfig
	System2         System2Config
	Attention       AttentionConfig
}

Config is the runtime configuration for LadyM. The flat fields are the source of truth for the provider factories; the nested structs are a convenience mirror populated by the loader.

func Default

func Default() *Config

Default returns a Config with all defaults populated (reading env at call time).

func ForTesting

func ForTesting(tmpDir string) *Config

ForTesting returns a Config pointing at a temp db using the offline hashing embedding and the in-memory vector index.

func FromFile

func FromFile(path string) (*Config, error)

FromFile builds a Config from a single TOML file (defaults + file, no env/CLI). Strips secret literals, renames deprecated keys, and populates the nested structs.

func Load

func Load(configPath string, cliOverrides map[string]any) (*Config, error)

Load resolves a Config through the 4-layer precedence: defaults → ~/.ladym/config.toml → ./ladym.toml → configPath, then env vars, then cli_overrides.

type ConfigError

type ConfigError struct {
	Msg string
}

ConfigError is raised when runtime configuration makes an operation impossible. The message MUST be actionable and one-line — CLI/MCP surface it verbatim instead of dumping a traceback. This is fail-fast, NOT a fallback.

func (*ConfigError) Error

func (e *ConfigError) Error() string

type ConsolidateConfig

type ConsolidateConfig struct {
	MinEpisodesToTrigger     int
	DedupSimilarityThreshold float64
}

ConsolidateConfig holds knobs for L1→L2 consolidation.

type EmbeddingConfig

type EmbeddingConfig struct {
	Provider         string
	BaseURL          string
	Model            string
	APIKeyEnv        string
	Fallback         string
	QueryCacheSize   int
	TimeoutS         float64
	AllowDimChange   bool
	HTTPRequest      string
	HTTPResponsePath string
}

EmbeddingConfig mirrors the flat embedding_* fields (populated by the loader).

type LLMConfig

type LLMConfig struct {
	Provider         string
	BaseURL          string
	Model            string
	APIKeyEnv        string
	MaxTokens        int
	Temperature      float64
	StructuredMethod string
	ReasoningEffort  string
	TimeoutS         float64
}

LLMConfig mirrors the flat llm_* fields (populated by the loader).

type RecallConfig

type RecallConfig struct {
	TopKTier1             int
	TopKTier2             int
	GraphHops             int
	ReflectionMinHits     int
	ReflectionMinCoverage float64
	EnableTier2           bool
}

RecallConfig holds two-tier retrieval knobs.

type StoreConfig added in v0.4.0

type StoreConfig struct {
	Backend string
	DSN     string
}

StoreConfig mirrors the flat store_* fields (populated by the loader).

type System2Config

type System2Config struct {
	Enabled              bool
	IntervalS            int
	MinEpisodesToRun     int
	MaxConsecutiveErrors int
	L5ClusterSimilarity  float64
	L5MinClusterSize     int
	L5MergeSimilarity    float64
	L5MergeEveryNCycles  int
	L6MaxEpisodes        int
	L6HorizonS           float64
}

System2Config holds background reflection cycle knobs.

Jump to

Keyboard shortcuts

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