Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68afbb01f7 | ||
|
|
eba3f206ab | ||
|
|
79fec131d6 | ||
|
|
e0cfed7fe8 | ||
|
|
935e967718 | ||
|
|
4a48ce5024 | ||
|
|
cb755b677c | ||
|
|
7c9d72b9ca | ||
|
|
7ad2bb9211 | ||
|
|
43bbd64f82 | ||
|
|
874a900bdc | ||
|
|
281667d5a8 | ||
|
|
e7689a6804 | ||
|
|
5f9af9fc97 | ||
|
|
ecaad48fad | ||
|
|
c0bd77b314 | ||
|
|
3069c11c3d | ||
|
|
4f8bb6ded2 |
72 changed files with 5695 additions and 5438 deletions
16
CLAUDE.md
16
CLAUDE.md
|
|
@ -63,12 +63,16 @@ hand-maintained per-file tree drifts out of sync with the code.
|
||||||
### Other top-level dirs
|
### Other top-level dirs
|
||||||
|
|
||||||
- **`frontend/`** — npm workspaces → static dashboard + per-agent UI
|
- **`frontend/`** — npm workspaces → static dashboard + per-agent UI
|
||||||
dist, built hermetically by `nix/frontend.nix`. Packages: `shared`
|
dist, built hermetically by `nix/packages/frontend.nix`. Packages:
|
||||||
(terminal pane + Catppuccin palette), `dashboard` (the operator SPA),
|
`shared` (terminal pane + Catppuccin palette), `dashboard` (the
|
||||||
`agent` (the default per-container UI).
|
operator SPA), `agent` (the default per-container UI).
|
||||||
- **`nix/`** — NixOS modules (`modules/hive-{c0re,forge,gateway,matrix,
|
- **`nix/`** — `host-modules/` (the host stack: hyperhive core options,
|
||||||
ci,network}.nix`) + per-container templates (`templates/{harness-base,
|
`hive-{c0re,priv,forge,gateway,matrix,network,tls,ci}`, otel, swarm),
|
||||||
agent-base,manager,weston-vnc}.nix`) + the options-doc derivation.
|
`agent-modules/` (the per-agent harness feature modules),
|
||||||
|
`templates/{agent,ruth}.nix` (container entry points), `packages/`
|
||||||
|
(flake package outputs), `docs/` (the options-doc derivation), plus
|
||||||
|
`sources.nix` / `rust.nix` / `checks.nix` / `devshell.nix` /
|
||||||
|
`treefmt.nix` behind the thin `flake.nix`.
|
||||||
- **`docs/`** — subsystem reference docs (see *Reading paths* below).
|
- **`docs/`** — subsystem reference docs (see *Reading paths* below).
|
||||||
- **`branding/`**, **`scripts/`** — static assets + helper scripts.
|
- **`branding/`**, **`scripts/`** — static assets + helper scripts.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ account), it prints the token to stdout and writes nothing.
|
||||||
nix develop -c cargo check
|
nix develop -c cargo check
|
||||||
nix flake check # rust + nix + toml fmt + clippy
|
nix flake check # rust + nix + toml fmt + clippy
|
||||||
|
|
||||||
# deploy from a host config that imports hyperhive.nixosModules.hive-c0re
|
# deploy from a host config that imports hyperhive.nixosModules.default
|
||||||
nix flake update --update-input hyperhive
|
nix flake update --update-input hyperhive
|
||||||
sudo nixos-rebuild switch --flake .#<host>
|
sudo nixos-rebuild switch --flake .#<host>
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ Tree-shape version:
|
||||||
`HYPERHIVE_STATE_DIR` is now injected uniformly via
|
`HYPERHIVE_STATE_DIR` is now injected uniformly via
|
||||||
`systemd.globalEnvironment` in `meta.rs` for every container
|
`systemd.globalEnvironment` in `meta.rs` for every container
|
||||||
(manager included), so all token/state paths resolve through
|
(manager included), so all token/state paths resolve through
|
||||||
`$HYPERHIVE_STATE_DIR`. The harness-base shell scripts
|
`$HYPERHIVE_STATE_DIR`. The agent-module shell scripts
|
||||||
(tea-login, forge-avatar-sync) simplified from glob+for loops to a
|
(tea-login, forge-avatar-sync) simplified from glob+for loops to a
|
||||||
direct `$HYPERHIVE_STATE_DIR/<token>` read.
|
direct `$HYPERHIVE_STATE_DIR/<token>` read.
|
||||||
|
|
||||||
|
|
@ -215,15 +215,15 @@ nspawn agent. Open questions, not yet wired:
|
||||||
## Harness systemd unit shape
|
## Harness systemd unit shape
|
||||||
|
|
||||||
One harness serve binary (`hive-agent`, with its `hive-agent-mcp` /
|
One harness serve binary (`hive-agent`, with its `hive-agent-mcp` /
|
||||||
`hive-agent-wake` siblings), one `harness-base.nix` template, one
|
`hive-agent-wake` siblings), one shared `nix/agent-modules/` tree, one
|
||||||
service unit (`systemd.services.hive-ag3nt`) for all agents. There
|
service unit (`systemd.services.hive-ag3nt`) for all agents. There
|
||||||
is no longer a separate manager service name or role distinction in
|
is no longer a separate manager service name or role distinction in
|
||||||
the harness — privilege differences live server-side in the broker
|
the harness — privilege differences live server-side in the broker
|
||||||
socket (which tool groups and manager-surface calls each agent
|
socket (which tool groups and manager-surface calls each agent
|
||||||
receives).
|
receives).
|
||||||
|
|
||||||
`agent-base.nix` and `manager.nix` both import `harness-base.nix`.
|
`agent.nix` and `ruth.nix` both import the shared `nix/agent-modules/`.
|
||||||
`manager.nix` additionally sets forge defaults to suppress the
|
`ruth.nix` additionally sets forge defaults to suppress the
|
||||||
subscription/participation firehose so ruth's inbox stays focused
|
subscription/participation firehose so ruth's inbox stays focused
|
||||||
on direct mentions, reviews, and assignments.
|
on direct mentions, reviews, and assignments.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,6 @@ GC on the coordinator host won't reclaim space on the builder.
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- `nix/modules/hive-ci.nix`: runner configuration, auto-registration script, container setup.
|
- `nix/host-modules/hive-ci.nix`: runner configuration, auto-registration script, container setup.
|
||||||
- `.forgejo/workflows/ci.yml`: workflow definition.
|
- `.forgejo/workflows/ci.yml`: workflow definition.
|
||||||
- `docs/gotchas.md`: nix sandboxing limitations in containers.
|
- `docs/gotchas.md`: nix sandboxing limitations in containers.
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,7 @@ now set unconditionally for every agent. The mechanism:
|
||||||
|
|
||||||
1. **Agent side**. `HIVE_WEB_SOCKET=/run/hive-agent/<name>/web.sock`
|
1. **Agent side**. `HIVE_WEB_SOCKET=/run/hive-agent/<name>/web.sock`
|
||||||
is set on every harness service env; `web_ui::serve` binds a
|
is set on every harness service env; `web_ui::serve` binds a
|
||||||
`UnixListener` at that path. The deprecated
|
`UnixListener` at that path.
|
||||||
`hyperhive.web.useUnixSocket` option is now a no-op.
|
|
||||||
2. **Host side**. `hive-c0re` bind-mounts the per-agent subdir
|
2. **Host side**. `hive-c0re` bind-mounts the per-agent subdir
|
||||||
(`/run/hive-agent/<name>/`) into the agent's container. Dir
|
(`/run/hive-agent/<name>/`) into the agent's container. Dir
|
||||||
bind, not file bind — file bind-mounts don't survive the
|
bind, not file bind — file bind-mounts don't survive the
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ socket without needing a clean reinstall.
|
||||||
## `claude-code` is unfree
|
## `claude-code` is unfree
|
||||||
|
|
||||||
`claude-code` comes from the flake's main `nixpkgs` (nixos-26.05).
|
`claude-code` comes from the flake's main `nixpkgs` (nixos-26.05).
|
||||||
It's unfree, so `harness-base.nix` sets `config.allowUnfreePredicate`
|
It's unfree, so the agent modules set `config.allowUnfreePredicate`
|
||||||
at the container level to whitelist `claude-code` specifically —
|
at the container level to whitelist `claude-code` specifically —
|
||||||
scoped, only this one package. This is needed because each per-agent
|
scoped, only this one package. This is needed because each per-agent
|
||||||
`nixosConfiguration` evaluates its own nixpkgs instance and the
|
`nixosConfiguration` evaluates its own nixpkgs instance and the
|
||||||
|
|
@ -204,7 +204,7 @@ containers don't get user-namespaces by default, so `nix build`
|
||||||
invocations _inside_ the container can't set up the build sandbox
|
invocations _inside_ the container can't set up the build sandbox
|
||||||
and fail outright if the host daemon's
|
and fail outright if the host daemon's
|
||||||
`nix.settings.sandbox-fallback` is `false` (nixpkgs default).
|
`nix.settings.sandbox-fallback` is `false` (nixpkgs default).
|
||||||
`nix/templates/harness-base.nix` does `lib.mkForce true` so builds
|
`nix/agent-modules/default.nix` does `lib.mkForce true` so builds
|
||||||
fall back to unsandboxed local builds rather than failing. Security
|
fall back to unsandboxed local builds rather than failing. Security
|
||||||
implications: `docs/security.md`.
|
implications: `docs/security.md`.
|
||||||
|
|
||||||
|
|
@ -232,7 +232,7 @@ CI on drift).
|
||||||
|
|
||||||
## Split asset derivations away from the rust workspace
|
## Split asset derivations away from the rust workspace
|
||||||
|
|
||||||
`nix/assets.nix` builds the branding SVG/PNG family + claude
|
`nix/packages/assets.nix` builds the branding SVG/PNG family + claude
|
||||||
system-prompt template + claude-settings JSON as its own derivation,
|
system-prompt template + claude-settings JSON as its own derivation,
|
||||||
separate from the hive-ag3nt / hive-c0re crates. Reason: when the
|
separate from the hive-ag3nt / hive-c0re crates. Reason: when the
|
||||||
rust build's `src` was the whole repo tree, any tweak to
|
rust build's `src` was the whole repo tree, any tweak to
|
||||||
|
|
@ -246,7 +246,7 @@ derivation's `nativeBuildInputs`.
|
||||||
|
|
||||||
## Weston VNC compositor (per-agent `hyperhive.gui.enable`)
|
## Weston VNC compositor (per-agent `hyperhive.gui.enable`)
|
||||||
|
|
||||||
`nix/templates/weston-vnc.nix` adds an optional Weston Wayland
|
`nix/agent-modules/weston-vnc.nix` adds an optional Weston Wayland
|
||||||
compositor with the VNC backend, surfaced as
|
compositor with the VNC backend, surfaced as
|
||||||
`hyperhive.gui.enable = true` per-agent. The harness's
|
`hyperhive.gui.enable = true` per-agent. The harness's
|
||||||
`/screen/ws` WebSocket relay (`docs/web-ui/agent.md::Per-agent endpoints`)
|
`/screen/ws` WebSocket relay (`docs/web-ui/agent.md::Per-agent endpoints`)
|
||||||
|
|
@ -284,7 +284,7 @@ connects to the compositor at `127.0.0.1:<vnc_port>`.
|
||||||
inherit it.
|
inherit it.
|
||||||
- **Fixed Wayland socket name (`--socket=wayland-0`)**: weston is
|
- **Fixed Wayland socket name (`--socket=wayland-0`)**: weston is
|
||||||
launched with `--socket=wayland-0` so the socket path is
|
launched with `--socket=wayland-0` so the socket path is
|
||||||
deterministic. `harness-base.nix` exports `WAYLAND_DISPLAY=wayland-0`
|
deterministic. `nix/agent-modules/weston-vnc.nix` exports `WAYLAND_DISPLAY=wayland-0`
|
||||||
and `XDG_RUNTIME_DIR=/run/gui` as global system environment
|
and `XDG_RUNTIME_DIR=/run/gui` as global system environment
|
||||||
variables (gated on `hyperhive.gui.enable`) so every systemd service
|
variables (gated on `hyperhive.gui.enable`) so every systemd service
|
||||||
in the container inherits them. Without this, services starting
|
in the container inherits them. Without this, services starting
|
||||||
|
|
@ -311,7 +311,7 @@ connects to the compositor at `127.0.0.1:<vnc_port>`.
|
||||||
must never block on weston signalling readiness. A misconfigured
|
must never block on weston signalling readiness. A misconfigured
|
||||||
weston degrades to a `Restart=on-failure` loop visible in
|
weston degrades to a `Restart=on-failure` loop visible in
|
||||||
`journalctl`, it does not abort the `nixos-container update`.
|
`journalctl`, it does not abort the `nixos-container update`.
|
||||||
Same reasoning as the `tea-login` unit in `harness-base.nix`.
|
Same reasoning as the `tea-login` unit in `nix/agent-modules/forge.nix`.
|
||||||
- **`[core] idle-time=0`**: disables weston's 300-second idle
|
- **`[core] idle-time=0`**: disables weston's 300-second idle
|
||||||
timeout. Without it the VNC desktop fades to black and
|
timeout. Without it the VNC desktop fades to black and
|
||||||
desktop-shell shows its click-to-unlock screen — useless for an
|
desktop-shell shows its click-to-unlock screen — useless for an
|
||||||
|
|
@ -323,9 +323,9 @@ connects to the compositor at `127.0.0.1:<vnc_port>`.
|
||||||
## Nix options reference (`nix/docs/default.nix`)
|
## Nix options reference (`nix/docs/default.nix`)
|
||||||
|
|
||||||
`pkgs.nixosOptionsDoc` over two evaluated module trees:
|
`pkgs.nixosOptionsDoc` over two evaluated module trees:
|
||||||
`hostEval` (a stub NixOS system loading `hive-c0re.nix` with every
|
`hostEval` (a stub NixOS system loading the `nix/host-modules/` aggregator with every
|
||||||
hyperhive subsystem `mkForce false` so heavy build inputs stay out of
|
hyperhive subsystem `mkForce false` so heavy build inputs stay out of
|
||||||
the eval) and `agentEval` (evaluates `agent-base.nix` fresh for the
|
the eval) and `agentEval` (evaluates `agent.nix` fresh for the
|
||||||
per-agent options tree).
|
per-agent options tree).
|
||||||
|
|
||||||
Three output trees consumed by `flake.nix`, all **markdown**:
|
Three output trees consumed by `flake.nix`, all **markdown**:
|
||||||
|
|
@ -333,7 +333,7 @@ Three output trees consumed by `flake.nix`, all **markdown**:
|
||||||
- `docs-host` — operator-facing host module options
|
- `docs-host` — operator-facing host module options
|
||||||
(`services.hyperhive.*`)
|
(`services.hyperhive.*`)
|
||||||
- `docs-agent` — per-agent harness options (`hyperhive.*`
|
- `docs-agent` — per-agent harness options (`hyperhive.*`
|
||||||
declared in `nix/templates/harness-base.nix`)
|
declared in `nix/agent-modules/`)
|
||||||
- `docs` — bundle of `index.md` + `host.md` + `agent.md`
|
- `docs` — bundle of `index.md` + `host.md` + `agent.md`
|
||||||
|
|
||||||
Pipeline:
|
Pipeline:
|
||||||
|
|
@ -356,7 +356,7 @@ options tree picks up everything under that root — picking against
|
||||||
stray roots produces an empty tree and renders the host page as
|
stray roots produces an empty tree and renders the host page as
|
||||||
template chrome with no `<h2>` headers.
|
template chrome with no `<h2>` headers.
|
||||||
|
|
||||||
### Docs drv stability: `nixSrc` + stub overlay
|
### Docs drv stability: `nixSrc`
|
||||||
|
|
||||||
Naively, the docs evaluation depends on `self` (the flake's store path),
|
Naively, the docs evaluation depends on `self` (the flake's store path),
|
||||||
so every commit — even Rust-only or frontend-only changes — produces new
|
so every commit — even Rust-only or frontend-only changes — produces new
|
||||||
|
|
@ -371,11 +371,11 @@ The fix (`nix/docs/default.nix`):
|
||||||
context. The resulting store path is content-addressed from the nix/
|
context. The resulting store path is content-addressed from the nix/
|
||||||
file contents only. Docs drvs only change when a `.nix` file changes.
|
file contents only. Docs drvs only change when a `.nix` file changes.
|
||||||
|
|
||||||
2. **`docsStubOverlay`** — replaces `self.overlays.default` with stub
|
2. The package options the modules consume (`hyperhive.packages.*`,
|
||||||
packages (`pkgs.emptyFile` / `pkgs.emptyDirectory`) for the docs eval.
|
`services.hyperhive.c0re.*`) carry no in-module defaults and every
|
||||||
`nixosOptionsDoc` renders `defaultText` for all package options anyway;
|
default that references them has a `defaultText`, so the doc walk
|
||||||
the stubs prevent attribute-missing eval errors without pulling in the
|
never forces a package — no stubs needed, and the Rust/frontend
|
||||||
Rust or frontend build closure.
|
build closure stays out of the eval.
|
||||||
|
|
||||||
3. Both `hostEval` and `agentEval` are evaluated from `nixSrc` paths
|
3. Both `hostEval` and `agentEval` are evaluated from `nixSrc` paths
|
||||||
(not `self`), so the docs drv dependency chain ends at `nixSrc`.
|
(not `self`), so the docs drv dependency chain ends at `nixSrc`.
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ which has two upstream gaps for fluffychat's web target:
|
||||||
- `native_imaging`'s C source isn't built — emscripten isn't a
|
- `native_imaging`'s C source isn't built — emscripten isn't a
|
||||||
flutter-builder native build input.
|
flutter-builder native build input.
|
||||||
|
|
||||||
Both fixed in `nix/modules/hive-matrix.nix` via two derivations:
|
Both fixed in `nix/host-modules/hive-matrix.nix` via two derivations:
|
||||||
|
|
||||||
- **`fluffychat-web-imaging`** builds `Imaging.{js,wasm}` from the
|
- **`fluffychat-web-imaging`** builds `Imaging.{js,wasm}` from the
|
||||||
`native_imaging` C source via `pkgs.emscripten`. Source comes
|
`native_imaging` C source via `pkgs.emscripten`. Source comes
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ Host-side bridge + per-agent private-netns isolation — always on
|
||||||
whenever hyperhive is enabled. Configured via
|
whenever hyperhive is enabled. Configured via
|
||||||
`services.hyperhive.network.*`.
|
`services.hyperhive.network.*`.
|
||||||
|
|
||||||
> **Historical note:** the bridge and private-netns isolation landed in
|
> Isolation is the only mode — there is no shared-netns fallback. The
|
||||||
> two separate phases. `services.hyperhive.network.enable` and
|
> former `services.hyperhive.network.enable`,
|
||||||
> `services.hyperhive.network.isolateContainers` are retained as
|
> `services.hyperhive.network.isolateContainers` and
|
||||||
> deprecated no-op options so existing configs eval without change; both
|
> `services.hyperhive.network.upstreamDns` options were removed; a
|
||||||
> are ignored — isolation is the only mode.
|
> config that still sets one fails eval with a removal message.
|
||||||
|
|
||||||
## Container shape (where dnsmasq lives)
|
## Container shape (where dnsmasq lives)
|
||||||
|
|
||||||
|
|
@ -26,7 +26,6 @@ listener on `bridgeIp` is on the host's bridge interface.
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "darkest.space";
|
domain = "darkest.space";
|
||||||
# network.bridgeIp = "10.42.0.1"; # default
|
# network.bridgeIp = "10.42.0.1"; # default
|
||||||
# network.upstreamDns = [ "1.1.1.1" "9.9.9.9" ]; # default
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -48,9 +47,12 @@ schemes pick their own.
|
||||||
dnsmasq is **authoritative** for the hive's own zones — answers
|
dnsmasq is **authoritative** for the hive's own zones — answers
|
||||||
`<hive-domain>`, `forge.<hive-domain>`, `matrix.<hive-domain>`
|
`<hive-domain>`, `forge.<hive-domain>`, `matrix.<hive-domain>`
|
||||||
queries with the bridge IP (where nginx is reachable). Everything
|
queries with the bridge IP (where nginx is reachable). Everything
|
||||||
else gets forwarded to `upstreamDns`. Containers don't need to know
|
else is forwarded to the host's own resolvers: dnsmasq reads the
|
||||||
the upstream — they query the bridge IP and dnsmasq does the right
|
gateway container's `/etc/resolv.conf`, the host copy nixos-container
|
||||||
thing per-name.
|
makes at each container start — a host resolver change is picked up
|
||||||
|
on the next gateway restart. Containers don't need to know the
|
||||||
|
upstream — they query the bridge IP and dnsmasq does the right thing
|
||||||
|
per-name.
|
||||||
|
|
||||||
`bind-interfaces` + `interface = [ bridgeName "lo" ]` means the
|
`bind-interfaces` + `interface = [ bridgeName "lo" ]` means the
|
||||||
listener only accepts queries from the bridge interface (plus lo for
|
listener only accepts queries from the bridge interface (plus lo for
|
||||||
|
|
@ -129,7 +131,7 @@ address arithmetic.
|
||||||
and `HOST_BRIDGE=<bridgeName>` via `lifecycle::set_nspawn_flags` when
|
and `HOST_BRIDGE=<bridgeName>` via `lifecycle::set_nspawn_flags` when
|
||||||
creating or updating containers. `LOCAL_ADDRESS` is left empty so the
|
creating or updating containers. `LOCAL_ADDRESS` is left empty so the
|
||||||
container's dhcpcd acquires an address from the bridge dnsmasq pool
|
container's dhcpcd acquires an address from the bridge dnsmasq pool
|
||||||
(`networking.useDHCP = true` in `harness-base.nix`). This applies uniformly
|
(`networking.useDHCP = true` in `nix/agent-modules/network.nix`). This applies uniformly
|
||||||
to all containers — agents and service containers alike.
|
to all containers — agents and service containers alike.
|
||||||
|
|
||||||
`HOST_ADDRESS` is the bridge gateway IP (the address part of
|
`HOST_ADDRESS` is the bridge gateway IP (the address part of
|
||||||
|
|
@ -154,7 +156,7 @@ wiring is runtime:
|
||||||
|
|
||||||
- `hive-priv` drops a marker file (`/etc/hyperhive-bridge-dns`, carrying the
|
- `hive-priv` drops a marker file (`/etc/hyperhive-bridge-dns`, carrying the
|
||||||
gateway IP) into each container's `/etc`.
|
gateway IP) into each container's `/etc`.
|
||||||
- the `hyperhive-isolated-dns` oneshot (harness-base.nix), gated on that
|
- the `hyperhive-isolated-dns` oneshot (`nix/agent-modules/network.nix`), gated on that
|
||||||
marker, rewrites `/etc/resolv.conf` to `nameserver <gateway-ip>` at boot.
|
marker, rewrites `/etc/resolv.conf` to `nameserver <gateway-ip>` at boot.
|
||||||
It is ordered `before` the harness (`hive-ag3nt`), the matrix daemon, and
|
It is ordered `before` the harness (`hive-ag3nt`), the matrix daemon, and
|
||||||
`tea-login` so the resolver is correct before the first DNS lookup.
|
`tea-login` so the resolver is correct before the first DNS lookup.
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ state dirs need a one-time data shuffle so they don't lose their claude
|
||||||
session.
|
session.
|
||||||
|
|
||||||
`system.activationScripts.hive-agent-user-migrate` (in
|
`system.activationScripts.hive-agent-user-migrate` (in
|
||||||
`nix/templates/harness-base.nix`) runs on every activation,
|
`nix/agent-modules/user.nix`) runs on every activation,
|
||||||
marker-guarded so the substantive moves only happen once per
|
marker-guarded so the substantive moves only happen once per
|
||||||
container lifetime:
|
container lifetime:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ component can't traverse.
|
||||||
Agent containers bind-mount the host's `nix-daemon` socket. The host daemon may
|
Agent containers bind-mount the host's `nix-daemon` socket. The host daemon may
|
||||||
have `sandbox-fallback = false` (strict NixOS defaults), which causes `nix build`
|
have `sandbox-fallback = false` (strict NixOS defaults), which causes `nix build`
|
||||||
inside nspawn containers to fail — containers lack kernel user namespaces, so nix
|
inside nspawn containers to fail — containers lack kernel user namespaces, so nix
|
||||||
cannot set up its build sandbox. `harness-base.nix` sets `sandbox-fallback = true`
|
cannot set up its build sandbox. the agent modules set `sandbox-fallback = true`
|
||||||
so that builds fall back to unsandboxed execution rather than failing outright.
|
so that builds fall back to unsandboxed execution rather than failing outright.
|
||||||
|
|
||||||
### Threat model
|
### Threat model
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Background shell execution via `hive-bash-mcp`. Tools land as
|
Background shell execution via `hive-bash-mcp`. Tools land as
|
||||||
`mcp__bash__<tool>` (the MCP server name is `bash`, not `hyperhive`).
|
`mcp__bash__<tool>` (the MCP server name is `bash`, not `hyperhive`).
|
||||||
Available on every agent unconditionally — `harness-base.nix` always
|
Available on every agent unconditionally — `nix/agent-modules/mcp.nix` always
|
||||||
injects bash into `hyperhive.extraMcpServers` (with `allowedTools =
|
injects bash into `hyperhive.extraMcpServers` (with `allowedTools =
|
||||||
["*"]`), so `mcp__bash__*` is in `--allowedTools` for every claude
|
["*"]`), so `mcp__bash__*` is in `--allowedTools` for every claude
|
||||||
invocation regardless of tool groups.
|
invocation regardless of tool groups.
|
||||||
|
|
@ -96,7 +96,7 @@ The bash tooling follows the same daemon + stdio-bridge pattern as the
|
||||||
matrix MCP:
|
matrix MCP:
|
||||||
|
|
||||||
- **`hive-bash-daemon`** — long-running process (one per agent container,
|
- **`hive-bash-daemon`** — long-running process (one per agent container,
|
||||||
systemd service in `harness-base.nix`). Owns subprocess management,
|
systemd service in `nix/agent-modules/mcp.nix`). Owns subprocess management,
|
||||||
output file writing, `mcp-loose-ends/` state, and wake signal delivery.
|
output file writing, `mcp-loose-ends/` state, and wake signal delivery.
|
||||||
Listens on `/run/hive-bash/socket` inside the container.
|
Listens on `/run/hive-bash/socket` inside the container.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# hive-forge CLI
|
# hive-forge CLI
|
||||||
|
|
||||||
`hive-forge` is the Forgejo API wrapper available in every agent
|
`hive-forge` is the Forgejo API wrapper available in every agent
|
||||||
container (installed via `harness-base.nix`; lives in `/hive-forge`
|
container (installed via `nix/agent-modules/forge.nix`; lives in `/hive-forge`
|
||||||
as a proper Rust binary). Use it instead of ad-hoc curl pipelines.
|
as a proper Rust binary). Use it instead of ad-hoc curl pipelines.
|
||||||
|
|
||||||
## Credentials and repo defaults
|
## Credentials and repo defaults
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ parsed from a turn (usage, cost, context window, resolved model) as
|
||||||
|
|
||||||
Hive-enforced settings ship at `/etc/claude-code/managed-settings.json`
|
Hive-enforced settings ship at `/etc/claude-code/managed-settings.json`
|
||||||
(claude-code's canonical managed-settings path — precedence #1,
|
(claude-code's canonical managed-settings path — precedence #1,
|
||||||
read-only, un-overridable), wired in `nix/templates/harness-base.nix`
|
read-only, un-overridable), wired in `nix/agent-modules/claude-settings.nix`
|
||||||
from the `prompts/claude-settings.json` asset. `effortLevel` is
|
from the `prompts/claude-settings.json` asset. `effortLevel` is
|
||||||
deliberately not in that file — effort is controlled live via the
|
deliberately not in that file — effort is controlled live via the
|
||||||
`--effort` flag (`HIVE_DEFAULT_EFFORT` / the per-agent UI slider), which
|
`--effort` flag (`HIVE_DEFAULT_EFFORT` / the per-agent UI slider), which
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ sentence into the agent's system prompt so it knows the docs exist and
|
||||||
where to find them. The tree is served by `claude --add-dir` so the full
|
where to find them. The tree is served by `claude --add-dir` so the full
|
||||||
markdown is readable during every turn.
|
markdown is readable during every turn.
|
||||||
|
|
||||||
Enabled by default only for the root/manager agent (`manager.nix`). Any
|
Enabled by default only for the root/manager agent (`nix/templates/ruth.nix`). Any
|
||||||
agent can opt in by adding the line above to its `agent.nix`.
|
agent can opt in by adding the line above to its `agent.nix`.
|
||||||
|
|
||||||
The `docs/` source is a narrow flake input (`hyperhive-docs`) tracked
|
The `docs/` source is a narrow flake input (`hyperhive-docs`) tracked
|
||||||
|
|
|
||||||
594
flake.nix
594
flake.nix
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
||||||
# Crane (replaces the former naersk-based build). Stateless — no nixpkgs input to
|
# Crane is stateless — no nixpkgs input to follow; `crane.mkLib
|
||||||
# follow; `crane.mkLib pkgs` returns the lib at whatever pkgs we
|
# pkgs` returns the lib at whatever pkgs we pass it (we use the
|
||||||
# pass it (we use the project's pinned nixpkgs).
|
# project's pinned nixpkgs).
|
||||||
crane.url = "github:ipetkov/crane";
|
crane.url = "github:ipetkov/crane";
|
||||||
treefmt-nix = {
|
treefmt-nix = {
|
||||||
url = "github:numtide/treefmt-nix";
|
url = "github:numtide/treefmt-nix";
|
||||||
|
|
@ -13,6 +13,14 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Thin entry point — the real logic lives under nix/:
|
||||||
|
# nix/sources.nix filtered source views (meta-flake + docs inputs)
|
||||||
|
# nix/rust.nix shared crane wiring (cleanSrc, cargoArtifacts)
|
||||||
|
# nix/packages/ every package output
|
||||||
|
# nix/checks.nix flake checks
|
||||||
|
# nix/devshell.nix dev shell
|
||||||
|
# nix/treefmt.nix formatter config
|
||||||
|
# nix/host-modules/, nix/agent-modules/, nix/templates/ the NixOS module trees
|
||||||
outputs =
|
outputs =
|
||||||
inputs@{
|
inputs@{
|
||||||
self,
|
self,
|
||||||
|
|
@ -26,61 +34,7 @@
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
];
|
];
|
||||||
# Explicit per-consumer source filter for the hyperhive flake path
|
sources = import ./nix/sources.nix { inherit lib; };
|
||||||
# handed to hive-c0re (`hyperhiveFlake`, below). A filtered view of
|
|
||||||
# this repo that drops files no nix or cargo derivation reads —
|
|
||||||
# shell helper scripts and root-level markdown — so editing them
|
|
||||||
# does NOT change the store path and therefore does NOT force a
|
|
||||||
# rebuild of every agent container.
|
|
||||||
#
|
|
||||||
# Companion to the rust `cleanSrc` (crane's cargo-source filter):
|
|
||||||
# each real source is a named, explicitly-filtered derivation used
|
|
||||||
# as `src`, rather than an inline filter at the use site.
|
|
||||||
#
|
|
||||||
# Dropped: scripts/, docs/, root-level *.md (README/CLAUDE/TODO/…).
|
|
||||||
# Kept (build needs them): .nix, .rs, Cargo.*, branding/,
|
|
||||||
# frontend/, prompts/, flake.lock. docs/ is deliberately dropped:
|
|
||||||
# it is shipped to agent containers as its OWN narrow
|
|
||||||
# meta-flake input (`hyperhiveDocsSource`, below), threaded through
|
|
||||||
# hive-c0re → the meta flake → `hyperhive.docs.source`. Keeping docs/
|
|
||||||
# out of THIS source means a doc edit only re-hashes the docs input
|
|
||||||
# (a cheap re-link), not the whole flake source (which would rebuild
|
|
||||||
# every agent container). The old `nix/reference-docs.nix` build from
|
|
||||||
# `../docs` stays only for standalone `nix build .#reference-docs`
|
|
||||||
# from a full checkout — the meta path never evaluates it.
|
|
||||||
hyperhiveFlakeSource = lib.cleanSourceWith {
|
|
||||||
name = "hyperhive-flake-source";
|
|
||||||
src = ./.;
|
|
||||||
filter =
|
|
||||||
path: type:
|
|
||||||
let
|
|
||||||
# Repo-relative path (strip the absolute source-dir prefix).
|
|
||||||
rel = lib.removePrefix (toString ./. + "/") (toString path);
|
|
||||||
in
|
|
||||||
!(lib.hasPrefix "scripts/" rel || rel == "scripts")
|
|
||||||
&& !(lib.hasPrefix "docs/" rel || rel == "docs")
|
|
||||||
&& !(type == "regular" && !lib.hasInfix "/" rel && lib.hasSuffix ".md" rel);
|
|
||||||
};
|
|
||||||
# The repo `docs/` tree as a standalone narrow source. Its
|
|
||||||
# store path moves ONLY on doc edits, decoupled from
|
|
||||||
# `hyperhiveFlakeSource`. hive-c0re threads this to the meta flake as
|
|
||||||
# the `hyperhive-docs` input (same pattern as `hyperhiveFlake`); the
|
|
||||||
# harness resolves `$HIVE_DOCS_DIR` from it via `hyperhive.docs.source`.
|
|
||||||
# Evaluated here on the host where docs/ exists — it cannot be derived
|
|
||||||
# from inside the docs-stripped `hyperhiveFlakeSource`.
|
|
||||||
hyperhiveDocsSource = lib.cleanSourceWith {
|
|
||||||
name = "hyperhive-docs-source";
|
|
||||||
src = ./docs;
|
|
||||||
};
|
|
||||||
treefmt-config = {
|
|
||||||
projectRootFile = "flake.nix";
|
|
||||||
programs = {
|
|
||||||
keep-sorted.enable = true;
|
|
||||||
nixfmt.enable = true;
|
|
||||||
rustfmt.enable = true;
|
|
||||||
taplo.enable = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
forAllSystems =
|
forAllSystems =
|
||||||
f:
|
f:
|
||||||
lib.genAttrs systems (
|
lib.genAttrs systems (
|
||||||
|
|
@ -88,70 +42,9 @@
|
||||||
f rec {
|
f rec {
|
||||||
inherit system;
|
inherit system;
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
treefmt-eval = treefmt-nix.lib.evalModule pkgs treefmt-config;
|
treefmt-eval = treefmt-nix.lib.evalModule pkgs (import ./nix/treefmt.nix);
|
||||||
craneLib = crane.mkLib pkgs;
|
craneLib = crane.mkLib pkgs;
|
||||||
# Narrowed source tree the rust derivations consume.
|
rust = import ./nix/rust.nix { inherit pkgs craneLib; };
|
||||||
# `cleanCargoSource` is crane's standard "everything cargo
|
|
||||||
# cares about" filter (Cargo.toml/Cargo.lock + *.rs). All
|
|
||||||
# non-rust runtime assets — branding + the claude system
|
|
||||||
# prompt template + claude-settings.json — live in the
|
|
||||||
# separate `hyperhive-assets` derivation and are
|
|
||||||
# loaded by the binaries at runtime from `$HIVE_ASSETS_DIR`.
|
|
||||||
# The unit tests in `hive-ag3nt::prompt` read the same
|
|
||||||
# `prompts/system.md` directly from the workspace tree at
|
|
||||||
# *test* runtime (via `env!("CARGO_MANIFEST_DIR")` — a
|
|
||||||
# compile-time string, no file open at compile), so the
|
|
||||||
# prompt template doesn't have to be in this fileset to
|
|
||||||
# keep `cargo test` honest. Net effect: tweaks to any
|
|
||||||
# non-`*.rs` / non-`Cargo.*` file (README, branding,
|
|
||||||
# nix modules, frontend tree, OR `hive-ag3nt/prompts/*`)
|
|
||||||
# do NOT bust this src hash, so the rust derivations
|
|
||||||
# stay fully cached.
|
|
||||||
cleanSrc = craneLib.cleanCargoSource ./.;
|
|
||||||
# Build the workspace's dependency tree once, cached as
|
|
||||||
# its own derivation. `buildPackage` and `cargoClippy`
|
|
||||||
# both reuse this via `inherit cargoArtifacts;` so a
|
|
||||||
# workspace-only edit doesn't rebuild deps. All three
|
|
||||||
# derivations consume the same `cleanSrc` so the input
|
|
||||||
# hash stays consistent across the chain.
|
|
||||||
cargoArtifacts = craneLib.buildDepsOnly {
|
|
||||||
src = cleanSrc;
|
|
||||||
# Workspace Cargo.toml is virtual (no `[package].name`),
|
|
||||||
# so crane can't auto-derive a name. Spell it out
|
|
||||||
# explicitly here and below — keeps the derivation name
|
|
||||||
# stable across crane bumps + silences the placeholder
|
|
||||||
# warning. Same `pname` everywhere so dep + workspace +
|
|
||||||
# clippy share a clean naming family.
|
|
||||||
pname = "hyperhive-workspace";
|
|
||||||
version = "0.1.0";
|
|
||||||
inherit nativeBuildInputs;
|
|
||||||
};
|
|
||||||
# Shared between buildDepsOnly + buildPackage + cargoClippy
|
|
||||||
# so the three derivations see the same toolchain shape.
|
|
||||||
# git: naersk used to auto-include it; crane is more
|
|
||||||
# minimal, so we add it explicitly so hive-c0re's
|
|
||||||
# `lifecycle::tests::setup_proposed_*` (which shell out to
|
|
||||||
# `git init` + commit) pass under `cargo test` in the
|
|
||||||
# sandbox.
|
|
||||||
# `librsvg` used to live here for `hive-c0re/build.rs`'s
|
|
||||||
# rsvg-convert call — that whole codepath moved into the
|
|
||||||
# `hyperhive-assets` derivation, so the rust
|
|
||||||
# derivation no longer needs the dependency.
|
|
||||||
# `sqlite` required by matrix-sdk's `sqlite` feature
|
|
||||||
# (`hive-matrix-mcp` workspace member) — the
|
|
||||||
# matrix-sdk-sqlite + rusqlite stack links against system
|
|
||||||
# libsqlite3 by default.
|
|
||||||
# `cmake` builds `aws-lc-sys` (BoringSSL) from source — pulled in by
|
|
||||||
# the `rustls` (aws-lc-rs) crypto provider under the OTLP/reqwest
|
|
||||||
# stack in `hive-metric`. Without it the crane deps build fails on
|
|
||||||
# `cargo-package-reqwest-0.13.4`. Kept in the shared inputs since
|
|
||||||
# more metric/crypto deps are expected to land in the workspace.
|
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.git
|
|
||||||
pkgs.sqlite
|
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.cmake
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
|
|
@ -160,272 +53,98 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
craneLib,
|
craneLib,
|
||||||
cleanSrc,
|
rust,
|
||||||
cargoArtifacts,
|
|
||||||
nativeBuildInputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
import ./nix/packages {
|
||||||
docsAttrs = import ./nix/docs {
|
inherit
|
||||||
inherit pkgs self;
|
pkgs
|
||||||
inherit (nixpkgs) lib;
|
craneLib
|
||||||
inherit (nixpkgs.lib) nixosSystem;
|
rust
|
||||||
};
|
self
|
||||||
# One package per daemon/harness/MCP-server binary — matches the
|
nixpkgs
|
||||||
# `hivectl` / `hive-forge` split below rather than grouping them
|
;
|
||||||
# into a single derivation. Consumers (agent containers, host
|
|
||||||
# module, `nix profile install`) depend on exactly the binaries
|
|
||||||
# they need instead of an all-or-nothing bundle. All share
|
|
||||||
# `cargoArtifacts` (built once via `buildDepsOnly` above), so
|
|
||||||
# splitting doesn't cost extra rustc invocations — each call
|
|
||||||
# below just asks crane to build+link its one requested `--bin`.
|
|
||||||
#
|
|
||||||
# Tests are kept in the separate `checks.cargo-test` derivation
|
|
||||||
# (carries the hyperhive-assets build input for the prompt-template
|
|
||||||
# assertions in hive-ag3nt::prompt::tests). Keeping them out of the
|
|
||||||
# binary derivations means a prompt edit doesn't bust the cargo cache.
|
|
||||||
mkDaemonBin =
|
|
||||||
bin: description:
|
|
||||||
craneLib.buildPackage {
|
|
||||||
src = cleanSrc;
|
|
||||||
inherit cargoArtifacts nativeBuildInputs;
|
|
||||||
cargoExtraArgs = "--bin ${bin}";
|
|
||||||
pname = bin;
|
|
||||||
version = "0.1.0";
|
|
||||||
meta.description = description;
|
|
||||||
doCheck = false;
|
|
||||||
};
|
|
||||||
hiveC0rePkg = mkDaemonBin "hive-c0re" "hyperhive host coordinator daemon";
|
|
||||||
hivePrivPkg = mkDaemonBin "hive-priv" "hyperhive privileged root helper";
|
|
||||||
hiveAgentPkg = mkDaemonBin "hive-agent" "hyperhive in-container agent harness serve loop";
|
|
||||||
hiveAgentMcpPkg = mkDaemonBin "hive-agent-mcp" "hyperhive agent-surface MCP server";
|
|
||||||
hiveAgentWakePkg = mkDaemonBin "hive-agent-wake" "hyperhive external wake CLI — push a message into an agent's own inbox";
|
|
||||||
hiveBashDaemonPkg = mkDaemonBin "hive-bash-daemon" "hyperhive per-agent bash-task runner daemon";
|
|
||||||
hiveBashMcpPkg = mkDaemonBin "hive-bash-mcp" "hyperhive bash-task MCP bridge";
|
|
||||||
hiveMatrixDaemonPkg = mkDaemonBin "hive-matrix-daemon" "hyperhive per-agent matrix-sdk daemon";
|
|
||||||
hiveMatrixMcpPkg = mkDaemonBin "hive-matrix-mcp" "hyperhive matrix MCP bridge";
|
|
||||||
hiveMetricPkg = mkDaemonBin "hive-metric" "hyperhive agent-emitted custom metrics CLI";
|
|
||||||
# Operator CLI — ships `hivectl` (with shell completions and the
|
|
||||||
# `wg` wrapper) without the daemon binaries. Suitable for
|
|
||||||
# `nix profile install .#hivectl` / `environment.systemPackages
|
|
||||||
# = [ inputs.hyperhive.packages.${system}.hivectl ]` when the
|
|
||||||
# operator only wants the admin CLI. Shares `cargoArtifacts` with
|
|
||||||
# `daemonBins` so there is no double-rustc cost.
|
|
||||||
hivectlPkg = craneLib.buildPackage {
|
|
||||||
src = cleanSrc;
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
cargoExtraArgs = "--bin hivectl";
|
|
||||||
pname = "hivectl";
|
|
||||||
version = "0.1.0";
|
|
||||||
meta.description = "hyperhive operator CLI";
|
|
||||||
doCheck = false;
|
|
||||||
# `installShellFiles` + `makeWrapper` scoped to this derivation
|
|
||||||
# only — daemon bins don't need them.
|
|
||||||
nativeBuildInputs = nativeBuildInputs ++ [
|
|
||||||
pkgs.installShellFiles
|
|
||||||
pkgs.makeWrapper
|
|
||||||
];
|
|
||||||
# Ship shell completions (the binary's own `completions <shell>`
|
|
||||||
# verb is the single source of truth, so they never drift from
|
|
||||||
# the actual verbs). Wrap with wireguard-tools so `hivectl wg`
|
|
||||||
# subcommands work before `swarm.wireguard.enable` is set (wg
|
|
||||||
# init is the very first setup step). Completion generation runs
|
|
||||||
# before wrapProgram since wrapProgram renames the real binary.
|
|
||||||
postInstall = ''
|
|
||||||
installShellCompletion --cmd hivectl \
|
|
||||||
--bash <("$out/bin/hivectl" completions bash) \
|
|
||||||
--zsh <("$out/bin/hivectl" completions zsh) \
|
|
||||||
--fish <("$out/bin/hivectl" completions fish)
|
|
||||||
wrapProgram "$out/bin/hivectl" \
|
|
||||||
--prefix PATH : ${pkgs.wireguard-tools}/bin
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
# Forgejo CLI — ships `hive-forge` without the rest of the
|
|
||||||
# workspace. Useful for operator workstations / CI environments
|
|
||||||
# that only need forge access. Shares `cargoArtifacts` with
|
|
||||||
# `daemonBins`.
|
|
||||||
hiveForgePkg = craneLib.buildPackage {
|
|
||||||
src = cleanSrc;
|
|
||||||
inherit cargoArtifacts nativeBuildInputs;
|
|
||||||
cargoExtraArgs = "--bin hive-forge";
|
|
||||||
pname = "hive-forge";
|
|
||||||
version = "0.1.0";
|
|
||||||
meta.description = "hyperhive Forgejo CLI";
|
|
||||||
doCheck = false;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# All workspace binaries in one derivation via symlinkJoin.
|
|
||||||
# Each binary is compiled exactly once (one rustc per bin, all
|
|
||||||
# sharing `cargoArtifacts`); symlinkJoin assembles the outputs
|
|
||||||
# without any additional compilation. The NixOS module's
|
|
||||||
# `pkgs.hyperhive` (= this) and `nix build .#` both land here.
|
|
||||||
default = pkgs.symlinkJoin {
|
|
||||||
name = "hyperhive";
|
|
||||||
paths = [
|
|
||||||
hiveC0rePkg
|
|
||||||
hivePrivPkg
|
|
||||||
hiveAgentPkg
|
|
||||||
hiveAgentMcpPkg
|
|
||||||
hiveAgentWakePkg
|
|
||||||
hiveBashDaemonPkg
|
|
||||||
hiveBashMcpPkg
|
|
||||||
hiveMatrixDaemonPkg
|
|
||||||
hiveMatrixMcpPkg
|
|
||||||
hiveMetricPkg
|
|
||||||
hivectlPkg
|
|
||||||
hiveForgePkg
|
|
||||||
];
|
|
||||||
};
|
|
||||||
# Per-bin split packages. Agent containers depend on the
|
|
||||||
# individual bins they actually exec/PATH-need (see
|
|
||||||
# `harness-base.nix`) instead of the `default` bundle — that
|
|
||||||
# keeps `hivectl` (dials the *host* admin socket, unreachable
|
|
||||||
# from inside a container, drags in `wireguard-tools`) and a
|
|
||||||
# redundant `hive-forge` copy (already on agent PATH via
|
|
||||||
# `hive-forge-tools.nix`) out of every agent's closure.
|
|
||||||
hivectl = hivectlPkg;
|
|
||||||
hive-forge = hiveForgePkg;
|
|
||||||
hive-c0re = hiveC0rePkg;
|
|
||||||
hive-priv = hivePrivPkg;
|
|
||||||
hive-agent = hiveAgentPkg;
|
|
||||||
hive-agent-mcp = hiveAgentMcpPkg;
|
|
||||||
hive-agent-wake = hiveAgentWakePkg;
|
|
||||||
hive-bash-daemon = hiveBashDaemonPkg;
|
|
||||||
hive-bash-mcp = hiveBashMcpPkg;
|
|
||||||
hive-matrix-daemon = hiveMatrixDaemonPkg;
|
|
||||||
hive-matrix-mcp = hiveMatrixMcpPkg;
|
|
||||||
hive-metric = hiveMetricPkg;
|
|
||||||
# Bundled browser assets — see ./nix/frontend.nix. Output is
|
|
||||||
# $out/{dashboard,agent}/ which the Rust binaries serve via
|
|
||||||
# tower_http::ServeDir.
|
|
||||||
frontend = pkgs.callPackage ./nix/frontend.nix {
|
|
||||||
branding-svg = ./branding/hyperhive.svg;
|
|
||||||
};
|
|
||||||
# Static runtime assets the rust binaries read via
|
|
||||||
# `hive_sh4re::assets::*`: branding/* + prompts/*,
|
|
||||||
# plus the rendered agent-configs.png. Split out of the
|
|
||||||
# rust derivation so a tweak to e.g. system.md doesn't bust
|
|
||||||
# the cargo cache. Build input of the `cargo-test` check but
|
|
||||||
# NOT of `packages.default`, so the binary derivation stays
|
|
||||||
# cached when a prompt edit ripples through.
|
|
||||||
assets = pkgs.callPackage ./nix/assets.nix { };
|
|
||||||
# The repo docs/ markdown tree as a standalone derivation —
|
|
||||||
# agents read it in-container (added as a claude additional
|
|
||||||
# directory) and the website repo reuses it as a flake input,
|
|
||||||
# neither of which needs the branding/prompt assets. See
|
|
||||||
# nix/reference-docs.nix. (`docs` above is the auto-generated
|
|
||||||
# nix-options reference, a different artifact.)
|
|
||||||
reference-docs = pkgs.callPackage ./nix/reference-docs.nix { };
|
|
||||||
# XDG icon set + .desktop entries for hyperhive processes.
|
|
||||||
# Narrow input: only the branding SVG, so unrelated source changes
|
|
||||||
# don't bust this derivation's cache.
|
|
||||||
xdg-icons = pkgs.callPackage ./nix/packages/hive-xdg-icons.nix {
|
|
||||||
hyperhiveSvg = ./branding/hyperhive.svg;
|
|
||||||
};
|
|
||||||
# Pre-built per-container system closures. Exposed as packages
|
|
||||||
# so operators can `nix build .#agent-base-toplevel` (or wire
|
|
||||||
# them into their host system closure via the
|
|
||||||
# `preBuildAgentTemplates` option on the hive-c0re module —
|
|
||||||
# see nix/modules/hive-c0re.nix). Speeds up the first agent
|
|
||||||
# spawn dramatically because the heavy lifting (nixpkgs +
|
|
||||||
# claude-code + hive-ag3nt binary) is already in the store
|
|
||||||
# when the meta evaluator goes to build the container.
|
|
||||||
#
|
|
||||||
# nixosConfigurations are pinned to x86_64-linux (nixos-
|
|
||||||
# containers only run native arch), so these toplevels are
|
|
||||||
# only useful on an x86_64-linux host — flake check across
|
|
||||||
# systems still tolerates evaluating them on aarch64 because
|
|
||||||
# they're plain derivations, but `nix build` from a non-x86
|
|
||||||
# host would only succeed via a remote x86 builder.
|
|
||||||
agent-base-toplevel = self.nixosConfigurations.agent-base.config.system.build.toplevel;
|
|
||||||
ruth-toplevel = self.nixosConfigurations.ruth.config.system.build.toplevel;
|
|
||||||
|
|
||||||
# Auto-generated nix options reference for hyperhive.
|
|
||||||
# `docs` bundles host + agent pages into one tree; the split
|
|
||||||
# outputs are useful when consumers only want one surface.
|
|
||||||
# All three are pure markdown — no rust or frontend deps in
|
|
||||||
# the closure, so `nix build .#docs` is cheap.
|
|
||||||
docs = docsAttrs.bundle;
|
|
||||||
docs-host = docsAttrs.host;
|
|
||||||
docs-agent = docsAttrs.agent;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
overlays = {
|
nixosModules =
|
||||||
default = final: prev: {
|
let
|
||||||
hyperhive = self.packages.${prev.stdenv.hostPlatform.system}.default;
|
# Package wiring for agent containers — the harness modules
|
||||||
# Per-binary daemon/harness/MCP-server packages, exposed via the
|
# consume hyperhive's own packages via the `hyperhive.packages`
|
||||||
# overlay so container nix evaluations can depend on exactly the
|
# option (see nix/agent-modules/packages.nix); no overlay.
|
||||||
# bin(s) they need instead of the full `hyperhive` bundle — see
|
# The `mkDefault` is applied PER KEY (`mapAttrs`), not to the
|
||||||
# `packages.<system>.hive-*` above and their use in
|
# whole attrset: definition-level priority filtering runs
|
||||||
# `harness-base.nix`.
|
# before `attrsOf`'s per-key merge, so a whole-set `mkDefault`
|
||||||
hive-c0re = self.packages.${prev.stdenv.hostPlatform.system}.hive-c0re;
|
# would be discarded entirely the moment an agent.nix
|
||||||
hive-priv = self.packages.${prev.stdenv.hostPlatform.system}.hive-priv;
|
# overrides a single key. Per-key priorities make an
|
||||||
hive-agent = self.packages.${prev.stdenv.hostPlatform.system}.hive-agent;
|
# individual override win while every other key keeps the
|
||||||
hive-agent-mcp = self.packages.${prev.stdenv.hostPlatform.system}.hive-agent-mcp;
|
# flake default.
|
||||||
hive-agent-wake = self.packages.${prev.stdenv.hostPlatform.system}.hive-agent-wake;
|
agentPackages =
|
||||||
hive-bash-daemon = self.packages.${prev.stdenv.hostPlatform.system}.hive-bash-daemon;
|
{ lib, pkgs, ... }:
|
||||||
hive-bash-mcp = self.packages.${prev.stdenv.hostPlatform.system}.hive-bash-mcp;
|
{
|
||||||
hive-matrix-daemon = self.packages.${prev.stdenv.hostPlatform.system}.hive-matrix-daemon;
|
hyperhive.packages = lib.mapAttrs (_: lib.mkDefault) {
|
||||||
hive-matrix-mcp = self.packages.${prev.stdenv.hostPlatform.system}.hive-matrix-mcp;
|
inherit (self.packages.${pkgs.stdenv.hostPlatform.system})
|
||||||
hive-metric = self.packages.${prev.stdenv.hostPlatform.system}.hive-metric;
|
hive-agent
|
||||||
# Bundled frontend dist (see ./nix/frontend.nix). Output is
|
hive-agent-mcp
|
||||||
# $out/{dashboard,agent}/; consumers pick the surface they
|
hive-agent-wake
|
||||||
# need. Exposed via the overlay so containers' nix evaluations
|
hive-bash-daemon
|
||||||
# can reach it as `pkgs.hyperhive-frontend` once the overlay
|
hive-bash-mcp
|
||||||
# is applied (manager + agent containers both apply it via
|
hive-forge
|
||||||
# `mkContainer` further down).
|
hive-matrix-daemon
|
||||||
hyperhive-frontend = self.packages.${prev.stdenv.hostPlatform.system}.frontend;
|
hive-matrix-mcp
|
||||||
# Static runtime assets. Exposed alongside the binary
|
hive-metric
|
||||||
# so the harness module can wire $HIVE_ASSETS_DIR straight
|
assets
|
||||||
# to `${pkgs.hyperhive-assets}/share/hyperhive`.
|
frontend
|
||||||
hyperhive-assets = self.packages.${prev.stdenv.hostPlatform.system}.assets;
|
reference-docs
|
||||||
# Standalone docs/ tree (see nix/reference-docs.nix). Exposed
|
;
|
||||||
# via the overlay so the harness module can build the
|
};
|
||||||
# in-container agent docs dir from it.
|
};
|
||||||
hyperhive-docs = self.packages.${prev.stdenv.hostPlatform.system}.reference-docs;
|
in
|
||||||
|
{
|
||||||
|
agent-base.imports = [
|
||||||
|
./nix/templates/agent.nix
|
||||||
|
agentPackages
|
||||||
|
];
|
||||||
|
ruth.imports = [
|
||||||
|
./nix/templates/ruth.nix
|
||||||
|
agentPackages
|
||||||
|
];
|
||||||
|
# The full host stack (nix/host-modules/default.nix aggregator) plus
|
||||||
|
# the package/source wiring from this flake. The wiring is a
|
||||||
|
# plain config module setting the `services.hyperhive.c0re.*`
|
||||||
|
# package options via `lib.mkDefault` — no overlay involved, and
|
||||||
|
# an operator override still wins. Intended usage:
|
||||||
|
#
|
||||||
|
# imports = [ hyperhive.nixosModules.default ];
|
||||||
|
# services.hyperhive.enable = true;
|
||||||
|
#
|
||||||
|
default =
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
{
|
||||||
|
imports = [ ./nix/host-modules ];
|
||||||
|
services.hyperhive.c0re = {
|
||||||
|
package = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||||
|
frontend = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.frontend;
|
||||||
|
assets = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.assets;
|
||||||
|
xdgIcons = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.xdg-icons;
|
||||||
|
hyperhiveFlake = lib.mkDefault "${sources.hyperhiveFlakeSource}";
|
||||||
|
# Narrow docs/ source, threaded as its own meta-flake input
|
||||||
|
# so doc edits don't re-hash the whole flake source.
|
||||||
|
hyperhiveDocs = lib.mkDefault "${sources.hyperhiveDocsSource}";
|
||||||
|
# Per-container toplevels — wired into
|
||||||
|
# `system.extraDependencies` when
|
||||||
|
# `services.hyperhive.c0re.preBuildAgentTemplates` is on so
|
||||||
|
# the host system closure pre-fetches the heavy build
|
||||||
|
# inputs. x86_64-linux only (nixosConfigurations are
|
||||||
|
# hardcoded to that system); the gate keeps aarch64 hosts
|
||||||
|
# from pulling them in via cross-build.
|
||||||
|
agentBaseToplevel = lib.mkDefault self.packages.x86_64-linux.agent-base-toplevel;
|
||||||
|
managerToplevel = lib.mkDefault self.packages.x86_64-linux.ruth-toplevel;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hive-ci = ./nix/host-modules/hive-ci.nix;
|
||||||
|
hive-forge = ./nix/host-modules/hive-forge;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
nixosModules = {
|
|
||||||
agent-base = ./nix/templates/agent-base.nix;
|
|
||||||
ruth = ./nix/templates/manager.nix;
|
|
||||||
# The hive-c0re module wants `pkgs.hyperhive` for its default
|
|
||||||
# `services.hyperhive.c0re.package`. To avoid making operators apply an
|
|
||||||
# overlay (which would also pollute their host pkgs with our
|
|
||||||
# build), we thread the package straight from this flake's
|
|
||||||
# `packages.<system>.default` via a `hyperhivePackage` argument.
|
|
||||||
hive-c0re = import ./nix/modules/hive-c0re.nix {
|
|
||||||
hyperhivePackage = system: self.packages.${system}.default;
|
|
||||||
hyperhiveFrontend = system: self.packages.${system}.frontend;
|
|
||||||
hyperhiveAssets = system: self.packages.${system}.assets;
|
|
||||||
hyperhiveXdgIcons = system: self.packages.${system}.xdg-icons;
|
|
||||||
hyperhiveFlake = "${hyperhiveFlakeSource}";
|
|
||||||
# Narrow docs/ source, threaded as its own meta-flake input so
|
|
||||||
# doc edits don't re-hash the whole flake source.
|
|
||||||
hyperhiveDocs = "${hyperhiveDocsSource}";
|
|
||||||
# Per-container toplevels — wired into `system.extraDependencies`
|
|
||||||
# when `services.hyperhive.c0re.preBuildAgentTemplates` is on so the
|
|
||||||
# host system closure pre-fetches the heavy build inputs.
|
|
||||||
# Defined only for x86_64-linux because nixosConfigurations are
|
|
||||||
# hardcoded to that system; the option's default keeps the
|
|
||||||
# extra deps gated so aarch64 hosts don't accidentally pull
|
|
||||||
# them in via cross-build.
|
|
||||||
agentBaseToplevel = self.packages.x86_64-linux.agent-base-toplevel;
|
|
||||||
managerToplevel = self.packages.x86_64-linux.ruth-toplevel;
|
|
||||||
};
|
|
||||||
hive-ci = ./nix/modules/hive-ci.nix;
|
|
||||||
hive-forge = ./nix/modules/hive-forge.nix;
|
|
||||||
# Convenience alias: one import covers the full hyperhive host
|
|
||||||
# stack (hive-c0re + hive-forge, since hive-c0re already pulls
|
|
||||||
# in hive-forge). Intended usage:
|
|
||||||
#
|
|
||||||
# imports = [ hyperhive.nixosModules.default ];
|
|
||||||
# services.hyperhive.enable = true;
|
|
||||||
#
|
|
||||||
default = self.nixosModules.hive-c0re;
|
|
||||||
};
|
|
||||||
|
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
let
|
let
|
||||||
|
|
@ -433,14 +152,7 @@
|
||||||
module:
|
module:
|
||||||
nixpkgs.lib.nixosSystem {
|
nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [ module ];
|
||||||
module
|
|
||||||
{
|
|
||||||
nixpkgs.overlays = [
|
|
||||||
self.overlays.default
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -448,23 +160,7 @@
|
||||||
ruth = mkContainer self.nixosModules.ruth;
|
ruth = mkContainer self.nixosModules.ruth;
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells = forAllSystems (
|
devShells = forAllSystems ({ pkgs, rust, ... }: import ./nix/devshell.nix { inherit pkgs rust; });
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
cargo
|
|
||||||
clippy
|
|
||||||
librsvg # rsvg-convert — hive-c0re/build.rs invokes it
|
|
||||||
pkg-config
|
|
||||||
rust-analyzer
|
|
||||||
rustc
|
|
||||||
rustfmt
|
|
||||||
sqlite
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
formatter = forAllSystems ({ treefmt-eval, ... }: treefmt-eval.config.build.wrapper);
|
formatter = forAllSystems ({ treefmt-eval, ... }: treefmt-eval.config.build.wrapper);
|
||||||
|
|
||||||
|
|
@ -474,84 +170,18 @@
|
||||||
system,
|
system,
|
||||||
treefmt-eval,
|
treefmt-eval,
|
||||||
craneLib,
|
craneLib,
|
||||||
cleanSrc,
|
rust,
|
||||||
cargoArtifacts,
|
|
||||||
nativeBuildInputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
import ./nix/checks.nix {
|
||||||
formatting = treefmt-eval.config.build.check self;
|
inherit
|
||||||
# Clippy as a check via crane's first-class `cargoClippy`
|
pkgs
|
||||||
# builder. Reuses the shared `cargoArtifacts` (deps already
|
craneLib
|
||||||
# built) and runs `cargo clippy --workspace --all-targets`
|
rust
|
||||||
# directly — no `overrideAttrs` hack needed, because crane
|
self
|
||||||
# parses `cargoClippyExtraArgs` correctly (naersk's
|
system
|
||||||
# `mode = "clippy"` used to mangle the `--` separator, which
|
treefmt-eval
|
||||||
# is why the old wiring went through overrideAttrs).
|
;
|
||||||
#
|
|
||||||
# `-D warnings` makes the default/correctness/style lints a
|
|
||||||
# hard CI gate. `-A clippy::pedantic` then drops the pedantic
|
|
||||||
# group from that gate: pedantic is the "extra, opinionated"
|
|
||||||
# group the clippy team grows freely, so denying it means
|
|
||||||
# every toolchain bump that adds a new pedantic lint breaks CI
|
|
||||||
# with zero code changes. The `pedantic = warn`
|
|
||||||
# workspace lint (Cargo.toml) keeps it as advisory signal in
|
|
||||||
# local `cargo clippy` — it just no longer blocks the build.
|
|
||||||
# (`-A` rather than `-W` here: `-W clippy::pedantic` would
|
|
||||||
# re-enable the specific pedantic lints the workspace lints
|
|
||||||
# table allows, e.g. `must_use_candidate`.)
|
|
||||||
clippy = craneLib.cargoClippy {
|
|
||||||
src = cleanSrc;
|
|
||||||
inherit cargoArtifacts nativeBuildInputs;
|
|
||||||
pname = "hyperhive-workspace";
|
|
||||||
version = "0.1.0";
|
|
||||||
cargoClippyExtraArgs = "--workspace --all-targets -- -D warnings";
|
|
||||||
};
|
|
||||||
# `cargo test --workspace` lifted out of `buildPackage` so the
|
|
||||||
# `hyperhive-assets` dep (which `hive-ag3nt::prompt::tests`
|
|
||||||
# needs via `HIVE_ASSETS_DIR` to assert against the actual
|
|
||||||
# production prompt template) is scoped to this one check
|
|
||||||
# instead of bleeding into the binary derivation's input
|
|
||||||
# hash. Net: editing `hive-ag3nt/prompts/system.md` still
|
|
||||||
# rebuilds this test check (correct — the tests assert
|
|
||||||
# against its wording), but `packages.default` and the
|
|
||||||
# per-container toplevels stay fully cached.
|
|
||||||
cargo-test = craneLib.cargoTest {
|
|
||||||
src = cleanSrc;
|
|
||||||
inherit cargoArtifacts nativeBuildInputs;
|
|
||||||
pname = "hyperhive-workspace";
|
|
||||||
version = "0.1.0";
|
|
||||||
cargoTestExtraArgs = "--workspace";
|
|
||||||
HIVE_ASSETS_DIR = "${self.packages.${system}.assets}/share/hyperhive";
|
|
||||||
};
|
|
||||||
# Nix options docs evaluation. Cheap: pulls in
|
|
||||||
# `nixosOptionsDoc` + the host module's stub eval, no rust or
|
|
||||||
# frontend deps. CI fails fast if a module change breaks
|
|
||||||
# option declarations or the doc rendering. Reuses the
|
|
||||||
# `packages.<system>.docs` derivation so the per-system eval
|
|
||||||
# of `nix/docs/default.nix` happens once.
|
|
||||||
inherit (self.packages.${system}) docs;
|
|
||||||
# `hivectl` CLI reference freshness check. The committed
|
|
||||||
# markdown at `docs/tools/hivectl-cli.md` is the rendered
|
|
||||||
# output of the hidden `hivectl markdown-docs` subcommand
|
|
||||||
# (clap-markdown walks the binary's own command tree). This
|
|
||||||
# check regenerates it from the built binary and fails if the
|
|
||||||
# committed copy drifted — so a verb / flag / help-string edit
|
|
||||||
# that forgets to refresh the doc is caught in CI. Reuses the
|
|
||||||
# already-built `packages.<system>.default` (no extra compile).
|
|
||||||
# Regenerate locally with:
|
|
||||||
# nix build .#default
|
|
||||||
# ./result/bin/hivectl markdown-docs > docs/tools/hivectl-cli.md
|
|
||||||
hivectl-docs = pkgs.runCommand "hivectl-docs-fresh" { nativeBuildInputs = [ pkgs.diffutils ]; } ''
|
|
||||||
${self.packages.${system}.default}/bin/hivectl markdown-docs > generated.md
|
|
||||||
if ! diff -u ${./docs/tools/hivectl-cli.md} generated.md; then
|
|
||||||
echo "" >&2
|
|
||||||
echo "ERROR: docs/tools/hivectl-cli.md is out of date — regenerate it:" >&2
|
|
||||||
echo " nix build .#default && ./result/bin/hivectl markdown-docs > docs/tools/hivectl-cli.md" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
touch "$out"
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -489,7 +489,7 @@ pub fn configured_effort() -> Option<&'static str> {
|
||||||
|
|
||||||
/// Context-window size in tokens for a given model name.
|
/// Context-window size in tokens for a given model name.
|
||||||
///
|
///
|
||||||
/// Canonical per-model sizes are declared in `harness-base.nix` as
|
/// Canonical per-model sizes are declared in the harness nix modules as
|
||||||
/// `hyperhive.contextWindowTokens` and injected as
|
/// `hyperhive.contextWindowTokens` and injected as
|
||||||
/// `HIVE_CONTEXT_WINDOW_TOKENS_<KEY_UPPER>` env vars — so this function
|
/// `HIVE_CONTEXT_WINDOW_TOKENS_<KEY_UPPER>` env vars — so this function
|
||||||
/// normally just reads them. The Rust code carries no model knowledge;
|
/// normally just reads them. The Rust code carries no model knowledge;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ pub const SERVER_NAME: &str = "hyperhive";
|
||||||
/// Default loopback port the built-in hyperhive MCP surface is served on
|
/// Default loopback port the built-in hyperhive MCP surface is served on
|
||||||
/// (streamable HTTP, via the persistent `hive-mcp-http` daemon). Overridable
|
/// (streamable HTTP, via the persistent `hive-mcp-http` daemon). Overridable
|
||||||
/// via `hyperhive.mcp.httpPort`; **must match that option's default** in
|
/// via `hyperhive.mcp.httpPort`; **must match that option's default** in
|
||||||
/// `nix/templates/harness-base.nix`. Safe as a single fixed value across all
|
/// `nix/templates/harness/`. Safe as a single fixed value across all
|
||||||
/// agents because each container runs in its own private network namespace,
|
/// agents because each container runs in its own private network namespace,
|
||||||
/// so `127.0.0.1:<port>` is per-container-private (no cross-agent collision).
|
/// so `127.0.0.1:<port>` is per-container-private (no cross-agent collision).
|
||||||
pub const DEFAULT_MCP_HTTP_PORT: u16 = 8790;
|
pub const DEFAULT_MCP_HTTP_PORT: u16 = 8790;
|
||||||
|
|
@ -246,13 +246,13 @@ pub fn builtin_tools_arg() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Where the NixOS module writes the per-agent extra-MCP spec (see
|
/// Where the NixOS module writes the per-agent extra-MCP spec (see
|
||||||
/// `nix/templates/harness-base.nix`). Each entry becomes an additional
|
/// `nix/templates/harness/`). Each entry becomes an additional
|
||||||
/// `mcpServers.<key>` block in the rendered claude config + a
|
/// `mcpServers.<key>` block in the rendered claude config + a
|
||||||
/// `mcp__<key>__<tool>` pattern in `--allowedTools`.
|
/// `mcp__<key>__<tool>` pattern in `--allowedTools`.
|
||||||
const EXTRA_MCP_PATH: &str = "/etc/hyperhive/extra-mcp.json";
|
const EXTRA_MCP_PATH: &str = "/etc/hyperhive/extra-mcp.json";
|
||||||
|
|
||||||
/// Where the NixOS module writes the per-agent send allow-list (see
|
/// Where the NixOS module writes the per-agent send allow-list (see
|
||||||
/// `nix/templates/harness-base.nix`). Empty list = unrestricted (the
|
/// `nix/templates/harness/`). Empty list = unrestricted (the
|
||||||
/// default). Non-empty list constrains `mcp__hyperhive__send`'s `to`
|
/// default). Non-empty list constrains `mcp__hyperhive__send`'s `to`
|
||||||
/// field; the manager is always implicitly permitted regardless of
|
/// field; the manager is always implicitly permitted regardless of
|
||||||
/// the list contents.
|
/// the list contents.
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ async fn set_nspawn_flags(
|
||||||
// Claude credentials land at `/home/<agent>/.claude` so the
|
// Claude credentials land at `/home/<agent>/.claude` so the
|
||||||
// `claude` CLI (which reads `$HOME/.claude`) finds them. The
|
// `claude` CLI (which reads `$HOME/.claude`) finds them. The
|
||||||
// harness service's environment sets `HOME` to the same path
|
// harness service's environment sets `HOME` to the same path
|
||||||
// (`agent-base.nix` / `manager.nix`), so no `--setenv` plumbing
|
// (`agent.nix` / `ruth.nix` templates), so no `--setenv` plumbing
|
||||||
// is needed here — the bind alone is enough.
|
// is needed here — the bind alone is enough.
|
||||||
let claude_mount = container_claude_mount(agent_name);
|
let claude_mount = container_claude_mount(agent_name);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ pub fn agent_uid_gid(agent_name: &str) -> Option<(u32, u32)> {
|
||||||
/// uid/gid via [`agent_uid_gid`] and shells out to `std::os::unix::fs::chown`.
|
/// uid/gid via [`agent_uid_gid`] and shells out to `std::os::unix::fs::chown`.
|
||||||
/// Silently no-ops when the container isn't built yet (`None` from
|
/// Silently no-ops when the container isn't built yet (`None` from
|
||||||
/// [`agent_uid_gid`]) and logs at debug on chown syscall failure — the
|
/// [`agent_uid_gid`]) and logs at debug on chown syscall failure — the
|
||||||
/// activation script in `harness-base.nix` is the steady-state safety
|
/// activation script in the harness user module is the steady-state safety
|
||||||
/// net. Used by per-agent state writers in `forge` + `matrix` so the
|
/// net. Used by per-agent state writers in `forge` + `matrix` so the
|
||||||
/// agent can read the file without waiting for the next container
|
/// agent can read the file without waiting for the next container
|
||||||
/// rebuild.
|
/// rebuild.
|
||||||
|
|
|
||||||
|
|
@ -701,7 +701,7 @@ struct OtelConfig {
|
||||||
/// Read the hive-wide OTEL config from env, or `None` when OTEL is off.
|
/// Read the hive-wide OTEL config from env, or `None` when OTEL is off.
|
||||||
/// Mirrors `hive_ca_source` — host state surfaced to the meta renderer
|
/// Mirrors `hive_ca_source` — host state surfaced to the meta renderer
|
||||||
/// so it can bake build-time `hyperhive.otel.*` config into each agent
|
/// so it can bake build-time `hyperhive.otel.*` config into each agent
|
||||||
/// (the per-agent options harness-base.nix consumes). Returns `None`
|
/// (the per-agent options the harness modules consume). Returns `None`
|
||||||
/// when the endpoint signal is absent so the renderer emits no
|
/// when the endpoint signal is absent so the renderer emits no
|
||||||
/// `hyperhive.otel.*` lines and agents keep the disabled default.
|
/// `hyperhive.otel.*` lines and agents keep the disabled default.
|
||||||
fn otel_config() -> Option<OtelConfig> {
|
fn otel_config() -> Option<OtelConfig> {
|
||||||
|
|
@ -914,7 +914,7 @@ where
|
||||||
// re-locks THIS input instead of re-hashing the whole `hyperhive`
|
// re-locks THIS input instead of re-hashing the whole `hyperhive`
|
||||||
// source. Threaded to each agent below as `hyperhive.docs.source`.
|
// source. Threaded to each agent below as `hyperhive.docs.source`.
|
||||||
// Empty = hive-c0re not built with the option wired up (legacy);
|
// Empty = hive-c0re not built with the option wired up (legacy);
|
||||||
// agents then keep the harness-base default (`pkgs.hyperhive-docs`).
|
// agents then keep the harness default (`hyperhive.packages.reference-docs`).
|
||||||
if !docs_flake.is_empty() {
|
if !docs_flake.is_empty() {
|
||||||
// `flake = false`: the docs/ tree is a plain source (no flake.nix),
|
// `flake = false`: the docs/ tree is a plain source (no flake.nix),
|
||||||
// so nix must treat it as raw source, not evaluate it as a flake.
|
// so nix must treat it as raw source, not evaluate it as a flake.
|
||||||
|
|
@ -971,8 +971,8 @@ where
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
// Point the in-container docs dir (`$HIVE_DOCS_DIR`) at the narrow
|
// Point the in-container docs dir (`$HIVE_DOCS_DIR`) at the narrow
|
||||||
// `hyperhive-docs` input instead of the harness-base default
|
// `hyperhive-docs` input instead of the harness default
|
||||||
// (`pkgs.hyperhive-docs`, built from the now-docs-stripped source).
|
// (`hyperhive.packages.reference-docs`, built from the now-docs-stripped source).
|
||||||
// `inputs."hyperhive-docs"` is reachable via the outputs `@inputs`
|
// `inputs."hyperhive-docs"` is reachable via the outputs `@inputs`
|
||||||
// capture. Emitted only when the input exists (docs_flake non-empty).
|
// capture. Emitted only when the input exists (docs_flake non-empty).
|
||||||
if !docs_flake.is_empty() {
|
if !docs_flake.is_empty() {
|
||||||
|
|
@ -1000,7 +1000,7 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Hive-wide OTEL stats export (`services.hyperhive.otel.*`): inject the
|
// Hive-wide OTEL stats export (`services.hyperhive.otel.*`): inject the
|
||||||
// build-time `hyperhive.otel.*` config harness-base.nix consumes (its
|
// build-time `hyperhive.otel.*` config the harness modules consume (its
|
||||||
// otelEnv + otelExecStart wrapper + LoadCredential). Host-driven, so
|
// otelEnv + otelExecStart wrapper + LoadCredential). Host-driven, so
|
||||||
// the same config lands on every agent; emitted only when enabled.
|
// the same config lands on every agent; emitted only when enabled.
|
||||||
// Mirrors the CA-cert injection above — host state -> build-time agent
|
// Mirrors the CA-cert injection above — host state -> build-time agent
|
||||||
|
|
@ -1055,7 +1055,7 @@ where
|
||||||
# `iris`, `root`, …). UID auto-assigned by NixOS; the
|
# `iris`, `root`, …). UID auto-assigned by NixOS; the
|
||||||
# per-agent override here is what makes
|
# per-agent override here is what makes
|
||||||
# `hyperhive.user.name` match the agent's identity
|
# `hyperhive.user.name` match the agent's identity
|
||||||
# instead of the harness-base default of `"agent"`.
|
# instead of the harness default of `"agent"`.
|
||||||
hyperhive.user.name = name;
|
hyperhive.user.name = name;
|
||||||
programs.git.config.user = {
|
programs.git.config.user = {
|
||||||
name = name;
|
name = name;
|
||||||
|
|
@ -1416,7 +1416,7 @@ mod tests {
|
||||||
"old-style follows must not appear when flake args are set:\n{out}"
|
"old-style follows must not appear when flake args are set:\n{out}"
|
||||||
);
|
);
|
||||||
// the narrow docs source is its own non-flake input, and each
|
// the narrow docs source is its own non-flake input, and each
|
||||||
// agent's docs dir resolves from it rather than pkgs.hyperhive-docs.
|
// agent's docs dir resolves from it rather than hyperhive.packages.reference-docs.
|
||||||
assert!(
|
assert!(
|
||||||
out.contains("hyperhive-docs.url = \"path:/nix/store/bbbb-hyperhive-docs-source\""),
|
out.contains("hyperhive-docs.url = \"path:/nix/store/bbbb-hyperhive-docs-source\""),
|
||||||
"expected hyperhive-docs input url:\n{out}"
|
"expected hyperhive-docs input url:\n{out}"
|
||||||
|
|
@ -1434,7 +1434,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn render_flake_omits_docs_input_when_docs_flake_empty() {
|
fn render_flake_omits_docs_input_when_docs_flake_empty() {
|
||||||
// Legacy / not-wired-up: empty docs_flake emits no docs input and
|
// Legacy / not-wired-up: empty docs_flake emits no docs input and
|
||||||
// leaves each agent on the harness-base default (pkgs.hyperhive-docs).
|
// leaves each agent on the harness default (hyperhive.packages.reference-docs).
|
||||||
let out = render_flake(
|
let out = render_flake(
|
||||||
"github:example/hyperhive",
|
"github:example/hyperhive",
|
||||||
"",
|
"",
|
||||||
|
|
@ -1674,7 +1674,7 @@ mod tests {
|
||||||
// services.hyperhive.otel.* -> HYPERHIVE_OTEL_* on hive-c0re's unit
|
// services.hyperhive.otel.* -> HYPERHIVE_OTEL_* on hive-c0re's unit
|
||||||
// -> injected as build-time hyperhive.otel.* into every agent. With
|
// -> injected as build-time hyperhive.otel.* into every agent. With
|
||||||
// no endpoint signal, no hyperhive.otel lines are emitted (agents
|
// no endpoint signal, no hyperhive.otel lines are emitted (agents
|
||||||
// keep the harness-base disabled default).
|
// keep the the harness modules disabled default).
|
||||||
//
|
//
|
||||||
// SAFETY: single-threaded mutation of process env vars no other
|
// SAFETY: single-threaded mutation of process env vars no other
|
||||||
// test asserts on; restored before returning.
|
// test asserts on; restored before returning.
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue