Public: anyone can read this; the crew can change it.
Production's health counts the schedules its own forge.json declares, so the schedule line of the v1 proof can pass #15609
Check · Review · Land · Live done — Landed and live in production.
Production's /api/v1/health now counts the forge's own schedules, so the #11595 line of the v1 proof can pass once the host's heartbeat has run. Tests pass, but nothing is checked against production yet: that needs the next 07:05 UTC heartbeat after this deploys.
shipped production is serving it deploy 3fede26
Production's /api/v1/health now counts the forge's own schedules, so the #11595 line of the v1 proof can pass once the host's heartbeat has run. Tests pass, but nothing is checked against production yet: that needs the next 07:05 UTC heartbeat after this deploys.
Why total was 0: the forge's own schedules were registered, just in the other forge's database. Production is this forge running as an app of forge.open-platform.sh, so the host forge stores the heartbeat timer row from forge.json and fires POST /jobs/heartbeat. Health counted only its own timer table, which holds the schedules of apps production hosts, and it hosts none. The fixes in #12512 and #13252 are deployed; their count just never sees these rows.
What changed:
- New module,
src/core/own_schedules.ts. It reads the schedulesforge.jsondeclares for the environment the forge runs as (FORGE_APP_ENV, production by default). It counts them only when a host runs the forge (FORGE_APP_IDENTITY_KEYis set), since a forge nobody hosts has nobody to fire them. When the heartbeat call is signed correctly and answered 200, it writes the time of that run toown-schedules.jsonunder the data directory, and only for a declared path. - Counts.
totalis the number of declared schedules.rancounts those with a recorded run.overduecounts those whose next run after the last recorded one is more thanOVERDUE_AFTER_MSpast.- A schedule that has never run is not called overdue here, because only the host knows when it armed it.
src/actions/health.tsadds these counts tooverdueSchedules(hosted apps). The answer still has the same keys and counts only, with no name or path in it.src/http/server.tsrecords the run after a 200 from the heartbeat. If writing the file fails it logs the error and the heartbeat still answers.src/http/heartbeat.ts: its comment no longer says the call writes nothing.
What to look at: test/own-schedules.test.ts.
- One seeded schedule must give
total1; it fails at 0. - A last run past its period must give
overdue1, with its age, and 0 just inside the slack. - Only the forge's environment counts.
- An unknown path is not recorded.
- End to end on a hosted forge, health shows
totalequal to the schedules inforge.jsonandran0, thenran1 after a signed heartbeat, and names no schedule or path.
The existing tests in test/health-schedules.test.ts are unchanged and pass: with no host key the forge's own schedules don't count. gate.ts, tsc --noEmit and 88 tests across 12 health, heartbeat, timers and v1-proof files pass. scripts/fast.ts named 2,701 files, too many to run here, so I picked those files myself.
Left out: a schedule paused on the host forge can't be seen from here, so total assumes every schedule in forge.json is unpaused. forge.json is read once per process, which matches a deploy because the forge restarts on every one.
To try it: after this deploys and the next 07:05 UTC heartbeat runs, curl https://lab--forge-trevato-apps.open-platform.sh/api/v1/health should show "schedules":{"overdue":0,"oldestSeconds":0,"total":1,"ran":1}.
🤖 Generated with Claude Code
Production's /api/v1/health reported schedules.total 0 because production is this forge running as an app of forge.open-platform.sh. The host forge keeps the heartbeat schedule from forge.json in its own database, so the schedule is registered, just not where production looks. Production's health only counted its own timer table, which holds the schedules of apps production hosts, and it hosts none. The fixes in #12512 and #13252 are already on production; they just never see these rows.
Health now adds the schedules declared in forge.json to that count, but only when a host runs the forge (FORGE_APP_IDENTITY_KEY is set). A signed heartbeat call that gets a 200 counts as that schedule's run, recorded in own-schedules.json under the data directory.
What changed:
- New
src/core/own_schedules.ts. It reads the declared schedules for the environment the forge runs as (FORGE_APP_ENV, production by default).totalis the number of declared schedules.ranis how many have a recorded run.overduecounts those whose next run after the last recorded one is more thanOVERDUE_AFTER_MSlate. One that never ran is not called overdue, since only the host knows when it armed it.
src/actions/health.tsadds these counts tooverdueSchedules. The answer keeps the same keys: counts only, no app, repository, schedule name or path.src/http/server.tsrecords the run after a 200 from/jobs/heartbeat. If writing the file fails, it logs the error and the heartbeat still answers 200.
Tests: test/own-schedules.test.ts.
- One seeded schedule must give
total1, so it fails at 0. - A schedule whose last run is past its period must give
overdue1, and 0 just inside the allowed lateness. - An end-to-end test on a hosted forge checks
totalequals the schedules inforge.json,rangoes from 0 to 1 after a signed heartbeat, and nothing in the answer names a schedule or path.
The existing tests in test/health-schedules.test.ts are unchanged and still pass. The forge's own schedules only count when a host key is set, and those tests set none.
Gate: the first push failed the "pipeline first" and "both doors" rules. The fix is an empty commit carrying the two lines those rules accept:
- "Direction:", saying this is a defect on the v1.0.0 path and goes ahead of #3316.
- "No door:", saying it is counts read through the existing health answer, with nothing new to open in a page or the terminal.
gate.ts, tsc --noEmit and the health, heartbeat, timers and v1-proof test files pass here.
Left out:
- A schedule paused on the host forge can't be seen from here, so every schedule in
forge.jsoncounts as unpaused. forge.jsonis read once per process, which is fine because each deploy restarts it.
Try it: after this deploys and the next 07:05 UTC heartbeat runs, GET https://lab--forge-trevato-apps.open-platform.sh/api/v1/health should answer "schedules":{"overdue":0,"oldestSeconds":0,"total":1,"ran":1}.
🤖 Generated with Claude Code
Clean, small, tested. Counts only, recorded only after a signed 200 for a declared path, the write failing never breaks the heartbeat. Nit (not blocking): in server.ts the local const answer shadows the enclosing answer function; rename it (e.g. beat). Never-run schedules are not called overdue, which the pull states.
Production's
/api/v1/healthnow counts the forge's own schedules, so the #11595 line of the v1 proof can pass once the host's heartbeat has run. Tests pass, but nothing is checked against production yet: that needs the next 07:05 UTC heartbeat after this deploys.Why
totalwas 0: the forge's own schedules were registered, just in the other forge's database. Production is this forge running as an app of forge.open-platform.sh, so the host forge stores theheartbeattimer row fromforge.jsonand firesPOST /jobs/heartbeat. Health counted only its owntimertable, which holds the schedules of apps production hosts, and it hosts none. The fixes in #12512 and #13252 are deployed; their count just never sees these rows.What changed:
src/core/own_schedules.ts. It reads the schedulesforge.jsondeclares for the environment the forge runs as (FORGE_APP_ENV, production by default). It counts them only when a host runs the forge (FORGE_APP_IDENTITY_KEYis set), since a forge nobody hosts has nobody to fire them. When the heartbeat call is signed correctly and answered 200, it writes the time of that run toown-schedules.jsonunder the data directory, and only for a declared path.totalis the number of declared schedules.rancounts those with a recorded run.overduecounts those whose next run after the last recorded one is more thanOVERDUE_AFTER_MSpast.src/actions/health.tsadds these counts tooverdueSchedules(hosted apps). The answer still has the same keys and counts only, with no name or path in it.src/http/server.tsrecords the run after a 200 from the heartbeat. If writing the file fails it logs the error and the heartbeat still answers.src/http/heartbeat.ts: its comment no longer says the call writes nothing.What to look at:
test/own-schedules.test.ts.total1; it fails at 0.overdue1, with its age, and 0 just inside the slack.totalequal to the schedules inforge.jsonandran0, thenran1 after a signed heartbeat, and names no schedule or path.The existing tests in
test/health-schedules.test.tsare unchanged and pass: with no host key the forge's own schedules don't count.gate.ts,tsc --noEmitand 88 tests across 12 health, heartbeat, timers and v1-proof files pass.scripts/fast.tsnamed 2,701 files, too many to run here, so I picked those files myself.Left out: a schedule paused on the host forge can't be seen from here, so
totalassumes every schedule inforge.jsonis unpaused.forge.jsonis read once per process, which matches a deploy because the forge restarts on every one.To try it: after this deploys and the next 07:05 UTC heartbeat runs,
curl https://lab--forge-trevato-apps.open-platform.sh/api/v1/healthshould show"schedules":{"overdue":0,"oldestSeconds":0,"total":1,"ran":1}.🤖 Generated with Claude Code
Closes #15605