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

/api/v1/health names the release and the schedule count, so the v1 proof can read them #13268

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

GET /api/v1/health now returns two new fields, release and schedules.total, and the v1 proof reads them. version is unchanged, so the release swap (src/release/boot.ts) and the keeper read what they did before.

Notes

shipped production is serving it deploy 59903fa

opened this

GET /api/v1/health now returns two new fields, release and schedules.total, and the v1 proof reads them. version is unchanged, so the release swap (src/release/boot.ts) and the keeper read what they did before.

What changed

  • release is in every health answer, strangers included: the running release as x.y.z, or null when the build has no release. A build run from source answers version: "dev" and release: null, so the word "dev" never appears in a field a probe reads as a version. It comes from a new releaseOf() in src/kernel/version.ts, which reads the same build stamp as version. Any stamp that is not x.y.z (1.0, 1.0.0-rc1, dev) is null.
  • schedules.total sits beside overdue and oldestSeconds. It counts every schedule that is not paused, forge-wide, so overdue is never more than total. The count comes from a new scheduleTotal() in src/core/timers.ts, joined into the answer in healthAnswer (src/actions/health.ts). overdueSchedules keeps its shape, and the MCP health tool gets both fields through the same function. The route summary in getApiV1Health.ts describes both.
  • The proof (src/core/v1_proof.ts): the two release checks (#10304, #13042) read release when the answer has it, and null fails them. A forge from before this change is still read by its version, so the existing proof tests pass unchanged. The schedule check (#11595) now says "no schedule of N is overdue" when it can.

Tests

  • I changed one existing test, test/health-schedules.test.ts: it lists the exact keys of the stranger's answer and the exact schedules object, so it now includes release and total. No other existing test changed.
  • New tests check that total counts unpaused schedules (overdue or not), that a build with no release answers release: null with version unchanged (the one test the issue asks to assert both), and how a stamp becomes release.
  • New tests in test/v1-proven.test.ts check that the proof reads release before version and fails on null.
  • The gate and bun x tsc --noEmit are clean. scripts/fast.ts said the diff was too broad to name tests, so I picked 25 files covering health, the version stamp, the proof and the OpenAPI contract: 218 pass, 0 fail.

What I chose not to do: the stranger's answer still carries version and commit. #2962 is the issue that removes them.

To try it: curl /api/v1/health on this pull's preview and read release and schedules.total.

🤖 Generated with Claude Code

Closes #13263

3 earlier comments · 1 event
commented

GET /api/v1/health now returns two new fields, release and schedules.total, and the v1 proof reads them. version is unchanged, so the release swap (src/release/boot.ts) and the keeper read what they did before.

What changed

  • release is in every health answer, strangers included: the running release as x.y.z, or null when the build has no release. A build run from source answers version: "dev" and release: null, so the word "dev" never appears in a field a probe reads as a version. It comes from a new releaseOf() in src/kernel/version.ts, which reads the same build stamp as version. Any stamp that is not x.y.z (1.0, 1.0.0-rc1, dev) is null.
  • schedules.total sits beside overdue and oldestSeconds. It counts every schedule that is not paused, forge-wide, so overdue is never more than total. The count comes from a new scheduleTotal() in src/core/timers.ts, joined into the answer in healthAnswer (src/actions/health.ts). overdueSchedules keeps its shape, and the MCP health tool gets both fields through the same function. The route summary in getApiV1Health.ts describes both.
  • The proof (src/core/v1_proof.ts): the two release checks (#10304, #13042) read release when the answer has it, and null fails them. A forge from before this change is still read by its version, so the existing proof tests pass unchanged. The schedule check (#11595) now says "no schedule of N is overdue" when it can.

Tests

  • I changed one existing test, test/health-schedules.test.ts: it lists the exact keys of the stranger's answer and the exact schedules object, so it now includes release and total. No other existing test changed.
  • New tests check that total counts unpaused schedules (overdue or not), that a build with no release answers release: null with version unchanged (the one test the issue asks to assert both), and how a stamp becomes release.
  • New tests in test/v1-proven.test.ts check that the proof reads release before version and fails on null.
  • The gate and bun x tsc --noEmit are clean. scripts/fast.ts said the diff was too broad to name tests, so I picked 25 files covering health, the version stamp, the proof and the OpenAPI contract: 218 pass, 0 fail.

What I chose not to do: the stranger's answer still carries version and commit. #2962 is the issue that removes them.

To try it: curl /api/v1/health on this pull's preview and read release and schedules.total.

🤖 Generated with Claude Code

commented

/api/v1/health now includes release: the running release as x.y.z, or null on a build that names none. version is unchanged, since the release swap and the keeper still read it. It also adds schedules.total, the number of unpaused schedules, next to overdue and oldestSeconds. The v1 proof reads release, falls back to version on a forge that predates the field, and its schedule line now says how many schedules there are in all.

What to look at

  • src/actions/health.ts (healthAnswer, with new ReleaseHealth and schedules.total)
  • scheduleTotal in src/core/timers.ts
  • releaseOf in src/kernel/version.ts
  • the release and schedule probes in src/core/v1_proof.ts
  • the route summary in getApiV1Health.ts

Test changed: test/vitals.test.ts. It pins the exact keys of the health answer, so the new top-level release key failed it. The test was out of date, not the code: it now lists release in both the site-admin set and the stranger set. Nothing else in it changed.

Other reds in the last check, not caused by this pull:

  • data browser core > every forge.db column that could hold a secret… fails on main at 2faf288 too, as the check log itself reports.
  • "a child writing 200 MB stays blocked while nobody reads…" (test/pull-pipe.test.ts) is in code this diff doesn't touch, and it passes here.

Checks run here: the gate, bun x tsc --noEmit, and the tests covering the health answer all pass. That is 216 tests: vitals, health-schedules, v1-proven, pull-pipe and the other suites that call /api/v1/health. scripts/fast.ts exited 2 because src/kernel/version.ts changed, so I picked those files by hand.

Try it: curl https://lab--13268--forge-trevato-apps.open-platform.sh/api/v1/health and read release and schedules.total.

🤖 Generated with Claude Code

commented

/api/v1/health now carries release: the running release as x.y.z, or null when the build doesn't name one. version is unchanged, so the release swap and the keeper read it as before. The v1 proof's release probe reads release and falls back to version only on a forge older than this change.

This push merges main. Main's #13252 (commit fad64fe7f) made overdueSchedules in src/core/timers.ts return total and ran itself. That made this branch's separate scheduleTotal a second query for the same count, so it is gone, and the health answer in src/actions/health.ts now makes that one call.

How each conflict was resolved:

  • src/actions/health.ts: ScheduleHealth uses main's ScheduleCounts type; ReleaseHealth and release: releaseOf() stay.
  • src/contract/openapi/routes/getApiV1Health.ts: the summary describes both release and schedules {overdue, oldestSeconds, total, ran}.
  • src/core/v1_proof.ts: the schedule probe is main's. It is unproven when there are no schedules or none has run. This branch's "no schedule of N is overdue" wording is dropped.
  • test/health-schedules.test.ts: keeps main's total/ran test and this branch's release tests. The paused-schedule test counts total through overdueSchedules. This branch's own "total counts every unpaused schedule" test is dropped because main's test checks the same thing.
  • test/v1-proven.test.ts: this branch's release test expected the old schedule-probe wording, so its stub now includes ran and it expects main's message. This was a fix to my own test, not to the code.

bun x tsc --noEmit and bun scripts/gate.ts --fix pass. test/health-schedules.test.ts and test/v1-proven.test.ts pass after the fix, and before it the wider set of health, vitals and OpenAPI tests passed apart from the one v1-proven test above.

To try it: curl https://lab--13268--forge-trevato-apps.open-platform.sh/api/v1/health and look for release and schedules.{overdue, oldestSeconds, total, ran}.

🤖 Generated with Claude Code

Changes requested — before the latest push

The code reads well and the tests cover the three boxes, but I cannot approve it because the preview at this head does not show it working. GET /api/v1/health and /healthz on https://lab--13268--forge-trevato-apps.open-platform.sh both answer 502, so I could not see release or schedules.total served. Production (without this change) answers version: dev and no release, as expected. Fix first: push so the preview boots, then confirm with curl that release is null on the unstamped preview, that version is still dev, and that schedules.total is present. Second: the route reply in getApiV1Health.ts does not list release; add it so the contract matches the answer.

commented

/api/v1/health now carries release: the running release as x.y.z, or null when the build doesn't name one. Every answer also carries schedules {overdue, oldestSeconds, total, ran}. version is unchanged, so the release swap and the keeper read it as before. The v1 proof's release probe reads release and falls back to version only on a forge older than this change. The preview at this head serves it:

$ curl https://lab--13268--forge-trevato-apps.open-platform.sh/api/v1/health
{"ok":true,"version":"dev","commit":"1afbfd9d…","draining":false,"release":null,"schedules":{"overdue":0,"oldestSeconds":0,"total":0,"ran":0}}

/healthz on the preview answers 200. The 502s in the review were most likely the preview redeploying after the merge push: the branch booted and answered normally when started here, the previous head had looks taken, and this head answered on the first try.

What changed in response to the review:

  • Contract: the route's reply in getApiV1Health.ts now lists release: "string|null". The contract had no way to write a nullable field, so schema in src/contract/openapi.ts now turns a field type written as "a|b" into an OpenAPI 3.1 type array. The served openapi.json shows release: {type: ["string", "null"]}.
  • Test: a new test in test/health-schedules.test.ts checks that schema. It also checks that every key the contract declares appears in the anonymous health answer. It fails without this change.

What the earlier merge of main did:

  • schedules.total: it now comes from main's overdueSchedules, which counts total and ran itself (#13252), so this branch's scheduleTotal is gone.
  • Schedule probe: the v1 proof's schedule probe is main's.
  • One test changed: the release test in test/v1-proven.test.ts pinned this branch's old schedule-probe wording, so it now expects main's message. That was my test being wrong, not the code.

bun x tsc --noEmit and the gate pass, and so do the health, v1-proven, vitals/version and OpenAPI tests. scripts/fast.ts exited 2 because src/kernel/version.ts changed, so I chose those test files myself rather than running the full suite.

I did not add version or commit to reply: those fields are on their way out (#2962), and the review asked only for release.

🤖 Generated with Claude Code

Approved

Earlier ask met: the route reply now declares release as a nullable string (OpenAPI 3.1 type array), and a test checks the contract and that every declared key is served. The preview at this head answers release:null, version:"dev", schedules {overdue,total,ran}. No UI change, so nothing to check on phone or keyboard. Non-blocking next steps: 1) the openapi.ts diff only rewraps comments; keep such churn out of feature pulls. 2) When #2962 drops version/commit, add the proof fallback removal to that pull so the version read does not linger.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs