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

A release keeps the forge's log and each child forge's up and down history, so "was it down?" has an answer #17913

opened this in answer to

Merged 21h 20m ago, live in production

The forge now keeps its own log across releases and records each child forge's up, asleep, woken and down changes. /forges shows the last 24 hours of them as a strip. The gate passes, apart from two notes.

Notes

opened this

The forge now keeps its own log across releases and records each child forge's up, asleep, woken and down changes. /forges shows the last 24 hours of them as a strip. The gate passes, apart from two notes. tsc is clean and the tests I ran pass: the new ones, the existing kept-log, week-line and doorless tests, and the repo-wide rules the issue names. Most of the suite was not run, because scripts/fast.ts found the diff too broad to name a subset; the forge's check runs the full suite on the push.

  • Forge log. Every log line, including the child forges' lines, is also appended to <data>/log/forge.log. It rotates daily and at 8 MiB per file, and files whose newest line is over 7 days old are deleted. The ceiling is about 250 MiB. I reused keptLog in src/perf/kept_log.ts and added age rotation to it. Read the log with bun scripts/forge-log.ts [dir] [text].
  • State history.
    • What existed. Only reach.ts proofs (one overwritten file per child) and the forge.child_unreachable and forge.child_reachable events existed. Asleep and woken were only logged, and nothing kept a history.
    • What's new. A new table, forge_state, has a row per state change with its time, kept for 8 days. src/spawn/state_history.ts samples each finished child every minute and writes a row only when its state changed. Down means it is running but the reach proof fails; woken means up again after asleep.
    • Where it shows. The /forges row shows the last 24 hours as one mark an hour (■ up, · asleep, ✕ down, ? not recorded) with the hours totalled in words, and the terminal forges screen shows the same marks. The how-to is docs/features/forge-state-history.md.
  • Tests. test/forge-state-history.test.ts covers a restart keeping the previous run's log lines and a child's state rows, the daily and weekly log rotation, the strip, and the sampler through to the page and the terminal. I also timed the new job in job-slices.test.ts.

Left out.

  • Release downtime isn't recorded. The forge isn't there to sample while a release replaces it, so that stretch shows as ? in the strip.
  • Finest resolution is a minute. The log lines still give exact times.
  • No look picture. The seeded page has no hosted child, so I said "No look" in the commit.
  • Release scripts untouched. I left run.sh, tick.sh and boot.sh alone, as asked.
  • Gate notes. The gate flags startStateWatch as 0.60-similar to startReachWatch. I kept them separate, since the first-run delay and the work differ. I added a "No door" line because the existing forges screen carries the strip.

Try it. Open /forges on the preview as an admin. Each forge's row shows the strip after the first sample, about a minute after boot. On a deployed forge, run bun scripts/forge-log.ts "$FORGE_APP_DATA" asleep.

🤖 Generated with Claude Code

Closes #17909

2 earlier comments
commented

The forge now keeps its own log across releases and records each child forge's up, asleep, woken and down changes. /forges shows the last 24 hours of them as a strip. The gate passes, apart from two notes. tsc is clean and the tests I ran pass: the new ones, the existing kept-log, week-line and doorless tests, and the repo-wide rules the issue names. Most of the suite was not run, because scripts/fast.ts found the diff too broad to name a subset; the forge's check runs the full suite on the push.

  • Forge log. Every log line, including the child forges' lines, is also appended to <data>/log/forge.log. It rotates daily and at 8 MiB per file, and files whose newest line is over 7 days old are deleted. The ceiling is about 250 MiB. I reused keptLog in src/perf/kept_log.ts and added age rotation to it. Read the log with bun scripts/forge-log.ts [dir] [text].
  • State history.
    • What existed. Only reach.ts proofs (one overwritten file per child) and the forge.child_unreachable and forge.child_reachable events existed. Asleep and woken were only logged, and nothing kept a history.
    • What's new. A new table, forge_state, has a row per state change with its time, kept for 8 days. src/spawn/state_history.ts samples each finished child every minute and writes a row only when its state changed. Down means it is running but the reach proof fails; woken means up again after asleep.
    • Where it shows. The /forges row shows the last 24 hours as one mark an hour (■ up, · asleep, ✕ down, ? not recorded) with the hours totalled in words, and the terminal forges screen shows the same marks. The how-to is docs/features/forge-state-history.md.
  • Tests. test/forge-state-history.test.ts covers a restart keeping the previous run's log lines and a child's state rows, the daily and weekly log rotation, the strip, and the sampler through to the page and the terminal. I also timed the new job in job-slices.test.ts.

Left out.

  • Release downtime isn't recorded. The forge isn't there to sample while a release replaces it, so that stretch shows as ? in the strip.
  • Finest resolution is a minute. The log lines still give exact times.
  • No look picture. The seeded page has no hosted child, so I said "No look" in the commit.
  • Release scripts untouched. I left run.sh, tick.sh and boot.sh alone, as asked.
  • Gate notes. The gate flags startStateWatch as 0.60-similar to startReachWatch. I kept them separate, since the first-run delay and the work differ. I added a "No door" line because the existing forges screen carries the strip.

Try it. Open /forges on the preview as an admin. Each forge's row shows the strip after the first sample, about a minute after boot. On a deployed forge, run bun scripts/forge-log.ts "$FORGE_APP_DATA" asleep.

🤖 Generated with Claude Code

commented

I fixed both failing tests and pushed the fix. The new src/spawn/state_history.ts timers and my test's imports were the cause, and none of the earlier work changed.

  • Timers rule. The state watch's setTimeout and setInterval callbacks now call background("forge-state", …) inline. Before, they went through a local run helper that the rule couldn't see. That was the "every server-side timer callback is wrapped in during or allowed by name" failure.
  • Duplicate imports. I merged the repeated node:fs and state_history.ts imports in test/forge-state-history.test.ts. That was the "no duplicate import" failure.

timers-named, dup-imports, forge-state-history and job-slices pass (23 tests), and tsc is clean. I did not rerun the full suite. The forge's check does that on this push.

The gate prints two notes, neither a refusal:

  • Similar functions. It says startStateWatch is 0.68 like startReachWatch ("one implementation?"). I kept them separate: the state watch is a short-delay sampler and the reach watch is a prober with its own schedule.
  • Comment width. One comment in src/main.ts runs over 100 columns, and --fix left it alone.
commented

I fixed items 1, 2, 3 and 5 and pushed. Item 4 is only half done: there is still no look picture for the strip.

  1. Named component. The strip is now .state-strip, on its own line, white-space: nowrap, tokens only. It scrolls sideways before it would wrap through the marks. The marks use .state-strip-marks in the mono font. The class is in src/web/style/components.ts and registered in docs/design/areas/forges.md. I only wrote the CSS and ran the tests. I did not view it at 360px.
  2. One legend. I dropped title, the .sr-only copy and the glyph legend. The marks are aria-hidden, and the visible words carry the meaning: "Last 24 h: up 20 h, asleep 3 h, down 1 h".
  3. No leading ?. Only the hours since the first row are marked. A newer forge's words add "recording began N h ago". The terminal screen shows the same marks and words after 24 h.
  4. Review and look.
    • No look added. /forges is not in app.looks, and the seeded app has no hosted child, so the strip has no page to be pictured on. I left "No look" in the commit with that reason.
    • 404 on the preview. /forges is admin-only and answers 404 to anyone else.
    • To see it. I haven't confirmed a preview child shows the strip, because the sample runs about a minute after boot. Sign in as an admin, send a forge at /forges/new, wait two minutes, and open /forges.
    • Review block. I did not write the review JSON block. I'm not sure it is needed, since the gate printed no refusal for it.
  5. Lint and comment. bun scripts/design-lint.ts reports "no colour, size or component added outside the system". tsc is clean and 143 tests pass, including the unused-exports and design tests. The over-100-column line the gate flags in src/main.ts is line 764. It is already on main and not in my diff, so I left it.

The gate's "startStateWatch is 0.68 like startReachWatch" is still only a note.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs