From 4afbecb429a71e409fa8ade32f50cd1964ab5247 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 04:50:05 -0700 Subject: [PATCH] test(cli): trim fast-serve coverage to the parity + dispatch invariants --- tests/hermes_cli/test_fast_serve_launch.py | 76 ++++++---------------- 1 file changed, 19 insertions(+), 57 deletions(-) diff --git a/tests/hermes_cli/test_fast_serve_launch.py b/tests/hermes_cli/test_fast_serve_launch.py index bf76cdae11..a0f3961596 100644 --- a/tests/hermes_cli/test_fast_serve_launch.py +++ b/tests/hermes_cli/test_fast_serve_launch.py @@ -12,78 +12,40 @@ def _capture(_args) -> None: return None -def test_standalone_serve_parser_matches_full_subcommand_parser() -> None: +def test_lean_serve_parser_matches_full_subcommand_parser() -> None: root = argparse.ArgumentParser() subparsers = root.add_subparsers(dest="command") - build_dashboard_parser( - subparsers, - cmd_dashboard=_capture, - cmd_dashboard_register=_capture, - ) + build_dashboard_parser(subparsers, cmd_dashboard=_capture, cmd_dashboard_register=_capture) lean = build_serve_parser(cmd_dashboard=_capture) argv = [ - "--host", - "127.0.0.1", - "--port", - "0", - "--no-open", - "--ssh-session-token-file", - "token.txt", - "--ssh-owner-nonce", - "0123456789abcdef", + "--host", "127.0.0.1", "--port", "0", "--no-open", + "--ssh-session-token-file", "token.txt", "--ssh-owner-nonce", "0123456789abcdef", ] assert vars(lean.parse_args(argv)) == vars(root.parse_args(["serve", *argv])) -def test_fast_serve_launch_dispatches_canonical_arguments(monkeypatch) -> None: +def test_fast_serve_launch_dispatches_only_unambiguous_serve(monkeypatch) -> None: captured = [] monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: None) monkeypatch.setattr(main_mod, "cmd_dashboard", captured.append) - monkeypatch.setattr( - sys, - "argv", - [ - "hermes", - "serve", - "--host", - "127.0.0.1", - "--port", - "0", - "--ssh-owner-nonce", - "0123456789abcdef", - ], + + monkeypatch.setattr(sys, "argv", ["hermes", "serve", "--host", "127.0.0.1", "--port", "0"]) + assert main_mod._try_fast_serve_launch() is True + assert (captured[0].command, captured[0].headless_backend, captured[0].no_open, captured[0].port) == ( + "serve", True, True, 0, ) - assert main_mod._try_fast_serve_launch() is True - assert len(captured) == 1 - assert captured[0].command == "serve" - assert captured[0].headless_backend is True - assert captured[0].no_open is True - assert captured[0].host == "127.0.0.1" - assert captured[0].port == 0 - assert captured[0].ssh_owner_nonce == "0123456789abcdef" - - -def test_fast_serve_launch_falls_back_for_unknown_arguments(monkeypatch) -> None: - monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: None) - monkeypatch.setattr(sys, "argv", ["hermes", "serve", "--future-flag"]) - - assert main_mod._try_fast_serve_launch() is False - - -def test_fast_serve_launch_preserves_container_routing(monkeypatch) -> None: - monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: {"name": "managed"}) - monkeypatch.setattr(sys, "argv", ["hermes", "serve"]) - - assert main_mod._try_fast_serve_launch() is False - - -def test_fast_serve_launch_preserves_help_and_opt_out(monkeypatch) -> None: - monkeypatch.setattr(sys, "argv", ["hermes", "serve", "--help"]) - assert main_mod._try_fast_serve_launch() is False - + # Every ambiguous shape falls back to the full parser: unknown flags, + # help, the opt-out, and container routing. + for argv in (["serve", "--future-flag"], ["serve", "--help"], ["chat"]): + monkeypatch.setattr(sys, "argv", ["hermes", *argv]) + assert main_mod._try_fast_serve_launch() is False monkeypatch.setenv("HERMES_DISABLE_FAST_SERVE_LAUNCH", "1") monkeypatch.setattr(sys, "argv", ["hermes", "serve"]) assert main_mod._try_fast_serve_launch() is False + monkeypatch.delenv("HERMES_DISABLE_FAST_SERVE_LAUNCH") + monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: {"name": "managed"}) + assert main_mod._try_fast_serve_launch() is False + assert len(captured) == 1