Watch
0
0
Fork
You've already forked hyperhive
0

fetch the agent's backend env file from the store, seeded from the existing file

the agent's own root unit reads swarm/agents/<agent>/backend-env into /run and
creates it from backendEnvironmentFile with -cas=0 when the store holds nothing.
the shared agent policy gains create (not update) on that one leaf. the harness
and the subagent daemon load the old file first and the fetched one after it.
This commit is contained in:
atlas 2026-10-27 21:14:44 +01:00
commit 75e9e205e3

View file

@ -0,0 +1,56 @@
# `checks.script-test-agent-backend-env` — runs ../agent-modules/backend-env.nix's
# unit against a stub `bao` that keeps its leaves in files. The cases are in
# ./agent-backend-env.sh and the stub is ./agent-backend-env-fake-bao.sh.
#
# What runs is the unit's rendered `ExecStart`, on the unit's own `PATH` with
# the stub in front. The edits are the unit's `/run/<unit>/` prefix and the
# operator's file, both moved under the build directory because the sandbox has
# no writable `/run` and no `/agents`.
{
pkgs,
lib,
self,
nixosSystem,
}:
let
inherit
(import ../module-eval/lib.nix {
inherit
pkgs
lib
self
nixosSystem
;
})
agentWith
;
earlierFile = "/agents/a1/harness/backend.env";
machine = agentWith {
services.hyperhive.agent = {
bao.addr = "https://bao.t.local:8200";
useApiKey = true;
backendEnvironmentFile = earlierFile;
};
};
unit = machine.systemd.services.hive-agent-backend-env;
fakeBao = pkgs.runCommand "fake-bao" { } ''
install -Dm755 ${./agent-backend-env-fake-bao.sh} $out/bin/bao
patchShebangs $out/bin
'';
in
pkgs.runCommand "hyperhive-script-test-agent-backend-env"
{
UNIT_SCRIPT = lib.removeSuffix " " unit.serviceConfig.ExecStart;
UNIT_PATH = unit.environment.PATH;
UNIT_BAO_ADDR = unit.environment.BAO_ADDR;
EARLIER_FILE = earlierFile;
FAKE_BAO_BIN = "${fakeBao}/bin";
}
''
${pkgs.bash}/bin/bash ${./agent-backend-env.sh}
touch "$out"
''