Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/nix/module-eval/agent-rea.nix

81 lines
2.7 KiB
Nix

# `checks.module-eval-agent-rea` — see ./lib.nix for the shared
# rationale (why this suite exists, naming convention, "evaluates
# not executes").
{
pkgs,
lib,
self,
nixosSystem,
shared,
}:
let
inherit
(import ./lib.nix {
inherit
pkgs
lib
self
nixosSystem
;
})
agentWith
runGroup
;
# The option is switched on by the archetype that exists for it, so this one
# fixture is the "on" arm and the archetype's own wiring.
agentRea = agentWith self.hyperhiveArchetypes.reverse-engineer.module;
agentNoRea = shared.agentBare;
rea = agentRea.services.hyperhive.agent.extraMcpServers.rea;
pkgsOf = machine: machine.environment.systemPackages;
reaTmpfiles = machine: lib.filter (lib.hasInfix "/state/rea") machine.systemd.tmpfiles.rules;
in
runGroup "agent-rea" [
{
# `rea` is the presence control for every absence below: the same lookups
# find the entry, the variables, the packages and the directories when
# the option is on.
name = "enabling rea registers its MCP server with every tool allowed and sets Ghidra's environment";
ok =
rea.allowedTools == [ "*" ]
&& rea.args == [ "mcp" ]
&& lib.hasSuffix "/bin/rea" rea.command
&& lib.all (n: rea.env ? ${n} && agentRea.environment.variables ? ${n}) [
"GHIDRA_INSTALL_DIR"
"JAVA_HOME"
"REA_GHIDRA_PROJECT_PATH"
"GHIDRA_HEADLESS_MAXMEM"
]
&& rea.env.GHIDRA_HEADLESS_MAXMEM == "2G"
&& lib.hasPrefix "/agents/a1/state/" rea.env.REA_GHIDRA_PROJECT_PATH;
}
{
name = "enabling rea installs rea and Ghidra 12.1, and creates the agent-owned project directories";
ok =
let
packages = agentRea.services.hyperhive.agent.packages;
in
lib.all (p: lib.elem p (pkgsOf agentRea)) [
packages.rea
packages.ghidra-12-1
]
&& lib.versionAtLeast packages.ghidra-12-1.version "12.1"
&& lib.length (reaTmpfiles agentRea) == 2
&& lib.all (lib.hasInfix " a1 a1 ") (reaTmpfiles agentRea);
}
{
name = "an agent without rea gets no REA server, no Ghidra variables, no REA packages and no project directories";
ok =
let
packages = agentNoRea.services.hyperhive.agent.packages;
in
!agentNoRea.services.hyperhive.agent.rea.enable
&& !(agentNoRea.services.hyperhive.agent.extraMcpServers ? rea)
&& !(agentNoRea.environment.variables ? GHIDRA_INSTALL_DIR)
&& !(agentNoRea.environment.variables ? REA_GHIDRA_PROJECT_PATH)
&& !(lib.elem packages.rea (pkgsOf agentNoRea))
&& !(lib.elem packages.ghidra-12-1 (pkgsOf agentNoRea))
&& reaTmpfiles agentNoRea == [ ];
}
]