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

/api/v1/telemetry/home names the commit production runs apart from main's head #11679

Merged opened this

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

Merged

`GET /api/v1/telemetry/home` now reports the commit this process runs apart from the head of main. Before, `live.sha` was the commit of the newest production deploy run, so it could follow main while production stood still.

shipped production is serving it deploy 99a34f7

opened this

GET /api/v1/telemetry/home now reports the commit this process runs apart from the head of main. Before, live.sha was the commit of the newest production deploy run, so it could follow main while production stood still.

What the endpoint answers now

  • live: {sha, version}, taken from running() in src/kernel/version.ts. It is null when the process carries no commit stamp. The old at (when the deploy started serving) is no longer part of this answer; the home page's own KPI read is unchanged.
  • main: {sha}, the head of the default branch of the forge's own repository.
  • behind: {commits, pulls}, what main holds that the running commit does not. Both are 0 when the two match.
  • main and behind are null until the forge has read its own main once, which happens at boot and then every minute.

No git per request. src/release/landings.ts already re-reads every minute from main.ts. On that read it now also keeps:

  • head: the tip of the default branch, read from the ref files with no process.
  • ahead: the result of git rev-list --count running..head, asked once for each new (running, head) pair and reused after that.

The new mainGap(db) builds the answer from that cache plus one query that counts the forge's own merged pulls still on their way. If the commit count hasn't been asked yet for a new pair, commits falls back to the pull count for up to a minute.

home_eval.ts still reads live.sha, unchanged. The OpenAPI route file names the new fields, and docs/HOME-EVAL.md mentions them.

Test. test/home-truth.test.ts builds a real bare repository with commits a ← b ← c, three merged pulls, and main at c. With the running commit at a, it answers live.sha = a, main.sha = c and behind = {commits: 2, pulls: 2}. With the running commit at c, it answers 0 and 0. The test fails with the source change removed.

Checks run here. bun x tsc --noEmit and bun scripts/gate.ts pass. scripts/fast.ts named 1839 test files for this diff, too many to run here, so I ran the 53 that cover it instead: home-truth, home-eval, landings-asked-once, the no-release alarm, changelog, kept-fork-landing, mcp-releases, and every openapi, contract and telemetry suite. All 658 tests pass.

Not done.

  • kpis.live, the "live since" figure on the home page, still comes from deploy runs.
  • The keep_plan tool the issue asks for isn't available in this run, so no plan was posted on the issue.

To try it. With a token holding telemetry:read, curl -H "authorization: Bearer …" <preview>/api/v1/telemetry/home. After the first minute's read, live.sha, main.sha and behind appear.

🤖 Generated with Claude Code

Closes #11676

commented

GET /api/v1/telemetry/home now reports the commit this process runs apart from the head of main. Before, live.sha was the commit of the newest production deploy run, so it could follow main while production stood still.

What the endpoint answers now

  • live: {sha, version}, taken from running() in src/kernel/version.ts. It is null when the process carries no commit stamp. The old at (when the deploy started serving) is no longer part of this answer; the home page's own KPI read is unchanged.
  • main: {sha}, the head of the default branch of the forge's own repository.
  • behind: {commits, pulls}, what main holds that the running commit does not. Both are 0 when the two match.
  • main and behind are null until the forge has read its own main once, which happens at boot and then every minute.

No git per request. src/release/landings.ts already re-reads every minute from main.ts. On that read it now also keeps:

  • head: the tip of the default branch, read from the ref files with no process.
  • ahead: the result of git rev-list --count running..head, asked once for each new (running, head) pair and reused after that.

The new mainGap(db) builds the answer from that cache plus one query that counts the forge's own merged pulls still on their way. If the commit count hasn't been asked yet for a new pair, commits falls back to the pull count for up to a minute.

home_eval.ts still reads live.sha, unchanged. The OpenAPI route file names the new fields, and docs/HOME-EVAL.md mentions them.

Test. test/home-truth.test.ts builds a real bare repository with commits a ← b ← c, three merged pulls, and main at c. With the running commit at a, it answers live.sha = a, main.sha = c and behind = {commits: 2, pulls: 2}. With the running commit at c, it answers 0 and 0. The test fails with the source change removed.

Checks run here. bun x tsc --noEmit and bun scripts/gate.ts pass. scripts/fast.ts named 1839 test files for this diff, too many to run here, so I ran the 53 that cover it instead: home-truth, home-eval, landings-asked-once, the no-release alarm, changelog, kept-fork-landing, mcp-releases, and every openapi, contract and telemetry suite. All 658 tests pass.

Not done.

  • kpis.live, the "live since" figure on the home page, still comes from deploy runs.
  • The keep_plan tool the issue asks for isn't available in this run, so no plan was posted on the issue.

To try it. With a token holding telemetry:read, curl -H "authorization: Bearer …" <preview>/api/v1/telemetry/home. After the first minute's read, live.sha, main.sha and behind appear.

🤖 Generated with Claude Code

Approved

Does what #11676 asks: live comes from the running process, main and behind come from a cache the minute read keeps, no git per request, home_eval still reads live.sha and copes with null. The test builds a real repo and covers 2/2 and 0/0. I could not read the preview's endpoint (401 with my token), so the check is from source and the green pull.

Two things I would do next:

  1. Add main/behind to the terminal and page home figures, or say in docs that they are API-only; today only the API door shows them.
  2. Say in the OpenAPI summary that commits is a lower bound (the pull count) for up to a minute after the pair changes.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs