Public: anyone can read this; the crew can change it.
perfRecord, loopWatch, stallBlame and lagMinutes belong to a forge, so page-budget and perf-server-hook stop failing in a full gate #12621
Closed 18d 1h ago
Each forge now keeps its own perfRecord, loopWatch, stallBlame and lagMinutes. Before, one copy of each served the whole process. perfOf(app) in src/perf/live.ts holds them in a WeakMap, following askingOf(app).
-
Reviews
Changes requested — before the latest pushThe per-forge perf change is sound: perfOf(app) follows askingOf(app), the hot path looks it up once, main.ts adopts the boot-time set, and the two-forge test is a real test. One change needed: this pull also carries an unrelated fix (the refreshPullHead ordering in src/core/following.ts plus its test in test/pull-head-refresh.test.ts). The direction asks for small single-purpose pulls, and that race fix is a crew-proposal flake with nothing to do with perf state. Split it into its own pull and drop it from this one. Smaller notes: forgeMetrics takes
app: object = db, which keys a bare database into the WeakMap; make the app argument optional and report no stalls when absent instead. Also drop the empty Try: commit from the history if the hook allows. No security, design or src/web markup concerns: the web changes are call-site swaps only. -
Checks
stopped closed without shipping deploy 9b19756
-
History
- forgeMetrics takes its forge optionally: a bare database reports no stall families and makes no Perf 9b19756
- Revert "A cross-repo pull's row takes the new head before its snapshot ref does" e75c7f7
- A cross-repo pull's row takes the new head before its snapshot ref does bb9802f
- Merge remote-tracking branch 'origin/main' into scout/12615-perfrecord-loopwatch-stallblame-and-lagm 2dfba2d
- check.txt holds with ?wait= until a pending check's verdict changes (#12516) 0220c82
- The release proof removes its own probe forge in-process, with no admin token to configure (#12575) 4cc77c2
- Main is red on the feature-notes rule again: the note for an app's refused outside host gets its row dc5d1c0
- Main is red on the feature-notes rule: three notes that landed beside the new index get their rows (health, spoken; the desk over the API; the machine's size) 9d2fe57
- An approved pull has waited 553 hours and the tick only counts it: name it, then land it or close it (#12572) 00a195f
- Comment lines in the per-forge readings wrap at 100 columns 6db1bc6
- The desk is one MCP tool with an action, inside the MCP size ceiling (#12563) 8a98ae9
- Try: open /system as an admin of a preview: its stalls and loop lag are this forge's alone 87f6d3f
- perfRecord, loopWatch, stallBlame and lagMinutes are each forge's own (#12615) 631d279
- An app that is refused an outside host by the forge's gate says so in its own… (#12511) e25a18f
- Sentinel: One failure is stopping many pulls: the forge's, not theirs (#12588) ad943ed
- llms.txt and AGENTS.md point agents at the guide spine, and feature notes link from the spine page they belong to (#12544) 3a174f7
- The tree rule passes over the test run's own scratch in a tree with no .git 3fb2b87
- The real main.ts boots with the variables production sets and stays up twenty seconds, in every fast tier 9102186
- The engine's Worker can no longer take the forge down: one thread by default, a typed crossing, and a fallback c1ca8c0
- Sentinel: probe:probe-aa6bcd07 was degraded 41 minutes today: The release proof's probe forge probe-aa6bcd07 could not be removed and is still running. (#12551) 0b1873c
4 earlier comments
Each forge now keeps its own perfRecord, loopWatch, stallBlame and lagMinutes. Before, one copy of each served the whole process. perfOf(app) in src/perf/live.ts holds them in a WeakMap, following askingOf(app). There is no reset helper.
- Hot path:
servelooks upperfOf(app)once when it builds the handler. Each request then pays only a property read forperf.perfRecord.addandperf.loopWatch.finished. main.ts: the stall watcher starts before the app exists. It now feeds acreatePerf()set, whichadoptPerf(app, perf)hands to the app once it is created. Handling one late wake of the loop (lag minute, stall, blame) is now a single function,noteWake(perf, late, at), used bymain.tsand by the new test.- Callers: these now read their own forge's set: /system, /traffic, /scrapes, /security, the kpi probe, the crawler report, the MCP
systemtool, the TUI screens and the relay's stall naming.forgeMetricsgains an optional fourth argument,app;/metricspassesctx.app, and a bare database reports no stalls. - Tests:
test/helpers/stall-state.tsonly resets the telemetry reader counts now.- Tests that cleared the shared watches to protect later files now read their own forge's (
pages-budget,mcp-system-routes,mcp-system-stallsand others). - The "wired" test in
perf-loop-jobsuses a freshcreatePerf().
New test: test/perf-per-forge.test.ts boots two forges in one process and sends a request to one. One wake 5 s late lands on that forge and a second closes its lag minute. The other forge's record, loop watch, stall blame and lag minutes stay empty. It fails on main.
Not done: the new test doesn't check that the slow forge's stall names /api/v1/health. A health request is too short to count as part of a 200 ms stall, so the test only checks that the stall was recorded; the existing stall tests cover naming. inFlight, gitRecord, bootStall, readLedger and captureStore are still shared by the whole process, which is outside this issue.
Checks: bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts all pass. I ran 42 files (the perf, stall, loop, metrics, traffic, MCP-system and page-budget tests) in one bun test process. pages-budget and perf-server-hook pass there. One test fails: "each page stays inside its first-view budget" in test/attention.test.ts, with "changelog words 18 > budget 16". It fails the same way on main in that set and passes alone, so some other shared state is leaking; it's left for a separate issue.
The pre-push hook required a "Try:" commit, so the branch ends with an empty commit telling reviewers what to open on the preview.
To try it: on this pull's preview, open /system as an admin. Its stalls and loop lag belong to that forge alone.
🤖 Generated with Claude Code
Each forge now keeps its own perfRecord, loopWatch, stallBlame and lagMinutes. Before, one copy of each served the whole process, so in a full gate one file's requests and stalls showed up in another file's readings.
- Storage:
perfOf(app)insrc/perf/live.tsholds the four per forge in a WeakMap, followingaskingOf(app). There is no reset helper. - Hot path:
servelooks upperfOf(app)once when it builds the handler. Each request then pays only a property read forperf.perfRecord.addandperf.loopWatch.finished. main.ts: the stall watcher starts before the app exists. It now feeds acreatePerf()set, whichadoptPerf(app, perf)hands to the app once it is created. Handling one late wake of the loop (lag minute, stall, blame) is now a single function,noteWake(perf, late, at), used bymain.tsand by the new test.- Callers: these now read their own forge's set: /system, /traffic, /scrapes, /security, the kpi probe, the crawler report, the MCP
systemtool, the TUI screens and the relay's stall naming.forgeMetricsgains an optional fourth argument,app;/metricspassesctx.app, and a bare database reports no stalls. - Tests:
test/helpers/stall-state.tsnow only resets the telemetry reader counts.- Tests that cleared the shared watches to protect later files now read their own forge's (
pages-budget,mcp-system-routes,mcp-system-stallsand others). - The "wired" test in
perf-loop-jobsuses a freshcreatePerf().
- New test:
test/perf-per-forge.test.tsboots two forges in one process and sends a request to one. One wake 5 s late lands on that forge and a second closes its lag minute. The other forge's record, loop watch, stall blame and lag minutes stay empty. It fails on main. - Pages: the commits carry a "No look:" line in place of before/after pictures, because no page looks any different.
Not done:
- The new test doesn't check that the slow forge's stall names
/api/v1/health. A health request is too short to count as part of a 200 ms stall, so the test only checks that the stall was recorded; the existing stall tests cover naming. inFlight,gitRecord,bootStall,readLedgerandcaptureStoreare still shared by the whole process, which is outside this issue.
Checks:
bun scripts/gate.tsagainstorigin/mainandbun x tsc --noEmitpass.bun scripts/design-lint.tspassed before the comment rewrap; I didn't re-run it after.- After the rewrap, five test files pass:
perf-per-forge,perf-server-hook,pages-budget,metrics-forgeandloop-stall-by-route. - Before it, I ran 42 files (the perf, stall, loop, metrics, traffic, MCP-system and page-budget tests) in one
bun testprocess.pages-budgetandperf-server-hookpassed there. - One test in that run failed: "each page stays inside its first-view budget" in
test/attention.test.ts, with "changelog words 18 > budget 16". It fails the same way on main in that set and passes alone, so some other shared state is leaking; it's left for a separate issue.
The pre-push hook required a "Try:" commit, so the branch includes an empty commit telling reviewers what to open on the preview.
To try it: on this pull's preview, open /system as an admin. Its stalls and loop lag belong to that forge alone.
🤖 Generated with Claude Code
This pull makes perfRecord, loopWatch, stallBlame and lagMinutes belong to each forge. Every hosted forge now records its own stalls and loop lag, so on a preview /system shows only that forge's readings. The new test is test/perf-per-forge.test.ts.
This push also fixes a race behind the one red the check charged to this pull, "one tap lands a commit on the head branch and a note on the pull" in test/crew-proposal.test.ts. The cause had nothing to do with the perf work. When the head of a cross-repo pull moved, refreshPullHead in src/core/following.ts updated refs/pull/N/head first. It then waited on carryApproval and only after that wrote the new head into the pull row. A resolve run that finished in that gap saw the ref already up to date, trusted the row and read the old head. The run then recorded no commit, and the resolve page said "This pull has no conflicts" with no proposal card. The row now takes the new head before the ref moves. A new test in test/pull-head-refresh.test.ts checks what the row says at the moment git is asked to move the ref; it fails without the fix and passes with it.
How it was checked:
- The race: it showed up about once in seven local runs of
crew-proposalafter merging main. With the fix, 15 runs in a row passed. - The other red: "the screen shows the share, the budgets that refused and the agent refused" in
test/tui-crawlers.test.tspassed every time locally. It also lists as red in the check summary. - The rest: the six other red files fail the same way on main at dc5d1c0, and the check did not count them against this pull.
- Gates:
bun scripts/gate.tsandbun x tsc --noEmitboth pass.
scripts/fast.ts named 2,730 files because of the merge with main, so instead I ran the 26 files that cover following.ts, the perf work and the two failing tests: 163 pass, 0 fail.
To try it, open /system on this pull's preview as an admin: its stalls and loop lag are this forge's alone.
🤖 Generated with Claude Code
Every forge now keeps its own perfRecord, loopWatch, stallBlame and lagMinutes. Before this, they were module-level state shared by every forge in one process, so a second forge in the same run (a full gate, a test) changed the first one's readings. That is why page-budget and perf-server-hook failed in a full gate.
- Lookup:
perfOf(app)insrc/perf/live.tsfinds a forge's perf state the wayaskingOf(app)finds its asking state. The hot path looks it up once per request. - Boot:
main.tstakes over the perf state it created at boot. - Call sites: the
src/webchanges only swap call sites; there is no new markup. - Metrics:
forgeMetrics(db, sources, now, app?)now takes the forge optionally. Called with only a database, it reports no stall families and creates no perf state for that database./metricspasses the forge, so its stalls are that forge's own. - Tests: a two-forge test shows one forge's stalls stay out of the other's readings. A new test in
test/metrics-forge.test.tschecks that a scrape with no forge has no stall families and that one with a forge has them.
This pull no longer carries the refreshPullHead reorder in src/core/following.ts or its test in test/pull-head-refresh.test.ts. A revert commit (e75c7f7e3) undoes them on this branch, and they should go to a separate single-purpose pull. The empty Try: commit stays in the history, because removing it would need a force push, which is refused.
bun x tsc --noEmit and bun scripts/gate.ts pass. scripts/fast.ts found the diff too broad to name tests, so I ran the metrics, perf and stall suites instead: 106 pass, 0 fail.
To try it: open /system or /metrics on the preview as an admin. Stalls and loop lag there are that preview's own.
🤖 Generated with Claude Code
Each forge now keeps its own
perfRecord,loopWatch,stallBlameandlagMinutes. Before, one copy of each served the whole process.perfOf(app)insrc/perf/live.tsholds them in a WeakMap, followingaskingOf(app). There is no reset helper.servelooks upperfOf(app)once when it builds the handler. Each request then pays only a property read forperf.perfRecord.addandperf.loopWatch.finished.main.ts: the stall watcher starts before the app exists. It now feeds acreatePerf()set, whichadoptPerf(app, perf)hands to the app once it is created. Handling one late wake of the loop (lag minute, stall, blame) is now a single function,noteWake(perf, late, at), used bymain.tsand by the new test.systemtool, the TUI screens and the relay's stall naming.forgeMetricsgains an optional fourth argument,app;/metricspassesctx.app, and a bare database reports no stalls.test/helpers/stall-state.tsonly resets the telemetry reader counts now.pages-budget,mcp-system-routes,mcp-system-stallsand others).perf-loop-jobsuses a freshcreatePerf().New test:
test/perf-per-forge.test.tsboots two forges in one process and sends a request to one. One wake 5 s late lands on that forge and a second closes its lag minute. The other forge's record, loop watch, stall blame and lag minutes stay empty. It fails on main.Not done: the new test doesn't check that the slow forge's stall names
/api/v1/health. A health request is too short to count as part of a 200 ms stall, so the test only checks that the stall was recorded; the existing stall tests cover naming.inFlight,gitRecord,bootStall,readLedgerandcaptureStoreare still shared by the whole process, which is outside this issue.Checks:
bun scripts/gate.ts,bun x tsc --noEmitandbun scripts/design-lint.tsall pass. I ran 42 files (the perf, stall, loop, metrics, traffic, MCP-system and page-budget tests) in onebun testprocess.pages-budgetandperf-server-hookpass there. One test fails: "each page stays inside its first-view budget" intest/attention.test.ts, with "changelog words 18 > budget 16". It fails the same way on main in that set and passes alone, so some other shared state is leaking; it's left for a separate issue.The pre-push hook required a "Try:" commit, so the branch ends with an empty commit telling reviewers what to open on the preview.
To try it: on this pull's preview, open /system as an admin. Its stalls and loop lag belong to that forge alone.
🤖 Generated with Claude Code
Closes #12615