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

Parked opened this in answer to
Closed without merging

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.

Notes

stopped parked by the crew deploy 7806b52

opened this

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_MIB still wins when set. Without it, the ceiling is 75% of the pod's cgroup memory.max, or 75% of the machine's memory when there is no pod limit. podMemoryLimit takes the tightest memory.max from the forge's cgroup up to the namespace root, because apps/cgroup.ts moves the forge into a forge/ leaf whose own value is max. The pod value is read once per process.
  • Where each limit comes from: resolveLimits now 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.json is read: limitClamps/clampWords turn each lowered field into a warning: line at the top of the check's log. The repository settings page (admins only) shows a "Limits lowered" card for the default branch's forge.json, using the new src/apps/declared_limits.ts. /system states the memory ceiling and where it comes from.
  • Check summary: when the cell stopped the check over a limit (cellStopped in src/apps/process.ts), the run's summary is that reason, not whatever line the killed process printed last.
  • docs/APPS.md describes the new default and the reporting.

Not done:

  • FORGE_CELL_MEMORY_MAX_MIB is 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;
  • declaredClamps reading both sections of forge.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

Closes #3128

2 earlier comments · 1 event
commented

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_MIB still wins when set. Without it, the ceiling is 75% of the pod's cgroup memory.max, or 75% of the machine's memory when there is no pod limit. podMemoryLimit takes the tightest memory.max from the forge's cgroup up to the namespace root, because apps/cgroup.ts moves the forge into a forge/ leaf whose own value is max. The pod value is read once per process.
  • Where each limit comes from: resolveLimits now 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.json is read: limitClamps/clampWords turn each lowered field into a warning: line at the top of the check's log. The repository settings page (admins only) shows a "Limits lowered" card for the default branch's forge.json, using the new src/apps/declared_limits.ts. /system states the memory ceiling and where it comes from.
  • Check summary: when the cell stopped the check over a limit (cellStopped in src/apps/process.ts), the run's summary is that reason, not whatever line the killed process printed last.
  • docs/APPS.md describes the new default and the reporting.

Not done:

  • FORGE_CELL_MEMORY_MAX_MIB is 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;
  • declaredClamps reading both sections of forge.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

Changes requested — before the latest push

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.

  1. 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 declaredClamps result in the terminal's repository/settings view, with a test, and add one line to the README on where to see it.
  2. 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 /system ceiling line is also a hand-rolled <p class="small"> with inline <code>; match the neighbouring cell-caps markup and shorten it to one sentence.

Smaller items:

  • settingsPage now 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.
  • resolveLimits builds 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.

commented

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_MIB still wins when set.
  • Without it, the ceiling is 75% of the pod's cgroup memory.max. podMemoryLimit takes the tightest memory.max from the forge's cgroup up to the namespace root, because the forge's own forge/ leaf reads max.
  • 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 to cell-caps, using the same markup, giving the memory ceiling and where it comes from.
  • src/apps/declared_limits.ts reads 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.ts covers:
    • 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.ts opens 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.ts runs a real check: the warning: line is in its log and the exact muted line is on the settings page.
  • test/system-telemetry.test.ts checks the /system sentence.

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

commented

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

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs