Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
loader.cpp File Reference

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 <algorithm>
#include <fstream>
#include <optional>
#include <sstream>
#include <dlfcn.h>
Include dependency graph for loader.cpp:

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 &registry, ModelConfig &config)
 Resolve config.path from an explicit path: or a selector (gh#62).
 
static void entropic::config::parse_gpu_layers (ryml::ConstNodeRef node, ModelConfig &config)
 Parse gpu_layers, which may be a count or the word auto (gh#148).
 
static std::string entropic::config::parse_model_config (ryml::ConstNodeRef node, const BundledModels &registry, ModelConfig &config)
 Parse a ModelConfig from a YAML node.
 
static std::string entropic::config::parse_tier_config (ryml::ConstNodeRef node, const BundledModels &registry, TierConfig &config)
 Parse a TierConfig from a YAML node.
 
static std::string entropic::config::parse_models_config (ryml::ConstNodeRef node, const BundledModels &registry, 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_delegation_config (ryml::ConstNodeRef node, DelegationConfig &config)
 Parse the delegation section from a YAML node (gh#160).
 
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_outside_root_access (ryml::ConstNodeRef node, FilesystemConfig &config)
 Parse mcp.filesystem.allow_outside_root (v2.13.0 tri-state).
 
static std::string entropic::config::parse_outside_root_list (ryml::ConstNodeRef node, c4::csubstr key, std::vector< std::filesystem::path > &out)
 Parse one outside-root path list (outside_root_allow/_deny).
 
static std::string entropic::config::parse_filesystem_config (ryml::ConstNodeRef node, FilesystemConfig &config)
 Parse the filesystem section from a YAML node.
 
static void entropic::config::parse_tool_descriptions (ryml::ConstNodeRef node, ExternalMCPConfig &config)
 Parse mcp.external.tool_descriptions into the override map.
 
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_bash_config (ryml::ConstNodeRef node, BashConfig &config)
 Parse mcp.bash (v2.13.0).
 
static ExternalServerEntry entropic::config::parse_external_server_entry (ryml::ConstNodeRef node)
 Parse one declared external server (v2.14.0).
 
static std::string entropic::config::parse_external_servers (ryml::ConstNodeRef node, MCPConfig &config)
 Parse mcp.external_servers (v2.14.0).
 
static void entropic::config::parse_mcpjson_enablement (ryml::ConstNodeRef node, MCPConfig &config)
 Parse the .mcp.json enablement keys (v2.14.0, gh#199).
 
static std::string entropic::config::validate_server_timeout (const MCPConfig &config)
 Refuse a server_timeout_seconds that cannot bound anything (gh#175).
 
static std::string entropic::config::parse_mcp_sections (ryml::ConstNodeRef node, MCPConfig &config)
 Parse the MCP section's per-server sub-sections (v2.13.0).
 
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 &registry, SpeculativeConfig &config)
 Parse inference.speculative YAML node into SpeculativeConfig.
 
static void entropic::config::parse_inference_subsections (ryml::ConstNodeRef root, const BundledModels &registry, ParsedConfig &config)
 Parse the nested optional config sub-sections.
 
static std::string entropic::config::parse_optional_subsections (ryml::ConstNodeRef root, const BundledModels &registry, 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 std::string entropic::config::validate_workspace_app_context (const ParsedConfig &config)
 Refuse a workspace_app_context that could leave a workspace root.
 
static std::string entropic::config::parse_optional_sections (ryml::ConstNodeRef root, const BundledModels &registry, ParsedConfig &config)
 Parse the optional config sections.
 
static std::string entropic::config::parse_top_sections (ryml::ConstNodeRef root, const BundledModels &registry, 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 &registry, 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 &registry, 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 &registry, 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 &registry, ParsedConfig &config)
 Load config using layered resolution.
 
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).
 
static std::string entropic::config::load_global_layer (const BundledModels &registry, ParsedConfig &config)
 Discover and parse .mcp.json from the project directory.
 
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 &registry, ParsedConfig &config)
 Load the consumer-defaults layer.
 
static std::string entropic::config::load_project_layer (const std::filesystem::path &project_dir, const BundledModels &registry, 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 &registry, ParsedConfig &config)
 Load config with consumer defaults + global + project layers.
 
static std::string entropic::config::parse_config_string (const std::string &content, const BundledModels &registry, 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 &registry, ParsedConfig &config)
 Load config from a YAML/JSON string (no layering).
 

Variables

static auto s_log = entropic::log::get("config")
 

Detailed Description

Config loader implementation — YAML parsing + layered merge.

Version
1.8.2

Definition in file loader.cpp.

Function Documentation

◆ extract_scalar_fields()

static void entropic::config::extract_scalar_fields ( ryml::ConstNodeRef  root,
ParsedConfig &  config 
)
static

Extract the top-level scalar/path config fields.

Parameters
rootYAML root node.
configConfig to populate. @dg_internal
Version
2.14.0

Definition at line 1012 of file loader.cpp.

◆ load_bundled_default()

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

Load bundled default config when no user config exists.

Parameters
global_pathPath for auto-created global config.
registryBundled models registry.
[in,out]configConfig to populate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-007
Version
2.9.5

Definition at line 1168 of file loader.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. @req REQ-CFG-001 @req REQ-CFG-006 @req REQ-CFG-007
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. @req REQ-CFG-001 @req REQ-CFG-006 @req REQ-CFG-007
Version
2.0.0

Definition at line 1249 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. @req REQ-CFG-001 @req REQ-CFG-006
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. @req REQ-CFG-001 @req REQ-CFG-006
Version
1.8.2

Definition at line 1276 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. @req REQ-CFG-001 @req REQ-CFG-006
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. @req REQ-CFG-001 @req REQ-CFG-006
Version
2.0.0

Definition at line 1621 of file loader.cpp.

◆ load_config_layers()

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

Load global, project, and bundled config layers in order.

Parameters
global_pathPath to global config file.
project_pathPath to project config file.
registryBundled models registry.
[in,out]configConfig to overlay onto.
Returns
Empty string on success, error message on failure. @req REQ-CFG-001 @req REQ-CFG-007
Version
2.0.0

Definition at line 1210 of file loader.cpp.

◆ load_consumer_layer()

static void entropic::config::load_consumer_layer ( const std::filesystem::path &  consumer_defaults_in,
const BundledModels &  registry,
ParsedConfig &  config 
)
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:.

Parameters
consumer_defaults_inConsumer defaults path.
registryBundled models registry.
[in,out]configConfig to overlay onto. @req REQ-CFG-001 @req REQ-CFG-002 @req REQ-CFG-007
Version
2.0.6

Definition at line 1422 of file loader.cpp.

◆ load_global_layer()

static std::string entropic::config::load_global_layer ( const BundledModels &  registry,
ParsedConfig &  config 
)
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.

Parameters
project_dirProject directory to search for .mcp.json.
[in,out]configConfig to populate external_servers into. @utility
Version
2.0.3

Load the global user config layer if present. @req REQ-CFG-001

Returns
Empty on success or absence; error message on parse failure.
Version
1

Definition at line 1317 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. @req REQ-CFG-001 @req REQ-CFG-002 @req REQ-CFG-007
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. @req REQ-CFG-001 @req REQ-CFG-002 @req REQ-CFG-007
Version
2.14.0

Definition at line 1523 of file loader.cpp.

◆ load_project_layer()

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

Load the project-local layer if present.

@utility

Returns
Empty on success or absence; error message on parse failure.
Version
1

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.

@req REQ-CFG-001 @req REQ-CFG-002

Returns
Empty on success or absence; error message on parse failure.
Version
2.0.6

Definition at line 1468 of file loader.cpp.

◆ parse_bash_config()

static std::string entropic::config::parse_bash_config ( ryml::ConstNodeRef  node,
BashConfig &  config 
)
static

Parse mcp.bash (v2.13.0).

timeout_seconds must be a positive integer. Zero and negatives are REFUSED rather than clamped or read as "no limit": the timeout is what stops a runaway command holding a run thread (and every lock above it), and a consumer who wrote 0 meaning "off" and silently got either reading would believe a posture that is not in force. An absent key keeps 30.

Parameters
nodeYAML node for the "bash" section.
[out]configOutput bash config.
Returns
Empty string on success, error message on a non-positive value. @req REQ-MCP-023
Version
2.13.0

Definition at line 642 of file loader.cpp.

◆ parse_compaction_config()

static std::string entropic::config::parse_compaction_config ( ryml::ConstNodeRef  node,
CompactionConfig &  config 
)
static

Parse the compaction section from a YAML node.

Parameters
nodeYAML node for "compaction" section.
[out]configOutput compaction config.
Returns
Empty string on success, error message on failure. @dg_internal
Version
1.8.2

Definition at line 380 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. @req REQ-CFG-001 @req REQ-CFG-006 @req REQ-TYPE-005
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 @req REQ-CFG-006 @req REQ-TYPE-005
Version
2.3.7

Definition at line 1138 of file loader.cpp.

◆ parse_config_string()

static std::string entropic::config::parse_config_string ( const std::string &  content,
const BundledModels &  registry,
ParsedConfig &  config 
)
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).

Parameters
contentRaw config string.
registryBundled models for path resolution.
[in,out]configConfig to overlay onto.
Returns
Empty string on success, error message on failure. @req REQ-CFG-001 @req REQ-CFG-006
Version
2.13.0

Definition at line 1581 of file loader.cpp.

◆ parse_constitutional_validation_config()

static void entropic::config::parse_constitutional_validation_config ( ryml::ConstNodeRef  node,
ConstitutionalValidationConfig &  config 
)
static

Parse constitutional_validation section.

Parameters
nodeYAML node for "constitutional_validation" section.
[out]configOutput constitutional validation config. @dg_internal
Version
2.0.7

Definition at line 888 of file loader.cpp.

◆ parse_delegation_config()

static std::string entropic::config::parse_delegation_config ( ryml::ConstNodeRef  node,
DelegationConfig &  config 
)
static

Parse the delegation section from a YAML node (gh#160).

An unrecognized isolation value is refused rather than silently treated as none: a consumer who asks for containment and gets the shipped default back would believe a guarantee that is not in force.

Parameters
nodeYAML node for the "delegation" section.
[out]configOutput delegation config.
Returns
Empty string on success, error message on an unknown mode. @req REQ-DELEG-005 @dg_internal
Version
2.13.0

Definition at line 410 of file loader.cpp.

◆ parse_external_mcp_config()

static std::string entropic::config::parse_external_mcp_config ( ryml::ConstNodeRef  node,
ExternalMCPConfig &  config 
)
static

Parse the external MCP section from a YAML node.

Parameters
nodeYAML node for "external" section.
[out]configOutput external MCP config.
Returns
Empty string on success, error message on failure. @dg_internal
Version
2.14.0

Definition at line 598 of file loader.cpp.

◆ parse_external_server_entry()

static ExternalServerEntry entropic::config::parse_external_server_entry ( ryml::ConstNodeRef  node)
static

Parse one declared external server (v2.14.0).

Parameters
nodeYAML node for one mcp.external_servers.<name> entry.
Returns
The entry; an empty command AND url means "not usable". @dg_internal
Version
2.14.0

Definition at line 664 of file loader.cpp.

◆ parse_external_servers()

static std::string entropic::config::parse_external_servers ( ryml::ConstNodeRef  node,
MCPConfig &  config 
)
static

Parse mcp.external_servers (v2.14.0).

The key has been in MCPConfig and the schema since v1.8.7; until now no config file could set it. An entry with neither command nor url is a typed error rather than a silent skip — it can only be a mistake.

Parameters
nodeYAML node for the "mcp" section.
[in,out]configMCP config to populate.
Returns
Empty on success, else the first bad entry's error. @dg_internal
Version
2.14.0

Definition at line 692 of file loader.cpp.

◆ parse_filesystem_config()

static std::string entropic::config::parse_filesystem_config ( ryml::ConstNodeRef  node,
FilesystemConfig &  config 
)
static

Parse the filesystem section from a YAML node.

Parameters
nodeYAML node for "filesystem" section.
[out]configOutput filesystem config.
Returns
Empty string on success, error message on failure — v2.13.0 the outside-root keys can now fail, and a bad value there must reach the operator rather than fall back. @dg_internal
Version
2.13.0 [reviewed]

Definition at line 533 of file loader.cpp.

◆ parse_generation_config()

static std::string entropic::config::parse_generation_config ( ryml::ConstNodeRef  node,
GenerationConfig &  config 
)
static

Parse the generation section from a YAML node.

Parameters
nodeYAML node for "generation" section.
[out]configOutput generation config.
Returns
Empty string on success, error message on failure. @dg_internal
Version
2.9.6

Definition at line 825 of file loader.cpp.

◆ parse_gpu_layers()

static void entropic::config::parse_gpu_layers ( ryml::ConstNodeRef  node,
ModelConfig &  config 
)
static

Parse gpu_layers, which may be a count or the word auto (gh#148).

auto is an explicit opt-in to have the engine derive the offload split from free VRAM at admission time; anything else is taken verbatim, as every gpu_layers value always has been. A tier that says auto keeps gpu_layers at its default until the gate resolves it, so nothing downstream sees a half-resolved value.

Parameters
nodeYAML node for the model/tier.
[out]configOutput model config. @dg_internal @req REQ-CFG-005 @req REQ-TYPE-005
Version
2.13.0

Definition at line 175 of file loader.cpp.

◆ parse_inference_subsections()

static void entropic::config::parse_inference_subsections ( ryml::ConstNodeRef  root,
const BundledModels &  registry,
ParsedConfig &  config 
)
static

Parse the nested optional config sub-sections.

Parameters
rootYAML root node.
registryBundled models for path resolution.
configConfig to populate. @dg_internal
Version
2.3.7

Parse the nested inference.* sub-sections, if present.

Parameters
rootYAML root node.
registryBundled models for path resolution.
configConfig to populate. @dg_internal
Version
2.3.7

Definition at line 957 of file loader.cpp.

◆ parse_lsp_config()

static std::string entropic::config::parse_lsp_config ( ryml::ConstNodeRef  node,
LSPConfig &  config 
)
static

Parse the LSP section from a YAML node.

Parameters
nodeYAML node for "lsp" section.
[out]configOutput LSP config.
Returns
Empty string on success, error message on failure. @dg_internal
Version
1.8.2

Definition at line 848 of file loader.cpp.

◆ parse_mcp_config()

static std::string entropic::config::parse_mcp_config ( ryml::ConstNodeRef  node,
MCPConfig &  config 
)
static

Parse the MCP section from a YAML node.

Parameters
nodeYAML node for "mcp" section.
[out]configOutput MCP config.
Returns
Empty string on success, error message on failure — v2.13.0 propagates the filesystem section's error, which used to be dropped here, and the bash section's. @dg_internal
Version
2.14.0

Definition at line 791 of file loader.cpp.

◆ parse_mcp_sections()

static std::string entropic::config::parse_mcp_sections ( ryml::ConstNodeRef  node,
MCPConfig &  config 
)
static

Parse the MCP section's per-server sub-sections (v2.13.0).

Split out of parse_mcp_config when mcp.bash joined filesystem and external, to keep that function inside the knots ABC gate. The first error wins; external has no failure mode of its own.

Parameters
nodeYAML node for "mcp" section.
[out]configOutput MCP config.
Returns
Empty string on success, else the first section's error. @dg_internal
Version
2.14.0

Definition at line 762 of file loader.cpp.

◆ parse_mcpjson_enablement()

static void entropic::config::parse_mcpjson_enablement ( ryml::ConstNodeRef  node,
MCPConfig &  config 
)
static

Parse the .mcp.json enablement keys (v2.14.0, gh#199).

Parameters
nodeYAML node for the "mcp" section.
[in,out]configMCP config to populate. @dg_internal
Version
2.14.0

Definition at line 719 of file loader.cpp.

◆ parse_model_config()

static std::string entropic::config::parse_model_config ( ryml::ConstNodeRef  node,
const BundledModels &  registry,
ModelConfig &  config 
)
static

Parse a ModelConfig from a YAML node.

Parameters
nodeYAML node containing model fields.
registryBundled models for path resolution.
[out]configOutput model config.
Returns
Empty string on success, error message on failure. @req REQ-CFG-003 @req REQ-CFG-005 @req REQ-TYPE-005
Version
2.13.0

Definition at line 195 of file loader.cpp.

◆ parse_model_runtime_knobs()

static void entropic::config::parse_model_runtime_knobs ( ryml::ConstNodeRef  node,
ModelConfig &  config 
)
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 @dg_internal

Version
2.13.0

Definition at line 35 of file loader.cpp.

◆ parse_models_config()

static std::string entropic::config::parse_models_config ( ryml::ConstNodeRef  node,
const BundledModels &  registry,
ModelsConfig &  config 
)
static

Parse the models section from a YAML node.

Parameters
nodeYAML node for "models" section.
registryBundled models for path resolution.
[out]configOutput models config.
Returns
Empty string on success, error message on failure. @req REQ-CFG-001 @req REQ-CFG-002
Version
2.13.0

Definition at line 305 of file loader.cpp.

◆ parse_optional_sections()

static std::string entropic::config::parse_optional_sections ( ryml::ConstNodeRef  root,
const BundledModels &  registry,
ParsedConfig &  config 
)
static

Parse the optional config sections.

gh#160 (v2.13.0): no longer infallible — delegation.isolation names a safety posture, so an unrecognized value is refused instead of being quietly read as the shipped default. The same holds for the mcp.filesystem outside-root keys, whose error is reported first.

Parameters
rootYAML root node.
registryBundled models for path resolution.
configConfig to populate.
Returns
Empty string on success, error message on failure. @dg_internal
Version
2.14.0

Definition at line 1080 of file loader.cpp.

◆ parse_optional_subsections()

static std::string entropic::config::parse_optional_subsections ( ryml::ConstNodeRef  root,
const BundledModels &  registry,
ParsedConfig &  config 
)
static

Parse the nested optional config sub-sections.

Parameters
rootYAML root node.
registryBundled models for path resolution.
configConfig to populate.
Returns
Empty string on success, else the mcp section's error (v2.13.0: its outside-root keys are refused, not defaulted). @dg_internal
Version
2.13.0

Definition at line 981 of file loader.cpp.

◆ parse_outside_root_access()

static std::string entropic::config::parse_outside_root_access ( ryml::ConstNodeRef  node,
FilesystemConfig &  config 
)
static

Parse mcp.filesystem.allow_outside_root (v2.13.0 tri-state).

true/false keep every spelling the bool parser accepted, so a pre-2.13 config means exactly what it meant. optional is new. An unrecognised value is REFUSED rather than read as a default: this key is a security boundary, and a consumer who typed maybe and silently got either extreme would believe a posture that is not in force. An absent key leaves the field untouched (default optional).

Parameters
nodeYAML node for the "filesystem" section.
[out]configOutput filesystem config.
Returns
Empty string on success, error message on an unknown value. @req REQ-MCP-021
Version
2.13.0

Definition at line 461 of file loader.cpp.

◆ parse_outside_root_list()

static std::string entropic::config::parse_outside_root_list ( ryml::ConstNodeRef  node,
c4::csubstr  key,
std::vector< std::filesystem::path > &  out 
)
static

Parse one outside-root path list (outside_root_allow/_deny).

Entries are ~-expanded like every other config path, and must then be ABSOLUTE: a relative entry has no defensible anchor (the process cwd? the root it is supposed to lie outside of?), so it is refused rather than guessed. A present key replaces the list, like every other list key, so a project layer can narrow what the global layer granted.

Parameters
nodeYAML node for the "filesystem" section.
keyList key.
[out]outOutput list; untouched when the key is absent.
Returns
Empty string on success, error message naming the bad entry. @req REQ-MCP-021
Version
2.13.0

Definition at line 502 of file loader.cpp.

◆ parse_permissions_config()

static std::string entropic::config::parse_permissions_config ( ryml::ConstNodeRef  node,
PermissionsConfig &  config 
)
static

Parse the permissions section from a YAML node.

Parameters
nodeYAML node for "permissions" section.
[out]configOutput permissions config.
Returns
Empty string on success, error message on failure. @dg_internal
Version
1.8.2

Definition at line 435 of file loader.cpp.

◆ parse_prompt_cache_config()

static std::string entropic::config::parse_prompt_cache_config ( ryml::ConstNodeRef  node,
PromptCacheConfig &  config 
)
static

Parse prompt_cache config from inference YAML section.

Parameters
nodeYAML node for "inference.prompt_cache" section.
[out]configOutput prompt cache config.
Returns
Empty string on success, error message on failure. @dg_internal
Version
1.8.3

Definition at line 866 of file loader.cpp.

◆ parse_routing_config()

static std::string entropic::config::parse_routing_config ( ryml::ConstNodeRef  node,
RoutingConfig &  config 
)
static

Parse the routing section from a YAML node.

Parameters
nodeYAML node for "routing" section.
[out]configOutput routing config.
Returns
Empty string on success, error message on failure. @dg_internal
Version
1.8.2

Definition at line 354 of file loader.cpp.

◆ parse_sampler_overrides()

static void entropic::config::parse_sampler_overrides ( ryml::ConstNodeRef  node,
TierConfig &  config 
)
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. @req REQ-CFG-005 @req REQ-TYPE-005

Version
2.8.2

Definition at line 71 of file loader.cpp.

◆ parse_speculative_config()

static void entropic::config::parse_speculative_config ( ryml::ConstNodeRef  node,
const BundledModels &  registry,
SpeculativeConfig &  config 
)
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.)

Parameters
nodeYAML node for inference.speculative.
[out]configOutput speculative config. @req REQ-CFG-005 @req REQ-TYPE-005
Version
2.9.0

Definition at line 920 of file loader.cpp.

◆ parse_tier_config()

static std::string entropic::config::parse_tier_config ( ryml::ConstNodeRef  node,
const BundledModels &  registry,
TierConfig &  config 
)
static

Parse a TierConfig from a YAML node.

gh#108 (v2.9.4): also parses the per-tier speculative.mtp override. The earlier static rejection of speculative.mtp=true + static grammar is removed in v2.10.0: to_common_sampling now propagates grammar to the MTP sampler chain, so the combination is valid.

Parameters
nodeYAML node containing tier fields.
registryBundled models for path resolution.
[out]configOutput tier config.
Returns
Empty string on success, error message on failure. @req REQ-CFG-005 @req REQ-TYPE-005
Version
2.13.0

Definition at line 239 of file loader.cpp.

◆ parse_tier_speculative_override()

static void entropic::config::parse_tier_speculative_override ( ryml::ConstNodeRef  node,
TierConfig &  config 
)
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.

Parameters
nodeYAML node for a single tier.
[out]configOutput tier config. @req REQ-CFG-005 @req REQ-TYPE-005
Version
2.9.4

Definition at line 103 of file loader.cpp.

◆ parse_tool_descriptions()

static void entropic::config::parse_tool_descriptions ( ryml::ConstNodeRef  node,
ExternalMCPConfig &  config 
)
static

Parse mcp.external.tool_descriptions into the override map.

gh#145 (v2.12.0). Keys are bare tool suffixes ("ask", "status", ...) so a consumer writes them independently of whatever tool_prefix is set to. Unknown keys are carried through and simply never matched — an unknown name is a no-op rather than an error, so a consumer's config does not break when a tool is renamed or removed.

Parameters
nodeYAML node for the "tool_descriptions" map.
[out]configOutput external MCP config. @dg_internal
Version
2.12.0

Definition at line 574 of file loader.cpp.

◆ parse_top_sections()

static std::string entropic::config::parse_top_sections ( ryml::ConstNodeRef  root,
const BundledModels &  registry,
ParsedConfig &  config 
)
static

Parse the top-level models/routing/optional sections.

Parameters
rootYAML root node.
registryBundled models for path resolution.
[in,out]configConfig to overlay onto.
Returns
Empty string on success, error message on failure. @dg_internal
Version
2.13.0

Definition at line 1104 of file loader.cpp.

◆ resolve_consumer_defaults()

static std::filesystem::path entropic::config::resolve_consumer_defaults ( const std::filesystem::path &  consumer_defaults)
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).

@req REQ-CFG-001

Returns
Path to use for config loading.
Version
1

Definition at line 1353 of file loader.cpp.

◆ resolve_model_path()

static std::string entropic::config::resolve_model_path ( ryml::ConstNodeRef  node,
const BundledModels &  registry,
ModelConfig &  config 
)
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).

Returns
Empty string on success, error message on a bad/unmatched selector. @req REQ-CFG-003 @req REQ-CFG-006
Version
2.8.0

Definition at line 125 of file loader.cpp.

◆ validate_server_timeout()

static std::string entropic::config::validate_server_timeout ( const MCPConfig &  config)
static

Refuse a server_timeout_seconds that cannot bound anything (gh#175).

A bound that was never consulted was a false contract; one that now is must be a usable value, and a bad one is said loudly rather than clamped.

Parameters
configParsed MCP config.
Returns
Empty when valid, else the error. @dg_internal
Version
2.14.0

Definition at line 740 of file loader.cpp.

◆ validate_workspace_app_context()

static std::string entropic::config::validate_workspace_app_context ( const ParsedConfig &  config)
static

Refuse a workspace_app_context that could leave a workspace root.

The path is joined to every workspace's root, so an absolute path or a .. component would read the same file outside every repository — the opposite of a per-repository document.

Parameters
configParsed config.
Returns
"" when unset or valid, else the reason. @req REQ-CFG-001
Version
2.14.0

Definition at line 1053 of file loader.cpp.

◆ yaml_has_key()

static bool entropic::config::yaml_has_key ( const std::filesystem::path &  path,
const char *  key 
)
static

Load the consumer/app defaults layer if present (non-fatal).

@utility

Version
2

Check whether a YAML file contains a top-level key.

Parameters
pathFile path.
keyKey to look for.
Returns
true if the file parses and has the key at root level. @req REQ-CFG-002
Version
2.0.6

Definition at line 1395 of file loader.cpp.

Variable Documentation

◆ s_log

auto s_log = entropic::log::get("config")
static

Definition at line 22 of file loader.cpp.