Watch
0
0
Fork
You've already forked hyperhive
0

agents: hand over the kept drop-in's cap, warn at boot without one

When hive-c0re can't read resource-limits.json and a limits drop-in
already exists, it keeps the drop-in, but it wrote no memory cap file. A
container whose runtime dir had no file yet (hive-c0re upgraded, /run
not cleared) then started with no heap ceiling and no subagent
MemoryHigh=, silently. `stage_limits` now writes the file on every
call: from the new limits, or from the last `MemoryMax=` in the kept
drop-in (`infinity` when it has none or can't be read).

A missing or malformed cap file at boot is no longer silent. The
generators run before the container's journal and an nspawn container
has no /dev/kmsg, so a oneshot `hyperhive-memory-cap-check.service`
logs a warning naming the path. The agent then runs with no JSC heap
ceiling and no subagent MemoryHigh=; the container's MemoryMax= still
applies.

module-eval-agent-memory gains a case pinning how the ceiling reaches
claude: `hive-agent` and `hive-subagent-daemon` neither set nor unset
BUN_JSC_forceRAMSize, both generators and the check unit are installed.

Part of #5081 (slice S0-2).
This commit is contained in:
atlas 2026-10-12 10:10:11 +02:00
commit 57955a6c53
6 changed files with 144 additions and 32 deletions

View file

@ -1,7 +1,8 @@
# `checks.script-test-agent-memory-cap` — runs the three readers of
# `checks.script-test-agent-memory-cap` — runs the four 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.
# environment generator, the unit generator, the boot check that warns about
# an unusable cap, 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
@ -32,6 +33,7 @@ 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;
CHECK = machine.systemd.services.hyperhive-memory-cap-check.serviceConfig.ExecStart;
PROFILE = machine.environment.etc."hyperhive/memory-cap.sh".source;
EXTRA_INIT = machine.environment.extraInit;
SHELLS = "${pkgs.dash}/bin/dash ${pkgs.bash}/bin/sh";