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

Merged opened this

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

Merged

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.

Notes

shipped production is serving it deploy 3fede26

opened this

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 schedules forge.json declares 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_KEY is 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 to own-schedules.json under the data directory, and only for a declared path.
  • Counts.
    • total is the number of declared schedules.
    • ran counts those with a recorded run.
    • overdue counts those whose next run after the last recorded one is more than OVERDUE_AFTER_MS past.
    • A schedule that has never run is not called overdue here, because only the host knows when it armed it.
  • src/actions/health.ts adds these counts to overdueSchedules (hosted apps). The answer still has the same keys and counts only, with no name or path in it.
  • src/http/server.ts records 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 total 1; it fails at 0.
  • A last run past its period must give overdue 1, 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 total equal to the schedules in forge.json and ran 0, then ran 1 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

Closes #15605

commented

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 schedules forge.json declares 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_KEY is 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 to own-schedules.json under the data directory, and only for a declared path.
  • Counts.
    • total is the number of declared schedules.
    • ran counts those with a recorded run.
    • overdue counts those whose next run after the last recorded one is more than OVERDUE_AFTER_MS past.
    • A schedule that has never run is not called overdue here, because only the host knows when it armed it.
  • src/actions/health.ts adds these counts to overdueSchedules (hosted apps). The answer still has the same keys and counts only, with no name or path in it.
  • src/http/server.ts records 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 total 1; it fails at 0.
  • A last run past its period must give overdue 1, 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 total equal to the schedules in forge.json and ran 0, then ran 1 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

commented

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).
    • total is the number of declared schedules.
    • ran is how many have a recorded run.
    • overdue counts those whose next run after the last recorded one is more than OVERDUE_AFTER_MS late. One that never ran is not called overdue, since only the host knows when it armed it.
  • src/actions/health.ts adds these counts to overdueSchedules. The answer keeps the same keys: counts only, no app, repository, schedule name or path.
  • src/http/server.ts records 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 total 1, so it fails at 0.
  • A schedule whose last run is past its period must give overdue 1, and 0 just inside the allowed lateness.
  • An end-to-end test on a hosted forge checks total equals the schedules in forge.json, ran goes 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.json counts as unpaused.
  • forge.json is 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

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs