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

Config validation implementation. More...

Include dependency graph for validate.cpp:

Go to the source code of this file.

Namespaces

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

Functions

ENTROPIC_EXPORT std::string entropic::config::validate_allowed_tools (const std::vector< std::string > &tools)
 Validate allowed_tools entries use "server.tool" format.
 
ENTROPIC_EXPORT std::string entropic::config::validate (const ModelConfig &config)
 Validate a ModelConfig.
 
ENTROPIC_EXPORT std::string entropic::config::validate (const ModelsConfig &config)
 Validate ModelsConfig.
 
ENTROPIC_EXPORT std::string entropic::config::validate (const CompactionConfig &config)
 Validate CompactionConfig.
 
ENTROPIC_EXPORT std::string entropic::config::validate_fallback_tier (const std::string &fallback, const std::unordered_map< std::string, TierConfig > &tiers)
 Check fallback_tier exists in tiers.
 
ENTROPIC_EXPORT std::string entropic::config::validate_tier_map (const std::unordered_map< std::string, std::string > &tier_map, const std::unordered_map< std::string, TierConfig > &tiers)
 Check all tier_map values exist in tiers.
 
ENTROPIC_EXPORT std::string entropic::config::validate_handoff_rules (const std::unordered_map< std::string, std::vector< std::string > > &rules, const std::unordered_map< std::string, TierConfig > &tiers)
 Check all handoff_rules keys and values exist in tiers.
 
std::string entropic::config::validate_classification_routable (const RoutingConfig &routing)
 A configured classification_prompt is inert without a tier_map.
 
ENTROPIC_EXPORT std::string entropic::config::validate_routing (const RoutingConfig &routing, const ModelsConfig &models)
 Validate RoutingConfig against defined tiers.
 
ENTROPIC_EXPORT std::string entropic::config::warn_auto_chain_without_targets (const std::unordered_map< std::string, TierConfig > &tiers, const std::unordered_map< std::string, std::vector< std::string > > &handoff_rules)
 Warn if tier has auto_chain but no handoff_rules entry.
 
ENTROPIC_EXPORT std::string entropic::config::validate (const PromptCacheConfig &config)
 Validate PromptCacheConfig.
 
static std::string entropic::config::validate_model_tiers (const ModelsConfig &models)
 Validate model tiers and router.
 
static bool entropic::config::holds_grammars (const std::filesystem::path &dir)
 Whether a directory holds at least one .gbnf file.
 
ENTROPIC_EXPORT std::vector< std::filesystem::path > entropic::config::grammar_search_paths (const ParsedConfig &config, const std::filesystem::path &data_dir)
 The directories a bare grammar stem is looked up in (gh#154).
 
static bool entropic::config::grammar_stem_resolves (const std::string &stem, const std::vector< std::filesystem::path > &search_dirs)
 Whether <stem>.gbnf exists in any search directory.
 
static std::string entropic::config::describe_search_dirs (const std::vector< std::filesystem::path > &search_dirs)
 Render the search-path list for an error message.
 
ENTROPIC_EXPORT std::string entropic::config::warn_unresolved_tier_grammars (const ParsedConfig &config, const std::vector< std::filesystem::path > &search_dirs)
 Warn about a tier whose grammar: stem resolves to no .gbnf (gh#154).
 
ENTROPIC_EXPORT std::string entropic::config::validate_config (const ParsedConfig &config, std::vector< std::string > &warnings)
 Validate the full ParsedConfig.
 

Variables

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

Detailed Description

Config validation implementation.

Version
1.8.2

Definition in file validate.cpp.

Function Documentation

◆ describe_search_dirs()

static std::string entropic::config::describe_search_dirs ( const std::vector< std::filesystem::path > &  search_dirs)
static

Render the search-path list for an error message.

Parameters
search_dirsDirectories searched.
Returns
Comma-separated list, or a note that none were searched. @dg_internal
Version
2.13.0

Definition at line 417 of file validate.cpp.

◆ grammar_search_paths()

std::vector< std::filesystem::path > entropic::config::grammar_search_paths ( const ParsedConfig &  config,
const std::filesystem::path &  data_dir 
)

The directories a bare grammar stem is looked up in (gh#154).

Mirrors the runtime rule rather than inventing one: ModelOrchestrator::load_bundled_grammars reads <config_dir>/grammars, and the facade falls back to <data_dir>/grammars only when that produced nothing. Both are returned when the first holds no .gbnf, so the check accepts exactly what the registry will hold.

Parameters
configParsed engine config (supplies config_dir).
data_dirResolved bundled data directory.
Returns
Search directories, most specific first. May be empty. @req REQ-INFER-007
Version
2.13.0
Parameters
configParsed engine config (supplies config_dir).
data_dirResolved bundled data directory.
Returns
Search directories, most specific first. @req REQ-INFER-007
Version
2.13.0

Definition at line 370 of file validate.cpp.

◆ grammar_stem_resolves()

static bool entropic::config::grammar_stem_resolves ( const std::string &  stem,
const std::vector< std::filesystem::path > &  search_dirs 
)
static

Whether <stem>.gbnf exists in any search directory.

Parameters
stemNormalized grammar stem.
search_dirsDirectories to look in.
Returns
true when the file is present in at least one. @dg_internal
Version
2.13.0

Definition at line 395 of file validate.cpp.

◆ holds_grammars()

static bool entropic::config::holds_grammars ( const std::filesystem::path &  dir)
static

Whether a directory holds at least one .gbnf file.

Parameters
dirDirectory to scan.
Returns
true when the directory exists and contains a .gbnf. @dg_internal
Version
2.13.0

Definition at line 348 of file validate.cpp.

◆ validate() [1/4]

std::string entropic::config::validate ( const CompactionConfig &  config)

Validate CompactionConfig.

Checks: warning_threshold_percent < threshold_percent, threshold_percent in [0.5, 0.99], preserve_recent_turns in [1, 10].

Parameters
configCompaction config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
configCompaction config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
2.1.3

Definition at line 106 of file validate.cpp.

◆ validate() [2/4]

std::string entropic::config::validate ( const ModelConfig &  config)

Validate a ModelConfig.

Checks: context_length range [512, 131072], adapter non-empty, allowed_tools entries use "server.tool" format.

Parameters
configModel config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
configModel config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006 @req REQ-INFER-027
Version
2.13.0

Definition at line 47 of file validate.cpp.

◆ validate() [3/4]

std::string entropic::config::validate ( const ModelsConfig &  config)

Validate ModelsConfig.

Checks: default tier exists in tiers dict.

Parameters
configModels config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
configModels config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.2

Definition at line 89 of file validate.cpp.

◆ validate() [4/4]

std::string entropic::config::validate ( const PromptCacheConfig &  config)

Validate PromptCacheConfig.

Checks: max_bytes > 0 when enabled.

Parameters
configPrompt cache config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.3
Parameters
configPrompt cache config to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.3

Definition at line 302 of file validate.cpp.

◆ validate_allowed_tools()

std::string entropic::config::validate_allowed_tools ( const std::vector< std::string > &  tools)

Validate allowed_tools entries use "server.tool" format.

Parameters
toolsTool name list to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
toolsTool name list to validate.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.2

Definition at line 28 of file validate.cpp.

◆ validate_classification_routable()

std::string entropic::config::validate_classification_routable ( const RoutingConfig &  routing)

A configured classification_prompt is inert without a tier_map.

v2.8.1 (gh#87 follow-up): routing.enabled + a classification_prompt instructs the router to emit a routing digit (see classify_task), but with an EMPTY tier_map no digit can resolve to a tier — every route burns a router generation and silently falls back to the default tier (the exact no-op the v2.8.0 classify_task fix closed). validate_tier_map only checks map VALUES, so an empty map passes it; reject the prompt+empty-map combination here so a misconfigured deployment fails loudly at load instead of degrading silently.

Parameters
routingRouting config.
Returns
Error string if a classification_prompt is set with an empty tier_map.
Version
2.8.1 @req REQ-CFG-006

Definition at line 222 of file validate.cpp.

◆ validate_config()

std::string entropic::config::validate_config ( const ParsedConfig &  config,
std::vector< std::string > &  warnings 
)

Validate the full ParsedConfig.

Runs all section validators + cross-section checks.

Parameters
configFull config to validate.
[out]warningsNon-fatal warnings (e.g., auto_chain without targets).
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
configFull config to validate.
[out]warningsNon-fatal warnings.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
2.0.0

Definition at line 482 of file validate.cpp.

◆ validate_fallback_tier()

std::string entropic::config::validate_fallback_tier ( const std::string &  fallback,
const std::unordered_map< std::string, TierConfig > &  tiers 
)

Check fallback_tier exists in tiers.

Parameters
fallbackFallback tier name.
tiersDefined tiers.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
fallbackFallback tier name.
tiersDefined tiers.
Returns
Empty string on success, error message on failure.
Version
1.8.2 @req REQ-CFG-006

Definition at line 148 of file validate.cpp.

◆ validate_handoff_rules()

std::string entropic::config::validate_handoff_rules ( const std::unordered_map< std::string, std::vector< std::string > > &  rules,
const std::unordered_map< std::string, TierConfig > &  tiers 
)

Check all handoff_rules keys and values exist in tiers.

Parameters
rulesHandoff rules.
tiersDefined tiers.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
rulesHandoff rules.
tiersDefined tiers.
Returns
Empty string on success, error message on failure.
Version
1.8.2 @req REQ-CFG-006

Definition at line 187 of file validate.cpp.

◆ validate_model_tiers()

static std::string entropic::config::validate_model_tiers ( const ModelsConfig &  models)
static

Validate model tiers and router.

Parameters
modelsModels config.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.3

Definition at line 317 of file validate.cpp.

◆ validate_routing()

std::string entropic::config::validate_routing ( const RoutingConfig &  routing,
const ModelsConfig &  models 
)

Validate RoutingConfig against defined tiers.

Cross-field: fallback_tier, tier_map values, handoff_rules keys and values must all reference tiers that exist.

Parameters
routingRouting config.
modelsModels config (provides tier names).
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
routingRouting config.
modelsModels config.
Returns
Empty string on success, error message on failure.
Version
2.8.1 @req REQ-CFG-006

Definition at line 241 of file validate.cpp.

◆ validate_tier_map()

std::string entropic::config::validate_tier_map ( const std::unordered_map< std::string, std::string > &  tier_map,
const std::unordered_map< std::string, TierConfig > &  tiers 
)

Check all tier_map values exist in tiers.

Parameters
tier_mapClassification to tier mapping.
tiersDefined tiers.
Returns
Empty string on success, error message on failure. @req REQ-CFG-006
Version
1.8.1
Parameters
tier_mapClassification to tier mapping.
tiersDefined tiers.
Returns
Empty string on success, error message on failure.
Version
1.8.2 @req REQ-CFG-006

Definition at line 166 of file validate.cpp.

◆ warn_auto_chain_without_targets()

std::string entropic::config::warn_auto_chain_without_targets ( const std::unordered_map< std::string, TierConfig > &  tiers,
const std::unordered_map< std::string, std::vector< std::string > > &  handoff_rules 
)

Warn if tier has auto_chain but no handoff_rules entry.

Parameters
tiersTier configs.
handoff_rulesHandoff rules from routing config.
Returns
Warning message (empty if no issues). @req REQ-CFG-006
Version
1.8.1
Parameters
tiersTier configs.
handoff_rulesHandoff rules.
Returns
Warning message (empty if no issues). @req REQ-CFG-006
Version
1.8.2

Definition at line 276 of file validate.cpp.

◆ warn_unresolved_tier_grammars()

std::string entropic::config::warn_unresolved_tier_grammars ( const ParsedConfig &  config,
const std::vector< std::filesystem::path > &  search_dirs 
)

Warn about a tier whose grammar: stem resolves to no .gbnf (gh#154).

Warn about every tier whose grammar: stem resolves to no .gbnf (gh#154).

Names a documented fail-open early. GrammarRegistry::get() returns "" on a miss and the decode proceeds UNCONSTRAINED — which is undetectable from outside, because constrained and unconstrained output have the same shape whenever the prompt also describes the shape. A consumer measured speculative decode for three days believing a grammar was active; their harness wrote each arm's config where no matching .gbnf sat.

A WARNING and not an error, because at configure time "unresolved" does not yet mean "wrong". entropic_grammar_register and entropic_grammar_register_file both require an orchestrator, which exists only AFTER entropic_configure*, so registering a tier's grammar from the host application is necessarily a post-configure act. gh#154 first made this an error and thereby made that documented sequence impossible to perform; the refusal now lands at FIRST USE instead (ModelOrchestrator::refuse_unresolved_tier_grammar, which returns ENTROPIC_ERROR_GRAMMAR_NOT_FOUND and decodes nothing).

A runtime params.grammar_key is not checked at all: it is per-call and keeps its fail-open, reported through generations[].grammar.resolved.

Parameters
configParsed engine config (tiers carry the stems).
search_dirsDirectories from grammar_search_paths().
Returns
Empty string when every tier stem resolves, else one message naming EVERY unresolved tier, its stem, every directory searched, and how to register the grammar. @req REQ-INFER-007 @req REQ-CFG-006
Version
2.13.0
Parameters
configParsed engine config.
search_dirsDirectories from grammar_search_paths().
Returns
Empty string when every stem resolves, else one message naming each unresolved tier and stem. @req REQ-INFER-007 @req REQ-CFG-006
Version
2.13.0

Definition at line 443 of file validate.cpp.

Variable Documentation

◆ s_log

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

Definition at line 17 of file validate.cpp.