refactor(#838): consolidate harness state files into hyperhive-harness.json

This commit is contained in:
damocles 2026-05-31 20:19:56 +02:00
commit fce1f49f6a
7 changed files with 166 additions and 78 deletions

View file

@ -84,21 +84,22 @@ unix-domain socket as each agent opts in. The mechanism:
harness's `unlink + bind(2)` cycle on socket replace. Per-agent
subdir keeps each agent's container blind to siblings' sockets.
3. **Marker gate**. After successful `bind_unix`, the harness drops
`<dir>/.bound` next to the socket. c0re's `agent_sockets::write`
filters its JSON map by marker presence — only agents whose
harness has actually bound the socket appear there. Without this
filter, the gateway would `proxy_pass` to a non-existent socket
for every sub-agent that hasn't opted in yet.
`<dir>/hyperhive-socket-bound` next to the socket. c0re's
`agent_sockets::write` filters its JSON map by marker presence —
only agents whose harness has actually bound the socket appear there.
Without this filter, the gateway would `proxy_pass` to a non-existent
socket for every sub-agent that hasn't opted in yet. (Legacy name
`.bound` also accepted during the transition window.)
4. **Gateway side**. `gateway_nginx::write` generates
`/var/lib/hyperhive/agents.conf` — a plain nginx include file with
one `location /agent/<name>/` block per agent. UDS upstream
(`http://unix:/run/hive-agent/<name>/web.sock:/`) when `.bound`
marker present; TCP loopback otherwise. The gateway container
bind-mounts `/var/lib/hyperhive/` at `/run/hive-state/`; nginx
includes `/run/hive-state/agents.conf`. A systemd path unit
(`hive-gateway-agents-conf.path`) inside the container watches the
file and fires `nginx -s reload` on every atomic rename from c0re
— no `nixos-rebuild` needed (#869).
(`http://unix:/run/hive-agent/<name>/web.sock:/`) when
`hyperhive-socket-bound` marker present; TCP loopback otherwise.
The gateway container bind-mounts `/var/lib/hyperhive/` at
`/run/hive-state/`; nginx includes `/run/hive-state/agents.conf`.
A systemd path unit (`hive-gateway-agents-conf.path`) inside the
container watches the file and fires `nginx -s reload` on every
atomic rename from c0re — no `nixos-rebuild` needed.
c0re regenerates `agents.conf` (and fires the path unit → reload) on
two triggers: every topology change (new/removed agents) and every