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

vitals() names each degraded cause with when it began, landed from pull #1363 on today's main #1519

Closed opened this
Closed without merging

vitals() now returns degraded, one entry per cause with when it began, and /api/v1/health carries it for site admins. The type check is clean and the four test files I ran pass. Vitals.degraded: each entry is { cause, sentence, since, href }.

Notes

stopped closed without shipping deploy bbfc259

opened this

vitals() now returns degraded, one entry per cause with when it began, and /api/v1/health carries it for site admins. The type check is clean and the four test files I ran pass.

  • Vitals.degraded: each entry is { cause, sentence, since, href }. needs is unchanged, and every needs sentence appears in degraded.
  • Causes: disk, errors, internal, queue:<kind> and stuck:<runId>. Each key lasts as long as its condition holds.
  • since:
    • A queue cause uses the oldest queued run's createdAt.
    • A stuck run uses its last heartbeat, falling back to startedAt and then createdAt.
    • disk, errors and internal record no start, so they use at.
  • internal cause (my addition): the refused-internal-call sentence is also in needs, so it gets an entry too, keyed internal.
  • Stuck runs: needs has one sentence for all of them ("2 runs are stuck."). Each stuck run still gets its own entry, so those entries share that sentence.
  • href: /settings/capacity for disk and queues, /<repo>/runs/<id> for a stuck run, and /api/v1/health for errors and refused calls. I picked these myself; change them if a better page exists.
  • Health route: readHealth already spreads the vitals, so src/http/api.ts needed no change.
  • Tests: I added one test in test/vitals.test.ts that covers each cause and its since. It also checks the health response carries degraded. The health key-list assertion in that file now includes degraded.
  • Gate list: I added no test files, so scripts/gate.ts is untouched and test/check-list.test.ts passes.
  • Not done: I did not bring over #1363's scripts/gate.ts hunks, and I did not change the board strip's needHref.

Checks run before the push:

  • bun x tsc --noEmit: no errors. It only worked after bun install.
  • bun test test/vitals.test.ts test/health.test.ts test/check-list.test.ts test/board.test.ts: 43 pass, 0 fail.

To try it: call GET /api/v1/health with a site admin's token and read degraded.

Closes #1456

Show 1 earlier items

7 earlier comments · 1 event
commented

Every degraded entry now carries a since that holds steady between polls, and the board and terminal show it. The type check and the board, vitals, terminal-screen and health tests pass. I did not run the whole bun test and did not open the preview.

  • since was false for disk, errors and internal. vitals() now keeps an in-process map from cause to the time it was first seen. An entry is dropped once its cause clears, so a cause that comes back starts again.
    • Errors use the oldest error in the hour, internal uses the oldest refused call in the hour, and queue and stuck keep their own evidence.
    • Disk has no evidence of its own, so it uses the first time this process saw it. That resets when the forge restarts.
    • To supply the oldest times, recentErrors and refusedInternal each return one extra oldest field.
  • Stuck now reads one run at a time. Each entry says "Run X is stuck: it has not moved since T."
  • Errors and internal now link to /audit, not the raw JSON API. I picked it because it was the closest owner-facing page I found. If you know a better one, it is a one-line change.
  • The board's forge strip links every cause, each with its since. Before, only a stuck run was linked. The terminal dashboard prints each cause with "Since T", through a shared needLine helper in src/actions/health.ts. The terminal has no links, so it shows since but not href.
  • README: a new Health section documents the degraded field.
  • Tests: the vitals test now asserts that since for errors and internal is identical across two calls with different now, and that it comes from the oldest evidence. It also checks that a cleared cause starts over.
    • I changed the board test, because its old assertion expected the "1 run is stuck." sentence this change removes.
    • I could not test disk, because the disk reading comes from the real filesystem. That is covered by the same code path as the other causes but has no test of its own.
Changes requested — before the latest push

Fix first: errors and internal link to /audit, but that page lists audited actions (src/web/pages/audit.ts) and shows neither the error ring nor refused internal calls. An admin who taps the board strip lands somewhere that does not explain the cause. Link to a page that does show them, or add a short section to one (for example the admin's capacity or health page) and link there. Then:

  1. Disk has no test. since for disk is the only cause with no evidence and the only one resting entirely on firstSeen. Make the free-space threshold injectable (or test through DISK_FREE_MIN) and assert it holds across two calls and resets after clearing.
  2. firstSeen is process-global and vitals() is called from several places (board, asks, tty, API, tests with arbitrary now). A call with an earlier now can set a cause's since to a time later than real; the test body also asserts >= first, which is weak. Key the fallback on real time, not input.now, or say why not.
  3. The asks page and header count (forgeNeedsFor in src/web/studio/asks.ts) still read .needs, so the asks cards show no since or href while the board and terminal do. Use degraded and needLine there so the three surfaces agree. The count also now grows by one per stuck run rather than one for all of them; that is probably right but worth a line in the pull.
  4. The terminal shows raw ISO strings (Since 2020-01-01T00:00:00.000Z). Say it as a person would (since 14:02 or 12 min ago).
  5. The preview at https://lab--1519--forge-trevato-apps.open-platform.sh was not reachable from my sandbox, so I could not check it by eye or see the phone and desktop captures. The author also said they did not open it. Please confirm the board strip at 360px, since each entry is now a full-sentence link that will wrap.

Security: degraded is only returned to site admins (readHealth gates on isAdmin), and hrefs are built from internal run ids and repo names and go through html escaping. No issues there.

Test hygiene: in test/vitals.test.ts the comment // every need has exactly one sentence match in degraded . and the unused-looking expect(entry!.sentence).toContain(run.id) inside the internal block are stray. Tidy them.

commented

I addressed each point from juniper's review except two: the 360px check (point 5) and an asks-card test. The type check is clean, and the vitals, capacity, board, TUI-screen and asks tests pass (101 tests). I ran those suites only, not the full check.

  • Broken links: errors and internal now link to /settings/capacity#errors and #internal. I added an "Errors and refused calls" card to the admin capacity page with those anchors. It shows the hour's error count and the latest 10 error lines. It also shows the refused-internal-call count and the latest refused call. The capacity test asserts both anchors exist.
  • Disk test: vitals() takes an optional diskFreeMin (default DISK_FREE_MIN). A new test shows disk appears, keeps the same since across two calls, and gets a later since after it clears and returns.
  • Fallback clock: a cause with no evidence of its own now takes its since from the real clock, not input.now, so a call with an earlier now can't move it. A test covers this, and the weak >= first assertion is now a strict check. at still follows now.
  • Asks: forgeNeedsFor returns degraded. The asks cards now link to href and use needLine, so they match the board and terminal. asksAnswer.forge stays a list of strings, now with the "Since …" text.
  • Count change: the asks and header count now grows by one per stuck run instead of one for all of them, as juniper expected.
  • Terminal text: needLine now writes "Since 12 min ago", "4 h ago", "just now", or the date (2020-01-01) after a day. A test covers it.
  • Test hygiene: I removed the stray comment and the stray sentence assertion in test/vitals.test.ts.

What I did not do:

  • I did not check the preview by eye. This sandbox reaches only the forge and the package registry, so I couldn't load it at 360px.
  • In the code, board-forge-need has no CSS rule, so each entry is plain inline text and wraps like text. Someone should still look at it on a phone.
  • I added no test for the asks card's href or since; that card is covered only by the type check and the existing asks tests.
commented

Vitals now names each degraded cause and when it began. This push merges the latest main into the branch. The merge conflicted in src/kernel/vitals.ts, src/actions/health.ts and test/vitals.test.ts, which is why the check failed. It is pushed; the forge's check is yet to run.

I ran the type check and test/vitals.test.ts plus test/board.test.ts here. The type check is clean and all 32 tests pass. I did not run the whole suite; the forge's check does that.

  • Check-lane sentence: main's lane line (queued, running, median, clears in) is kept in the check queue's sentence. That cause still reports when the oldest queued check began waiting.
  • Killed-twice runs: main's "a run was killed twice" need is now a degraded cause of its own, budget:<runId>. It dates from when the run finished and links to /settings/capacity.
  • Admin health shape: /api/v1/health now carries both degraded and lane. forgeLane and laneLine are in alongside needLine and sinceWords.
  • Test fix: main's lane test deletes every run, which left my queue-cause test with no queued agent run to date the cause from. The test was wrong, not the code, so it now seeds its own agent run.

To try it, an admin opens /api/v1/health and reads degraded. Each entry has cause, sentence, since and href.

commented

The branch now merges cleanly with main. bun x tsc --noEmit ran clean, and test/board.test.ts and test/vitals.test.ts pass (33 tests). I didn't run the full check.

The check failed because src/web/pages/board.ts conflicted with main in the forge strip on the home board. main added the sentinel's open-findings link (sentinelSpan) and a needHref helper. This branch already links each degraded cause through its own href.

  • Kept: sentinelSpan and its import, so the sentinel link still shows on the strip.
  • Dropped: needHref, which nothing calls now that each cause carries its own link.

Vitals still names each degraded cause and when it began.

commented

Parked by the crew: this issue started its day's share of runs without landing, so nothing more starts here until a person says what to try.

commented

I merged main into the branch, resolved the three conflicts, and pushed. Type check is clean. In the four suites I ran (vitals, capacity, board, sentinel), 58 tests pass and 1 fails.

The failure: the capacity test "an admin changes each one from the page, the API and MCP…" fails on capacityEnv after the shards reset (it still holds FORGE_CHECK_SHARDS: "6"). It fails the same way on a clean origin/main checkout, so I left it alone. I didn't run the full check; the forge runs that on the push.

How I resolved the conflicts:

  • internal_refused.ts, log.ts: main had moved the error and refusal counters into per-forge ledgers (ErrorLedger, RefusedLedger), so I kept those. I added the "oldest line in the last hour" timestamp to what each ledger's recent() returns, which is what the degraded causes use as their start time. The old module-level refusedInternal() and resetRefusedInternal() are gone.
  • vitals.ts: I kept both sides: the signals input from main and this branch's diskFreeMin and per-cause start times (firstSeen).
  • capacity.ts: the "Errors and refused calls" card now reads ctx.app.signals instead of the process-wide counters.
  • test/vitals.test.ts: updated to pass app.signals and use the ledger methods.
commented

Parked by the crew: the check failed ("home is the feed > On you can be cleared in one move: a box each, select all, by kind and by repository, one form") and the decider saw no point in another try

commented

Parked by the crew: this issue started its day's share of runs without landing, so nothing more starts here until a person says what to try.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs