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:
parent
0d619e215e
commit
57955a6c53
6 changed files with 144 additions and 32 deletions
|
|
@ -34,6 +34,26 @@ let
|
|||
name = "the subagent daemon's memory ceiling is not built into its unit";
|
||||
ok = !((agentSubagentDaemon agentDefault).serviceConfig ? MemoryHigh);
|
||||
}
|
||||
{
|
||||
# claude's heap ceiling reaches it only as inherited environment: the
|
||||
# environment generator fills the manager's, systemd hands that to every
|
||||
# unit, and both units spawn claude as a plain child. A unit that sets
|
||||
# or unsets the variable itself cuts that. Without the two generators the
|
||||
# cap reaches nothing, and without the check unit nothing says so.
|
||||
name = "claude's units take the heap ceiling from the memory cap read at boot";
|
||||
ok =
|
||||
let
|
||||
leavesIt =
|
||||
unit:
|
||||
!(unit.environment ? BUN_JSC_forceRAMSize)
|
||||
&& !(lib.elem "BUN_JSC_forceRAMSize" (lib.toList (unit.serviceConfig.UnsetEnvironment or [ ])));
|
||||
in
|
||||
leavesIt (agentHarness agentDefault)
|
||||
&& leavesIt (agentSubagentDaemon agentDefault)
|
||||
&& agentDefault.environment.etc ? "systemd/system-environment-generators/50-hyperhive-memory-cap"
|
||||
&& agentDefault.systemd.generators ? hyperhive-memory-cap
|
||||
&& lib.elem "multi-user.target" agentDefault.systemd.services.hyperhive-memory-cap-check.wantedBy;
|
||||
}
|
||||
{
|
||||
# The sign is the whole property, and it is easy to write backwards:
|
||||
# a HIGHER OOMScoreAdjust is a MORE likely victim. So the subagent
|
||||
|
|
|
|||
Loading…
Reference in a new issue