mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-19 15:18:03 +00:00
fix(managed-scope): honor managed scope in all standalone config loaders
The skin bug was one instance of a class: several subsystems build their
config dict directly from config.yaml instead of routing through
hermes_cli.config.load_config (which carries the managed merge), so they
silently ignored administrator-pinned values. Audited every config.yaml
reader and fixed the behavioral-read bypasses:
- gateway/config.py load_gateway_config (messaging gateway: session_reset,
quick_commands, stt, model, ...)
- gateway/run.py _load_gateway_config (its read_raw_config fast path also
skipped the merge — read_raw_config returns raw user YAML)
- tui_gateway/server.py _load_cfg (new TUI + desktop backend: skin,
reasoning_effort, service_tier, provider_routing)
- cron/scheduler.py (scheduled-job model/reasoning/toolsets/provider_routing)
- hermes_logging.py (logging.level/max_size_mb/backup_count)
- hermes_time.py (timezone)
- hermes_cli/doctor.py (memory-provider diagnostic reads effective config)
All route through a new shared managed_scope.apply_managed_overlay() helper
that mirrors _load_config_impl (env-only expansion so a user ${VAR} can't
shadow a managed literal, root-model-string normalization, leaf-merge) and is
fail-open. cli.py's earlier inline fix is refactored onto the same helper.
Write-back paths (slash_commands, telegram/yuanbao dm_topics, profile
distribution) are deliberately left reading raw user YAML — overlaying managed
values there would persist them into the user file. The dashboard
(web_server.py) already routes through load_config and needed no change.
TUI loader caches the RAW config so _save_cfg never writes managed values to
disk. Adds test_managed_scope_overlay.py (helper) and
test_managed_scope_loaders.py (per-surface integration); mutation-checked.
This commit is contained in:
parent
732293cf87
commit
b0e47a98f9
11 changed files with 314 additions and 23 deletions
19
cli.py
19
cli.py
|
|
@ -567,21 +567,12 @@ def load_cli_config() -> Dict[str, Any]:
|
|||
# hermes_cli.config._load_config_impl (which has its own managed merge), so
|
||||
# without this the entire interactive CLI/TUI surface — skin, display prefs,
|
||||
# etc. read from CLI_CONFIG — would silently ignore managed scope while
|
||||
# `hermes config`/`doctor`/guards (which use load_config) honor it. Mirror
|
||||
# _load_config_impl: expand managed against the process env only (so a user
|
||||
# ${VAR} can't shadow a managed literal), normalize its root model key so a
|
||||
# managed `model: x/y` string can't clobber the dict shape callers expect,
|
||||
# then leaf-merge on top. Fail-open — managed scope must never block startup.
|
||||
try:
|
||||
from hermes_cli import managed_scope
|
||||
from hermes_cli.config import _deep_merge, _normalize_root_model_keys
|
||||
# `hermes config`/`doctor`/guards (which use load_config) honor it. The
|
||||
# shared helper mirrors _load_config_impl (env-only expansion, root-model
|
||||
# normalization, leaf-merge) and is fail-open.
|
||||
from hermes_cli import managed_scope
|
||||
|
||||
managed_config = managed_scope.load_managed_config()
|
||||
if managed_config:
|
||||
managed_expanded = _normalize_root_model_keys(_expand_env_vars(managed_config))
|
||||
defaults = _deep_merge(defaults, managed_expanded)
|
||||
except Exception as e: # noqa: BLE001 — never let managed scope break CLI startup
|
||||
logger.warning("Failed to apply managed scope to CLI config: %s", e)
|
||||
defaults = managed_scope.apply_managed_overlay(defaults)
|
||||
|
||||
# Apply terminal config to environment variables (so terminal_tool picks them up)
|
||||
terminal_config = defaults.get("terminal", {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue