hermes: run three lanes on accelerator headroom

This commit is contained in:
jenkins 2026-08-17 05:44:55 -03:00
parent ab346f5550
commit 3d59664a8f
2 changed files with 205 additions and 130 deletions

View File

@ -24,7 +24,7 @@ spec:
ai.bstein.dev/router-wire-contract: ollama-numeric-keepalive 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/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/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" ai.bstein.dev/config-rev: "20260816-auth-health-quarantine-v6"
prometheus.io/scrape: "true" prometheus.io/scrape: "true"
prometheus.io/path: /metrics prometheus.io/path: /metrics
@ -112,8 +112,22 @@ spec:
- key: kubernetes.io/hostname - key: kubernetes.io/hostname
operator: NotIn operator: NotIn
values: [titan-04, titan-08, titan-13, titan-14, titan-17, titan-18, titan-19] 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: preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100 - weight: 100
preference:
matchExpressions:
- key: node-role.kubernetes.io/accelerator
operator: Exists
- weight: 50
preference: preference:
matchExpressions: matchExpressions:
- key: hardware - key: hardware
@ -874,7 +888,7 @@ spec:
- {name: CLAUDE_CONFIG_DIR, value: /runtime-access/claude} - {name: CLAUDE_CONFIG_DIR, value: /runtime-access/claude}
- {name: KUBECONFIG, value: /opt/data/home/.kube/config} - {name: KUBECONFIG, value: /opt/data/home/.kube/config}
- {name: PYTHONPATH, value: /opt/hermes} - {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: 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} - {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: securityContext:
@ -896,8 +910,8 @@ spec:
- {name: auto-router-plugin, mountPath: /opt/data/plugins/auto-router, readOnly: true} - {name: auto-router-plugin, mountPath: /opt/data/plugins/auto-router, readOnly: true}
- {name: tmp, mountPath: /tmp} - {name: tmp, mountPath: /tmp}
resources: resources:
requests: {cpu: 100m, memory: 256Mi} requests: {cpu: 500m, memory: 512Mi}
limits: {cpu: "2", memory: 6Gi} limits: {cpu: "3", memory: 6Gi}
- name: model-steward - name: model-steward
image: registry.bstein.dev/bstein/hermes-agent@sha256:81970563e542f0720773e72297810b3a844b83e381e278f25c0916c78d930107 image: registry.bstein.dev/bstein/hermes-agent@sha256:81970563e542f0720773e72297810b3a844b83e381e278f25c0916c78d930107
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent

View File

@ -115,9 +115,7 @@ def test_manual_lane_is_still_enforced_by_switchyard():
def route(request, timeout): def route(request, timeout):
observed["payload"] = json.loads(request.data) observed["payload"] = json.loads(request.data)
return _SwitchyardResponse( return _SwitchyardResponse("worker/claude/claude-sonnet-5/high", "manual route")
"worker/claude/claude-sonnet-5/high", "manual route"
)
route = lanes.select_route( route = lanes.select_route(
"Implement it.", "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) return lanes.ProcessResult(0, "", {"status": "completed"}, False)
monkeypatch.setattr(lanes, "stream_process", fake_stream) 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( lanes.run_provider(
route, 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): 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" state_file = tmp_path / "state.json"
calls = [] 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) return lanes.ProcessResult(0, "", {"status": "completed"}, False)
monkeypatch.setattr(lanes, "stream_process", fake_stream) monkeypatch.setattr(lanes, "stream_process", fake_stream)
route = lanes.Route("claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, ()) route = lanes.Route(
lanes.run_provider(route, "Continue.", tmp_path, state, state_file, tmp_path / "log", lambda _: True, 60) "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 "--resume" in calls[0]
assert "--session-id" in calls[1] 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 = {"claude_session_id": "24927cee-f3da-4bcf-b624-602c22860155"}
state_file = tmp_path / "state.json" state_file = tmp_path / "state.json"
calls = [] 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) return lanes.ProcessResult(0, "", {"status": "completed"}, False)
monkeypatch.setattr(lanes, "stream_process", fake_stream) monkeypatch.setattr(lanes, "stream_process", fake_stream)
route = lanes.Route("claude", "claude-opus-5", "high", "claude-high", "jetson", "vote", 1, ()) route = lanes.Route(
lanes.run_provider(route, "Continue.", tmp_path, state, state_file, tmp_path / "log", lambda _: True, 60) "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 "--session-id" in calls[0]
assert "--resume" in calls[1] 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): 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")] 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): class CorruptBoardError(Exception):
pass pass
@ -681,7 +716,9 @@ def test_claim_requires_structured_evidence_and_surfaces_artifacts(
block_task=lambda *_args, **kwargs: calls.append(("block", kwargs)), block_task=lambda *_args, **kwargs: calls.append(("block", kwargs)),
) )
monkeypatch.setitem(sys.modules, "hermes_cli", SimpleNamespace(kanban_db=fake_db)) 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( monkeypatch.setattr(
lanes, lanes,
"select_route", "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, () "codex", "gpt-5.6-sol", "high", "codex-high", "jetson", "vote", 1, ()
), ),
) )
def run_provider(*args, **_kwargs): def run_provider(*args, **_kwargs):
assert connections[0].closed assert connections[0].closed
before_heartbeat = len(connections) 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][0] == "complete"
assert calls[0][1]["metadata"]["goal_turn"] == 2 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(
assert any("Goal route 2/3: codex/gpt-5.6-sol at xhigh" in item for item in comments) "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 route_calls[2][1]["exclude_provider"] == "claude"
assert "prior rejected reports" in judge_contexts[1] assert "prior rejected reports" in judge_contexts[1]
assert "commit, push, and remote verification are missing" in judge_contexts[1] assert "commit, push, and remote verification are missing" in judge_contexts[1]
assert reports == [] 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") task = SimpleNamespace(id="t_bad_worktree", current_run_id=7, assignee="cli-auto")
calls = [] 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), block_task=lambda *_args, **kwargs: calls.append(kwargs),
) )
monkeypatch.setitem(sys.modules, "hermes_cli", SimpleNamespace(kanban_db=fake_db)) 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") lanes.execute_claim("cassandra", "t_bad_worktree")
@ -873,7 +919,9 @@ def test_artifacts_cannot_escape_the_task_worktree(tmp_path: Path):
) == [str(inside)] ) == [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( task = SimpleNamespace(
id="t_resume", id="t_resume",
current_run_id=9, 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): 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, ()) route = lanes.Route(
command = lanes._codex_command(route, "Work.", tmp_path, {}, tmp_path / "result.json") "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 "--dangerously-bypass-approvals-and-sandbox" in command
assert "--json" in command assert "--json" in command
assert "--output-schema" 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_state = {"claude_session_id": "13864642-2985-4f91-bef5-53f145f878e8"}
claude = lanes._claude_command( 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.", "Review.",
claude_state, claude_state,
False, False,
@ -978,7 +1032,10 @@ def test_worker_contract_separates_review_findings_from_task_blockers(tmp_path:
assert set(lanes.RESULT_SCHEMA["required"]) == set( assert set(lanes.RESULT_SCHEMA["required"]) == set(
lanes.RESULT_SCHEMA["properties"] 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( @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 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" state = tmp_path / ".claude.json"
settings = tmp_path / "settings.json" settings = tmp_path / "settings.json"
state.write_text('{"promptQueueUseCount": 4}\n', encoding="utf-8") 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): def test_legacy_state_is_archived_without_removing_provider_transcripts(tmp_path: Path):
session = tmp_path / "home/.config/herdr/session.json" session = tmp_path / "home/.config/herdr/session.json"
session.parent.mkdir(parents=True) 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 = tmp_path / "tools/bin/herdr"
binary.parent.mkdir(parents=True) binary.parent.mkdir(parents=True)
binary.write_text("legacy", encoding="utf-8") 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 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() deployment = _agent_deployment()
containers = { containers = {
item["name"]: item item["name"]: item
@ -1093,37 +1154,53 @@ def test_cli_lane_reserves_cpu_headroom_for_ui_and_auth():
lane = containers["cli-lane-runner"] lane = containers["cli-lane-runner"]
environment = {item["name"]: item["value"] for item in lane["env"]} 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"] == { assert lane["resources"] == {
"requests": {"cpu": "100m", "memory": "256Mi"}, "requests": {"cpu": "500m", "memory": "512Mi"},
"limits": {"cpu": "2", "memory": "6Gi"}, "limits": {"cpu": "3", "memory": "6Gi"},
} }
def test_agent_avoids_unhealthy_nodes_and_fits_its_remaining_capacity(): def test_agent_avoids_unhealthy_nodes_and_prefers_accelerator_headroom():
"""Placement correction: keep the agent off nodes that cannot hold it. """Keep unsafe workers excluded and prefer the larger arm64 nodes."""
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.
"""
pod = _agent_deployment()["spec"]["template"]["spec"] pod = _agent_deployment()["spec"]["template"]["spec"]
hostnames = next( terms = pod["affinity"]["nodeAffinity"][
"requiredDuringSchedulingIgnoredDuringExecution"
]["nodeSelectorTerms"]
worker_hostnames = next(
item item
for item in pod["affinity"]["nodeAffinity"][ for item in terms[0]["matchExpressions"]
"requiredDuringSchedulingIgnoredDuringExecution"
]["nodeSelectorTerms"][0]["matchExpressions"]
if item["key"] == "kubernetes.io/hostname" if item["key"] == "kubernetes.io/hostname"
) )
assert hostnames["operator"] == "NotIn" assert worker_hostnames["operator"] == "NotIn"
assert set(hostnames["values"]) >= {"titan-04", "titan-19"} assert set(worker_hostnames["values"]) >= {"titan-04", "titan-19"}
hermes = next( accelerator = {item["key"]: item for item in terms[1]["matchExpressions"]}
item for item in pod["containers"] if item["name"] == "hermes" 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" 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( patch_init = next(
item for item in pod["initContainers"] item for item in pod["initContainers"] if item["name"] == "patch-tui-gateway"
if item["name"] == "patch-tui-gateway"
) )
assert patch_init["command"][-1] == "/patched/server.py" assert patch_init["command"][-1] == "/patched/server.py"
for name in ("hermes", "terminal"): 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"][ assert middlewares["hermes-agent-terminal-slash"]["spec"]["redirectRegex"][
"replacement" "replacement"
].endswith("/terminal/") ].endswith("/terminal/")
assert middlewares["hermes-agent-stock-dashboard-headers"]["spec"]["headers"][ assert (
"customRequestHeaders" middlewares["hermes-agent-stock-dashboard-headers"]["spec"]["headers"][
]["Origin"] == "http://127.0.0.1:9119" "customRequestHeaders"
]["Origin"]
== "http://127.0.0.1:9119"
)
ingresses = { ingresses = {
item["metadata"]["name"]: item item["metadata"]["name"]: item
for item in ingress_documents for item in ingress_documents
if item["kind"] == "Ingress" if item["kind"] == "Ingress"
} }
assert ingresses["hermes-agent-dashboard"]["metadata"]["annotations"][ assert (
"traefik.ingress.kubernetes.io/router.middlewares" ingresses["hermes-agent-dashboard"]["metadata"]["annotations"][
] == "hermes-hermes-agent-stock-dashboard-headers@kubernetescrd" "traefik.ingress.kubernetes.io/router.middlewares"
assert ingresses["hermes-agent-terminal"]["metadata"]["annotations"][ ]
"traefik.ingress.kubernetes.io/router.middlewares" == "hermes-hermes-agent-stock-dashboard-headers@kubernetescrd"
] == "hermes-hermes-agent-terminal-slash@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(): 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(): def test_agent_dashboard_reconnects_all_transient_websockets():
dockerfile = ( dockerfile = (HERMES.parents[1] / "dockerfiles/Dockerfile.hermes-agent").read_text(
HERMES.parents[1] / "dockerfiles/Dockerfile.hermes-agent" encoding="utf-8"
).read_text(encoding="utf-8") )
assert "eventsRetryAttempt.current" in dockerfile assert "eventsRetryAttempt.current" in dockerfile
assert "if (!unmounting) setVersion((v) => v + 1);" in dockerfile assert "if (!unmounting) setVersion((v) => v + 1);" in dockerfile
assert "events feed rejected (${ev.code}) — reload the page" 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" assert env["PYTHONPATH"] == "/opt/hermes"
for name in ("bootstrap-coordinator", "configure-agent-clients"): for name in ("bootstrap-coordinator", "configure-agent-clients"):
route_env = { route_env = {
item["name"]: item["value"] item["name"]: item["value"] for item in init_containers[name]["env"]
for item in init_containers[name]["env"]
} }
assert route_env["CODEX_HOME"] == "/runtime-access/codex" assert route_env["CODEX_HOME"] == "/runtime-access/codex"
assert route_env["CLAUDE_CONFIG_DIR"] == "/runtime-access/claude" 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"] for item in deployment["spec"]["template"]["spec"]["containers"]
} }
steward_env = { steward_env = {
item["name"]: item["value"] item["name"]: item["value"] for item in containers["model-steward"]["env"]
for item in containers["model-steward"]["env"]
} }
assert steward_env["CODEX_HOME"] == "/runtime-access/codex" assert steward_env["CODEX_HOME"] == "/runtime-access/codex"
assert steward_env["CLAUDE_CONFIG_DIR"] == "/runtime-access/claude" 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(): def test_flux_health_checks_follow_the_owner_oauth_sidecar():
flux = yaml.safe_load(FLUX_HERMES.read_text()) flux = yaml.safe_load(FLUX_HERMES.read_text())
checks = { checks = {(item["kind"], item["name"]) for item in flux["spec"]["healthChecks"]}
(item["kind"], item["name"])
for item in flux["spec"]["healthChecks"]
}
assert ("Deployment", "hermes-agent") in checks assert ("Deployment", "hermes-agent") in checks
assert ("DaemonSet", "hermes-node-ssh-access") in checks assert ("DaemonSet", "hermes-node-ssh-access") in checks
assert ("Deployment", "oauth2-proxy-hermes-agent") not 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(): def test_agent_auth_is_bstein_group_and_email_bounded():
deployment = _agent_deployment() deployment = _agent_deployment()
oauth = next( 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" if item["name"] == "oauth2-proxy"
) )
args = oauth["args"] 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()) for item in yaml.safe_load_all((HERMES / "networkpolicy.yaml").read_text())
if item 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"] == [ assert isolation["spec"]["ingress"] == [
{ {
"from": [ "from": [
{ {
"namespaceSelector": { "namespaceSelector": {
"matchLabels": { "matchLabels": {"kubernetes.io/metadata.name": "traefik"}
"kubernetes.io/metadata.name": "traefik"
}
}, },
"podSelector": { "podSelector": {
"matchLabels": {"app.kubernetes.io/name": "traefik"} "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}], "ports": [{"protocol": "TCP", "port": 4180}],
}, },
{ {
"from": [ "from": [{"podSelector": {"matchLabels": {"app": "hermes-chat-tenant"}}}],
{
"podSelector": {
"matchLabels": {"app": "hermes-chat-tenant"}
}
}
],
"ports": [ "ports": [
{"protocol": "TCP", "port": 9002}, {"protocol": "TCP", "port": 9002},
{"protocol": "TCP", "port": 9003}, {"protocol": "TCP", "port": 9003},
], ],
}, },
{ {
"from": [ "from": [{"podSelector": {"matchLabels": {"app": "hermes-switchyard"}}}],
{
"podSelector": {
"matchLabels": {"app": "hermes-switchyard"}
}
}
],
"ports": [ "ports": [
{"protocol": "TCP", "port": 9003}, {"protocol": "TCP", "port": 9003},
{"protocol": "TCP", "port": 9006}, {"protocol": "TCP", "port": 9006},
@ -1387,9 +1458,7 @@ def test_agent_network_boundary_allows_only_authenticated_and_metrics_surfaces()
"from": [ "from": [
{ {
"namespaceSelector": { "namespaceSelector": {
"matchLabels": { "matchLabels": {"kubernetes.io/metadata.name": "monitoring"}
"kubernetes.io/metadata.name": "monitoring"
}
}, },
"podSelector": {"matchLabels": {"app": "server"}}, "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(): def test_owner_agent_has_pinned_dedicated_node_ssh_access():
deployment = _agent_deployment() deployment = _agent_deployment()
annotations = deployment["spec"]["template"]["metadata"]["annotations"] annotations = deployment["spec"]["template"]["metadata"]["annotations"]
assert annotations[ assert (
"vault.hashicorp.com/agent-inject-secret-node-ssh-private-key" annotations["vault.hashicorp.com/agent-inject-secret-node-ssh-private-key"]
] == "kv/data/atlas/hermes/developer-ssh" == "kv/data/atlas/hermes/developer-ssh"
assert annotations[ )
"vault.hashicorp.com/agent-inject-secret-node-ssh-config" assert (
] == "kv/data/atlas/hermes/developer-ssh" annotations["vault.hashicorp.com/agent-inject-secret-node-ssh-config"]
assert annotations[ == "kv/data/atlas/hermes/developer-ssh"
"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-known-hosts"]
== "kv/data/atlas/hermes/developer-ssh"
)
init = next( init = next(
item item
@ -1453,9 +1525,7 @@ def test_owner_agent_has_pinned_dedicated_node_ssh_access():
assert "ssh_known_hosts" not in config assert "ssh_known_hosts" not in config
assert "ssh-ed25519" not in (HERMES / "agent-configmap.yaml").read_text() assert "ssh-ed25519" not in (HERMES / "agent-configmap.yaml").read_text()
resources = yaml.safe_load((HERMES / "kustomization.yaml").read_text())[ resources = yaml.safe_load((HERMES / "kustomization.yaml").read_text())["resources"]
"resources"
]
assert "node-ssh-access.yaml" in resources assert "node-ssh-access.yaml" in resources
access = [ access = [
item item
@ -1489,10 +1559,8 @@ def test_owner_agent_has_pinned_dedicated_node_ssh_access():
assert "grep -qxF" in reconciler assert "grep -qxF" in reconciler
assert "for user in atlas oceanus" in reconciler assert "for user in atlas oceanus" in reconciler
assert "/host-etc/passwd" in reconciler assert "/host-etc/passwd" in reconciler
assert "chown \"${uid}:${gid}\"" in reconciler assert 'chown "${uid}:${gid}"' in reconciler
host_passwd = next( host_passwd = next(item for item in pod["volumes"] if item["name"] == "host-passwd")
item for item in pod["volumes"] if item["name"] == "host-passwd"
)
assert host_passwd["hostPath"] == {"path": "/etc/passwd", "type": "File"} 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 for item in service_accounts
) )
switchyard = yaml.safe_load( switchyard = yaml.safe_load((HERMES / "switchyard-deployment.yaml").read_text())
(HERMES / "switchyard-deployment.yaml").read_text()
)
switchyard_pod = switchyard["spec"]["template"]["spec"] switchyard_pod = switchyard["spec"]["template"]["spec"]
assert switchyard_pod["serviceAccountName"] == "hermes-switchyard" assert switchyard_pod["serviceAccountName"] == "hermes-switchyard"
agent_pod = _agent_deployment()["spec"]["template"]["spec"] 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"), (switchyard_pod, "worker-route-broker"),
(agent_pod, "claude-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( catalog = next(
item item
for item in container["volumeMounts"] for item in container["volumeMounts"]
@ -1593,9 +1661,9 @@ def test_switchyard_active_state_uses_a_relocatable_rwx_claim():
} }
pod = deployment["spec"]["template"]["spec"] pod = deployment["spec"]["template"]["spec"]
state = next(item for item in pod["volumes"] if item["name"] == "state") state = next(item for item in pod["volumes"] if item["name"] == "state")
assert state["persistentVolumeClaim"]["claimName"] == active_claim["metadata"][ assert (
"name" state["persistentVolumeClaim"]["claimName"] == active_claim["metadata"]["name"]
] )
def test_worker_route_broker_accepts_pod_network_health_checks(): def test_worker_route_broker_accepts_pod_network_health_checks():
@ -1648,9 +1716,7 @@ def test_switchyard_network_boundary_allows_metrics_scraping():
== [ == [
{ {
"namespaceSelector": { "namespaceSelector": {
"matchLabels": { "matchLabels": {"kubernetes.io/metadata.name": "monitoring"}
"kubernetes.io/metadata.name": "monitoring"
}
}, },
"podSelector": {"matchLabels": {"app": "server"}}, "podSelector": {"matchLabels": {"app": "server"}},
} }
@ -1680,10 +1746,7 @@ def test_owner_agent_installs_the_pinned_operator_toolchain():
]: ]:
assert value in script assert value in script
assert "go1.26.5.linux-arm64.tar.gz" in script assert "go1.26.5.linux-arm64.tar.gz" in script
assert ( assert "fe4789e92b1f33358680864bbe8704289e7bb5fc207d80623c308935bd696d49" in script
"fe4789e92b1f33358680864bbe8704289e7bb5fc207d80623c308935bd696d49"
in script
)
assert script.count("sha256sum -c -") == 1 assert script.count("sha256sum -c -") == 1
deployment = _agent_deployment() 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 = tmp_path / "codex_runtime.py"
turn.write_text( turn.write_text(
codex_runtime_patch.FALLBACK_CONTEXT_BEFORE codex_runtime_patch.FALLBACK_CONTEXT_BEFORE + codex_runtime_patch.TURN_BEFORE,
+ codex_runtime_patch.TURN_BEFORE,
encoding="utf-8", encoding="utf-8",
) )
turn_out = tmp_path / "patched/codex_runtime.py" turn_out = tmp_path / "patched/codex_runtime.py"
@ -1830,8 +1892,7 @@ def test_agent_mounts_codex_auxiliary_runtime_patch():
deployment = _agent_deployment() deployment = _agent_deployment()
pod = deployment["spec"]["template"]["spec"] pod = deployment["spec"]["template"]["spec"]
patch_init = next( patch_init = next(
item for item in pod["initContainers"] item for item in pod["initContainers"] if item["name"] == "patch-codex-runtime"
if item["name"] == "patch-codex-runtime"
) )
assert patch_init["command"][-2:] == [ assert patch_init["command"][-2:] == [
"/opt/hermes/agent/auxiliary_client.py", "/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") content = destination.read_text(encoding="utf-8")
assert "HERMES_TUI_AGENT_INIT_TIMEOUT_S" in content 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 "return max(30.0, min(configured, 900.0))" in content
assert "timeout: float | None = None" in content assert "timeout: float | None = None" in content
assert "ready.wait(timeout=wait_timeout)" in content assert "ready.wait(timeout=wait_timeout)" in content