Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
loader.h File Reference

Config loader — YAML to C++ structs with validation. More...

#include <entropic/entropic_export.h>
#include <entropic/types/config.h>
#include <entropic/config/bundled_models.h>
#include <filesystem>
#include <string>
Include dependency graph for loader.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Functions

ENTROPIC_EXPORT std::string entropic::config::load_config (const std::filesystem::path &global_path, const std::filesystem::path &project_path, const BundledModels &registry, ParsedConfig &config)
 Load config using layered resolution.
 
ENTROPIC_EXPORT std::string entropic::config::load_layered (const std::filesystem::path &project_dir, const std::filesystem::path &consumer_defaults, const BundledModels &registry, ParsedConfig &config)
 Load config with consumer defaults + global + project layers.
 
ENTROPIC_EXPORT std::string entropic::config::load_config_from_file (const std::filesystem::path &path, const BundledModels &registry, ParsedConfig &config)
 Load config from a single YAML file (no layering).
 
ENTROPIC_EXPORT std::string entropic::config::parse_config_file (const std::filesystem::path &path, const BundledModels &registry, ParsedConfig &config)
 Parse a config YAML file and overlay onto existing config.
 
ENTROPIC_EXPORT void entropic::config::apply_env_overrides (ParsedConfig &config)
 Apply ENTROPIC_* environment variable overrides.
 
ENTROPIC_EXPORT std::filesystem::path entropic::config::resolve_data_dir (const ParsedConfig &config)
 Resolve the bundled data directory.
 
ENTROPIC_EXPORT std::string entropic::config::load_config_from_string (const std::string &content, const BundledModels &registry, ParsedConfig &config)
 Load config from a YAML/JSON string (no layering).
 

Detailed Description

Config loader — YAML to C++ structs with validation.

Loads configuration using layered resolution:

  1. Compiled defaults (struct initializers)
  2. Global config (~/.entropic/config.yaml)
  3. Project config (.entropic/config.local.yaml)
  4. Environment variables (ENTROPIC_*)
Version
1.8.1

Definition in file loader.h.

Function Documentation

◆ apply_env_overrides()

void entropic::config::apply_env_overrides ( ParsedConfig config)

Apply ENTROPIC_* environment variable overrides.

Variable format: ENTROPIC_{SECTION}__{FIELD} (double underscore). Examples: ENTROPIC_LOG_LEVEL=DEBUG, ENTROPIC_ROUTING__ENABLED=true

Parameters
[in,out]configConfig to override.
Version
1.8.1
Parameters
[in,out]configConfig to override.
Version
2.3.7 @utility

Definition at line 68 of file env_overrides.cpp.

◆ load_config()

std::string entropic::config::load_config ( const std::filesystem::path &  global_path,
const std::filesystem::path &  project_path,
const BundledModels registry,
ParsedConfig config 
)

Load config using layered resolution.

Resolution order (highest wins):

  1. Compiled defaults (struct initializers)
  2. Global config (~/.entropic/config.yaml)
  3. Project config (.entropic/config.local.yaml)
  4. Environment variables (ENTROPIC_*)
Parameters
global_pathPath to global config file (may not exist).
project_pathPath to project config file (may not exist).
registryBundled models registry for path resolution.
[out]configOutput parsed config.
Returns
Empty string on success, error message on failure.
Version
1.8.1
Parameters
global_pathPath to global config file.
project_pathPath to project config file.
registryBundled models registry.
[out]configOutput parsed config.
Returns
Empty string on success, error message on failure.

Definition at line 676 of file loader.cpp.

◆ load_config_from_file()

std::string entropic::config::load_config_from_file ( const std::filesystem::path &  path,
const BundledModels registry,
ParsedConfig config 
)

Load config from a single YAML file (no layering).

Load config from a single YAML file.

Applies compiled defaults first, then overlays the file. Used by entropic_configure_from_file().

Parameters
pathPath to YAML config file.
registryBundled models registry for path resolution.
[out]configOutput parsed config.
Returns
Empty string on success, error message on failure.
Version
1.8.1
Parameters
pathPath to YAML config file.
registryBundled models registry.
[out]configOutput parsed config.
Returns
Empty string on success, error message on failure.

Definition at line 702 of file loader.cpp.

◆ load_config_from_string()

std::string entropic::config::load_config_from_string ( const std::string &  content,
const BundledModels registry,
ParsedConfig config 
)

Load config from a YAML/JSON string (no layering).

Load config from a YAML/JSON string with validation.

Parses the string with ryml (accepts both YAML and JSON since JSON is a YAML subset), applies env overrides, validates. Used by entropic_configure().

Parameters
contentConfig string (YAML or JSON).
registryBundled models registry for path resolution.
[out]configOutput parsed config.
Returns
Empty string on success, error message on failure.
Version
2.0.0
Parameters
contentConfig string (YAML or JSON).
registryBundled models registry.
[out]configOutput parsed config.
Returns
Empty string on success, error message on failure.

Definition at line 1109 of file loader.cpp.

◆ load_layered()

std::string entropic::config::load_layered ( const std::filesystem::path &  project_dir,
const std::filesystem::path &  consumer_defaults,
const BundledModels registry,
ParsedConfig config 
)

Load config with consumer defaults + global + project layers.

Load config with global → consumer defaults → project-local layering.

Resolution order (highest wins):

  1. Consumer defaults (CWD/default_config.yaml or specified path)
  2. Global (~/.entropic/config.yaml)
  3. Project ({project_dir}/config.local.yaml)
  4. Environment variables (ENTROPIC_*)
Parameters
project_dirProject config directory (empty = skip project layer).
consumer_defaultsPath to consumer defaults YAML (empty = skip).
registryBundled models registry for path resolution.
[out]configOutput parsed config.
Returns
Empty string on success, error message on failure.
Version
2.0.1

Later layers override earlier ones (standard config-precedence semantics: more-specific wins). Order is:

  1. Global user config (~/.entropic/config.yaml) — personal defaults.
  2. Consumer defaults (e.g., an app's bundled default_config.yaml) — the app knows what it needs; overrides the user's global defaults.
  3. Project-local (<project_dir>/config.local.yaml) — most specific.

Prior to v2.0.6 consumer defaults loaded first and were overridden by the user's global config. That meant a user's aggressive global settings (e.g. context_length: 131072) would override an app's deliberate lightweight defaults (e.g. context_length: 16384) — reversing expected precedence semantics. Now consumer defaults win over global.

Parameters
project_dirProject config directory.
consumer_defaultsPath to consumer defaults YAML.
registryBundled models registry.
configOutput config.
Returns
Empty string on success.

Definition at line 1033 of file loader.cpp.

◆ parse_config_file()

std::string entropic::config::parse_config_file ( const std::filesystem::path &  path,
const BundledModels registry,
ParsedConfig config 
)

Parse a config YAML file and overlay onto existing config.

Fields not present in YAML retain their current values. This is the merge primitive used for layered config loading.

Parameters
pathPath to YAML file.
registryBundled models for path resolution.
[in,out]configConfig to overlay onto.
Returns
Empty string on success, error message on failure.
Version
1.8.1

Passes the bundled-models registry through to optional-section parsers so inference.speculative.draft_model can be resolved (bundled key or path) at parse time. (v2.1.11)

Parameters
pathPath to YAML file.
registryBundled models for path resolution.
[in,out]configConfig to overlay onto.
Returns
Empty string on success, error message on failure. @req REQ-CFG-001
Version
2.3.7

Definition at line 573 of file loader.cpp.

◆ resolve_data_dir()

std::filesystem::path entropic::config::resolve_data_dir ( const ParsedConfig config)

Resolve the bundled data directory.

Priority:

  1. config.config_dir / "data" (if config_dir set)
  2. CONFIG_ENTROPIC_DATA_DIR (compile-time install path)
  3. Source-tree data/ (development fallback)
Parameters
configParsed config.
Returns
Resolved data directory path.
Version
1.8.1

Priority (v2.0.5.1):

  1. ENTROPIC_DATA_DIR env var (explicit operator override)
  2. config.config_dir / "data" (project-specific override)
  3. Binary-relative discovery via dladdr — <prefix>/share/entropic derived from librentropic.so's on-disk location. Portable across install prefixes regardless of build-time CMAKE_INSTALL_PREFIX.
  4. CONFIG_ENTROPIC_DATA_DIR (compile-time install path, last resort; historically unreliable for relocated installs).
  5. CONFIG_ENTROPIC_SOURCE_DATA_DIR + CWD-relative data/ (development fallback when running from the build tree).

First path that is_directory() on disk wins.

Parameters
configParsed config.
Returns
Resolved data directory path (empty if none found).

Definition at line 81 of file data_dir.cpp.