lifecycle: drop manager port special case (#753) — manager hashes into 8100..8999 like every other agent

This commit is contained in:
damocles 2026-05-31 13:17:32 +02:00 committed by Mara
commit 4526e40a49
11 changed files with 43 additions and 39 deletions

View file

@ -16,9 +16,6 @@ pub const MAX_AGENT_NAME: usize = 9;
/// nixosConfiguration (`manager`, not `agent-base`).
pub const MANAGER_NAME: &str = "hm1nd";
/// Web UI port reserved for the manager (sub-agents hash into 8100..8999).
pub const MANAGER_PORT: u16 = 8000;
/// Mount point of the per-agent runtime directory inside the container.
pub const CONTAINER_RUNTIME_MOUNT: &str = "/run/hive";
@ -57,18 +54,16 @@ const WEB_PORT_RANGE: u16 = 900;
const DEFAULT_MEMORY_MAX: &str = "2G";
const DEFAULT_CPU_QUOTA: &str = "50%";
/// Per-agent web UI port. Manager is fixed at `MANAGER_PORT`; every
/// sub-agent is `WEB_PORT_BASE + FNV-1a(name) % WEB_PORT_RANGE`,
/// pure and reproducible from just the name. Collisions are
/// possible (birthday paradox at ~30 agents); the operator resolves
/// them by renaming an agent (different hash → different port).
/// Stable across hosts, restarts, and dashboard renders — no
/// state-file dance.
/// Per-agent web UI port — `WEB_PORT_BASE + FNV-1a(name) %
/// WEB_PORT_RANGE` for every agent including the manager (#753
/// dropped the pre-#753 "manager pinned at 8000" special case so
/// the port allocation rule reads the same for every name).
/// Collisions are possible (birthday paradox at ~30 agents); the
/// operator resolves them by renaming an agent (different hash →
/// different port). Stable across hosts, restarts, and dashboard
/// renders — no state-file dance.
#[must_use]
pub fn agent_web_port(name: &str) -> u16 {
if name == MANAGER_NAME {
return MANAGER_PORT;
}
let mut hash: u32 = 2_166_136_261;
for b in name.bytes() {
hash ^= u32::from(b);