Syntropy.RuntimeConfig
(syntropy v0.2.0)
Copy Markdown
Read and apply runtime provider configuration.
Provider settings live in the Application environment, seeded from env vars
at boot (config/runtime.exs). apply_provider/1 validates a candidate
configuration with Syntropy.LLMClient.Config and only then writes it with
Application.put_env/3, so an invalid update never disturbs a working
provider.
Applied changes take effect immediately for subsequent LLM calls. When
persistence is enabled they are also written through to runtime_settings
and rehydrated on boot (hydrate/0), so an applied configuration survives
restarts. Without persistence they are memory-scoped and reset on restart;
reports include an env-var block (env_export) that operators can copy to
make a configuration permanent either way.
Summary
Functions
Validates a candidate provider configuration and applies it to the running node when valid.
Env-var block that reproduces the given configuration across restarts. The API key is always redacted.
Rehydrates persisted provider overrides into the Application environment.
Fair-use limits posture: the rolling token budget and its enforcement state.
Effective provider configuration with the API key redacted, plus the env block that reproduces it permanently.
Full runtime configuration report: effective provider config plus persistence, cluster, and source-tool posture. Never includes secrets.
Probes the configured provider endpoint without mutating anything.
Types
@type provider_report() :: %{ provider: String.t(), profile: String.t(), model: String.t() | nil, base_url: String.t() | nil, api_key_configured: boolean(), timeout_ms: pos_integer(), retry_count: non_neg_integer(), max_tokens: pos_integer() | nil, max_concurrency: pos_integer() | nil, temperature: float() | nil, top_p: float() | nil, repeat_penalty: float() | nil, disable_thinking: boolean(), valid: boolean(), validation_errors: [String.t()], applied_scope: String.t(), env_export: String.t() }
Functions
@spec apply_provider(map()) :: {:ok, provider_report()} | {:error, [String.t()]}
Validates a candidate provider configuration and applies it to the running node when valid.
Accepts a map with string keys (JSON body). Unknown keys are ignored. Keys
that are present with nil or "" clear the stored value; absent keys keep
the current value. Records a redacted runtime_config_updated event on
success.
@spec env_export(Syntropy.LLMClient.Config.t()) :: String.t()
Env-var block that reproduces the given configuration across restarts. The API key is always redacted.
@spec hydrate() :: :ok
Rehydrates persisted provider overrides into the Application environment.
Runs at boot (before the endpoint and scheduler start) so an applied configuration survives restarts. Persisted overrides layer on top of the env-seeded configuration and are ignored when they no longer validate.
@spec limits_report() :: map()
Fair-use limits posture: the rolling token budget and its enforcement state.
@spec provider_report() :: provider_report()
Effective provider configuration with the API key redacted, plus the env block that reproduces it permanently.
@spec report() :: map()
Full runtime configuration report: effective provider config plus persistence, cluster, and source-tool posture. Never includes secrets.
@spec test_provider(map()) :: %{ status: String.t(), provider: String.t(), model: String.t() | nil, base_url: String.t() | nil, details: map() }
Probes the configured provider endpoint without mutating anything.
Accepts the same params as apply_provider/1, layered over the current
configuration, so a candidate can be tested before it is applied. Mock is
always reachable; Ollama probes GET /tags; OpenAI-compatible providers
probe GET /models with the bearer key.