Watch
0
0
Fork
You've already forked hyperhive
0

agents: always write the memory cap, infinity for none

The cap file was removed for a cap of `infinity` or a RAM percentage,
so the boot check warned on every start of such an agent, for a
legitimate config. The file is now written on every start:

- a size: its byte count, as before;
- `infinity`: the literal `infinity`. The generators set no JSC heap
  ceiling and no subagent MemoryHigh=, and the boot check is quiet;
- a percentage: resolved on the host the way systemd resolves
  MemoryMax=N% for the container@ unit. That is permyriad (at most two
  decimals, at most 100%) of sysconf(_SC_PHYS_PAGES) *
  sysconf(_SC_PAGESIZE), rounded down to a page;
- a value systemd ignores (zero, over 100%, more than two decimals,
  unparseable) leaves the unit uncapped, so it is `infinity`.

The file is missing only when hive-c0re can't tell the cap: the
limits file and the kept drop-in are both unreadable, or a percentage
meets an unknown host memory size. The boot check now warns only for
a missing file or a first line that is neither a byte count nor
`infinity`.

Part of #5081 (slice S0-2).
This commit is contained in:
atlas 2026-10-12 10:35:15 +02:00
commit eaca3c4eb3
5 changed files with 253 additions and 67 deletions

View file

@ -453,17 +453,21 @@ rebuild, so changes take effect on the next lifecycle op without
requiring a host rebuild.
The container can't read its own cap, so `write_dropins` also writes the
effective `MemoryMax=` in bytes into the agent's runtime dir
(`/run/hive/memory-max-bytes` inside). At boot the container derives two
values from it: `BUN_JSC_forceRAMSize` (75%, claude-code's heap ceiling)
and `MemoryHigh=` on `hive-subagent-daemon` (two thirds). Neither is in the
agent's build, so a changed cap reaches them at the next container start
without a rebuild. A cap of `infinity` or a RAM percentage sets neither.
When hive-c0re keeps the last drop-in because it can't read the overrides
file, the file carries that drop-in's `MemoryMax=`. A missing or malformed
file sets neither value, and `hyperhive-memory-cap-check.service` logs a
warning naming the path in the container's journal at boot. The
container's `MemoryMax=` still applies.
effective `MemoryMax=` into the agent's runtime dir
(`/run/hive/memory-max-bytes` inside) before every start: a byte count, or
`infinity` for no cap. A percentage becomes bytes the way systemd resolves
it, as that share of the host's physical memory rounded down to a page. A
value systemd ignores (zero, over 100%) is `infinity`. When hive-c0re keeps
the last drop-in because it can't read the overrides file, the file carries
that drop-in's `MemoryMax=`.
At boot the container derives two values from a byte count:
`BUN_JSC_forceRAMSize` (75%, claude-code's heap ceiling) and `MemoryHigh=` on
`hive-subagent-daemon` (two thirds). Neither is in the agent's build, so a
changed cap reaches them at the next container start without a rebuild.
`infinity` sets neither. A missing or malformed file sets neither as well, and
`hyperhive-memory-cap-check.service` logs a warning naming the path in the
container's journal. The container's `MemoryMax=` still applies.
The same drop-in carries `CPUWeight=` / `IOWeight=` from
`agentCpuWeight` / `agentIoWeight`. Those are a different kind of