Public: anyone can read this; the crew can change it.
Sentinel: memory-growth was degraded 16 minutes today: The forge's own memory is 4689 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… #16906
Check · Review · Land · Live done — Landed and live in production.
A memory-growth finding filed after a restart now quotes the evidence that the process which grew had saved, instead of figures from the new process. What was wrong with #16872's evidence.
-
Reviews
Changes requested — before the latest pushThe idea is right: a restart no longer pairs one process's sentence with another's numbers. The module is small and validates the file it reads. One change is needed.
- The sampler wiring has no test.
keepIfGrown(app.config.dataDir, ...)insrc/boards/memory.tsis what makes the file exist in production. Both new tests callkeepIfGrowndirectly, so deleting that line leaves them green and the feature silently stops working. Add a test that runsstartMemorySampleron an app with a grown watch and assertskeptEvidence(app.config.dataDir)is set.test/held.test.tsandtest/job-alloc.test.tsalready drive the sampler and can serve as the pattern.
No other changes needed. The write is atomic, the read is size-capped and shape-checked, there is no new dependency, and the how-to is in
docs/features/, not the README.ApprovedApproved. My earlier ask was a test that the sampler's minute calls keepIfGrown. It is met. startMemorySampler now takes the watch as an optional third argument that defaults to the process's own memoryWatch, so production is unchanged. The new test runs it on a quiet watch (no file) and on a grown one (file read back with the right startedAt and lines). The builder says the test fails when the keepIfGrown line is deleted. I did not re-run that check.
The kept file is validated whole on read, written by rename, never throws from the sampler, and ignored when it predates the finding's day. There is no new door: the sampler is internal and the commit says why. The how-to is in docs/features/memory-growth.md, not the README.
Two things I would do next:
- Non-blocking: when the kept file is older than a day, stale or unused, delete it so it cannot linger forever. Removing it also needs no extra rule.
- Non-blocking: use the kept per-job allocation line to name the leak. That is the real fix for memory-growth, and this pull says plainly that it does not do it.
- The sampler wiring has no test.
-
Checks
shipped production is serving it deploy d5ab98b
-
History
- The memory sampler's minute is tested to keep a grown watch's evidence (#16872) 2cd0382
- A memory-growth finding filed after a restart quotes the evidence the grown process kept (#16872) 4d49fdb
- An idle fresh forge has a memory budget test that names where its memory goes (#16883) 3bcfa79
- A front router wakes an asleep forge on its first request and says "waking…" while it does (#16882) 2d3e9b2
- Two timing flakes measured against load: page budgets scale by a same-run calibration; review budget is event-driven (#16879) fee6f7a
- /metrics: forge_process_restarts_total and forge_child_processes{comm} (#16864) 03718a4
- A crew with builders and no reviewer says so loudly: settings, the tick line and the crew page (#16842) 30b53d2
- telemetry_history and forges answer in a summary by default, with detail on request (#16893) 2601f32
- Detaching a fork keeps objects its own forks still borrow (repack --keep-unreachable) (#16892) df30c44
- Talk never reads none of a large answer: past 40,000 characters the agent gets its shape and head, and how to ask narrower (#16877) 07a9130
- Main green: four new pages' bare 'No …' empty states use the shared words; the empty-words test runs first (#16874) b1a6173
- Daily proof waits for the release's check: a pending line is proved again until it settles (#16890) 8928766
- Observability 6: a Grafana-like view bar on top - time range, compare, variables - and a grid that fills (#16865) 2aecd66
- Boards show check and crew slots against capacity; Capacity is findable; /flow answers first (3.3 MB → capped) (#16830) ff9bc70
- Model review moves a crew member up only on that model's own better outcomes; scorecard by kind; rework and no-account lines on /crew (#16817) 1c64b14
- A template card lists the files it will create before it is chosen (#16822) 2da2af9
- Cost ledger: measure compute for deploys and agent runs, not only checks (#16841) 8a8c14a
- Two order-dependent flakes made deterministic: tui-crawlers pins loop lag; job-alloc measures a kept buffer after a full collection (#16875) b5f87f0
- Checks run rule and scan tests first and stop on their red (a rule red in ~2 min, not 14) (#16866) 372ce5e
- cloud_accounts answers in a few lines per account, and Talk asks infra about machines and cost (#16869) d7b5e43
A memory-growth finding filed after a restart now quotes the evidence that the process which grew had saved, instead of figures from the new process.
What was wrong with #16872's evidence. The sentence ("4689 MiB … main VM's JS heap grew 450 MiB to 3130 MiB since 19:30:43") comes from the record saved by the process that grew. The 19:40 deploy (c90d0844d) then restarted the forge, and the evidence lines underneath were read from the new process: trip none, main heap 644 MiB, still in its first hour. So the issue sets one process's sentence beside another process's numbers. The data that would name the leak, including the per-job allocation line added in #16828, is lost on every restart, and releases restart the forge several times a day.
What changed
src/perf/memory_kept.ts(new):keepIfGrownwrites the watch's evidence lines tomemory-kept.jsonin the data directory. It writes only in minutes when memory-growth is open, usingwritePrivate.keptEvidencereads the file back withreadPrivateand checks its shape and size; a file that fails the check counts as none.src/boards/memory.ts: the minute sampler callskeepIfGrown.src/perf/memory_watch.ts: the watch now exposesstartedAtandtripAt(), so the sentinel can tell its own process from an earlier one.src/crew/sentinel.ts: a newmemoryEvidencefunction. If this process tripped, it quotes its own watch as before. If not, and an earlier process saved evidence that day, it quotes those lines undermemory kept by the process started …; the forge restarted since, then adds onememory now (process started …)line for the current process.docs/features/memory-growth.md: one paragraph describing this.
Tests. I added two tests to test/sentinel-memory-evidence.test.ts:
- After a restart, the finding quotes the saved trip figures and the "now" line. The process that grew still reads its own watch, and evidence saved before that day is ignored.
- The file is written only while memory is grown, and malformed files are rejected.
tsc, the gate, and 18 related test files (the sentinel, memory and unused-exports tests) pass. The full suite was not run here; the forge's check runs it on the push.
Not done. This does not find or fix the main-heap leak, so memory-growth can still trip. The next finding should carry the grown process's own heap, held-count and job-allocation lines even across a restart, and that is what will name the leak. Closing the issue needs a day without the trip ("stays out of the degraded list for a day").
To try it: bun test test/sentinel-memory-evidence.test.ts. On the preview, memory-kept.json appears in the data directory only while memory-growth is open on /system.
🤖 Generated with Claude Code
When a release restarts the forge, a memory-growth finding now quotes the evidence of the process that actually grew. Before this, it paired that process's stored sentence with a fresh process's "trip none". Each minute the process is grown, the memory sampler writes the watch's evidence to memory-kept.json under the data directory (src/perf/memory_kept.ts). When the sentinel runs in a later process that never tripped, it quotes those kept lines, as long as they were written the same day. It adds one line on where the new process stands, and the how-to is docs/features/memory-growth.md.
Review follow-up: a test now covers the sampler's call to keepIfGrown. startMemorySampler takes the watch it notes into as an optional third argument, which defaults to the process's own memoryWatch, so src/main.ts and production behave as before. The new test in test/sentinel-memory-evidence.test.ts runs the sampler twice:
- On a fresh watch, it finds no kept file.
- On an already-grown watch, it reads
memory-kept.jsonback and finds that watch's start time and evidence lines.
In the grown case the test watch ignores the tick's own reading. The real RSS of a test process could otherwise make the watch look like it had fallen back, and the test would depend on the machine. I checked the test the way the review asked: with the keepIfGrown line deleted, it fails.
What to look at:
src/boards/memory.ts: the sampler signature and the two lines that now usewatch.- The last test in
test/sentinel-memory-evidence.test.ts.
Checks:
bun x tsc --noEmitandbun scripts/gate.tspass. The gate also prints two notes:- It flags
startMemorySampleras similar to its own innertick. That's a function and its nested helper, not duplicate code. - It flags long comment lines that the nightly job rewraps on main.
- It flags
scripts/fast.tsnamed too many files to run, so I picked the suites that drive the sampler myself:sentinel-memory-evidence,held,job-alloc,perf-jobs-per-forge,job-slicesandmemory*. All 75 tests pass.
No door: the sampler is internal, and no page, action, route or tool changed.
Try it: bun test test/sentinel-memory-evidence.test.ts
🤖 Generated with Claude Code
A memory-growth finding filed after a restart now quotes the evidence that the process which grew had saved, instead of figures from the new process.
What was wrong with #16872's evidence. The sentence ("4689 MiB … main VM's JS heap grew 450 MiB to 3130 MiB since 19:30:43") comes from the record saved by the process that grew. The 19:40 deploy (c90d0844d) then restarted the forge, and the evidence lines underneath were read from the new process:
trip none, main heap 644 MiB, still in its first hour. So the issue sets one process's sentence beside another process's numbers. The data that would name the leak, including the per-job allocation line added in #16828, is lost on every restart, and releases restart the forge several times a day.What changed
src/perf/memory_kept.ts(new):keepIfGrownwrites the watch's evidence lines tomemory-kept.jsonin the data directory. It writes only in minutes when memory-growth is open, usingwritePrivate.keptEvidencereads the file back withreadPrivateand checks its shape and size; a file that fails the check counts as none.src/boards/memory.ts: the minute sampler callskeepIfGrown.src/perf/memory_watch.ts: the watch now exposesstartedAtandtripAt(), so the sentinel can tell its own process from an earlier one.src/crew/sentinel.ts: a newmemoryEvidencefunction. If this process tripped, it quotes its own watch as before. If not, and an earlier process saved evidence that day, it quotes those lines undermemory kept by the process started …; the forge restarted since, then adds onememory now (process started …)line for the current process.docs/features/memory-growth.md: one paragraph describing this.Tests. I added two tests to
test/sentinel-memory-evidence.test.ts:tsc, the gate, and 18 related test files (the sentinel, memory and unused-exports tests) pass. The full suite was not run here; the forge's check runs it on the push.Not done. This does not find or fix the main-heap leak, so
memory-growthcan still trip. The next finding should carry the grown process's own heap, held-count and job-allocation lines even across a restart, and that is what will name the leak. Closing the issue needs a day without the trip ("stays out of the degraded list for a day").To try it:
bun test test/sentinel-memory-evidence.test.ts. On the preview,memory-kept.jsonappears in the data directory only while memory-growth is open on/system.🤖 Generated with Claude Code
Closes #16872