From 3d59664a8fd5def5d195653b3a3f340e9d0b6a8a Mon Sep 17 00:00:00 2001 From: jenkins Date: Mon, 17 Aug 2026 05:44:55 -0300 Subject: [PATCH] hermes: run three lanes on accelerator headroom --- services/hermes/agent-deployment.yaml | 22 +- testing/tests/test_hermes_cli_lanes.py | 313 +++++++++++++++---------- 2 files changed, 205 insertions(+), 130 deletions(-) diff --git a/services/hermes/agent-deployment.yaml b/services/hermes/agent-deployment.yaml index 5ed758cf..22d6b337 100644 --- a/services/hermes/agent-deployment.yaml +++ b/services/hermes/agent-deployment.yaml @@ -24,7 +24,7 @@ spec: ai.bstein.dev/router-wire-contract: ollama-numeric-keepalive ai.bstein.dev/execution: Hermes Kanban with durable direct Codex and Claude Code CLI workers ai.bstein.dev/model-policy: Jetson-assisted AUTO routing, low through xhigh, cross-provider fallback - ai.bstein.dev/placement: rpi5 preferred; Jetson deferred until state storage is available + ai.bstein.dev/placement: arm64 accelerator preferred for execution headroom; rpi5 fallback ai.bstein.dev/config-rev: "20260816-auth-health-quarantine-v6" prometheus.io/scrape: "true" prometheus.io/path: /metrics @@ -112,8 +112,22 @@ spec: - key: kubernetes.io/hostname operator: NotIn values: [titan-04, titan-08, titan-13, titan-14, titan-17, titan-18, titan-19] + - matchExpressions: + - key: kubernetes.io/arch + operator: In + values: [arm64] + - key: node-role.kubernetes.io/accelerator + operator: Exists + - key: kubernetes.io/hostname + operator: In + values: [titan-20, titan-21] preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 + preference: + matchExpressions: + - key: node-role.kubernetes.io/accelerator + operator: Exists + - weight: 50 preference: matchExpressions: - key: hardware @@ -874,7 +888,7 @@ spec: - {name: CLAUDE_CONFIG_DIR, value: /runtime-access/claude} - {name: KUBECONFIG, value: /opt/data/home/.kube/config} - {name: PYTHONPATH, value: /opt/hermes} - - {name: HERMES_CLI_LANE_CONCURRENCY, value: "2"} + - {name: HERMES_CLI_LANE_CONCURRENCY, value: "3"} - {name: HERMES_AUTO_ROUTER_PROFILE, value: agent} - {name: PATH, value: /opt/coordinator:/opt/data/tools/bin:/opt/data/home/.local/bin:/opt/hermes/.venv/bin:/usr/local/bin:/usr/bin:/bin} securityContext: @@ -896,8 +910,8 @@ spec: - {name: auto-router-plugin, mountPath: /opt/data/plugins/auto-router, readOnly: true} - {name: tmp, mountPath: /tmp} resources: - requests: {cpu: 100m, memory: 256Mi} - limits: {cpu: "2", memory: 6Gi} + requests: {cpu: 500m, memory: 512Mi} + limits: {cpu: "3", memory: 6Gi} - name: model-steward image: registry.bstein.dev/bstein/hermes-agent@sha256:81970563e542f0720773e72297810b3a844b83e381e278f25c0916c78d930107 imagePullPolicy: IfNotPresent diff --git a/testing/tests/test_hermes_cli_lanes.py b/testing/tests/test_hermes_cli_lanes.py index fe5272da..b0c39158 100644 --- a/testing/tests/test_hermes_cli_lanes.py +++ b/testing/tests/test_hermes_cli_lanes.py @@ -115,9 +115,7 @@ def test_manual_lane_is_still_enforced_by_switchyard(): def route(request, timeout): observed["payload"] = json.loads(request.data) - return _SwitchyardResponse( - "worker/claude/claude-sonnet-5/high", "manual route" - ) + return _SwitchyardResponse("worker/claude/claude-sonnet-5/high", "manual route") route = lanes.select_route( "Implement it.", @@ -244,7 +242,9 @@ def test_claude_session_is_reserved_before_first_process(tmp_path: Path, monkeyp return lanes.ProcessResult(0, "", {"status": "completed"}, False) monkeypatch.setattr(lanes, "stream_process", fake_stream) - route = lanes.Route("claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, ()) + route = lanes.Route( + "claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, () + ) lanes.run_provider( route, @@ -263,7 +263,10 @@ def test_claude_session_is_reserved_before_first_process(tmp_path: Path, monkeyp def test_claude_recovery_uses_verified_error_state_machine(tmp_path: Path, monkeypatch): - state = {"claude_session_id": "d4f91f59-88cb-43d0-a64f-f3284688fe9e", "claude_started": True} + state = { + "claude_session_id": "d4f91f59-88cb-43d0-a64f-f3284688fe9e", + "claude_started": True, + } state_file = tmp_path / "state.json" calls = [] @@ -279,15 +282,31 @@ def test_claude_recovery_uses_verified_error_state_machine(tmp_path: Path, monke return lanes.ProcessResult(0, "", {"status": "completed"}, False) monkeypatch.setattr(lanes, "stream_process", fake_stream) - route = lanes.Route("claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, ()) - lanes.run_provider(route, "Continue.", tmp_path, state, state_file, tmp_path / "log", lambda _: True, 60) + route = lanes.Route( + "claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, () + ) + lanes.run_provider( + route, + "Continue.", + tmp_path, + state, + state_file, + tmp_path / "log", + lambda _: True, + 60, + ) assert "--resume" in calls[0] assert "--session-id" in calls[1] - assert calls[0][calls[0].index("--resume") + 1] == calls[1][calls[1].index("--session-id") + 1] + assert ( + calls[0][calls[0].index("--resume") + 1] + == calls[1][calls[1].index("--session-id") + 1] + ) -def test_claude_collision_never_double_starts_a_reserved_session(tmp_path: Path, monkeypatch): +def test_claude_collision_never_double_starts_a_reserved_session( + tmp_path: Path, monkeypatch +): state = {"claude_session_id": "24927cee-f3da-4bcf-b624-602c22860155"} state_file = tmp_path / "state.json" calls = [] @@ -299,12 +318,26 @@ def test_claude_collision_never_double_starts_a_reserved_session(tmp_path: Path, return lanes.ProcessResult(0, "", {"status": "completed"}, False) monkeypatch.setattr(lanes, "stream_process", fake_stream) - route = lanes.Route("claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, ()) - lanes.run_provider(route, "Continue.", tmp_path, state, state_file, tmp_path / "log", lambda _: True, 60) + route = lanes.Route( + "claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, () + ) + lanes.run_provider( + route, + "Continue.", + tmp_path, + state, + state_file, + tmp_path / "log", + lambda _: True, + 60, + ) assert "--session-id" in calls[0] assert "--resume" in calls[1] - assert calls[0][calls[0].index("--session-id") + 1] == calls[1][calls[1].index("--resume") + 1] + assert ( + calls[0][calls[0].index("--session-id") + 1] + == calls[1][calls[1].index("--resume") + 1] + ) def test_codex_thread_started_is_persisted_before_completion(tmp_path: Path): @@ -491,7 +524,9 @@ def test_unassigned_ready_task_is_persistently_routed_to_auto_lane(monkeypatch): assert assigned == [("t_auto", "cli-auto")] -def test_corrupt_board_is_quarantined_without_stopping_healthy_lanes(monkeypatch, capsys): +def test_corrupt_board_is_quarantined_without_stopping_healthy_lanes( + monkeypatch, capsys +): class CorruptBoardError(Exception): pass @@ -681,7 +716,9 @@ def test_claim_requires_structured_evidence_and_surfaces_artifacts( block_task=lambda *_args, **kwargs: calls.append(("block", kwargs)), ) monkeypatch.setitem(sys.modules, "hermes_cli", SimpleNamespace(kanban_db=fake_db)) - monkeypatch.setattr(lanes, "state_path", lambda _board, _task_id: tmp_path / "state.json") + monkeypatch.setattr( + lanes, "state_path", lambda _board, _task_id: tmp_path / "state.json" + ) monkeypatch.setattr( lanes, "select_route", @@ -689,6 +726,7 @@ def test_claim_requires_structured_evidence_and_surfaces_artifacts( "codex", "gpt-5.6-sol", "high", "codex-high", "jetson", "vote", 1, () ), ) + def run_provider(*args, **_kwargs): assert connections[0].closed before_heartbeat = len(connections) @@ -823,15 +861,21 @@ def test_goal_card_continues_after_local_judge_rejects_progress( assert calls[0][0] == "complete" assert calls[0][1]["metadata"]["goal_turn"] == 2 - assert any("Goal completion rejected; continuing turn 2/3" in item for item in comments) - assert any("Goal route 2/3: codex/gpt-5.6-sol at xhigh" in item for item in comments) + assert any( + "Goal completion rejected; continuing turn 2/3" in item for item in comments + ) + assert any( + "Goal route 2/3: codex/gpt-5.6-sol at xhigh" in item for item in comments + ) assert route_calls[2][1]["exclude_provider"] == "claude" assert "prior rejected reports" in judge_contexts[1] assert "commit, push, and remote verification are missing" in judge_contexts[1] assert reports == [] -def test_workspace_preparation_failure_durably_blocks_the_claim(tmp_path: Path, monkeypatch): +def test_workspace_preparation_failure_durably_blocks_the_claim( + tmp_path: Path, monkeypatch +): task = SimpleNamespace(id="t_bad_worktree", current_run_id=7, assignee="cli-auto") calls = [] @@ -850,7 +894,9 @@ def test_workspace_preparation_failure_durably_blocks_the_claim(tmp_path: Path, block_task=lambda *_args, **kwargs: calls.append(kwargs), ) monkeypatch.setitem(sys.modules, "hermes_cli", SimpleNamespace(kanban_db=fake_db)) - monkeypatch.setattr(lanes, "state_path", lambda _board, _task_id: tmp_path / "state.json") + monkeypatch.setattr( + lanes, "state_path", lambda _board, _task_id: tmp_path / "state.json" + ) lanes.execute_claim("cassandra", "t_bad_worktree") @@ -873,7 +919,9 @@ def test_artifacts_cannot_escape_the_task_worktree(tmp_path: Path): ) == [str(inside)] -def test_restart_provider_change_includes_explicit_workspace_handoff(tmp_path: Path, monkeypatch): +def test_restart_provider_change_includes_explicit_workspace_handoff( + tmp_path: Path, monkeypatch +): task = SimpleNamespace( id="t_resume", current_run_id=9, @@ -946,8 +994,12 @@ def test_restart_provider_change_includes_explicit_workspace_handoff(tmp_path: P def test_provider_commands_are_structured_unattended_and_capped(tmp_path: Path): - route = lanes.Route("codex", "gpt-5.6-sol", "xhigh", "codex-xhigh", "jetson", "vote", 1, ()) - command = lanes._codex_command(route, "Work.", tmp_path, {}, tmp_path / "result.json") + route = lanes.Route( + "codex", "gpt-5.6-sol", "xhigh", "codex-xhigh", "jetson", "vote", 1, () + ) + command = lanes._codex_command( + route, "Work.", tmp_path, {}, tmp_path / "result.json" + ) assert "--dangerously-bypass-approvals-and-sandbox" in command assert "--json" in command assert "--output-schema" in command @@ -955,7 +1007,9 @@ def test_provider_commands_are_structured_unattended_and_capped(tmp_path: Path): claude_state = {"claude_session_id": "13864642-2985-4f91-bef5-53f145f878e8"} claude = lanes._claude_command( - lanes.Route("claude", "claude-opus-5", "xhigh", "claude-xhigh", "jetson", "vote", 1, ()), + lanes.Route( + "claude", "claude-opus-5", "xhigh", "claude-xhigh", "jetson", "vote", 1, () + ), "Review.", claude_state, False, @@ -978,7 +1032,10 @@ def test_worker_contract_separates_review_findings_from_task_blockers(tmp_path: assert set(lanes.RESULT_SCHEMA["required"]) == set( lanes.RESULT_SCHEMA["properties"] ) - assert "assigned task itself" in lanes.RESULT_SCHEMA["properties"]["blockers"]["description"] + assert ( + "assigned task itself" + in lanes.RESULT_SCHEMA["properties"]["blockers"]["description"] + ) @pytest.mark.parametrize( @@ -1001,7 +1058,9 @@ def test_claude_pretool_hook_allows_normal_engineering(): assert policy.denial_reason("vault kv get kv/atlas/hermes") is None -def test_claude_settings_preserve_state_and_install_three_guardrail_layers(tmp_path: Path): +def test_claude_settings_preserve_state_and_install_three_guardrail_layers( + tmp_path: Path, +): state = tmp_path / ".claude.json" settings = tmp_path / "settings.json" state.write_text('{"promptQueueUseCount": 4}\n', encoding="utf-8") @@ -1043,7 +1102,9 @@ def test_claude_settings_preserve_state_and_install_three_guardrail_layers(tmp_p def test_legacy_state_is_archived_without_removing_provider_transcripts(tmp_path: Path): session = tmp_path / "home/.config/herdr/session.json" session.parent.mkdir(parents=True) - session.write_text('{"agents":[{"agent":"claude","session_id":"abc"}]}', encoding="utf-8") + session.write_text( + '{"agents":[{"agent":"claude","session_id":"abc"}]}', encoding="utf-8" + ) binary = tmp_path / "tools/bin/herdr" binary.parent.mkdir(parents=True) binary.write_text("legacy", encoding="utf-8") @@ -1084,7 +1145,7 @@ def test_agent_uses_one_native_kanban_control_plane(): assert "herdr-dispatch" not in rendered -def test_cli_lane_reserves_cpu_headroom_for_ui_and_auth(): +def test_cli_lane_reserves_capacity_for_three_concurrent_workers(): deployment = _agent_deployment() containers = { item["name"]: item @@ -1093,37 +1154,53 @@ def test_cli_lane_reserves_cpu_headroom_for_ui_and_auth(): lane = containers["cli-lane-runner"] environment = {item["name"]: item["value"] for item in lane["env"]} - assert environment["HERMES_CLI_LANE_CONCURRENCY"] == "2" + assert environment["HERMES_CLI_LANE_CONCURRENCY"] == "3" assert lane["resources"] == { - "requests": {"cpu": "100m", "memory": "256Mi"}, - "limits": {"cpu": "2", "memory": "6Gi"}, + "requests": {"cpu": "500m", "memory": "512Mi"}, + "limits": {"cpu": "3", "memory": "6Gi"}, } -def test_agent_avoids_unhealthy_nodes_and_fits_its_remaining_capacity(): - """Placement correction: keep the agent off nodes that cannot hold it. - - titan-04 is cordoned after repeated kernel undervoltage and kubelet - failure, and titan-19 was probe/Longhorn unstable under worker load, so - both must join the existing hard exclusions. That leaves titan-05 as the - healthy candidate, which is tight enough on requested CPU that the main - container has to give back 50m to schedule there. - """ +def test_agent_avoids_unhealthy_nodes_and_prefers_accelerator_headroom(): + """Keep unsafe workers excluded and prefer the larger arm64 nodes.""" pod = _agent_deployment()["spec"]["template"]["spec"] - hostnames = next( + terms = pod["affinity"]["nodeAffinity"][ + "requiredDuringSchedulingIgnoredDuringExecution" + ]["nodeSelectorTerms"] + worker_hostnames = next( item - for item in pod["affinity"]["nodeAffinity"][ - "requiredDuringSchedulingIgnoredDuringExecution" - ]["nodeSelectorTerms"][0]["matchExpressions"] + for item in terms[0]["matchExpressions"] if item["key"] == "kubernetes.io/hostname" ) - assert hostnames["operator"] == "NotIn" - assert set(hostnames["values"]) >= {"titan-04", "titan-19"} + assert worker_hostnames["operator"] == "NotIn" + assert set(worker_hostnames["values"]) >= {"titan-04", "titan-19"} - hermes = next( - item for item in pod["containers"] if item["name"] == "hermes" - ) + accelerator = {item["key"]: item for item in terms[1]["matchExpressions"]} + assert accelerator["kubernetes.io/arch"] == { + "key": "kubernetes.io/arch", + "operator": "In", + "values": ["arm64"], + } + assert accelerator["node-role.kubernetes.io/accelerator"]["operator"] == "Exists" + assert accelerator["kubernetes.io/hostname"] == { + "key": "kubernetes.io/hostname", + "operator": "In", + "values": ["titan-20", "titan-21"], + } + + preferences = pod["affinity"]["nodeAffinity"][ + "preferredDuringSchedulingIgnoredDuringExecution" + ] + assert preferences[0]["weight"] == 100 + assert preferences[0]["preference"]["matchExpressions"] == [ + { + "key": "node-role.kubernetes.io/accelerator", + "operator": "Exists", + } + ] + + hermes = next(item for item in pod["containers"] if item["name"] == "hermes") assert hermes["resources"]["requests"]["cpu"] == "300m" @@ -1188,8 +1265,7 @@ def test_agent_root_is_stock_dashboard_and_terminal_is_a_separate_path(): ) patch_init = next( - item for item in pod["initContainers"] - if item["name"] == "patch-tui-gateway" + item for item in pod["initContainers"] if item["name"] == "patch-tui-gateway" ) assert patch_init["command"][-1] == "/patched/server.py" for name in ("hermes", "terminal"): @@ -1213,20 +1289,29 @@ def test_agent_root_is_stock_dashboard_and_terminal_is_a_separate_path(): assert middlewares["hermes-agent-terminal-slash"]["spec"]["redirectRegex"][ "replacement" ].endswith("/terminal/") - assert middlewares["hermes-agent-stock-dashboard-headers"]["spec"]["headers"][ - "customRequestHeaders" - ]["Origin"] == "http://127.0.0.1:9119" + assert ( + middlewares["hermes-agent-stock-dashboard-headers"]["spec"]["headers"][ + "customRequestHeaders" + ]["Origin"] + == "http://127.0.0.1:9119" + ) ingresses = { item["metadata"]["name"]: item for item in ingress_documents if item["kind"] == "Ingress" } - assert ingresses["hermes-agent-dashboard"]["metadata"]["annotations"][ - "traefik.ingress.kubernetes.io/router.middlewares" - ] == "hermes-hermes-agent-stock-dashboard-headers@kubernetescrd" - assert ingresses["hermes-agent-terminal"]["metadata"]["annotations"][ - "traefik.ingress.kubernetes.io/router.middlewares" - ] == "hermes-hermes-agent-terminal-slash@kubernetescrd" + assert ( + ingresses["hermes-agent-dashboard"]["metadata"]["annotations"][ + "traefik.ingress.kubernetes.io/router.middlewares" + ] + == "hermes-hermes-agent-stock-dashboard-headers@kubernetescrd" + ) + assert ( + ingresses["hermes-agent-terminal"]["metadata"]["annotations"][ + "traefik.ingress.kubernetes.io/router.middlewares" + ] + == "hermes-hermes-agent-terminal-slash@kubernetescrd" + ) def test_broker_services_survive_sibling_container_readiness_loss(): @@ -1242,9 +1327,9 @@ def test_broker_services_survive_sibling_container_readiness_loss(): def test_agent_dashboard_reconnects_all_transient_websockets(): - dockerfile = ( - HERMES.parents[1] / "dockerfiles/Dockerfile.hermes-agent" - ).read_text(encoding="utf-8") + dockerfile = (HERMES.parents[1] / "dockerfiles/Dockerfile.hermes-agent").read_text( + encoding="utf-8" + ) assert "eventsRetryAttempt.current" in dockerfile assert "if (!unmounting) setVersion((v) => v + 1);" in dockerfile assert "events feed rejected (${ev.code}) — reload the page" in dockerfile @@ -1273,8 +1358,7 @@ def test_agent_refreshes_routes_after_restoring_cli_logins(): assert env["PYTHONPATH"] == "/opt/hermes" for name in ("bootstrap-coordinator", "configure-agent-clients"): route_env = { - item["name"]: item["value"] - for item in init_containers[name]["env"] + item["name"]: item["value"] for item in init_containers[name]["env"] } assert route_env["CODEX_HOME"] == "/runtime-access/codex" assert route_env["CLAUDE_CONFIG_DIR"] == "/runtime-access/claude" @@ -1289,8 +1373,7 @@ def test_agent_refreshes_routes_after_restoring_cli_logins(): for item in deployment["spec"]["template"]["spec"]["containers"] } steward_env = { - item["name"]: item["value"] - for item in containers["model-steward"]["env"] + item["name"]: item["value"] for item in containers["model-steward"]["env"] } assert steward_env["CODEX_HOME"] == "/runtime-access/codex" assert steward_env["CLAUDE_CONFIG_DIR"] == "/runtime-access/claude" @@ -1308,10 +1391,7 @@ def test_agent_refreshes_routes_after_restoring_cli_logins(): def test_flux_health_checks_follow_the_owner_oauth_sidecar(): flux = yaml.safe_load(FLUX_HERMES.read_text()) - checks = { - (item["kind"], item["name"]) - for item in flux["spec"]["healthChecks"] - } + checks = {(item["kind"], item["name"]) for item in flux["spec"]["healthChecks"]} assert ("Deployment", "hermes-agent") in checks assert ("DaemonSet", "hermes-node-ssh-access") in checks assert ("Deployment", "oauth2-proxy-hermes-agent") not in checks @@ -1320,7 +1400,8 @@ def test_flux_health_checks_follow_the_owner_oauth_sidecar(): def test_agent_auth_is_bstein_group_and_email_bounded(): deployment = _agent_deployment() oauth = next( - item for item in deployment["spec"]["template"]["spec"]["containers"] + item + for item in deployment["spec"]["template"]["spec"]["containers"] if item["name"] == "oauth2-proxy" ) args = oauth["args"] @@ -1340,15 +1421,17 @@ def test_agent_network_boundary_allows_only_authenticated_and_metrics_surfaces() for item in yaml.safe_load_all((HERMES / "networkpolicy.yaml").read_text()) if item ] - isolation = next(item for item in documents if item.get("metadata", {}).get("name") == "hermes-agent-isolation") + isolation = next( + item + for item in documents + if item.get("metadata", {}).get("name") == "hermes-agent-isolation" + ) assert isolation["spec"]["ingress"] == [ { "from": [ { "namespaceSelector": { - "matchLabels": { - "kubernetes.io/metadata.name": "traefik" - } + "matchLabels": {"kubernetes.io/metadata.name": "traefik"} }, "podSelector": { "matchLabels": {"app.kubernetes.io/name": "traefik"} @@ -1358,26 +1441,14 @@ def test_agent_network_boundary_allows_only_authenticated_and_metrics_surfaces() "ports": [{"protocol": "TCP", "port": 4180}], }, { - "from": [ - { - "podSelector": { - "matchLabels": {"app": "hermes-chat-tenant"} - } - } - ], + "from": [{"podSelector": {"matchLabels": {"app": "hermes-chat-tenant"}}}], "ports": [ {"protocol": "TCP", "port": 9002}, {"protocol": "TCP", "port": 9003}, ], }, { - "from": [ - { - "podSelector": { - "matchLabels": {"app": "hermes-switchyard"} - } - } - ], + "from": [{"podSelector": {"matchLabels": {"app": "hermes-switchyard"}}}], "ports": [ {"protocol": "TCP", "port": 9003}, {"protocol": "TCP", "port": 9006}, @@ -1387,9 +1458,7 @@ def test_agent_network_boundary_allows_only_authenticated_and_metrics_surfaces() "from": [ { "namespaceSelector": { - "matchLabels": { - "kubernetes.io/metadata.name": "monitoring" - } + "matchLabels": {"kubernetes.io/metadata.name": "monitoring"} }, "podSelector": {"matchLabels": {"app": "server"}}, } @@ -1420,15 +1489,18 @@ def test_owner_agent_has_cluster_admin_kubernetes_context(): def test_owner_agent_has_pinned_dedicated_node_ssh_access(): deployment = _agent_deployment() annotations = deployment["spec"]["template"]["metadata"]["annotations"] - assert annotations[ - "vault.hashicorp.com/agent-inject-secret-node-ssh-private-key" - ] == "kv/data/atlas/hermes/developer-ssh" - assert annotations[ - "vault.hashicorp.com/agent-inject-secret-node-ssh-config" - ] == "kv/data/atlas/hermes/developer-ssh" - assert annotations[ - "vault.hashicorp.com/agent-inject-secret-node-ssh-known-hosts" - ] == "kv/data/atlas/hermes/developer-ssh" + assert ( + annotations["vault.hashicorp.com/agent-inject-secret-node-ssh-private-key"] + == "kv/data/atlas/hermes/developer-ssh" + ) + assert ( + annotations["vault.hashicorp.com/agent-inject-secret-node-ssh-config"] + == "kv/data/atlas/hermes/developer-ssh" + ) + assert ( + annotations["vault.hashicorp.com/agent-inject-secret-node-ssh-known-hosts"] + == "kv/data/atlas/hermes/developer-ssh" + ) init = next( item @@ -1453,9 +1525,7 @@ def test_owner_agent_has_pinned_dedicated_node_ssh_access(): assert "ssh_known_hosts" not in config assert "ssh-ed25519" not in (HERMES / "agent-configmap.yaml").read_text() - resources = yaml.safe_load((HERMES / "kustomization.yaml").read_text())[ - "resources" - ] + resources = yaml.safe_load((HERMES / "kustomization.yaml").read_text())["resources"] assert "node-ssh-access.yaml" in resources access = [ item @@ -1489,10 +1559,8 @@ def test_owner_agent_has_pinned_dedicated_node_ssh_access(): assert "grep -qxF" in reconciler assert "for user in atlas oceanus" in reconciler assert "/host-etc/passwd" in reconciler - assert "chown \"${uid}:${gid}\"" in reconciler - host_passwd = next( - item for item in pod["volumes"] if item["name"] == "host-passwd" - ) + assert 'chown "${uid}:${gid}"' in reconciler + host_passwd = next(item for item in pod["volumes"] if item["name"] == "host-passwd") assert host_passwd["hostPath"] == {"path": "/etc/passwd", "type": "File"} @@ -1542,9 +1610,7 @@ def test_switchyard_has_a_dedicated_non_owner_identity_and_read_only_catalog(): for item in service_accounts ) - switchyard = yaml.safe_load( - (HERMES / "switchyard-deployment.yaml").read_text() - ) + switchyard = yaml.safe_load((HERMES / "switchyard-deployment.yaml").read_text()) switchyard_pod = switchyard["spec"]["template"]["spec"] assert switchyard_pod["serviceAccountName"] == "hermes-switchyard" agent_pod = _agent_deployment()["spec"]["template"]["spec"] @@ -1552,7 +1618,9 @@ def test_switchyard_has_a_dedicated_non_owner_identity_and_read_only_catalog(): (switchyard_pod, "worker-route-broker"), (agent_pod, "claude-broker"), ): - container = next(item for item in pod["containers"] if item["name"] == container_name) + container = next( + item for item in pod["containers"] if item["name"] == container_name + ) catalog = next( item for item in container["volumeMounts"] @@ -1593,9 +1661,9 @@ def test_switchyard_active_state_uses_a_relocatable_rwx_claim(): } pod = deployment["spec"]["template"]["spec"] state = next(item for item in pod["volumes"] if item["name"] == "state") - assert state["persistentVolumeClaim"]["claimName"] == active_claim["metadata"][ - "name" - ] + assert ( + state["persistentVolumeClaim"]["claimName"] == active_claim["metadata"]["name"] + ) def test_worker_route_broker_accepts_pod_network_health_checks(): @@ -1648,9 +1716,7 @@ def test_switchyard_network_boundary_allows_metrics_scraping(): == [ { "namespaceSelector": { - "matchLabels": { - "kubernetes.io/metadata.name": "monitoring" - } + "matchLabels": {"kubernetes.io/metadata.name": "monitoring"} }, "podSelector": {"matchLabels": {"app": "server"}}, } @@ -1680,10 +1746,7 @@ def test_owner_agent_installs_the_pinned_operator_toolchain(): ]: assert value in script assert "go1.26.5.linux-arm64.tar.gz" in script - assert ( - "fe4789e92b1f33358680864bbe8704289e7bb5fc207d80623c308935bd696d49" - in script - ) + assert "fe4789e92b1f33358680864bbe8704289e7bb5fc207d80623c308935bd696d49" in script assert script.count("sha256sum -c -") == 1 deployment = _agent_deployment() @@ -1771,8 +1834,7 @@ def test_codex_runtime_patch_uses_cli_and_forwards_route(tmp_path: Path): turn = tmp_path / "codex_runtime.py" turn.write_text( - codex_runtime_patch.FALLBACK_CONTEXT_BEFORE - + codex_runtime_patch.TURN_BEFORE, + codex_runtime_patch.FALLBACK_CONTEXT_BEFORE + codex_runtime_patch.TURN_BEFORE, encoding="utf-8", ) turn_out = tmp_path / "patched/codex_runtime.py" @@ -1830,8 +1892,7 @@ def test_agent_mounts_codex_auxiliary_runtime_patch(): deployment = _agent_deployment() pod = deployment["spec"]["template"]["spec"] patch_init = next( - item for item in pod["initContainers"] - if item["name"] == "patch-codex-runtime" + item for item in pod["initContainers"] if item["name"] == "patch-codex-runtime" ) assert patch_init["command"][-2:] == [ "/opt/hermes/agent/auxiliary_client.py", @@ -1942,7 +2003,7 @@ def test_tui_gateway_patch_extends_and_bounds_agent_startup(tmp_path: Path): content = destination.read_text(encoding="utf-8") assert "HERMES_TUI_AGENT_INIT_TIMEOUT_S" in content - assert 'configured = 180.0' in content + assert "configured = 180.0" in content assert "return max(30.0, min(configured, 900.0))" in content assert "timeout: float | None = None" in content assert "ready.wait(timeout=wait_timeout)" in content