refactor: remove hyperhive.role option — there is only one role: agent

This commit is contained in:
damocles 2026-06-04 12:40:24 +02:00 committed by mara
commit 41eb3f806c
23 changed files with 105 additions and 229 deletions

View file

@ -197,8 +197,7 @@ in
'';
}
{
assertion =
!config.services.hyperhive.forge.enable || config.services.hyperhive.gateway.enable;
assertion = !config.services.hyperhive.forge.enable || config.services.hyperhive.gateway.enable;
message = ''
services.hyperhive.network.isolateContainers = true with
services.hyperhive.forge.enable = true requires

View file

@ -1,11 +1,7 @@
{ ... }:
{
imports = [ ./harness-base.nix ];
# Sub-agent role: the role-driven `systemd.services.hive-ag3nt` plus
# the default forge notification surface live in `harness-base.nix`.
# This file is the bare entry-point referenced from `flake.nix`
# Entry-point for sub-agent containers. Referenced from `flake.nix`
# (`nixosConfigurations.agent-base`) and the meta-flake's
# `applied/<name>/flake.nix` for sub-agent containers.
hyperhive.role = "agent";
# `applied/<name>/flake.nix`.
}

View file

@ -19,10 +19,9 @@ let
homeDir = "/home/${userName}";
in
{
# Shared scaffolding for any hyperhive harness container — both
# sub-agents (`agent-base.nix`) and the manager (`manager.nix`) extend
# this. The systemd service that actually runs the harness binary
# differs per role and lives in the child module.
# Shared scaffolding for every hyperhive harness container.
# `agent-base.nix` and `manager.nix` both import this; all agents
# use the same service unit regardless of which entry-point they came from.
# Optional feature modules. Each declares its own `hyperhive.*`
# option(s), default-off, so every agent has them available but
@ -86,28 +85,6 @@ in
'';
};
options.hyperhive.role = lib.mkOption {
type = lib.types.enum [
"agent"
"manager"
];
default = "agent";
example = "manager";
description = ''
Whether this container runs as a sub-agent (`"agent"`, the
default) or as the swarm's manager (`"manager"` both invoke
`hive serve`;
defaults the forge notification surface to mentions-only).
meta.rs flips this to `"manager"` for the manager container
and leaves it at the default for every sub-agent. Agents
and `agent.nix` files don't normally touch this option;
it's exposed so a standalone `nixos-rebuild` against
`nixosConfigurations.manager` keeps working without the
meta-flake wrapper around it.
'';
};
options.hyperhive.model = lib.mkOption {
type = lib.types.str;
default = "haiku";
@ -292,9 +269,7 @@ in
Computed: the merged static tree consumed by the harness via
`HIVE_STATIC_DIR`. Composed at evaluation time by copying
`hyperhive.frontend.dist`'s `agent/` subdir as the base, then
layering each `extraFiles` entry on top. Read-only
consumers (`agent-base.nix`, `manager.nix`) reference this in
their systemd service environment; do not set directly.
layering each `extraFiles` entry on top. Read-only do not set directly.
'';
};
@ -1357,18 +1332,6 @@ in
};
};
# Manager-only forge defaults: subscription/participation
# firehose stays off so the manager's inbox isn't drowned in
# noise. Full rationale + sub-agent contrast:
# docs/agent-hierarchy.md::Manager-only defaults.
hyperhive.forge = lib.mkIf (config.hyperhive.role == "manager") {
keepSubscriptions = lib.mkDefault false;
skipNotifyReasons = lib.mkDefault [
"subscribed"
"participating"
];
};
# Harness systemd unit. Unit shape (PATH wrapper-dir trick, env vars,
# RuntimeDirectory, User=, standalone-eval fallbacks):
# docs/agent-hierarchy.md::Harness systemd unit shape. PATH /bin
@ -1376,11 +1339,10 @@ in
# appends /bin to every entry.
systemd.services.hive-ag3nt =
let
isManager = config.hyperhive.role == "manager";
binary = "hive";
in
{
description = "${binary}${lib.optionalString isManager " manager"} harness";
description = "${binary} harness";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
# `/run/wrappers` before `/run/current-system/sw` so setuid
@ -1395,16 +1357,11 @@ in
HOME = homeDir;
HIVE_STATIC_DIR = "${config.hyperhive.frontend.mergedDist}";
HIVE_ASSETS_DIR = "${pkgs.hyperhive-assets}/share/hyperhive";
HIVE_ROLE = config.hyperhive.role;
# Unix-socket path for the harness web UI. All agents (sub-agents
# and manager) always bind here; TCP fallback is removed. Path
# matches `hive_c0re::agent_sockets::socket_path_for(name)` so
# lifecycle bind-mounts and gateway upstream config stay in sync.
# Unix-socket path for the harness web UI. All agents always bind
# here; TCP fallback is removed. Path matches
# `hive_c0re::agent_sockets::socket_path_for(name)` so lifecycle
# bind-mounts and gateway upstream config stay in sync.
HIVE_WEB_SOCKET = "/run/hive-agent/${userName}/web.sock";
}
// lib.optionalAttrs isManager {
# Standalone-eval fallback; meta.rs overrides at deploy time.
HIVE_LABEL = "ruth";
};
serviceConfig = {
ExecStart = "${pkgs.hyperhive}/bin/${binary} serve";

View file

@ -2,14 +2,15 @@
{
imports = [ ./harness-base.nix ];
# Manager role: the `systemd.services.hive-ag3nt` unit plus
# the manager-only forge defaults (`keepSubscriptions = false`,
# `skipNotifyReasons = [ "subscribed" "participating" ]`) live in
# `harness-base.nix` under `lib.mkIf (config.hyperhive.role ==
# "manager")`. This file is the bare entry-point referenced from
# Entry-point for the privileged root agent (ruth). Referenced from
# `flake.nix` (`nixosConfigurations.ruth`) and the meta-flake's
# `applied/ruth/flake.nix`. HIVE_PORT / HIVE_LABEL are injected by
# the meta-flake at deploy time and have manager-only standalone-eval
# fallbacks in `harness-base.nix`.
hyperhive.role = "manager";
# `applied/ruth/flake.nix`. Forge subscription/participation firehose
# stays off so ruth's inbox isn't drowned in noise.
hyperhive.forge = {
keepSubscriptions = false;
skipNotifyReasons = [
"subscribed"
"participating"
];
};
}