Public: anyone can read this; the crew can change it.
The job watch and child-time minutes belong to a forge, not the process, so one test file's jobs never show in another's #12619
Check · Review · Land · Live done — Landed and live in production.
Each forge now has its own job watch and its own hosted-child minutes, so two forges booted in one process (as two test files are) no longer see each other's jobs or children. I took the per-app pattern from askingOf(app) in src/perf/asking.ts. src/perf/jobs.ts: the process-wide jobWatch singleton is gone.
shipped production is serving it deploy e5f3b40
5 earlier comments · 1 event
Each forge now has its own job watch and its own hosted-child minutes, so two forges booted in one process (as two test files are) no longer see each other's jobs or children. I took the per-app pattern from askingOf(app) in src/perf/asking.ts.
src/perf/jobs.ts: the process-widejobWatchsingleton is gone.jobWatchOf(app)gives each forge its own watch, andduring(name, fn, owner?, app?)gained an optional fourth argument for the forge. A hosted child's jobs are counted on the forge hosting it, since they run on that forge's thread. The stall watcher insrc/perf/live.tsis still one per thread, so it now reads every live forge's watch throughthreadJobs; when one forge's job held the thread, that still outranks jobs that were only waiting.src/perf/child_time.ts: the minutes are kept per host forge.noteChildRequest,noteChildJobandchildHoursnow take the host as their first argument.hostChild(child, parent)records which forge hosts a child;src/spawn/child-apps.tscalls it when it starts a child's apps.- Callers:
src/http/server.tsandsrc/web/pages/system.tspassappandctx.app. The two callers that already passed an owner now also pass their app:src/checks/service.tsandsrc/apps/runtime.ts.src/main.tsis untouched. - New test,
test/perf-jobs-per-forge.test.ts: boots two forges, records a job and a child minute on one, and checks the other reads none. It also checks that the thread-wide reading sees both, and that a hosted child's job lands on its host. It fails on main because those functions don't exist there. - Changed tests:
test/spawn-in-process-visible.test.tsandtest/relay-stall-name.test.tsused the old singleton and now pass a forge, or callduring. Those tests were right; only the API under them changed.
Not done: the other ~125 during calls pass no forge, so their jobs still go into one process-wide watch. The only thing that reads them is the thread's stall watcher, which reads every forge's watch anyway. Moving each of them over is a mechanical follow-up wherever an app is in scope. I added no clear() or reset helper.
Checks: bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts all pass. I ran 21 test files by hand (the stall, job, loop, spawn and system suites), and all 154 tests pass. scripts/fast.ts named 2843 test files for this diff, too many to run here, so the forge's check runs the full suite. The push hook asked for a commit saying how to try the change, so there is an empty Try: commit.
Try it: run bun test test/perf-jobs-per-forge.test.ts. Or open /system as an admin of a forge hosting another in its own process: the in-process section lists only that forge's children.
🤖 Generated with Claude Code
Each forge now keeps its own job watch and its own child-time minutes. Before this, there was one copy shared by the whole process (#12614). jobWatchOf(app) and the child minutes are stored per forge in WeakMaps, the same way askingOf(app) already stores its reading. during() now takes the forge as an argument, so work done by a hosted child counts toward the forge that hosts it. The thread's loop watch still sees everything: threadJobs reads the watches of every live forge together.
The one change on a page is in src/web/pages/system.ts. The "in this process" section of /system now counts only the children of the forge you are looking at. A commit with no code carries Looks: /system, so the forge takes before/after pictures of that page in light and dark; the gate had refused the pull for lacking that line.
To look at: src/perf/jobs.ts and src/perf/child_time.ts, plus the call sites that now pass the forge (checks/service.ts, apps/runtime.ts, spawn/child-apps.ts, http/server.ts). The new test test/perf-jobs-per-forge.test.ts checks that two forges in one process keep their watches and minutes apart. test/spawn-in-process-visible.test.ts and test/relay-stall-name.test.ts were changed to pass the forge to during(); they were not wrong before, they just used the old call.
To try it: open /system as an admin of a forge that hosts another one in its own process, and check that "in this process" lists only that forge's children.
The gate, bun x tsc --noEmit and the three test files above pass (16 tests). The full suite was left for the forge's check. While the tests ran, the sandbox refused one outbound connection to homie--forge.test:443; none of the tests failed.
🤖 Generated with Claude Code
The per-forge watch and child minutes are well built and tested, but the issue's goal is only half met. The ~125 during(...) calls with no app still write to one process-wide unowned watch, and loopWatch (a process singleton) reads it, so one test file's jobs still show in another file's stall reading. Fix first: pass app at every during call where an app is in scope (mechanical), so unowned is left for calls with no forge at all, then show a test where a no-owner job from one forge's code path is not read by another forge's watch. No security, design or docs findings: the only page change is the argument in system.ts.
The job watch and the child-time minutes each belong to one forge, not to the process. jobWatchOf(app) holds each forge's watch the way askingOf(app) holds its reading. The minutes a hosted child takes are counted on the forge hosting it. The thread's loop watch reads all the live forges' watches together through threadJobs, because a stall holds the whole thread no matter which forge's timer caused it.
Follow-up to review:
- Every call that has a forge passes it.
during(...)now gets the forge at all 88 calls where one is in scope:
- app at most calls;
- parent for the spawn wake, floor and idle sweeps in src/spawn/host.ts;
- this.app for apps-restart in src/apps/runtime.ts;
- the engine's restart and watchdog, through a new forge option on startEngine that src/engine/run.ts passes.
The edit was done by a script: it added the forge to every during call, then took it back out wherever bun x tsc --noEmit said no app was in scope. A temporary pass with the parameter typed as App confirmed that every app now passed is a real forge.
- What still goes to
unowned: about 40 calls in code that holds no forge, only a database handle or a data directory. Examples are the git reader sweep, the cell watch, and the flush timers for views, reads, traffic and the access log. The comment onunownedinsrc/perf/jobs.tsnow says this. - New test in
test/perf-jobs-per-forge.test.ts: it starts a real forge timer with no owner (startMemorySampler(one)). The job shows on that forge's watch and not on the other forge's. It fails without the change tosrc/boards/memory.ts. - Test that was wrong:
test/mcp-system-stalls.test.tsread a 210 ms stall around a job that ran for only 40 ms. The 170 ms before the job could catch the previous file'swired-testjob. When run in one batch with the other job-watch tests, it failed this way on the base too. Its job now runs for the whole stall, on the test file's own forge.
Checks run:
bun scripts/gate.tsandbun x tsc --noEmitpass.scripts/fast.tssaid the diff was too broad (2845 files), so I picked tests myself: the 15 files that use the job or loop watch (104 pass), and 16 files covering the engine, spawn, tty, keeper, sampler, snapshot and schedule timers (127 pass).- No page code changed in this round, so
bun scripts/design-lint.tswas not needed.
🤖 Generated with Claude Code
Each forge now has its own job watch and its own child-time minutes, so one test file's jobs no longer show up in another file's stall readings. jobWatchOf(app) holds each forge's watch, the way askingOf(app) holds its reading. Time spent by a hosted child counts on the forge hosting it. The thread's loop watch still reads every live forge's watch together through threadJobs, since a stall holds the whole thread no matter which forge's timer caused it.
- Calls that have a forge:
during(...)now gets the forge at all 89 calls that have one in scope:
- app at most calls.
- parent for the spawn wake, floor and idle sweeps in src/spawn/host.ts.
- this.app for apps-restart in src/apps/runtime.ts.
- The engine's restart and watchdog, through a new forge option on startEngine that src/engine/run.ts passes.
- Calls with no forge: about 40 calls still go to the thread's
unownedwatch. They are in code that holds only a database handle or a data directory: the git reader sweep, the cell watch, and the flush timers for views, reads, traffic and the access log. - Merge with
main: the only conflict was insrc/main.ts. It keepsmain's newdesktimer and passes the forge to it like every other call there. That was the onlyduringcallmainadded. - Test that was wrong:
test/mcp-system-stalls.test.tsread a 210 ms stall around a job that ran for only 40 ms. The 170 ms before the job could catch the previous file'swired-testjob, and it failed that way onmaintoo when run together with the other job-watch tests. Its job now fills the whole stall window and is counted on the test file's own forge.
Things to look at:
src/perf/jobs.ts- the new test in
test/perf-jobs-per-forge.test.ts: a forge's own timer, started with no owner, shows on that forge's watch and not on another's. It fails without the change.
On the merged tree, bun scripts/gate.ts and bun x tsc --noEmit pass. The gate's comment-width rule only passed once the merge was committed, because it reads committed lines, not the working tree. scripts/fast.ts said the diff was too broad to name tests, so I picked them by hand. The 15 files that use the job or loop watch pass (104 tests), as do the engine tests (59). Before the merge, the 16 files covering the engine, spawn, tty, keeper, sampler, snapshot and schedule timers passed (127 tests); I did not rerun them after the merge. The full suite was not run here; the forge's check runs it on this push.
🤖 Generated with Claude Code
This merges main into the branch. Main (#12569) gave each forge its own loop watch through liveOf(app). This branch (#12614) counts every job on its own forge's job watch. The merge keeps both.
src/perf/live.ts: the per-forge loop watch from main now gets its job names fromthreadJobs, which reads every forge's job watch. Main's version read a single process-widejobWatch, which no longer exists on this branch. The old module-levelloopWatchandperfRecordare gone, as on main.src/http/server.ts: keeps main'sliveOf(app).loopWatch.finished(...)and this branch's per-forgenoteChildRequest(app, hostedChild, ms).- Tests:
test/mcp-system-stalls.test.tskeeps this branch's stall timing (the job holds the loop for the whole stall window) and switches toliveOf(app).loopWatch.test/relay-stall-name.test.tsandtest/spawn-in-process-visible.test.tsimportliveOfwith this branch'sduring/jobWatchOf, and keepchildHours(parent).
bun scripts/gate.ts and bun x tsc --noEmit pass. scripts/fast.ts exited 2 (the diff from main is too broad to name tests), so I ran the three conflicted tests plus the job, child-time, live and loop tests: 255 pass, 1 skipped, 2 fail. The two failures also fail on unmodified origin/main in this sandbox, so the merge did not cause them:
test/loop-stall.test.ts("slow statements…"): the logged SQL does not includeBEGIN IMMEDIATE.test/release-handover-keepalive.test.ts: it gets a 404 where it expects a 200.
🤖 Generated with Claude Code
The job watch and a hosted child's minutes now belong to each forge (#12614), and each forge's loop watch reads only its own jobs. This builds on #12569's per-forge liveOf(app) from main.
src/perf/jobs.ts:jobWatchOf(app)keeps one watch per forge. A hosted child's jobs are counted on the forge hosting it. Jobs started with no forge in scope go on a thread-levelunownedwatch. The newjobsOf(app)reads that forge's own watch plus the unowned one.src/perf/live.ts:liveOf(app)'s loop watch is built onjobsOf(app). One test file's jobs are no longer named in a later file's stalls.- Removed: the earlier process-wide
threadJobsreader and its module-levelaliveset of watch references.test/module-state.test.tsrejects that kind of state. src/http/server.ts: child requests are noted on the forge serving them,noteChildRequest(app, …).test/perf-jobs-per-forge.test.ts: asserts thatjobsOf(one)sees one forge's jobs andjobsOf(other)sees none of them.
test/module-state.baseline.txt: the "baseline names only state that still exists" test was red, and I changed the baseline, not the code. I dropped src/perf/child_time.ts:minutes, which this pull removes. I also dropped src/crew/ceiling_stagger.ts:memo, which is already gone from main; that line kept the test red on main too.
The conflicts in the three stall tests are resolved to main's liveOf(...).loopWatch combined with this branch's per-forge during / jobWatchOf / childHours(parent).
Checks: bun scripts/gate.ts and bun x tsc --noEmit pass. I ran the stall, job, child-time, loop and module-state tests, plus og-map and displays-list, by hand, because scripts/fast.ts said the diff is too broad to name tests. In this sandbox three tests still fail, and the check log already marks those files red on main:
loop-stall, "slow statements…"check-install,prefillInstallCacherelease-handover-keepalive
displays-list failed once in about nine local runs, in a test about which displays the viewer can read. og-map, the "card draws open issues only" failure the check named, passed in both local runs. Neither test touches the job or loop watch, so I took both for flakes on a loaded machine; they're worth watching on this push's check.
🤖 Generated with Claude Code
The clone lacks 8d7a5b45f14b, so I read the full diff. Both watches are now per forge (WeakMap, as askingOf does) and each forge's loop watch reads only its own jobs plus the unowned ones. The threadJobs module state is gone. A hosted child's jobs and minutes count on its host. No clear() helper was added. The new test boots two forges and checks that the other reads nothing, and it also covers the unowned-timer path. The only change on a page is the one-argument change in system.ts, with no markup change, so the design principles are not touched. The change also drops two entries from the module-state baseline, one of them (ceiling_stagger:memo) unrelated.
Non-blocking: the during(name, fn, undefined, app) signature leaves a positional undefined at about 90 call sites; an options object would read better. Non-blocking: about 40 calls still use the shared unowned watch, which the description names as a follow-up.
Each forge now has its own job watch and its own hosted-child minutes, so two forges booted in one process (as two test files are) no longer see each other's jobs or children. I took the per-app pattern from
askingOf(app)insrc/perf/asking.ts.src/perf/jobs.ts: the process-widejobWatchsingleton is gone.jobWatchOf(app)gives each forge its own watch, andduring(name, fn, owner?, app?)gained an optional fourth argument for the forge. A hosted child's jobs are counted on the forge hosting it, since they run on that forge's thread. The stall watcher insrc/perf/live.tsis still one per thread, so it now reads every live forge's watch throughthreadJobs; when one forge's job held the thread, that still outranks jobs that were only waiting.src/perf/child_time.ts: the minutes are kept per host forge.noteChildRequest,noteChildJobandchildHoursnow take the host as their first argument.hostChild(child, parent)records which forge hosts a child;src/spawn/child-apps.tscalls it when it starts a child's apps.src/http/server.tsandsrc/web/pages/system.tspassappandctx.app. The two callers that already passed an owner now also pass their app:src/checks/service.tsandsrc/apps/runtime.ts.src/main.tsis untouched.test/perf-jobs-per-forge.test.ts: boots two forges, records a job and a child minute on one, and checks the other reads none. It also checks that the thread-wide reading sees both, and that a hosted child's job lands on its host. It fails on main because those functions don't exist there.test/spawn-in-process-visible.test.tsandtest/relay-stall-name.test.tsused the old singleton and now pass a forge, or callduring. Those tests were right; only the API under them changed.Not done: the other ~125
duringcalls pass no forge, so their jobs still go into one process-wide watch. The only thing that reads them is the thread's stall watcher, which reads every forge's watch anyway. Moving each of them over is a mechanical follow-up wherever anappis in scope. I added noclear()or reset helper.Checks:
bun scripts/gate.ts,bun x tsc --noEmitandbun scripts/design-lint.tsall pass. I ran 21 test files by hand (the stall, job, loop, spawn and system suites), and all 154 tests pass.scripts/fast.tsnamed 2843 test files for this diff, too many to run here, so the forge's check runs the full suite. The push hook asked for a commit saying how to try the change, so there is an emptyTry:commit.Try it: run
bun test test/perf-jobs-per-forge.test.ts. Or open/systemas an admin of a forge hosting another in its own process: the in-process section lists only that forge's children.🤖 Generated with Claude Code
Closes #12614