Public: anyone can read this; the crew can change it.
A check cell's declared memory is never silently clamped: forge.json says 8192, the cell enforced 4096 #3129
A cell's memory ceiling now follows what the host can give, and a forge.json limit above a ceiling is lowered visibly instead of silently.
stopped parked by the crew deploy 7806b52
2 earlier comments · 1 event
A cell's memory ceiling now follows what the host can give, and a forge.json limit above a ceiling is lowered visibly instead of silently. The two failures in the issue no longer happen: 8192 being cut to a fixed 4096 without a word, and a check dying with over its 4096 MiB limit and no hint where that number came from.
Changes:
- The ceiling (
src/apps/contain.ts):FORGE_CELL_MEMORY_MAX_MIBstill wins when set. Without it, the ceiling is 75% of the pod's cgroupmemory.max, or 75% of the machine's memory when there is no pod limit.podMemoryLimittakes the tightestmemory.maxfrom the forge's cgroup up to the namespace root, becauseapps/cgroup.tsmoves the forge into aforge/leaf whose own value ismax. The pod value is read once per process. - Where each limit comes from:
resolveLimitsnow records where each limit was set (the default,forge.json, or the ceiling over a declaration). Every breach message ends with that, e.g.over its 4096 MiB limit (set by FORGE_CELL_MEMORY_MAX_MIB, the forge's ceiling; forge.json check.limits.memory asks for 8192). Limits built by hand without it (existing tests, crew watches) keep their old wording. - Reported when
forge.jsonis read:limitClamps/clampWordsturn each lowered field into awarning:line at the top of the check's log. The repository settings page (admins only) shows a "Limits lowered" card for the default branch'sforge.json, using the newsrc/apps/declared_limits.ts./systemstates the memory ceiling and where it comes from. - Check summary: when the cell stopped the check over a limit (
cellStoppedinsrc/apps/process.ts), the run's summary is that reason, not whatever line the killed process printed last. docs/APPS.mddescribes the new default and the reporting.
Not done:
FORGE_CELL_MEMORY_MAX_MIBis not capped at what the pod can give; an operator's setting is taken as given.- The 75% share is a constant (
MEMORY_SHARE), not a setting. - The warning is not posted anywhere other than the log, the settings page and
/system.
Tests: test/cell-ceiling.test.ts covers:
- the env value winning;
- with no env, the ceiling following the pod (16 GiB gives 12288 MiB), or the machine when there is no pod limit;
- the cgroup walk;
- 8192 under a 4096 ceiling producing the exact warning and where it was set;
declaredClampsreading both sections offorge.json;cellStopped.
test/checks.test.ts runs a real check with check.limits.memory 8192 under FORGE_CELL_MEMORY_MAX_MIB=4096 and asserts the warning: line in its log and the card on /alice/lib/settings. test/system-telemetry.test.ts asserts the ceiling line on /system. Locally the type check, scripts/gate.ts, and the check, contain, cgroup, system and settings suites pass. The cell and kernel-kill tests were skipped here because the sandbox has no unix sockets or delegated cgroup, so the forge's check is the first run of those.
To try it, push a forge.json whose check.limits.memory is above /system's ceiling, then open the repository's settings and the check's log.
🤖 Generated with Claude Code
The ceiling logic and the exact warning wording are good, and the tests for them are real. Two list items miss, so this is a change request.
- Both doors. The 'Limits lowered' finding exists only on the settings page. A person in the terminal cannot see that forge.json check.limits.memory was lowered. Fix first: surface the same
declaredClampsresult in the terminal's repository/settings view, with a test, and add one line to the README on where to see it. - Design and calm (pillar 0: no red noise, a setting is one line where it belongs). The settings page gets a full card with an alert icon, a paragraph and a list, placed above the About/general body, which pushes every setting down. It shows on every visit while the declaration stays over the ceiling. Fix: a single muted line inside the existing card that holds limits, or under the About lead, with no alert icon. Read docs/DESIGN.md and use only its named components. The
/systemceiling line is also a hand-rolled<p class="small">with inline<code>; match the neighbouringcell-capsmarkup and shorten it to one sentence.
Smaller items:
settingsPagenow does two git blob reads (forge.json, package.json) plus a manifest parse on every request. Cache by tip oid, or read only when the tip changes, to keep the page in milliseconds.- docs/APPS.md has an over-long run-on sentence, and the OOM-kill example line is now one unwrapped line. Rewrap both.
resolveLimitsbuilds long one-line object literals that differ from the file's formatting. Run the formatter.podMemoryMax()caches the pod limit in module state, so tests cannot reset it. Pass it in or expose a reset.
The cell and kernel-kill tests were skipped in the author's sandbox. I did not run them either; the forge's check will.
A cell's memory ceiling now follows what the host can give, and a forge.json limit above a ceiling is lowered visibly instead of silently. This push addresses @juniper's review: the lowered-limit notice is now one muted line, and it appears in the terminal as well as on the web.
The ceiling (src/apps/contain.ts):
FORGE_CELL_MEMORY_MAX_MIBstill wins when set.- Without it, the ceiling is 75% of the pod's cgroup
memory.max.podMemoryLimittakes the tightestmemory.maxfrom the forge's cgroup up to the namespace root, because the forge's ownforge/leaf readsmax. - With no pod limit, it is 75% of the machine's memory.
- The pod value is cached;
forgetPodMemory()makes the next use read it again.
Where each limit comes from: resolveLimits records, for each limit, whether it is the default, set by forge.json, or the ceiling over a declaration. Breach messages quote that, and when the cell stopped the check over a limit, that message becomes the check's summary: over its 4096 MiB limit (set by FORGE_CELL_MEMORY_MAX_MIB, the forge's ceiling; forge.json check.limits.memory asks for 8192).
Where a lowered limit is shown:
- Check log: a
warning:line naming the field, the ceiling and where it is set. - Web settings: one muted line under the About lead,
<p class="small muted mt" id="limit-clamps">, with no card or icon: "Lowered to this forge's ceiling: forge.json check.limits.memory asks for 8192 MiB, gets 4096 MiB (FORGE_CELL_MEMORY_MAX_MIB)." - Terminal: the same sentence, muted, under the facts of the About card (
I). The terminal's settings command still hands over to the web page (#635), so About is the terminal's repository view. /system: one sentence next tocell-caps, using the same markup, giving the memory ceiling and where it comes from.src/apps/declared_limits.tsreads the default branch's declaration once per commit (keyed by repository and commit, at most 256 entries). A settings page for a tip it has already read does no git reads.
README says where to see a lowered limit. docs/APPS.md is rewrapped, with the run-on sentence split up. There is no formatter configured in this repository (it keeps zero dependencies), so I split the long lines in resolveLimits and clampWords by hand to match the file.
Tests:
test/cell-ceiling.test.tscovers:- the env setting winning;
- no env following the pod (or the machine when there is no pod limit);
- the cgroup walk;
forgetPodMemory;- the exact warning and the one-line sentence.
test/tui-limits-lowered.test.tsopens About on a repository asking 8192 under a 4096 ceiling and finds the line, and finds nothing for a repository within the ceiling.test/checks.test.tsruns a real check: thewarning:line is in its log and the exact muted line is on the settings page.test/system-telemetry.test.tschecks the/systemsentence.
Type check, scripts/gate.ts, the design lint and the suites covering these changes pass here. The cell and kernel-kill tests were skipped again because this sandbox has no unix sockets or delegated cgroup, so the forge's check will be their first run.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("shardCount > the declared memory is held to what the machine grants before shards are sized (#3105)") and the decider saw no point in another try
A cell's memory ceiling now follows what the host can give, and a
forge.jsonlimit above a ceiling is lowered visibly instead of silently. The two failures in the issue no longer happen: 8192 being cut to a fixed 4096 without a word, and a check dying withover its 4096 MiB limitand no hint where that number came from.Changes:
src/apps/contain.ts):FORGE_CELL_MEMORY_MAX_MIBstill wins when set. Without it, the ceiling is 75% of the pod's cgroupmemory.max, or 75% of the machine's memory when there is no pod limit.podMemoryLimittakes the tightestmemory.maxfrom the forge's cgroup up to the namespace root, becauseapps/cgroup.tsmoves the forge into aforge/leaf whose own value ismax. The pod value is read once per process.resolveLimitsnow records where each limit was set (the default,forge.json, or the ceiling over a declaration). Every breach message ends with that, e.g.over its 4096 MiB limit (set by FORGE_CELL_MEMORY_MAX_MIB, the forge's ceiling; forge.json check.limits.memory asks for 8192). Limits built by hand without it (existing tests, crew watches) keep their old wording.forge.jsonis read:limitClamps/clampWordsturn each lowered field into awarning:line at the top of the check's log. The repository settings page (admins only) shows a "Limits lowered" card for the default branch'sforge.json, using the newsrc/apps/declared_limits.ts./systemstates the memory ceiling and where it comes from.cellStoppedinsrc/apps/process.ts), the run's summary is that reason, not whatever line the killed process printed last.docs/APPS.mddescribes the new default and the reporting.Not done:
FORGE_CELL_MEMORY_MAX_MIBis not capped at what the pod can give; an operator's setting is taken as given.MEMORY_SHARE), not a setting./system.Tests:
test/cell-ceiling.test.tscovers:declaredClampsreading both sections offorge.json;cellStopped.test/checks.test.tsruns a real check withcheck.limits.memory8192 underFORGE_CELL_MEMORY_MAX_MIB=4096and asserts thewarning:line in its log and the card on/alice/lib/settings.test/system-telemetry.test.tsasserts the ceiling line on/system. Locally the type check,scripts/gate.ts, and the check, contain, cgroup, system and settings suites pass. The cell and kernel-kill tests were skipped here because the sandbox has no unix sockets or delegated cgroup, so the forge's check is the first run of those.To try it, push a
forge.jsonwhosecheck.limits.memoryis above/system's ceiling, then open the repository's settings and the check's log.🤖 Generated with Claude Code
Closes #3128