Skip to content

feat(ci): the API launch gate — refuse a prod release that breaks the deployed contract (#658) - #1247

Merged
athvin merged 4 commits into
mainfrom
issue/658-api-launch-gate
Nov 26, 2026
Merged

athvin merged 4 commits into
mainfrom
issue/658-api-launch-gate

Conversation

@athvin

@athvin athvin commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #658

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

The API launch gate, enforced at the production deploy. The store it reads and writes landed in #1246 and is applied: er-prod-api-contract-797781631727, plus er-ci-deploy-prod:api-contract.

  • er-server api-check <base> <candidate> [--strict] (api_check.rs): file-against-file, using the shipped openapi::breaking_changes, the same detection the PR-time advisory runs. Exit 0 when compatible, 2 when breaking under --strict, and 64 when an input is unreadable or not JSON. An unreadable input is never "no changes".
  • The prod deploy job (deploy.yml):
    1. runs the gate's self-test;
    2. copies er-server out of the release's own er-api image by digest (api-launch-gate-binary.sh), because the deploy job has no Rust toolchain;
    3. compares the candidate's openapi.public.json with deployed/openapi.public.json before the inactive colour exists;
    4. after cutover and retire, publishes releases/<sha>/openapi.public.json once (If-None-Match: *; the bucket policy forbids deleting a release) and moves the deployed/ pointer and release.json.
  • Decisions (api-launch-gate.sh):
    • a break is refused, unless the new workflow_dispatch input api_break_ok names a reason (a deliberate version change or a rollback), which is printed;
    • an unreadable baseline is refused;
    • a checker that cannot run is refused;
    • a missing baseline (NoSuchKey) is first publication.

The ticket's checklist:

  • publish the effective contract after a successful deployment, with immutable release identity and a durable pointer;
  • compare with that baseline and enforce before external exposure;
  • document the detector's actual coverage (the api-contract skill: query inputs, compositions and payload narrowing are not detected);
  • first deployment, a missing or unreadable baseline, rollback and intentional version change are each explicit;
  • the gate is proven failing on an incompatible fixture and passing an additive one (below);
  • baseline access is independent of cluster reachability (S3), and Terraform owns the storage and IAM (feat(infra): the deployed public-contract store, and the prod deploy role's grant (#1245) #1246).

Why

#658: the launch prerequisite for #1013. An external consumer's integration must not be broken by accident.

Proof

make check: 1,195 passed, 0 failed, with the new api-launch-gate-check target. The gates caught one thing on the way: structured_logging.rs forbids eprintln! in er-server, so the verb's report moved to its own api_check.rs, allowlisted by exact count beside er-openapi-check.rs. actionlint and workflow-shell-check pass on deploy.yml.

  • api_check_passes_additive_and_refuses_breaking_or_unreadable (real breaking_changes over the real public document):
    • an added operation → 0;
    • a removed operation → 2, and advisory 0 without --strict;
    • a retyped GoldenRecord.id → 2;
    • a missing file, an <html>AccessDenied</html> body, or a single argument → 64.
  • api-launch-gate-test.sh, 14 cases, run in make check (api-launch-gate-check) and in the deploy job before the gate: compatible passes; breaking is refused; breaking with a reason passes and prints it; NoSuchKey is first publication; AccessDenied is refused even if the checker would pass; checker exits 64 and 101 are refused; an empty candidate is refused; publish writes all three objects with the conditional put; a redeploy of a published sha keeps it; a failed write fails.
Mutation Caught by
an unreadable baseline returns success api-launch-gate-test: "an unreadable baseline refuses"

The first prod deploy after this merge is the live proof. It must log no deployed contract yet; first publication, then publish. The next deploy compares against it. Both are recorded in the ledger.

Risk & rollback

A prod deploy can now be refused, which is the point. A false refusal is overridden by re-running the deploy via workflow_dispatch with api_break_ok. If the gate itself is broken, git revert <merge-sha> restores the ungated deploy. The store stays (prevent_destroy).

Post-merge ledger

Closed by: agent · session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on Mac · 2026-11-26T01:56:34Z

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

bmoore813 and others added 4 commits November 25, 2026 16:58
… deployed contract (#658)

er-server api-check compares two contract files with the shipped
breaking_changes. The prod deploy copies that binary out of the release's
own er-api image, compares the candidate with s3://er-prod-api-contract/
deployed/ under --strict, and refuses on a break (unless api_break_ok names a
reason), on an unreadable baseline, and on a checker that cannot run; a
missing baseline is first publication. After cutover it publishes
releases/<sha>/ once and moves the deployed/ pointer. The decision logic is
self-tested (14 cases, in make check and in the deploy job).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#658)

structured_logging.rs forbids eprintln! in er-server product code and
allowlists, by exact count, the CI helpers whose stderr report is the
product. api_check.rs joins er-openapi-check.rs there; the detection stays
in openapi::breaking_changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit bae09b2 into main Nov 26, 2026
44 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 26, 2026 01:21 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — 7de72c8a Deployed Nov 26, 2026 by athvin via remove closed PR previews #61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API launch gate: enforce compatibility against the deployed public contract

2 participants