The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): gateway.multiplex_profiles has one valid value; a retired false is rewritten to true with a one-time boxed notice
Hermes Agentb93654656188
diff --git a/hermes_cli/gateway_multiplex_mode.py b/hermes_cli/gateway_multiplex_mode.pyindex a2b871394c3..3744a6150d0 100644--- a/hermes_cli/gateway_multiplex_mode.py+++ b/hermes_cli/gateway_multiplex_mode.py@@ -41,9 +41,13 @@ STANDALONE_DEPRECATION_NOTICE = (#: ``gateway.multiplex_profiles: false`` is no longer an opt-out from the one-gateway-per-host#: topology; it parses, it is reported, and it is ignored.RETIRED_OPT_OUT_REASON = (- "gateway.multiplex_profiles: false is retired and was ignored: one gateway per host serves "- "every profile. Remove the key; `hermes gateway migrate --multiplex` folds any leftover "- "per-profile gateway.")+ "gateway.multiplex_profiles: false is retired and was rewritten to true; one gateway per host "+ "serves every profile. A per-profile gateway is `gateway.standalone: true` in that profile's "+ "config (temporary shim) or `--force`.")++#: One-time marker the gateway leaves after rewriting a retired ``false``; ``hermes update``'s summary+#: prints the notice from it and clears it, so the flip is never silent on either surface.+REWRITTEN_MARKER_NAME = ".multiplex_opt_out_rewritten"def explicit_multiplex_flag(default_home: Path) -> Optional[bool]:@@ -165,26 +169,62 @@ def _default_profile_home() -> Path:def persist_resolved_default(decision: MultiplexDecision, default_home: Optional[Path] = None) -> bool:- """Write ``gateway.multiplex_profiles: true`` into the DEFAULT profile's config.yaml once the- runtime has resolved the unset key to on, so the file reads as the gateway behaves ("left unset"- was read as "off" by more than one operator). Comment-preserving writer, once, never on a guard- refusal (the file would then promise a topology the gateway refused). Returns True on a write."""+ """Write ``gateway.multiplex_profiles: true`` into the DEFAULT profile's config.yaml so the file+ reads as the gateway behaves. The key has ONE valid value right now (Teknium ruling): an unset key+ is made explicit ("left unset" was read as "off"), a retired ``false`` is rewritten in place and+ leaves a one-time marker for the boxed notice. Comment-preserving writer, once, and NEVER on a guard+ refusal (the file must not say true while the runtime is standalone). Returns True on a write."""if not decision.enabled or decision.source == "guard":return Falsedefault_home = Path(default_home) if default_home is not None else _default_profile_home()+ cfg_path = default_home / "config.yaml"try:- if explicit_multiplex_flag(default_home) is True:+ from hermes_cli.config import read_user_config_raw+ cfg = read_user_config_raw(cfg_path) or {} if cfg_path.exists() else {}+ section = cfg.get("gateway") if isinstance(cfg.get("gateway"), dict) else {}+ in_file = cfg.get("multiplex_profiles", section.get("multiplex_profiles"))+ if in_file is True:return Falsefrom hermes_cli.gateway_migrate import _write_multiplex_flag_write_multiplex_flag(default_home, True)+ if decision.source == "retired-opt-out":+ (default_home / REWRITTEN_MARKER_NAME).write_text(RETIRED_OPT_OUT_REASON + "\n", encoding="utf-8")except Exception:logger.debug("could not persist gateway.multiplex_profiles: true", exc_info=True)return False- logger.info("Wrote gateway.multiplex_profiles: true to %s (the resolved default, made explicit).",- default_home / "config.yaml")+ logger.info("Wrote gateway.multiplex_profiles: true to %s (was %s).", cfg_path,+ "unset" if in_file is None else repr(in_file))return True+def retired_opt_out_notice_lines() -> list[str]:+ """The one-time boxed notice for a rewritten ``false`` (same box as the guard warning)."""+ return _box(["⚠ gateway.multiplex_profiles: false is retired and was rewritten to true;",+ "one gateway per host serves every profile.",+ "A per-profile gateway is `gateway.standalone: true` in that profile's config",+ "(temporary shim) or `--force`."])+++def consume_rewritten_notice(default_home: Optional[Path] = None) -> list[str]:+ """``hermes update``'s summary: print the rewrite notice ONCE more, then clear the marker."""+ default_home = Path(default_home) if default_home is not None else _default_profile_home()+ marker = default_home / REWRITTEN_MARKER_NAME+ if not marker.exists():+ return []+ try:+ marker.unlink()+ except OSError:+ return []+ return retired_opt_out_notice_lines()+++def _box(body: list[str]) -> list[str]:+ width = max(len(line) for line in body) + 2+ return ["┌" + "─" * width + "┐",+ *[f"│ {line.ljust(width - 1)}│" for line in body],+ "└" + "─" * width + "┘"]++def resolve_multiplex_mode(config) -> MultiplexDecision:"""Settle ``config.multiplex_profiles`` for one gateway boot; the config is updated in place.@@ -232,6 +272,9 @@ def log_multiplex_decision(decision: MultiplexDecision) -> None:record_multiplex_decision(decision)if decision.source == "retired-opt-out":logger.warning("%s", RETIRED_OPT_OUT_REASON)+ persist_resolved_default(decision)+ for line in retired_opt_out_notice_lines():+ print(line)elif decision.source == "guard" and decision.reason == SINGLE_PROFILE_REASON:logger.info("Single-profile install: gateway.multiplex_profiles unset, serving the default profile only.")elif decision.source == "guard":@@ -276,10 +319,7 @@ def standalone_warning_lines(decision: MultiplexDecision, unserved: Optional[lisf"Why: {decision.reason}",f"Fix: {MIGRATE_COMMAND}",]- width = max(len(line) for line in body) + 2- return ["┌" + "─" * width + "┐",- *[f"│ {line.ljust(width - 1)}│" for line in body],- "└" + "─" * width + "┘"]+ return _box(body)def recorded_standalone_warning_lines() -> list[str]:diff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.pyindex 258ee2f6f27..339bf3449ff 100644--- a/hermes_cli/update_cmd_maint.py+++ b/hermes_cli/update_cmd_maint.py@@ -397,8 +397,8 @@ def _print_update_summary(*, node_failures: list, desktop_build_ok: bool, pre_up# A multi-profile host whose gateway came back standalone on a guard says so here too — the# update summary is the one line operators read (the boot log under s6 is not).with suppress(Exception):- from hermes_cli.gateway_multiplex_mode import recorded_standalone_warning_lines- for line in recorded_standalone_warning_lines():+ from hermes_cli.gateway_multiplex_mode import consume_rewritten_notice, recorded_standalone_warning_lines+ for line in [*consume_rewritten_notice(), *recorded_standalone_warning_lines()]:print(line)return desktop_build_ok and sqlite_runtime_okdiff --git a/tests/hermes_cli/test_gateway_multiplex_s6.py b/tests/hermes_cli/test_gateway_multiplex_s6.pyindex 53e2361ffdd..54db1cbfaa9 100644--- a/tests/hermes_cli/test_gateway_multiplex_s6.py+++ b/tests/hermes_cli/test_gateway_multiplex_s6.py@@ -114,3 +114,15 @@ def test_resolved_default_is_written_once_and_never_on_a_guard(s6_host):text = (root / "config.yaml").read_text(encoding="utf-8")assert "# my config" in text and "multiplex_profiles: true" in text # comment-preserving writerassert mode.persist_resolved_default(on, root) is False # already explicit: once+ # A retired ``false`` is rewritten in place, never silently: the one-time notice reaches the+ # gateway start (log_multiplex_decision prints it) and the next ``hermes update`` summary.+ (root / "config.yaml").write_text("# my config\ngateway:\n multiplex_profiles: false\n", encoding="utf-8")+ from gateway.config import GatewayConfig+ decision = mode.resolve_multiplex_mode(GatewayConfig.from_dict({"gateway": {"multiplex_profiles": False}}))+ assert decision.source == "retired-opt-out"+ mode.log_multiplex_decision(decision)+ text = (root / "config.yaml").read_text(encoding="utf-8")+ assert "# my config" in text and "multiplex_profiles: true" in text and "false" not in text+ notice = mode.consume_rewritten_notice(root)+ assert any("rewritten to true" in line for line in notice) and notice[0].startswith("┌")+ assert mode.consume_rewritten_notice(root) == [] # one-timediff --git a/website/docs/user-guide/multi-profile-gateways.md b/website/docs/user-guide/multi-profile-gateways.mdindex 6262e97438d..bb82a5fba9d 100644--- a/website/docs/user-guide/multi-profile-gateways.md+++ b/website/docs/user-guide/multi-profile-gateways.md@@ -121,11 +121,13 @@ profile that opts out with `gateway.standalone: true`:- `gateway.multiplex_profiles: true` (what the migration writes) multiplexesregardless of the preflight — you, or the migration, made the call.-- `gateway.multiplex_profiles: false` is **retired**. It used to keep- per-profile gateways for good; now it resolves exactly like an unset key and- the gateway logs a warning pointing at `hermes gateway migrate --multiplex`.- `--force` remains the path for the boundary cases below; `gateway.standalone:- true` is a temporary shim for fleets the switch broke, not a supported topology.+- `gateway.multiplex_profiles` has **one valid value right now: `true`**, and+ it is written for you. An unset key resolves on and is made explicit in the+ default profile's `config.yaml`. `false` is **retired**: the gateway rewrites+ it to `true` in place and prints a one-time boxed notice at that start and in+ the next `hermes update` summary — never a silent flip. A per-profile gateway+ is `gateway.standalone: true` in that profile's own config (a temporary shim,+ not a supported topology) or `--force` for the boundary cases below.- `GATEWAY_MULTIPLEX_PROFILES` in the process environment overrides theunset-key decision the same way an explicit `true` does.- `gateway.standalone: true` in a **named** profile's own `config.yaml`