FORGE-217: stage-scoped health receipts, a real promote, changesets on manual deploys #967

Merged
gmackie merged 3 commits from FORGE-217-stage-health-receipts into main 2026-10-26 00:02:19 +00:00
Owner

Kanbanger: https://tasks.gmac.io/gmacko/issue/FORGE-217. Unblocks LOOM-13, LOOM-15, LOOM-16, LOOM-17, LOOM-18 and LOOM-19.

Root cause (checked against live data, read-only)

Loom's health.url is the relative /.well-known/forge-health, and its targets have no healthCheckUrl. So:

  • the app has no health endpoint
  • the agent gets no health URL, so the production active receipts (9d0d4cd1, 49ac2dda) carry no health
  • FORGE-164's coverage credit for contained PRs never starts
  • forge receipts backfill --app loom --dry-run refuses

Both production deployments also have changesetId: null.

Changes

  • Stage-scoped health: config apply resolves a relative health path per stage, from the stage url or the workers.dev URL of the stage's main target (its first enabled target). Endpoints record stage_id and target_id, added by migration 0139.
    • The poll, receipt and replay use the deployment's own stage URL.
    • Probes and heartbeats record the stage, and evidence is emitted only for that stage, so a staging 200 can't satisfy production.
    • Unresolvable or duplicate stages produce a warning, never a guess. Absolute health.url is unchanged.
  • Changesets on manual deploys: deploy creation records the changeset the commit delivers: the merged PR whose merge commit it is, otherwise a changeset headed at that commit.
  • forge deploy promote is real: it creates a deployment of the same commit in the next stage (the pipeline order), inheriting the changeset, through the normal deploy route with every gate. It refuses clearly for the last stage, an inactive source, or a source with no commit.
  • Coverage receipts (FORGE-164) and replay (FORGE-204) are unchanged and now work, because receipts carry health.

Migration (apply before the server deploy)

packages/db/drizzle/0139_stage_health_endpoints.sql is additive and idempotent: two nullable FK columns and an index. Apply it to forgegraph and forgegraph_beta first, or deploy.yml's drift gate fails.

Tests

  • New database tests (local Postgres), passing:
    • staging deploy → staging receipt only
    • production deploy → production receipt and coverage credit
    • two-stage app → no cross-stage leakage
    • Loom-shaped coverage credits each contained PR once and never from staging
    • promote (4 cases), the apply sync, and the resolution rules
  • Other suites:
    • web unit 2180 and API unit 1835 pass, and typecheck is clean
    • the Go CLI test passes
  • Local caveat: the full web database lane drops connections on this Mac, and clean main fails the same way. CI's database lane is the arbiter.

After deploy

  1. In Loom, run forge apply (no manifest change) to create stage health endpoints.
  2. Run forge receipts backfill --app loom --dry-run, expecting #22, #24, #25, #26 and #27 as would_credit, then run it for real.
  3. Read back LOOM-13, 15, 16 and 17.

🤖 Generated with Claude Code

Kanbanger: https://tasks.gmac.io/gmacko/issue/FORGE-217. Unblocks LOOM-13, LOOM-15, LOOM-16, LOOM-17, LOOM-18 and LOOM-19. ## Root cause (checked against live data, read-only) Loom's `health.url` is the relative `/.well-known/forge-health`, and its targets have no `healthCheckUrl`. So: - the app has no health endpoint - the agent gets no health URL, so the production `active` receipts (9d0d4cd1, 49ac2dda) carry no health - FORGE-164's coverage credit for contained PRs never starts - `forge receipts backfill --app loom --dry-run` refuses Both production deployments also have `changesetId: null`. ## Changes - **Stage-scoped health:** config apply resolves a relative health path per stage, from the stage `url` or the workers.dev URL of the stage's main target (its first enabled target). Endpoints record `stage_id` and `target_id`, added by migration `0139`. - The poll, receipt and replay use the deployment's own stage URL. - Probes and heartbeats record the stage, and evidence is emitted only for that stage, so a staging 200 can't satisfy production. - Unresolvable or duplicate stages produce a warning, never a guess. Absolute `health.url` is unchanged. - **Changesets on manual deploys:** deploy creation records the changeset the commit delivers: the merged PR whose merge commit it is, otherwise a changeset headed at that commit. - **`forge deploy promote` is real:** it creates a deployment of the same commit in the next stage (the pipeline order), inheriting the changeset, through the normal deploy route with every gate. It refuses clearly for the last stage, an inactive source, or a source with no commit. - Coverage receipts (FORGE-164) and replay (FORGE-204) are unchanged and now work, because receipts carry health. ## Migration (apply before the server deploy) `packages/db/drizzle/0139_stage_health_endpoints.sql` is additive and idempotent: two nullable FK columns and an index. Apply it to `forgegraph` and `forgegraph_beta` first, or `deploy.yml`'s drift gate fails. ## Tests - **New database tests (local Postgres), passing:** - staging deploy → staging receipt only - production deploy → production receipt and coverage credit - two-stage app → no cross-stage leakage - Loom-shaped coverage credits each contained PR once and never from staging - promote (4 cases), the apply sync, and the resolution rules - **Other suites:** - web unit 2180 and API unit 1835 pass, and typecheck is clean - the Go CLI test passes - **Local caveat:** the full web database lane drops connections on this Mac, and clean main fails the same way. CI's database lane is the arbiter. ## After deploy 1. In Loom, run `forge apply` (no manifest change) to create stage health endpoints. 2. Run `forge receipts backfill --app loom --dry-run`, expecting #22, #24, #25, #26 and #27 as `would_credit`, then run it for real. 3. Read back LOOM-13, 15, 16 and 17. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`forge deploy create production` inserted deployments with no changeset,
so Loom's production deployments (9d0d4cd1, 49ac2dda) named no change:
stage health could not say what it proved, and receipts had to recover
the PR later from the commit (FORGE-149).

Deploy creation now resolves the changeset from server-recorded identity
only (changesetForCommit): the merged PR whose merge commit is the
deployed revision, else the newest changeset of the repository headed at
it. Branch names and timestamps are never used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Loom has a staging and a production Worker and `health.url:
/.well-known/forge-health`. A path was not probeable, so Loom had no
health endpoint, the poll handed the agent no health URL, its `active`
reports carried no health, coverage credit never started, and
`forge receipts backfill --app loom` refused ("Configure a
healthCheckUrl"). Any app with a second gated stage hit the same wall:
the one app-wide endpoint could not say which stage it proved.

- app_health_endpoints gains nullable stage_id and target_id
  (drizzle/0139_stage_health_endpoints.sql, with its D1 twin).
- Config apply resolves a relative health path once per stage, against
  the stage's declared url, else the workers.dev URL of the stage's
  health target (its first enabled target, never a one-box, jobs runner
  or later auxiliary Worker such as Loom's preview tier), read from
  Cloudflare and only when the Worker's workers.dev route is on. Stages
  it cannot resolve, or that share one URL, are reported as warnings.
  An absolute health URL keeps its app-wide endpoint, as before.
- The agent poll, the agent report's receipt and the receipts probe
  (health_deploy, backfill_active) use the stage endpoint for the
  deployment's own stage and target, so a staging deploy probes and
  signs staging.
- The cron probe and agent heartbeats record the endpoint's stage on
  every check, and stage endpoints emit attestation evidence for their
  own stage and target only; an app-wide endpoint keeps the ambiguity
  guard. A serving deployment without a changeset is identified by its
  commit.

Coverage receipts are unchanged: once a production receipt carries
health, FORGE-164's ancestor credit sends each contained, merged PR its
own signed inclusion receipt, once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FORGE-217: make forge deploy promote promote
Some checks failed
CI / superseded (pull_request) Successful in 0s
CI / gitleaks (pull_request) Successful in 9s
CI / storybook (pull_request) Successful in 1m21s
Registry deps hash / pnpm-deps-hash (pull_request) Failing after 1m53s
CI / web-build (pull_request) Successful in 1m56s
CI / unit-api (pull_request) Successful in 3m11s
CI / checks (pull_request) Successful in 2m2s
CI / go (pull_request) Successful in 2m14s
CI / database (pull_request) Successful in 4m11s
CI / database-d1 (pull_request) Successful in 3m37s
CI / unit-web (pull_request) Successful in 10m53s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 34s
Preview / deploy (pull_request) Has been skipped
Preview / e2e (pull_request) Has been skipped
Preview / cleanup (pull_request) Successful in 31s
Preview / release (pull_request) Has been skipped
0241dec2b7
POST /api/fg/deploy/[id]/promote re-marked the same deployment active and
reported success while nothing moved. It now creates a deployment of the
source's commit in the app's next stage (pipeline order: canonical by
stage name, then sortOrder, the order the pipeline chart and lane
enforcement use), through POST /api/fg/deploy for the same principal, so
the freeze, beta verification, migration ledger, one-box, in-flight and
source-order gates all apply and their refusals come back unchanged. The
new deployment inherits the source's changeset.

It refuses an inactive source, a source without a commit, and the last
stage, instead of pretending. The CLI prints the deployment it created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Worker Preview: https://pr-967.previews.forgegraf.com (updates on every push; behind Cloudflare Access; shared previews database, the banner shows which PR owns it)

<!-- forgegraph-preview --> Worker Preview: https://pr-967.previews.forgegraf.com (updates on every push; behind Cloudflare Access; shared previews database, the banner shows which PR owns it)
Sign in to join this conversation.
No description provided.