|
Entropic 2.9.4
Local-first agentic inference engine
|
Config loader implementation — YAML parsing + layered merge. More...
#include <entropic/config/loader.h>#include <entropic/config/validate.h>#include <entropic/types/logging.h>#include "yaml_util.h"#include <nlohmann/json.hpp>#include <fstream>#include <optional>#include <sstream>#include <dlfcn.h>
Go to the source code of this file.
Namespaces | |
| namespace | entropic |
| Activate model on GPU (WARM → ACTIVE). | |
Functions | |
| static void | entropic::config::parse_model_runtime_knobs (ryml::ConstNodeRef node, ModelConfig &config) |
| Read the model-runtime knobs (KV cache, batching, threads). | |
| static void | entropic::config::parse_sampler_overrides (ryml::ConstNodeRef node, TierConfig &config) |
| Read per-tier sampler overrides from a YAML model/tier node. | |
| static void | entropic::config::parse_tier_speculative_override (ryml::ConstNodeRef node, TierConfig &config) |
Parse the per-tier speculative.mtp override (gh#108, v2.9.4). | |
| static std::string | entropic::config::resolve_model_path (ryml::ConstNodeRef node, const BundledModels ®istry, ModelConfig &config) |
Resolve config.path from an explicit path: or a selector (gh#62). | |
| static std::string | entropic::config::parse_model_config (ryml::ConstNodeRef node, const BundledModels ®istry, ModelConfig &config) |
| Parse a ModelConfig from a YAML node. | |
| static std::string | entropic::config::parse_tier_config (ryml::ConstNodeRef node, const BundledModels ®istry, TierConfig &config) |
| Parse a TierConfig from a YAML node. | |
| static std::string | entropic::config::parse_models_config (ryml::ConstNodeRef node, const BundledModels ®istry, ModelsConfig &config) |
| Parse the models section from a YAML node. | |
| static std::string | entropic::config::parse_routing_config (ryml::ConstNodeRef node, RoutingConfig &config) |
| Parse the routing section from a YAML node. | |
| static std::string | entropic::config::parse_compaction_config (ryml::ConstNodeRef node, CompactionConfig &config) |
| Parse the compaction section from a YAML node. | |
| static std::string | entropic::config::parse_permissions_config (ryml::ConstNodeRef node, PermissionsConfig &config) |
| Parse the permissions section from a YAML node. | |
| static std::string | entropic::config::parse_filesystem_config (ryml::ConstNodeRef node, FilesystemConfig &config) |
| Parse the filesystem section from a YAML node. | |
| static std::string | entropic::config::parse_external_mcp_config (ryml::ConstNodeRef node, ExternalMCPConfig &config) |
| Parse the external MCP section from a YAML node. | |
| static std::string | entropic::config::parse_mcp_config (ryml::ConstNodeRef node, MCPConfig &config) |
| Parse the MCP section from a YAML node. | |
| static std::string | entropic::config::parse_generation_config (ryml::ConstNodeRef node, GenerationConfig &config) |
| Parse the generation section from a YAML node. | |
| static std::string | entropic::config::parse_lsp_config (ryml::ConstNodeRef node, LSPConfig &config) |
| Parse the LSP section from a YAML node. | |
| static std::string | entropic::config::parse_prompt_cache_config (ryml::ConstNodeRef node, PromptCacheConfig &config) |
| Parse prompt_cache config from inference YAML section. | |
| static void | entropic::config::parse_constitutional_validation_config (ryml::ConstNodeRef node, ConstitutionalValidationConfig &config) |
| Parse constitutional_validation section. | |
| static void | entropic::config::parse_speculative_config (ryml::ConstNodeRef node, const BundledModels ®istry, SpeculativeConfig &config) |
Parse inference.speculative YAML node into SpeculativeConfig. | |
| static void | entropic::config::parse_inference_subsections (ryml::ConstNodeRef root, const BundledModels ®istry, ParsedConfig &config) |
| Parse the nested optional config sub-sections. | |
| static void | entropic::config::parse_optional_subsections (ryml::ConstNodeRef root, const BundledModels ®istry, ParsedConfig &config) |
| Parse the nested optional config sub-sections. | |
| static void | entropic::config::extract_scalar_fields (ryml::ConstNodeRef root, ParsedConfig &config) |
| Extract the top-level scalar/path config fields. | |
| static void | entropic::config::parse_optional_sections (ryml::ConstNodeRef root, const BundledModels ®istry, ParsedConfig &config) |
| Parse optional config sections that don't return errors. | |
| static std::string | entropic::config::parse_top_sections (ryml::ConstNodeRef root, const BundledModels ®istry, ParsedConfig &config) |
| Parse the top-level models/routing/optional sections. | |
| ENTROPIC_EXPORT std::string | entropic::config::parse_config_file (const std::filesystem::path &path, const BundledModels ®istry, ParsedConfig &config) |
| Parse a config YAML file and overlay onto existing config. | |
| static std::string | entropic::config::load_bundled_default (const std::filesystem::path &global_path, const BundledModels ®istry, ParsedConfig &config) |
| Load bundled default config when no user config exists. | |
| static std::string | entropic::config::load_config_layers (const std::filesystem::path &global_path, const std::filesystem::path &project_path, const BundledModels ®istry, ParsedConfig &config) |
| Load global, project, and bundled config layers in order. | |
| ENTROPIC_EXPORT std::string | entropic::config::load_config (const std::filesystem::path &global_path, const std::filesystem::path &project_path, const BundledModels ®istry, ParsedConfig &config) |
| Load config using layered resolution. | |
| ENTROPIC_EXPORT std::string | entropic::config::load_config_from_file (const std::filesystem::path &path, const BundledModels ®istry, ParsedConfig &config) |
| Load config from a single YAML file (no layering). | |
| static ExternalServerEntry | entropic::config::parse_mcp_json_entry (const std::string &name, const nlohmann::json &entry) |
| Parse a single mcpServers entry from .mcp.json. | |
| static std::optional< nlohmann::json > | entropic::config::read_mcp_servers (const std::filesystem::path &path) |
| Discover and parse .mcp.json from the project directory. | |
| static void | entropic::config::discover_mcp_json (const std::filesystem::path &project_dir, ParsedConfig &config) |
| Discover + merge external MCP servers from <dir>/.mcp.json. | |
| static std::string | entropic::config::load_global_layer (const BundledModels ®istry, ParsedConfig &config) |
| Load the global user config layer if present. | |
| static std::filesystem::path | entropic::config::resolve_consumer_defaults (const std::filesystem::path &consumer_defaults) |
| Resolve a relative consumer_defaults path against install prefix. | |
| static bool | entropic::config::yaml_has_key (const std::filesystem::path &path, const char *key) |
| Load the consumer/app defaults layer if present (non-fatal). | |
| static void | entropic::config::load_consumer_layer (const std::filesystem::path &consumer_defaults_in, const BundledModels ®istry, ParsedConfig &config) |
| Load the consumer-defaults layer. | |
| static std::string | entropic::config::load_project_layer (const std::filesystem::path &project_dir, const BundledModels ®istry, ParsedConfig &config) |
| Load the project-local layer if present. | |
| ENTROPIC_EXPORT std::string | entropic::config::load_layered (const std::filesystem::path &project_dir, const std::filesystem::path &consumer_defaults, const BundledModels ®istry, ParsedConfig &config) |
| Load config with consumer defaults + global + project layers. | |
| static std::string | entropic::config::parse_config_string (const std::string &content, const BundledModels ®istry, ParsedConfig &config) |
| Parse a config string (YAML or JSON) and overlay onto config. | |
| ENTROPIC_EXPORT std::string | entropic::config::load_config_from_string (const std::string &content, const BundledModels ®istry, ParsedConfig &config) |
| Load config from a YAML/JSON string (no layering). | |
Variables | |
| static auto | s_log = entropic::log::get("config") |
Config loader implementation — YAML parsing + layered merge.
Definition in file loader.cpp.
|
static |
Discover + merge external MCP servers from <dir>/.mcp.json.
Definition at line 949 of file loader.cpp.
|
static |
Extract the top-level scalar/path config fields.
| root | YAML root node. |
| config | Config to populate. |
Definition at line 645 of file loader.cpp.
|
static |
Load bundled default config when no user config exists.
| global_path | Path for auto-created global config. | |
| registry | Bundled models registry. | |
| [in,out] | config | Config to populate. |
Definition at line 750 of file loader.cpp.
| 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):
| global_path | Path to global config file (may not exist). | |
| project_path | Path to project config file (may not exist). | |
| registry | Bundled models registry for path resolution. | |
| [out] | config | Output parsed config. |
| global_path | Path to global config file. | |
| project_path | Path to project config file. | |
| registry | Bundled models registry. | |
| [out] | config | Output parsed config. |
Definition at line 823 of file loader.cpp.
| 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().
| path | Path to YAML config file. | |
| registry | Bundled models registry for path resolution. | |
| [out] | config | Output parsed config. |
| path | Path to YAML config file. | |
| registry | Bundled models registry. | |
| [out] | config | Output parsed config. |
Definition at line 849 of file loader.cpp.
| 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().
| content | Config string (YAML or JSON). | |
| registry | Bundled models registry for path resolution. | |
| [out] | config | Output parsed config. |
| content | Config string (YAML or JSON). | |
| registry | Bundled models registry. | |
| [out] | config | Output parsed config. |
Definition at line 1256 of file loader.cpp.
|
static |
Load global, project, and bundled config layers in order.
| global_path | Path to global config file. | |
| project_path | Path to project config file. | |
| registry | Bundled models registry. | |
| [in,out] | config | Config to overlay onto. |
Definition at line 786 of file loader.cpp.
|
static |
Load the consumer-defaults layer.
Consumer config is a complete application config, not a patch. If the consumer file defines a models: block, existing tiers from prior layers are cleared before parsing so the consumer's tier set fully replaces the global one. Same for routing:.
| consumer_defaults_in | Consumer defaults path. | |
| registry | Bundled models registry. | |
| [in,out] | config | Config to overlay onto. @utility |
Definition at line 1082 of file loader.cpp.
|
static |
Load the global user config layer if present.
@utility
Definition at line 979 of file loader.cpp.
| 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):
| project_dir | Project config directory (empty = skip project layer). | |
| consumer_defaults | Path to consumer defaults YAML (empty = skip). | |
| registry | Bundled models registry for path resolution. | |
| [out] | config | Output parsed config. |
Later layers override earlier ones (standard config-precedence semantics: more-specific wins). Order is:
~/.entropic/config.yaml) — personal defaults.default_config.yaml) — the app knows what it needs; overrides the user's global defaults.<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.
| project_dir | Project config directory. |
| consumer_defaults | Path to consumer defaults YAML. |
| registry | Bundled models registry. |
| config | Output config. |
Definition at line 1180 of file loader.cpp.
|
static |
Load the project-local layer if present.
@utility
Load the project-local layer if present.
Same replace semantics as consumer layer: if the project config defines a models: or routing: block, existing entries from prior layers are cleared before parsing.
@utility
Definition at line 1127 of file loader.cpp.
|
static |
Parse the compaction section from a YAML node.
| node | YAML node for "compaction" section. | |
| [out] | config | Output compaction config. |
Definition at line 341 of file loader.cpp.
| 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.
| path | Path to YAML file. | |
| registry | Bundled models for path resolution. | |
| [in,out] | config | Config to overlay onto. |
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)
| path | Path to YAML file. | |
| registry | Bundled models for path resolution. | |
| [in,out] | config | Config to overlay onto. |
Definition at line 720 of file loader.cpp.
|
static |
Parse a config string (YAML or JSON) and overlay onto config.
Threads the bundled-models registry through to the optional-section parser for speculative draft_model resolution (v2.1.11).
| content | Raw config string. | |
| registry | Bundled models for path resolution. | |
| [in,out] | config | Config to overlay onto. |
Definition at line 1217 of file loader.cpp.
|
static |
Parse constitutional_validation section.
| node | YAML node for "constitutional_validation" section. | |
| [out] | config | Output constitutional validation config. |
Definition at line 526 of file loader.cpp.
|
static |
Parse the external MCP section from a YAML node.
| node | YAML node for "external" section. | |
| [out] | config | Output external MCP config. |
Definition at line 409 of file loader.cpp.
|
static |
Parse the filesystem section from a YAML node.
| node | YAML node for "filesystem" section. | |
| [out] | config | Output filesystem config. |
Definition at line 383 of file loader.cpp.
|
static |
Parse the generation section from a YAML node.
| node | YAML node for "generation" section. | |
| [out] | config | Output generation config. |
Definition at line 465 of file loader.cpp.
|
static |
Parse the nested optional config sub-sections.
| root | YAML root node. |
| registry | Bundled models for path resolution. |
| config | Config to populate. |
Parse the nested inference.* sub-sections, if present.
| root | YAML root node. |
| registry | Bundled models for path resolution. |
| config | Config to populate. |
Definition at line 594 of file loader.cpp.
|
static |
Parse the LSP section from a YAML node.
| node | YAML node for "lsp" section. | |
| [out] | config | Output LSP config. |
Definition at line 486 of file loader.cpp.
|
static |
Parse the MCP section from a YAML node.
| node | YAML node for "mcp" section. | |
| [out] | config | Output MCP config. |
Definition at line 434 of file loader.cpp.
|
static |
Parse a single mcpServers entry from .mcp.json.
| name | Server name (key in mcpServers object). |
| entry | JSON value for that server. |
Definition at line 877 of file loader.cpp.
|
static |
Parse a ModelConfig from a YAML node.
| node | YAML node containing model fields. | |
| registry | Bundled models for path resolution. | |
| [out] | config | Output model config. |
Definition at line 161 of file loader.cpp.
|
static |
Read the model-runtime knobs (KV cache, batching, threads).
Extracted (gh#23 v2.3.19) to keep parse_model_config under the knots ABC gate as new MVP-10 model-load knobs land. @utility
Definition at line 34 of file loader.cpp.
|
static |
Parse the models section from a YAML node.
| node | YAML node for "models" section. | |
| registry | Bundled models for path resolution. | |
| [out] | config | Output models config. |
Definition at line 268 of file loader.cpp.
|
static |
Parse optional config sections that don't return errors.
| root | YAML root node. |
| config | Config to populate. |
Definition at line 670 of file loader.cpp.
|
static |
Parse the nested optional config sub-sections.
| root | YAML root node. |
| registry | Bundled models for path resolution. |
| config | Config to populate. |
Definition at line 616 of file loader.cpp.
|
static |
Parse the permissions section from a YAML node.
| node | YAML node for "permissions" section. | |
| [out] | config | Output permissions config. |
Definition at line 365 of file loader.cpp.
|
static |
Parse prompt_cache config from inference YAML section.
| node | YAML node for "inference.prompt_cache" section. | |
| [out] | config | Output prompt cache config. |
Definition at line 504 of file loader.cpp.
|
static |
Parse the routing section from a YAML node.
| node | YAML node for "routing" section. | |
| [out] | config | Output routing config. |
Definition at line 315 of file loader.cpp.
|
static |
Read per-tier sampler overrides from a YAML model/tier node.
gh#94 (v2.7.3): give config.local.yaml a per-tier sampler lever independent of identity frontmatter — both a consumer override and a workaround on pinned releases. Each optional is set ONLY when the key is present, so an absent key leaves the orchestrator's GenerationParams default in place (same precedence as the frontmatter path, thread_frontmatter_sampler). YAML is loaded before init_orchestrator, so unlike frontmatter these land in the orchestrator's config snapshot. @utility
Definition at line 66 of file loader.cpp.
|
static |
Parse inference.speculative YAML node into SpeculativeConfig.
Off-by-default semantics: missing keys leave the struct defaults intact (enabled=false, n_draft=16). The draft model is configured via a nested draft: block that accepts every ModelConfig field (path, gpu_layers, n_threads, flash_attn, context_length, use_mlock, etc.); defaults for the kernel come from make_default_draft_model_config(). (v2.1.11 refactor — earlier flat draft_model/draft_n_gpu_layers/draft_cpu_threads keys are absorbed into the nested block.)
| node | YAML node for inference.speculative. | |
| [out] | config | Output speculative config. |
Definition at line 557 of file loader.cpp.
|
static |
Parse a TierConfig from a YAML node.
gh#108 (v2.9.4): also parses the per-tier speculative.mtp override and rejects a tier that statically combines speculative.mtp=true with a static grammar — that combination fails every request at generate-time (MTP does not enforce GBNF), so it's caught here instead.
| node | YAML node containing tier fields. | |
| registry | Bundled models for path resolution. | |
| [out] | config | Output tier config. |
Definition at line 204 of file loader.cpp.
|
static |
Parse the per-tier speculative.mtp override (gh#108, v2.9.4).
Nested under models.<tier>.speculative.mtp — a tier-scoped mirror of the global inference.speculative.mtp flag. nullopt (key absent) means inherit the global value; resolve_mtp_effective applies the precedence.
| node | YAML node for a single tier. | |
| [out] | config | Output tier config. |
Definition at line 97 of file loader.cpp.
|
static |
Parse the top-level models/routing/optional sections.
| root | YAML root node. | |
| registry | Bundled models for path resolution. | |
| [in,out] | config | Config to overlay onto. |
Definition at line 688 of file loader.cpp.
|
static |
Discover and parse .mcp.json from the project directory.
Auto-registers external MCP servers (stdio/SSE) declared in the project's .mcp.json. Format matches Claude Code / VSCode MCP config: { "mcpServers": { "name": { "type": "stdio|sse", ... } } }
Entries are merged into config.mcp.external_servers. The ServerManager initializes them during builtin setup.
| project_dir | Project directory to search for .mcp.json. | |
| [in,out] | config | Config to populate external_servers into. @utility |
Read + validate the mcpServers object from a .mcp.json file.
| path | Path to .mcp.json. |
Definition at line 925 of file loader.cpp.
|
static |
Resolve a relative consumer_defaults path against install prefix.
The facade passes a bare filename ("default_config.yaml") that resolves against CWD by default. For tarball-installed consumers whose CWD isn't the install prefix, the bundled <prefix>/share/entropic/<filename> is the correct fallback. Uses the same dladdr-derived discovery as src/config/data_dir.cpp.
Returns the input unchanged if it's absolute or already exists. Otherwise attempts <prefix>/share/entropic/<filename>; returns that if found, else returns the original (so the caller's error messages remain sensible).
Definition at line 1015 of file loader.cpp.
|
static |
Resolve config.path from an explicit path: or a selector (gh#62).
Precedence: an explicit path: (bundled key or literal path) wins. Otherwise, if ALL of family/size/quant are present, resolve via the bundled registry (find_by → resolve). A partial selector (some but not all three) or an unmatched triple is a clear error. Absent both leaves config.path untouched (downstream validation reports the missing model). @utility
Definition at line 118 of file loader.cpp.
|
static |
Load the consumer/app defaults layer if present (non-fatal).
@utility
Check whether a YAML file contains a top-level key.
| path | File path. |
| key | Key to look for. |
Definition at line 1057 of file loader.cpp.
|
static |
Definition at line 21 of file loader.cpp.