An agent's memory cap was rendered into its flake (`memoryMaxBytes` → `services.hyperhive.agent.claudeMemoryMaxBytes`), so the closure depended on it and a changed cap reached the JSC heap ceiling and the subagent `MemoryHigh=` only after a rebuild. hive-c0re now writes the effective `MemoryMax=` in bytes to the agent's runtime dir (`/run/hive/memory-max-bytes` inside) in `write_dropins`, from the same value the drop-in gets. The file is removed for `infinity` or a RAM percentage, and left alone when the drop-in is kept. Inside the container, `nix/agent-modules/memory-cap.nix` reads it at boot: an environment generator sets `BUN_JSC_forceRAMSize` (75%) for every unit and `machinectl shell`, `/etc/set-environment` exports it in login shells, and a unit generator writes `MemoryHigh=` (2/3) as a drop-in for `hive-subagent-daemon`. The render drops `memoryMaxBytes`, the agent option is removed (both spellings fail eval with a removal message), and `effective_memory_bytes_from` goes with its only caller. Part of #5081 (slice S0-2).
42 lines
1.2 KiB
Nix
42 lines
1.2 KiB
Nix
# `checks.script-test-agent-memory-cap` — runs the three readers of
|
|
# `/run/hive/memory-max-bytes` in ../agent-modules/memory-cap.nix: the
|
|
# environment generator, the unit generator, and the login-shell snippet
|
|
# `/etc/set-environment` sources. The cases are in ./agent-memory-cap.sh.
|
|
#
|
|
# What runs is the rendered scripts. The one edit is the cap file's path, moved
|
|
# under the build directory, and the snippet's reference to the environment
|
|
# generator, pointed at that edited copy.
|
|
{
|
|
pkgs,
|
|
lib,
|
|
self,
|
|
nixosSystem,
|
|
}:
|
|
let
|
|
inherit
|
|
(import ../module-eval/lib.nix {
|
|
inherit
|
|
pkgs
|
|
lib
|
|
self
|
|
nixosSystem
|
|
;
|
|
})
|
|
agentWith
|
|
;
|
|
|
|
machine = agentWith { };
|
|
in
|
|
pkgs.runCommand "hyperhive-script-test-agent-memory-cap"
|
|
{
|
|
ENV_GENERATOR =
|
|
machine.environment.etc."systemd/system-environment-generators/50-hyperhive-memory-cap".source;
|
|
UNIT_GENERATOR = machine.systemd.generators.hyperhive-memory-cap;
|
|
PROFILE = machine.environment.etc."hyperhive/memory-cap.sh".source;
|
|
EXTRA_INIT = machine.environment.extraInit;
|
|
SHELLS = "${pkgs.dash}/bin/dash ${pkgs.bash}/bin/sh";
|
|
}
|
|
''
|
|
${pkgs.bash}/bin/bash ${./agent-memory-cap.sh}
|
|
touch "$out"
|
|
''
|