Skip to content

chore(cd): deploy pipeline per ADR-0110 round 29 (expand, deploy 100 %, smoke, auto-rollback) #49

Closed

Description

@aRustyDev

Context

Nothing deploys today. docs/src/architecture/cicd.md:80 reads "Any deploy. There is no workflow for it.", and :96-97 says nothing implements ADR-0110. The repository's workflows are ci.yml, contract-cell.yml and flake-hunt.yml. ADR-0110 (accepted in round 24) prescribes this sequence:

  • expand migration;
  • upload at 0 %;
  • smoke and an oracle subset through the version-override header;
  • 10 % for 10 minutes;
  • 100 %, with absolute-count gates and an automatic wrangler rollback (adrs/cd/0110-deploy-pipeline.md:38, :79; Q-0110.1, QUESTIONS.md:234).

The only script that tests a deployed Worker is scripts/stage2-contract.sh, which needs the test routes and the admin token (:36-39). Migrations are the migrate binary (docs/src/architecture/infra.md:128-129). Today the only way into the CNPG clusters is kubectl exec on the primary (research/0010 §2, lines 107-112).

Problem

  • FR-12: traffic is about 5 M requests a month (research/0004 §9, line 317), so 10 % for 10 minutes is roughly 100 requests, most of them the owner's. The ADR itself says percentage slices are meaningless at ≤50 users (0110-deploy-pipeline.md:79). The 10 % stage observes nothing the smoke suite does not, and the version-override plumbing costs build and maintenance.
  • Two constraints remain. A rollback does not revert connected resources, so migrations stay expand/contract (:15-17, :25). A deploy cannot be rolled back across a Durable Object lifecycle change (:18-19).
  • A third comes from ADR-0011 (round 26). The SPA fallback answers a missing hashed asset with 200 text/html, so deploys must keep old hashes until clients age out (adrs/ui/0011-static-asset-hosting.md:76). A 100 % deploy drops the previous version's assets.

Proposal

Add .github/workflows/deploy.yml, triggered on push to main and by hand for each environment (dev, staging and prod, per Q-0092.2), with credentials per ADR-0101.

  1. Expand migration. Q-0110.2 says CI runs it, but nothing gives CI a route to thrust-pg today, so this issue chooses one: a runner with cluster access, or a tunnel route with an Access service token. If spike(db): run spike 0002 with a worker-pg cell and an instance-level worker-do SQLite cell #37 picks the Durable Object cell, this step becomes the object's own migration.
  2. Deploy. Record the current version id, then wrangler deploy at 100 %.
  3. Smoke. Run a new pass against the live hostname that needs no test routes: /healthz first; then, once feat(compat): the 48-route minimum slice with the auth-client JSON change #44 exists, sign in with a dedicated smoke account and read a seeded project. Vacuity guard: /healthz reports the deployed version id (from the version metadata binding, or a var set at deploy), and the smoke checks it equals the new one.
  4. Roll back. If the smoke fails, run wrangler rollback <previous id> and fail the job. If the release adds a [[migrations]] tag, skip the automatic rollback and require manual approval (the DO-lifecycle rule).
  5. Assets. Once feat(compat): the 48-route minimum slice with the auth-client JSON change #44 adds static assets, include the previous release's hashed files in each upload, or answer 404 for a missing /assets/* file.

Acceptance criteria

  • deploy.yml exists and runs the steps in order on push to main.
  • Control: on staging, a release with a smoke check that fails on purpose ends with the previous version active again (wrangler deployments list) and the job red.
  • Control: the smoke pass fails when pointed at a Worker that still serves the previous version id.
  • A release that adds a DO migration stops for approval and does not roll back automatically.
  • After a deploy, an asset URL from the previous release still returns its JavaScript, not HTML.
  • docs/src/architecture/cicd.md describes the pipeline, and ADR-0110 (round-29 note) and Q-0110.1 match it.

References

  • Review: .agents/plans/contrail/reviews/2026-10-19-fable-architecture-review.md (FR-12)
  • ADR-0110 (:13-20, :25, :38, :79; round-29 note), ADR-0101, ADR-0011 (:76), ADR-0090, ADR-0093, ADR-0130
  • Q-0110.1, Q-0110.2, Q-0092.2
  • docs/src/architecture/cicd.md:73-80, :94-97; docs/src/architecture/infra.md:128-129; scripts/stage2-contract.sh:36-39
  • research/0004-rust-on-workers-binding-matrix.md §9 (traffic model); research/0010-thrust-postgres-infra-plan.md §2 (database access path)

Blocked by: #43

Finding: FR-12

Activity

  1. added this to the M1 Walking skeleton milestone on Oct 20, 2026
  2. added
    area:infra
    review:fable-2026-10-19
    on Oct 20, 2026
  3. aRustyDev commented on Nov 15, 2026

    @aRustyDev
    OwnerAuthor

    Infra side of the staging pipeline, after the live runs of ApiraTech/infrastructure #1015 to #1017 (2026-11-14). #49 stays open: its criteria need a real staging deploy and the rollback drill, which have not happened.

    What exists now

    Infra issue State What Thrust gets
    #1015 closed, live acceptance run role staging and schema staging on thrust-pg-dev, pg_trgm in public. migrate (built from 77ec027) ran twice as staging over verify-ca: migrated (tls: verify-ca) both times
    #1016 closed, live acceptance run an Access-gated TCP route, thrust-pg-stage-ci.sow.foo, to the dev database only. scripts/migrate-ci.sh ran twice from a laptop: migrated (tls: verify-ca) both times. Refused, each checked: no token, an unlisted token, plaintext, a wrong CA
    #1017 open the Hyperdrive config thrust-staging, the R2 bucket and the queue with its dead-letter queue exist. A throwaway Worker bound to the config connected as staging over TLS 1.3, search_path held, and CREATE TABLE in public was refused (Worker deleted afterwards). The Worker, its hostname and /healthz wait for the first deploy

    The queue has no consumer yet; wrangler deploy attaches it.

    Not tried: the Postgres session through cloudflared access tcp from a GitHub-hosted runner (only a laptop so far). If migrate-ci.sh fails there, send infra the log.

    What this repo's staging environment holds now (read through the API, names only). The environment exists (created 2026-11-14 06:32Z) with 0 variables, 0 secrets and no reviewers. staging-do-lifecycle exists with no required reviewers: the plan job runs assert-gated-environments.sh for it and fails closed (NOT GATED), so no staging deploy will start until it has one. THRUST_DEPLOY_ENABLED is not set, so a push to main stays quiet, as designed.

    Values for the variables. None is a secret. deploy.yml says staging-do-lifecycle needs the same variables and secrets as staging.

    Variable Value
    DB_ACCESS_HOSTNAME thrust-pg-stage-ci.sow.foo
    THRUST_WORKER_NAME thrust-staging
    THRUST_BASE_URL https://thrust-staging.sow.foo
    THRUST_HYPERDRIVE_ID 1c873d803aed4b21bf8a887ead727d9d
    THRUST_R2_BUCKET thrust-staging-blobs
    THRUST_QUEUE / THRUST_QUEUE_DLQ thrust-staging-events / thrust-staging-events-dlq
    THRUST_RL_SIGNIN_ID / THRUST_RL_V1_ID 92002 / 92003
    CLOUDFLARE_ACCOUNT_ID, THRUST_CSRF_ENFORCE, SMOKE_EMAIL, SMOKE_WORKSPACE the owner's; nothing in infra provides them

    Infra also reserved 92001 for the create limiter, which #166 deleted. It is unused.

    Secrets

    • TUNNEL_SERVICE_TOKEN_ID and TUNNEL_SERVICE_TOKEN_SECRET: the client_id and client_secret of the Access service token thrust-ci-migrate, in AWS Secrets Manager at /thrust/ci-access-service-token. It expires 2027-11-14. Rotation is create-ci-service-token.sh --rotate (infra runbook, "CI route to thrust-pg-dev") and only this GitHub secret changes.
    • DATABASE_URL: role staging, password in /thrust/pg-dev-staging-password, database thrust, host and port the tunnel's local end (migrate-ci.sh refuses anything else).
    • CLOUDFLARE_API_TOKEN and SMOKE_PASSWORD: the owner's. Infra creates neither.

    Order, and what infra needs from the first deploy

    1. Variables, secrets and reviewers on staging and on staging-do-lifecycle.
    2. The first deploy, as a manual run. It carries the Durable Object migration, so deploy defers it to deploy-do behind the reviewers. first_deploy_skip_smoke exists because the hostname is not attached until step 4. crates/thrust-worker/wrangler.deploy.toml has no routes or custom_domain entry, and it must stay that way: infra's cloudflare_workers_custom_domain owns the hostname, and two owners of it would collide.
    3. A deploy with a wrong Hyperdrive id must fail. That is infra #1017's acceptance, not only Thrust's.
    4. Tell infra the Worker exists. Infra then attaches the domain (attach_staging_domain=true, one resource to add) and checks GET https://thrust-staging.sow.foo/healthz returns ok with x-thrust-version equal to the deployed commit. That closes #1017.
  4. aRustyDev commented on Nov 15, 2026

    @aRustyDev
    OwnerAuthor

    The infra side is done (2026-11-15). This follows my earlier comment above. #49 stays open: two of its criteria were not exercised, and one needs rewording (see the table).

    In place

    • ApiraTech/infrastructure #1015, #1016 and #1017 are all closed, each with its evidence.
    • Staging serves at https://thrust-staging.sow.foo: /healthz answers 200 ok, and x-thrust-version is a767aadfe83ec7441831c6171e50776bbdaa6211, the commit that was deployed.
    • staging and staging-do-lifecycle each hold 13 variables and 5 secrets. Only staging-do-lifecycle has a required reviewer (staging is unattended by design). Both take only rc/*. production and production-do-lifecycle have a reviewer and the v* rule but no variables or secrets yet (the production infra issue is held).
    • The smoke account is bootstrapped (scripts/smoke-bootstrap.sh) and the real smoke passes against the live Worker.
    • THRUST_DEPLOY_ENABLED is unset, so nothing deploys by itself. The open release candidate is chore(release): v0.1.0 #187.

    The runs

    Run Result
    43676097831 first attempt: deferred, then deploy-do failed at assets-upload-session (the token held only Workers read permissions). Second attempt: created the Worker (9b0550ae), no smoke
    43758233044 from a throwaway rc/manual-* branch: deferred to the manual gate, approved, deployed a767aadf, smoke and its control passed
    43763466550 a deliberately wrong THRUST_HYPERDRIVE_ID: failed at the version upload (Cloudflare code 10157), the previous version untouched
    43763954773 the right id, same dispatch: deployed, smoke passed

    #49's checklist against those runs (not ticked: that is for you to decide)

    Criterion Evidence
    deploy.yml runs the steps in order on push to main it runs in order: migration only when one changed (the later runs print no expand migration), deploy at 100 %, smoke, control. The trigger is no longer main: since #185 and #186 staging deploys from rc/* and production from v*, so this wording is stale
    rollback drill: a failing smoke ends with the previous version active not run. It needs a manual staging dispatch with inject_smoke_failure from the rc/* branch just deployed
    the smoke fails against a Worker that still serves the previous version shown: every deploy ran "the smoke must refuse a version nobody deployed" and it did; run by hand against a version nobody deployed, it exited 1
    a release that adds a DO migration stops for approval and does not roll back shown for the first deploy ([[migrations]] v1): deploy deferred, deploy-do waited for the reviewer, automatic rollback: false. A later [[migrations]] change has not been exercised
    an asset URL from the previous release still returns its JavaScript not shown: every deploy so far was a first deploy or the same commit again (retained=0). It needs two real releases
    cicd.md, ADR-0110 and Q-0110.1 match the pipeline deploy.md is fixed in #189. I did not check cicd.md, the ADR or the question

    Worth knowing

    • The first deploy after a version that was deployed from main always goes through the manual gate, because the previous release's bundle is only accepted from a run on rc/* or v*. That is why run 43758233044 needed an approval.
    • The deploy token (Workers Editor + Queues Write) cannot create a Worker, but it can change a Custom Domain, and the picker cannot scope it to one Worker. The domain stays in Terraform so a plan reviews it.
    • The deploy job's token and the deploy-do job's token are different tokens (the latter is Workers Admin). Both are in the docs now.

    Open follow-ups

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:infraprio:p0review:fable-2026-10-19

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions