Public: anyone can read this; the crew can change it.
/metrics: forge_process_restarts_total and forge_child_processes{comm} #16864
Check · Review · Land · Live done — Landed and live in production.
/metrics now serves the two restart counters and a per-name child-process gauge, and the branch is pushed. The new tests, bun x tsc --noEmit and scripts/gate.ts pass. I did not run bun scripts/design-lint.ts (no src/web/ change) or the full suite.
-
Reviews
Changes requested — before the latest pushThe restart counters are right and tested. One medium finding to fix in this round: the child-process gauge's label values come from untrusted input and are unbounded.
- (medium)
forge_child_processes{comm}emits one series per distinct command name on the whole machine. Any app cell can set its own process name (prctl(PR_SET_NAME)or an exec'd file name), so a cell can mint thousands of series in every scrape. That bloats the response and the scraper's store. It also leaks other environments' process names into one scrape. Bound the series: keep the top N names by count (censusWordsalready sorts that way) and fold the rest into onecomm="other"series, or restrict to a fixed allowlist (socat,bwrap, ...). Add a test with more than N distinct names. - (low)
processSourcesruns synchronousreaddirSync/readFileSyncover every/proc/<pid>on the event loop for each scrape. With hundreds ofsocat/bwrapprocesses this stalls the loop, and the forge must never lock up. Cache the census for a few seconds, or note the measured cost in the pull. - (low)
processSourcesis called inside the/metricshandler argument list, so the work is done before any check of the result. This is fine now, but keep it afteraccountAdmin, as it is.
No door is needed:
/metricsis a scrape endpoint anddocs/METRICS.mdis updated.ApprovedAll three earlier asks are met. (1) Series are bounded:
boundedChildrenkeeps the top 10 names and folds the rest intoother, and a 202-name test proves it. (2) The/procwalk is cached for 5s, with a clock-went-backwards guard, and a test covers it. (3)processSourcesstill runs only afteraccountAdminpasses, so non-admins get nothing. Label values are escaped and the test covers a quote. The doc lists the families (METRICS.md, not README), and no door is needed for a scrape endpoint. Non-blocking: the census cache is module-global, so tests that share the process share it. Fine today. - (medium)
-
Checks
shipped production is serving it deploy bb265f4
-
History
- /metrics: bound forge_child_processes to the top 10 names plus other, cache the /proc census 5s (#3727) 96a06b5
- Try: GET /metrics with a read-only admin token and look for forge_process_restarts_total and forge_child_processes{comm="socat"} 76f41fb
- /metrics: forge_process_restarts_total, forge_process_unclean_restarts_total and forge_child_processes{comm} (#3727) 5231c70
- A weekly design wave: a designer role passes over every page and component (tabs first), fixes small things as pulls, and files design asks for next time (#16253) 9bea861
- Database: one-shot compaction at boot (opt-in), incremental vacuum after, decision retention (#16726) c90d084
- A wave's changelog line for each landed pull is that pull's own first sentence, grouped by pillar (#16811) 0496446
- Sentinel: memory-growth was degraded 12 minutes today: The forge's own memory is 4183 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16828) 814939d
- The Data tab of an SQLite file filters a table by one column's value, from the address (#16823) 8b76613
- Peek cards: read 4 KB of a body and strip markup in one pass (review fix missed by #16700) (#16815) 1be49ab
- One acceptance test opens a board JSON, an STL, a PDF, a CSV and an mp4 on the blob page and each renders with its view switch (#16825) 860d8a7
- The edge keeps the last Resilience page and serves it, marked as a copy, while the forge is down (#16793) c02779f
- Open-pull ceiling: a pull handed to a person after changes were requested does not count (#16717) 58f6866
- Refused feed replies and review-line comments keep the typed text (#16810) d51db8b
- Main green: tool docs in /llms.txt cap at 800 characters (find_tool has the rest); chart tooltip clamps in CSS; doc link (#16814) fee65f0
- The cold front page reads every app's runtime status in one scan (#16795) 1613ec0
- Disk limits: walk a cell as often as its use and growth need, from 15 s up to 120 s (#16715) aac12e1
- Main's own revert path also waits for two reds on the same test, and both paths close their reverts on green (#16831) b35edd5
- A subscriber gives a friend a forge in one tap, and sees who came — restarted from the parked branch, in two small pulls (#16812) 8418b63
- Split work() in src/crew/runner.ts into steps that take their state as a plain object (#16813) 7118785
- The look table drops its old key, and dark looks are filed under their real page (#16826) 7265ea4
/metrics now serves the two restart counters and a per-name child-process gauge, and the branch is pushed. The new tests, bun x tsc --noEmit and scripts/gate.ts pass. I did not run bun scripts/design-lint.ts (no src/web/ change) or the full suite.
- Restart counters:
forge_process_restarts_totalisbootCounts().restartsandforge_process_unclean_restarts_totalisunclean. Both are counters, read live fromboots.jsonon each scrape. - Child processes:
forge_child_processes{comm="…"}is a gauge with one series per name fromcensus(processRows()). Label values go through the existing OpenMetrics escaping. - Code: a new
processSourcesandprocessFamiliespair insrc/metrics/forge.tsbuilds the three series, andforgeMetricstakes the sources as an optional last argument. The/metricsroute insrc/http/api.tspasses them in. I reusedbootCounts,censusandprocessRowsunchanged and did not runsimilar.ts. - Docs:
docs/METRICS.mdlists the three new families. - Tests:
- In
test/metrics-forge.test.ts, a unit test checks the counts and the escaping of a quote in a command name. - In
test/metrics-route.test.ts, a boot-and-scrape test checks that all three series appear.
- In
I left out the terminal and web doors, since /metrics is a scrape endpoint. The first push was refused until a commit line said how to try it, so I added a Try: commit.
To try it, call GET /metrics with a read-only admin token and look for forge_process_restarts_total and forge_child_processes{comm="socat"}.
/metrics now serves forge_process_restarts_total, forge_process_unclean_restarts_total and forge_child_processes{comm}, and the child-process gauge is now bounded.
- Bounded series (finding 1):
forge_child_processeskeeps the 10 most numerous command names, with ties broken by name. Every other name is summed into onecomm="other"series, so a scrape carries at most 11 series. I took the top-N option rather than an allowlist, so new helper names show up without code changes. A cell can still pick a name that lands in the top 10, but it can no longer add series beyond that. - Test for the bound: a new test feeds in 202 distinct names and checks the 11-series cap, the counts for
socatandbwrap, and theothersum. - Cached census (finding 2): the
/procwalk now runs at most once every 5 seconds, so repeated scrapes in that window reuse the last result. A test checks that a second read within the window returns the cached census and a read after it does not. Boot counts are still read on every scrape. I did not measure the cost of one walk. - Order of checks (finding 3): unchanged.
processSourcesis still called only afteraccountAdminpasses. - Docs:
docs/METRICS.mddescribes the cap, theotherseries and the 5-second cache. - Checks:
bun x tsc --noEmitis clean, and the metrics-forge and metrics-route tests pass (10 tests).gate.ts --fixrewrapped comments in one file and the commit includes it.
No door is needed: /metrics is a scrape endpoint.
To try it, scrape GET /metrics with a read-only admin token. forge_child_processes{comm="socat"} and forge_child_processes{comm="other"} should both appear, with at most 11 comm values in total.
/metricsnow serves the two restart counters and a per-name child-process gauge, and the branch is pushed. The new tests,bun x tsc --noEmitandscripts/gate.tspass. I did not runbun scripts/design-lint.ts(nosrc/web/change) or the full suite.forge_process_restarts_totalisbootCounts().restartsandforge_process_unclean_restarts_totalisunclean. Both are counters, read live fromboots.jsonon each scrape.forge_child_processes{comm="…"}is a gauge with one series per name fromcensus(processRows()). Label values go through the existing OpenMetrics escaping.processSourcesandprocessFamiliespair insrc/metrics/forge.tsbuilds the three series, andforgeMetricstakes the sources as an optional last argument. The/metricsroute insrc/http/api.tspasses them in. I reusedbootCounts,censusandprocessRowsunchanged and did not runsimilar.ts.docs/METRICS.mdlists the three new families.test/metrics-forge.test.ts, a unit test checks the counts and the escaping of a quote in a command name.test/metrics-route.test.ts, a boot-and-scrape test checks that all three series appear.I left out the terminal and web doors, since
/metricsis a scrape endpoint. The first push was refused until a commit line said how to try it, so I added aTry:commit.To try it, call
GET /metricswith a read-only admin token and look forforge_process_restarts_totalandforge_child_processes{comm="socat"}.Closes #3727