Architecture

Config Resolution Precedence

FFI/Hermes path - Config loaderProxy path - MultiConfig::resolvesetunsetsetunsetsetunsethitmisshitmisshitmissaphrodite.toml [[proxies]] + [defaults] +[compression]per keyenv APHRODITE_* (env_parse_warn / env var)valueproxy TOML field[defaults] fieldhardcoded default./aphrodite.toml →~/.hermes/aphrodite/aphrodite.tomlget_bool/u64/usize/string1. runtime override (set_override)value2. env var (APHRODITE_*)3. toml[section][key]4. default arg
PRECEDENCE FLOWCHART
INERT / RESERVED (parsed for schema compatibility, no consumer)CONFIG-RELOADABLE (config-file watcher, applies to live atomics)LIVE - actually consumedtool_threshold_cache/token →cache/token_compress_threshold (atomics)inline_threshold → inline_ccr_threshold (atomic)code_multiplier → code_multiplier_x100 (atomic)defaults.api_url/model, ccr_ttl_seconds, timeout[flow] budget_chars → flow_budget_chars[compression] context_engine,tool_threshold_token, terminal_threshold (FFIstate)[compression] engine_threshold_pct /engine_protect_first/last / engine_min_msgs (FFIstate, load-bearing middle-turn archiving)[compression] auto_expand / auto_expand_limit(inline marker resolution; /reload-applied)[previews] model_family → preview template familyselector[templates.preview.*] / [templates.marker] /[templates.prompts] / [templates.reverse] →format strings + ctype→key remap[prompts] retrieve_guidance / ccr_marker_hint /catalog_intent_hints (FFI state)[directives] active (seeds active_directives)[previews] preview_max_chars → preview cap(env APHRODITE_PREVIEW_MAX_CHARS > TOML; shippedtemplate default 0 = no cap)the 4 threshold atomics onlycatalog_mode (RESERVED)previews.* inert remainder (code_structure_map /rust_preview_lines)classifier_poll (CompressionConfig field, unused)mode/listen: not env-overridable in resolve(would break dual-proxy)
LIVE VS INERT KEYS
IN THIS DOCUMENT

Crimson marks the heading currently in view; every entry is one of the document's own headings.

Two independent resolution stacks share the same env > TOML > default precedence but live in different modules:

  • the proxy’s MultiConfig::resolve, which produces one Cli per listener
  • and the Hermes/FFI Config loader, whose apply_compression writes straight into AphroditeState.

Both read the same aphrodite.toml; nearly the whole schema is consumed at runtime, with a small residual set that stays parsed-but-inert (catalog_mode, code_structure_map, rust_preview_lines, classifier_poll).

Precedence flowchart

FFI/Hermes path - Config loaderProxy path - MultiConfig::resolvesetunsetsetunsetsetunsethitmisshitmisshitmissaphrodite.toml [[proxies]] + [defaults] +[compression]per keyenv APHRODITE_* (env_parse_warn / env var)valueproxy TOML field[defaults] fieldhardcoded default./aphrodite.toml →~/.hermes/aphrodite/aphrodite.tomlget_bool/u64/usize/string1. runtime override (set_override)value2. env var (APHRODITE_*)3. toml[section][key]4. default arg
PRECEDENCE FLOWCHART

Live vs inert keys

INERT / RESERVED (parsed for schema compatibility, no consumer)CONFIG-RELOADABLE (config-file watcher, applies to live atomics)LIVE - actually consumedtool_threshold_cache/token →cache/token_compress_threshold (atomics)inline_threshold → inline_ccr_threshold (atomic)code_multiplier → code_multiplier_x100 (atomic)defaults.api_url/model, ccr_ttl_seconds, timeout[flow] budget_chars → flow_budget_chars[compression] context_engine,tool_threshold_token, terminal_threshold (FFIstate)[compression] engine_threshold_pct /engine_protect_first/last / engine_min_msgs (FFIstate, load-bearing middle-turn archiving)[compression] auto_expand / auto_expand_limit(inline marker resolution; /reload-applied)[previews] model_family → preview template familyselector[templates.preview.*] / [templates.marker] /[templates.prompts] / [templates.reverse] →format strings + ctype→key remap[prompts] retrieve_guidance / ccr_marker_hint /catalog_intent_hints (FFI state)[directives] active (seeds active_directives)[previews] preview_max_chars → preview cap(env APHRODITE_PREVIEW_MAX_CHARS > TOML; shippedtemplate default 0 = no cap)the 4 threshold atomics onlycatalog_mode (RESERVED)previews.* inert remainder (code_structure_map /rust_preview_lines)classifier_poll (CompressionConfig field, unused)mode/listen: not env-overridable in resolve(would break dual-proxy)
LIVE VS INERT KEYS

Precedence subtleties:

  • The proxy’s resolve deliberately gives mode/listen no blanket env override - a process-wide APHRODITE_MODE/APHRODITE_LISTEN would clobber every [[proxies]] entry and break the cache/token split. Port overrides stay per-mode (APHRODITE_CACHE_PORT / APHRODITE_TOKEN_PORT).
  • apply_compression maps the FFI state’s tool_threshold to the tool_threshold_token TOML key and the APHRODITE_TOOL_THRESHOLD_TOKEN env var. The old tool_threshold names shipped in no TOML, so wiring them as-is would have silently resolved to the default forever.
  • env_bool accepts 1/true (case-insensitive) as truthy and everything else as false; env_parse_warn warns loudly on a present-but-malformed numeric override instead of silently defaulting.
  • [previews] preview_max_chars caps rendered previews (env APHRODITE_PREVIEW_MAX_CHARS wins over TOML; shipped default 0 = no cap). It is applied at proxy startup and whenever the FFI config is (re)loaded - a dylib reload re-applies it, and POST /reload re-applies it to the proxy, but the config-file watcher does not.
  • The config-file watcher reacts to Modify events on aphrodite.toml (500 ms debounce), reloads the file, and stores the four resolved thresholds (cache, token, inline, code_multiplier) into every live AppState’s atomics. Nothing else is updated live.