Public: anyone can read this; the crew can change it.

A forge runs anywhere: a stated footprint, proven on a 1-CPU, 512 MiB machine #12236

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I merged main into the branch and pushed it. The type check and the three test files below pass. I didn't run the full suite, and the forge's check runs it on this push.

Notes

opened this

I merged main into the branch and pushed it. The type check and the three test files below pass. I didn't run the full suite, and the forge's check runs it on this push.

  • Conflict: the only one was in src/main.ts, where the branch called markReady() after serve(app) and main had added warmHome(app) and warmBoards(app) there. I kept all three, with markReady() first.
  • Fork commit: my first push was rejected because the fork's branch held a commit the local clone lacked, c99b2dc66, "A small pod keeps room for the forge". That commit changes how system and health read the pod's memory limit. I merged it in with no conflicts.
  • Checks run: bun x tsc --noEmit is clean. test/footprint.test.ts, test/memory-ceiling.test.ts, test/vitals-release.test.ts and test/web.test.ts pass (51 and 14 tests). scripts/gate.ts printed only pin-migrations: every migration is already pinned.
  • Not run: scripts/fast.ts reported the diff as too broad to name tests (2065 of 3058 files), so I picked the footprint, memory and web tests by hand.

Continues #12236

Show 7 earlier items

7 earlier comments
commented

This pull is the first step of #12092: the footprint is stated and measured, and one holder is fixed. The largest memory holders are not cut yet, and no 1-CPU, 512 MiB run of the check was done here.

I could not see the log of the earlier red check. On this branch (merged with main), bun scripts/gate.ts, bun x tsc --noEmit, bun scripts/design-lint.ts and the 293 tests that cover the changed modules pass. I did not run the full suite; the forge's check does that on this push.

What changed

  • src/system/footprint.ts holds the stated budget for a 1-CPU, 512 MiB forge: 256 MiB resident at rest, first page within 5 s, an empty forge under 64 MiB on disk. I chose those numbers; change BUDGET if you want others. It also reads memory, heap, data-directory size, start-to-first-page time, architecture and CPUs.
  • The release proof (src/release/prove.ts) records that reading in release/proof.json once the new version answers /healthz. /system shows it under "What the forge costs", says "Over budget" when it is, and lists what is optional and off: Chromium, the crew's AI tool, and the serve/work threads.
  • A cell now gets at most the pod's memory.max less 192 MiB (src/apps/contain.ts). On the 384 MiB pod the check dies, not the forge. I did not re-run the 384 MiB case on a real pod.
  • /system and /api/v1/health report the pod's memory limit, not the host's (src/kernel/vitals.ts).
  • docs/features/footprint.md now has the measured table from the issue.

What I did not do

  • I cut no memory. The forge is still about 170 MiB at rest and about 380 MiB after the first-hour journey, so it will read "Over budget" against the 256 MiB budget.
  • The launcher-free start (bun src/main.ts directly saves 15 MiB, 17 with --smol) and the lazy-loading of what a small forge never uses (TUI, boards, studio) are not done.
  • There is no serve/work split to switch on by core count, so the page reports one thread. FORGE_ENGINE=worker stays off.
  • I did not make an ARM release. The Dockerfile's oven/bun base is multi-arch, so I expect it to build on arm64 as is, but I did not build it. The release pipeline still publishes amd64 only.
  • The 42 MB empty forge on disk is untouched.

How to try it Open /system and read "What the forge costs". After a release proof runs, release/proof.json under the data directory has a footprint field.

The cuts should be separate pulls, one per holder: lazy-loading, the launcher, ARM images.

🤖 Generated with Claude Code

commented

I fixed the one failure this pull caused and pushed. The other seven failures were red on main at d5b2fe2 as well, so the check doesn't count them against this pull.

The failing test was test/attention.test.ts: the system page's first view was over its budget, because the new "What the forge costs" section added words and blocks.

  • src/web/pages/system.ts: footprintSection now puts its heading in the summary of one closed disclosure (#sys-footprint-more). The verdict, the numbers and the optional-parts rows sit inside it, so they stay out of the first view. The heading is still an h2 inside the settings block, so the one-h2-per-block test passes.
  • docs/design/attention-budget.json: the system budget rises from 190 words and 69 blocks to 194 and 70, at both 390 and 1280 px. The heading is the only part still counted, so the rise is 4 words and 1 block. This is a budget raise, so it needs the note the test file asks for in the pull.

bun x tsc --noEmit is clean. scripts/design-lint.ts reports nothing outside the system. test/attention.test.ts, test/footprint.test.ts and the system-related tests pass, 194 in all.

One failure remains in what I ran locally: the TUI test "System command passes the session…". It's one of the failures the check reported as red on main as well. I didn't run the full suite; the forge's check runs it on this push.

commented

All seven points are addressed and pushed. tsc, scripts/gate.ts, design-lint, and the footprint, TUI system, vitals, attention, memory-ceiling and release-prober tests pass. I did not run the whole suite; the forge's check does. My one broad test/tui*.test.ts run timed out and I did not retry it, so the other TUI test files haven't run here.

  1. Both doors.
    • src/tui/screens/system.ts has footprintLines, the full view. It gives a heading, the verdict sentence, and one line per optional part, gated by telemetryReader like the other sections.
    • footprintBrief is the System dialog's share, since the dialog doesn't scroll: the verdict plus an off: list.
    • docs/features/footprint.md says how to read it in the terminal.
    • Tests are in tui-system.test.ts. I raised the height of one existing screen test from 50 to 60 rows because the dialog now carries more lines.
  2. Verdict on first view.
    • /system puts one sentence on first view: Within or Over budget, then the resident figure, with a danger badge when over. The optional-parts rows stay behind the disclosure.
    • Both renderings share one footprintVerdict in src/system/footprint.ts.
    • attention-budget.json for system goes 194→216 words and 70→71 blocks; the note says why.
  3. Tests.
    • The proof test no longer swallows errors.
    • A new vitals test asserts memoryReading() reports the pod's limit. I pulled it out of vitals() for this.
    • A new test covers the Over-budget verdict sitting in the summary, with the rows after it.
    • markReady() is checked only by asserting that src/main.ts contains markReady() right after serve(app), plus the footprint call into the proof. I did not boot the whole of main.ts.
  4. withinBudget. A readyMs of null now reads as not within budget, with a test. I dropped the threads field. The "Serve/work threads" row stays as a stated off, and a code comment says it is a statement, not a measurement.
  5. memoryReading(). vitals() and /api/v1/health now share memoryReading(), which reads process.memoryUsage() and memoryLimitBytes() once each.
  6. ARM claim. Removed from the docs.
  7. prove.ts. The footprint field and its comment now sit after journey, so journey has its own doc line again.

I did not split off separate issues for the remaining holders, which is your last point on direction. They stay listed under "Not done yet" in docs/features/footprint.md.

commented

The failed check on #12236 was an unresolved merge of main, plus comment lines the gate wanted rewrapped. I fixed both and pushed.

  • Merge conflicts: the commit on the branch had the conflict markers still in src/main.ts and test/tui-system.test.ts.
    • In src/main.ts I kept both markReady() and keepFlowReadings(KEPT_MS), in that order, right after serve(app).
    • In test/tui-system.test.ts I took main's 70-row terminal height for the System-screen test, since it is taller than my 60.
  • Comment wrapping: scripts/gate.ts refused six comment lines over 100 columns, in vitals.ts, prove.ts, footprint.ts and tui/screens/system.ts. I rewrapped them. The gate only sees committed lines, so it still reported them until I committed.

The gate, tsc, and the footprint, TUI system and release-prober tests all pass; I did not run the whole suite. attention.test.ts and vitals.test.ts passed before the comment rewrap but were not rerun afterward.

How to try it: open /system and read "What the forge costs" (the Within or Over budget sentence is on first view). In the terminal, open the System screen.

commented

This pull now does one thing: it measures what a forge costs and shows it. The cell ceiling and the pod-limit change are back to main's code, each in its own issue with its patch. It does not cut any memory, so it doesn't meet #12092's "done", and #12092 now waits on the follow-up issues below.

What changed after review:

  • Split (1): src/apps/contain.ts, src/kernel/vitals.ts and test/memory-ceiling.test.ts are back to main's code. The cell ceiling is #12346 and reading the pod's memory limit in /system and health is #12347. The other holders have their own issues: launcher-free start #12348, lazy-loading #12349, ARM image #12350, serve/work split only with cores #12351. #12092 is linked to wait on all six.
  • Verdict in plain words (3, 4): the summary is now one sentence, e.g. "Over budget: the forge is using 300 MiB; it should stay under 256 MiB.", or "the first page came 6.5 s after start…" when start-up time is what's over. The badge and "One process." are gone. Memory, first page, data on disk and machine/architecture are now dl rows behind the disclosure, built by the new footprintFacts. The fact row helper, which dbSizeSection also used, now lives once at module level in src/web/pages/system.ts.
  • Serve/work row (5): removed, along with the small branch. optionals(chromium, crewTool) now lists only the parts that exist.
  • Tests (2): the check on the text of main.ts and the ?fresh= re-import are gone. clearReadyMark() resets the ready mark between tests. The tests now cover: never ready means not within budget, the first mark is kept, a slow first page is over budget, each verdict sentence, the facts, no badge in the summary, a data directory that can't be read, and the release proof storing the footprint through a real proveRelease call. A new test in test/tui-system.test.ts opens the System dialog and checks it shows the verdict and the off: line.
  • Terminal: the review mentions a full view in footprintLines, but that view was never on a screen; only the dialog's short version called it. I merged the two into one footprintLines (heading, verdict, off: line). The facts and reasons are on /system only.
  • Doc (6, 7): docs/features/footprint.md now says where each view really is: the /system section and its disclosure, and palette → System, after the database lines. It also says the disk figure walks the whole data directory once per release proof (never on a page view), which can take seconds on a big data directory. I didn't reuse the cached largestDirs walk because it only keeps the five largest directories, not a total.
  • Attention budget: the empty-state sentence is shorter, so the system page is set to its measured 212 words.

Where I differed from the instructions:

  • Direction (1): #12092 is assigned to me. The owner's comment on it asked for the cell ceiling and pod-limit findings to be folded into this pull. I followed the review and split them out instead.
  • Stray issue: a test request created an empty issue, #12346 "x". I edited it to become the cell-ceiling issue, so nothing stray is left.

Checks: bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts are clean. scripts/fast.ts named 2,091 files for this diff, too broad to run here, so I ran the 18 files that cover the change: footprint, tui-system, the system-* tests, attention, design and release-prove (202 pass).

To try it: on the preview, sign in as an admin and open /system → "What the forge costs", then open the disclosure. In the terminal, open palette → System.

🤖 Generated with Claude Code

commented

The check failed because the doc comment on footprintFacts in src/system/footprint.ts was one line of 103 characters, over the gate's 100-column limit. I split it into a block comment; the wording and the code are unchanged.

Gate, type check and the footprint tests (8/8) pass. scripts/fast.ts named 2091 test files for the whole branch diff, so I ran only the footprint test file, since this commit touches one comment and nothing else. The forge's full check runs on this push.

---

Measures and reports the forge's footprint (memory, time to first page, data on disk, the machine it runs on) against a stated budget, proven on a 1-CPU, 512 MiB machine. The status page shows the verdict in plain words, with the measured facts as rows behind a disclosure. The cell ceiling and the pod-limit reading are split off to #12346 and #12347.

The latest commit only rewraps the footprintFacts doc comment in src/system/footprint.ts to fit the 100-column rule.

🤖 Generated with Claude Code

commented

This fixes the one check failure that came from this pull: the dead-code test flagged clearReadyMark in src/system/footprint.ts because nothing in src/ calls it.

What changed: clearReadyMark is the reset that test/footprint.test.ts runs after each test, so every reading in that file starts from a forge that has not reported ready yet. I added it to scripts/unused-exports-allow.json, in alphabetical order. That list already holds the repository's other test resets of the same kind, such as clearRelayWaits, clearCreditCache and resetTelemetryReads. The footprint code itself is unchanged.

What I chose not to do: I left the other five red files alone: spawn-pipes, spawn-sites, did-you-mean, mcp-table and first-screen-line. The check log says the same tests are red on main at 4c3a9d3, so they don't count against this pull. I also left the two stale entries the dead-code test reports (rememberPullFiles, cachedVitals) in the shared list, because the test says a pull should not have to edit that list for them.

How to try it: bun test test/unused-exports.test.ts test/footprint.test.ts passes (11 tests), and bun scripts/gate.ts and bun x tsc --noEmit both pass.

🤖 Generated with Claude Code

commented

This pull makes a forge state its own footprint: what it uses at rest, how long until its first page answers, and what it turns off on a small machine. It adds a footprint section to /system.

What changed

  • src/system/footprint.ts takes one reading: the machine's architecture, CPUs and memory, the process's memory, how big the data directory is on disk, and which optional parts are on. It checks that reading against a fixed budget: 256 MiB at rest and the first page within 5 s. A forge that has not yet said its first page is up counts as over budget.
  • src/main.ts calls markReady() once the listener is up. Only the first mark is kept.
  • src/web/pages/system.ts shows the verdict in plain words, with the individual readings as rows inside a disclosure. When Chromium or the crew AI tool is missing, it says what is off and why.
  • clearReadyMark is only there so tests can reset the ready mark. It is listed in scripts/unused-exports-allow.json next to the other test resets.
  • The cell ceiling and the pod-limit reading were split out into #12346 and #12347, so this pull does one thing.

Check failures that are not from this pull test/spawn-pipes, spawn-sites, did-you-mean, mcp-table and first-screen-line fail on main at 4c3a9d3 with the same tests. I left them alone.

How to try it

  • Run bun test test/footprint.test.ts test/unused-exports.test.ts, then bun scripts/gate.ts and bun x tsc --noEmit. All pass locally.
  • Open /system on the preview to see the new section.

Looks: /system

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs