cb2d778a8f
Sweep for vestiges of the old combined-plane model and the pre-split shared rootfs. Two are load-bearing, the rest are stale docs/comments: - Bug: macOS `enumerate_active` only excluded the gateway container from the agent list, so after the split the orchestrator container (`bot-bottle-mac-orchestrator`, also `bot-bottle-`-prefixed) was enumerated as a phantom agent. Exclude both infra containers; test covers it. - Dead code: the gateway `bootstrap.py` still carried an `orchestrator` daemon spec + `_OPT_IN_DAEMONS` + a signing-key/JWT env branch, all for the old combined container where the gateway process could also run the control plane. No backend ever requests it now — removed; the key-stripping stays as defense-in-depth. Stale-comment reframes: "the/single infra container" -> the orchestrator + gateway pair (or the specific plane); "shared rootfs / bb_role init / one published rootfs" -> the per-plane rootfs + `role_init`; the deleted Dockerfile.infra references in Dockerfile.orchestrator/.gateway; and the macOS "one infra container ... same address" docstring + its now-false share-one-address test (the planes are distinct containers with distinct addresses). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
"""Active-agent enumeration for the macOS Apple Container backend."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
|
|
from ...bottle_state import read_metadata
|
|
from .. import ActiveAgent
|
|
from .infra import INFRA_NAME, ORCHESTRATOR_NAME
|
|
|
|
# The name every agent container carries: `bot-bottle-<slug>`. Exported
|
|
# because callers that act on a running bottle (gateway-host rewrites,
|
|
# registry reconciliation) have to map an enumerated slug back to a
|
|
# container name.
|
|
CONTAINER_NAME_PREFIX = "bot-bottle-"
|
|
# The two shared per-host infra containers (orchestrator + gateway) carry the
|
|
# same `bot-bottle-` prefix as agent containers but are infrastructure, not
|
|
# bottles — one pair serves every agent, so enumerating either as an agent would
|
|
# invent a phantom bottle per host.
|
|
_INFRA_NAMES = frozenset({INFRA_NAME, ORCHESTRATOR_NAME})
|
|
|
|
|
|
class EnumerationError(RuntimeError):
|
|
"""container list failed; the resulting live set is not authoritative."""
|
|
|
|
|
|
def enumerate_active() -> list[ActiveAgent]:
|
|
result = subprocess.run(
|
|
["container", "list", "--quiet"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
if result.returncode != 0:
|
|
raise EnumerationError(
|
|
f"container list failed: "
|
|
f"{(result.stderr or '').strip() or '<no stderr>'}"
|
|
)
|
|
out: list[ActiveAgent] = []
|
|
for name in sorted(line.strip() for line in result.stdout.splitlines()):
|
|
if not name.startswith(CONTAINER_NAME_PREFIX) or name in _INFRA_NAMES:
|
|
continue
|
|
slug = name[len(CONTAINER_NAME_PREFIX):]
|
|
metadata = read_metadata(slug)
|
|
out.append(ActiveAgent(
|
|
backend_name="macos-container",
|
|
slug=slug,
|
|
agent_name=metadata.agent_name if metadata else "?",
|
|
started_at=metadata.started_at if metadata else "",
|
|
services=(),
|
|
label=metadata.label if metadata else "",
|
|
color=metadata.color if metadata else "",
|
|
))
|
|
return out
|