3"""Runner-class naming and transport derivations for the fleet model."""
5from __future__
import annotations
8from dataclasses
import dataclass
12@dataclass(frozen=True)
14 """Describe capacity, budget, and transport behavior for one host class.
17 capacity_runner: Whether the host carries scalable runner capacity.
18 budget_mode: The only budget mode this class may declare.
19 transport: Direct ``ssh`` or Windows-mediated ``wsl`` transport.
20 capacity_kind: Capacity controller arm used to scale this host.
21 summary: One-line human-readable description.
31CLASSES: dict[str, HostClass] = {
37 summary=
"an ARC scale set on a k8s cluster",
39 "docker_linux": HostClass(
41 budget_mode=
"reserved",
43 capacity_kind=
"docker",
44 summary=
"runner containers on a plain Docker host",
46 "docker_wsl": HostClass(
48 budget_mode=
"reserved",
50 capacity_kind=
"docker",
51 summary=
"runner containers inside a Windows WSL2 distro",
56 capacity_runner=
False,
57 budget_mode=
"reserved",
60 summary=
"the shared verification box and dedicated HIL listener",
62 "hil_bench": HostClass(
63 capacity_runner=
False,
64 budget_mode=
"reserved",
67 summary=
"the hardware-in-the-loop bench",
72CONTAINER_BASE =
"ra8-ci-runner"
75def instance_names(name: str, host: dict[str, Any]) -> list[str]:
76 """Return the stable runner-registration names for one host."""
77 if CLASSES[host[
"class"]].capacity_kind !=
"docker":
79 runners = host.get(
"runners")
or {}
80 base = runners.get(
"name", name)
81 count = int(runners.get(
"instances", 0))
84 return [f
"{base}-{index}" for index
in range(1, count + 1)]
87def container_names(host: dict[str, Any]) -> list[str]:
88 """Return Docker container names for one host in instance order."""
89 if CLASSES[host[
"class"]].capacity_kind !=
"docker":
91 count = int((host.get(
"runners")
or {}).get(
"instances", 0))
93 return [CONTAINER_BASE]
94 return [f
"{CONTAINER_BASE}-{index}" for index
in range(1, count + 1)]
97def remote_shell(host: dict[str, Any]) -> str:
98 """Return the fixed remote command that executes a stdin shell script."""
99 if CLASSES[host[
"class"]].transport ==
"wsl":
100 distro = shlex.quote(str(host[
"connect"][
"distro"]))
102 f
"wsl -d {distro} -u root -e /usr/bin/env -i HOME=/root PATH=/usr/bin:/bin /bin/bash -s"
104 return "/bin/bash -s"
107def docker_command(host: dict[str, Any]) -> str:
108 """Return the fixed Docker command for one host's transport."""
109 if CLASSES[host[
"class"]].transport ==
"wsl":