# Field — Release Engineering & Continuous Delivery

**Packet:** software-supply-chain-and-release-engineering · **Date:** 2026-07-24
**Grounds:** the guarded prod switch in `scripts/ops/miadi-refresh.sh` and the outage
hazard in the predecessor `miadi-prod-rebuild.sh`.

## Canonical concepts

- **The deployment pipeline.** Build → verify → promote → release as a first-class,
  automated discipline (Humble & Farley, *Continuous Delivery*, 2010). Release engineering
  is a recognized field, not an afterthought (Adams & McIntosh, "Modern Release Engineering
  in a Nutshell," SANER 2016).
- **Separation of build from cutover.** A build produces an immutable, verifiable artifact;
  the *cutover* switches serving to it. Blue-green and atomic-symlink deploys exist precisely
  so a half-built artifact is never exposed and rollback is instantaneous.
- **Health-gated release.** Traffic is admitted only after a readiness signal; a failed
  build or failed health check must leave the *previous* good state serving.
- **Delivery performance (DORA / *Accelerate*, Forsgren, Humble, Kim, 2018).** Deployment
  frequency, lead time, change-fail rate, and time-to-restore — the outcome metrics a safe
  pipeline improves.

## Key finding

Safe deployment is an **ordering** property. The invariant: *never mutate serving state
ahead of a verified artifact.* Build first, while the current version keeps serving; switch
only once a completed artifact exists (for Next.js, a written `.next/BUILD_ID`).

The predecessor `miadi-prod-rebuild.sh` violates the ordering: it **stops the server and
sets the mode flag to `prod` before building**, then `exit 1`s on build failure. The
failure mode is a stranded outage — a stopped server pinned to prod mode with no
`BUILD_ID`, which the launcher then refuses to start. A human is required to recover. The
corrected `miadi-refresh.sh` builds first and only restarts once `BUILD_ID` is present, so a
failed build costs **zero** downtime.

## Cautions

- Next.js builds from the **working tree, not git**. Untracked work under `app/` and
  `packages/` is included in a prod build — a reproducibility and provenance hazard
  (jgwill/Miadi#520). State what is shipping (`git status --short`) before a rebuild.
- Health "200" on the wrong port proves nothing. Verify on the surface the audience actually
  reaches (here, `:3335`).

## Engineering implication (what this grounds)

`miadi-refresh.sh` encodes fail-safe state ordering as executable policy; `scripts/ops/`
carries it under review. This is the deployment-time instance of **fail-safe defaults**
(Saltzer & Schroeder, 1975): when an action cannot complete safely, the system must fall
back to the last known-good state, not to a broken one.

## Lines worth carrying into voice chronicle

> Build in daylight while the old house still stands; move in only once the new one has a
> roof. A deploy that stops the world before it knows it can rebuild it is not a deploy —
> it is a wager.

## Sources

See `source-ledger.yaml` — `humble-farley-2010`, `accelerate-2018`, `adams-mcintosh-2016`,
`saltzer-schroeder-1975`.
