Loads llm_core configuration files (routing, providers, etc.) from disk and updates the store.
Handles the full TOML loading pipeline: reading multiple config layers, deep-merging, resolving environment variable placeholders, normalizing provider definitions, and broadcasting change notifications to dependent processes.
Configuration Layers (later overrides earlier)
- Compiled defaults —
priv/config/llm_core.toml(bundled with the library) - Global override —
~/.llm_core/config/llm_core.toml - Project override —
<project>/.llm_core/llm_core.toml - Environment variable — path in
LLM_CORE_CONFIG - Custom path — explicit
:pathoption
Environment Variable Interpolation
TOML values like "${ANTHROPIC_API_KEY}" are resolved at load time.
Supports defaults: "${OLLAMA_URL:http://localhost:11434}".
Key Functions
reload_providers/1— Full TOML load + provider normalization + store updatereload_routing/1— Load and apply routing rules onlyrouting_from_layers/1— Build a routing table from the merged layers (no store mutation)load_config/1— Read merged TOML without mutating runtime state
Summary
Functions
Returns the merged TOML configuration without mutating runtime state.
Loads the routing configuration from disk without mutating the store.
Loads TOML configuration (providers, memory, routing defaults) and writes the normalized provider metadata to the runtime store.
Loads the routing configuration and writes it to the runtime store. Broadcasts change notifications so dependent processes can refresh.
Builds a routing table from the merged TOML layers (bundled base, home,
project, LLM_CORE_CONFIG, :path) without mutating the store.
Functions
Returns the merged TOML configuration without mutating runtime state.
@spec load_routing(keyword()) :: {:ok, LlmCore.Router.RoutingTable.t()} | {:error, term()}
Loads the routing configuration from disk without mutating the store.
@spec reload_providers(keyword()) :: {:ok, %{optional(String.t()) => LlmCore.Provider.Definition.t()}} | {:error, term()}
Loads TOML configuration (providers, memory, routing defaults) and writes the normalized provider metadata to the runtime store.
@spec reload_routing(keyword()) :: {:ok, LlmCore.Router.RoutingTable.t()} | {:error, term()}
Loads the routing configuration and writes it to the runtime store. Broadcasts change notifications so dependent processes can refresh.
A routing.yml that omits default inherits the default from the merged
config layers; its explicit task rules win.
When routing.yml is missing, the existing Store routing is preserved
(e.g. a table already installed from TOML via reload_providers/1). Only
when the Store has no routing at all is the table built from the merged
config layers (routing_from_layers/1); no provider alias is ever
hardcoded, so with no default in any layer the table has none and routing
fails with :no_routing_default.
@spec routing_from_layers(keyword()) :: {:ok, LlmCore.Router.RoutingTable.t()}
Builds a routing table from the merged TOML layers (bundled base, home,
project, LLM_CORE_CONFIG, :path) without mutating the store.
Always returns {:ok, table}. The table's default is nil when no layer
supplies [routing] default, or when the routing section is invalid.