All cases

2026-06 · DevOps

From one outage to a standing ops harness

Production went down with MIDDLEWARE_INVOCATION_FAILED. The bug was one setting. What made it expensive was everything around it, so every gap became a checked-in command, a CI gate, and a reproduction against a pre-fix checkout.

Verification and trustShipping under constraintSystem design

5

tools from four gaps

n/a

minutes to diagnose, before the harness: no metric captured

55

merges in DevOps, CI & Quality to date

When

#1011#1015#1016#1460#2255#22692026-06-052026-07-31

Part of an arc of 3 merges on auth, 2026-06-08 to 2026-06-11. The whole arc, derived from the record

Before and after, drag to compare

A mostly blank phone screen with 500 and Internal Server Error in the middle: the outage reproduced on a checkout of main from before the fix.
The version endpoint's JSON on a phone: generated true, the deployed commit sha, a build timestamp, and a buildEnv object of variable names each mapped to true or false, then a runtime object with vercelEnv production and the Node version.

2026-09-20 to 2026-09-20 · the same viewport, nothing staged

before

The outage, reproduced on the pre-fix checkout today: every route through the middleware answers 500, and robots.txt, outside the matcher, still answers 200.

2026-09-20 · Reproduced on a checkout of main from before #1015, built with the Sentry token present and served with next start; headless Chromium, 390 by 844

before

The same server's log: the Sentry wrapper the edge alias had removed, called as undefined on every request.

2026-09-20 · The reproduction server's own log, rendered as text; nothing edited

during

The probe matrix run against production today: seven rows, seven passes, and an exit code a workflow can gate on.

2026-09-20 · Real output of scripts/probe.sh against production, rendered as text; nothing edited

after

The version endpoint on production: the deployed commit and a presence boolean for every build-time variable, values never, answering from outside the middleware matcher.

2026-09-20 · Headless Chromium, 390 by 844, against production (www.jakelawrence.xyz)

walkthrough

The version endpoint on production: the deployed commit and every build-time variable as a presence boolean, values never.

2026-09-21 · The studio recorder against production (www.jakelawrence.xyz): headless Chromium, 390 by 844 at 2x, the site's own bumpers and music, nothing staged · on the Case Studies channel

Host build onlySENTRY_AUTH_TOKEN presentwithSentryConfig runswraps the middlewareEdge bundlealias removes Sentrywrapper is undefinedevery matched route: 500Local buildno token, no wrappereverything answers 200the path never ranParity buildfills the env manifest with safedummies so the host-only pathruns here, then boots and probesStanding harness/api/version outside the matcherprobe matrix, PID-file lifecycleper-PR gate that needs no secretsreproduced on purpose

Problem

Every route through the edge middleware returned a 500 while routes outside its matcher stayed healthy. The Sentry build plugin auto-injects a middleware wrapper into the built edge bundle, but the site's webpack config deliberately aliases the Sentry package away in that bundle, so the injected call was undefined at runtime. That path only runs when the Sentry token is present at build time: true on the host, never locally.

Constraint

The failing code path was structurally invisible to local builds. Recovery had to be safe to run from an agent's own shell, which the first attempt, a kill by process name, had taken down with it. And the fix had to be proven, not asserted.

Decision

Do not write a postmortem nobody reruns. Each gap became a command: a version endpoint that returns the deployed sha and presence booleans for every build-time variable, excluded from the middleware matcher so it answers while the middleware is crashing; a declarative probe matrix with disciplined exit codes; a parity build that fills the env manifest with safe dummies so the host-only path runs locally, boots, and probes; PID-file server lifecycle; and a per-PR workflow that runs the parity build and probe with no secrets.

Rejected

  • A postmortem document

    Nobody reruns a document. Each gap is a command in the repository, and the class of failure has a CI gate.

  • Kill the server by process name

    It matched the agent's own shell and killed the operator mid-incident. Servers start in their own process group under a PID file and stop by signaling exactly that group.

What shipped

The version endpoint with its matcher-exclusion test, the probe matrix, the parity build, PID-file lifecycle, and the per-PR guardrail, plus the proof: on a pre-fix checkout the gate reproduces the exact 500; on main it is green.

What I'd do differently

The guardrail then failed for its own reasons: the parity build ran out of memory on the CI runner and took six follow-up merges to settle (a heap raise, a warm cache, path gating, serialized static generation, a smaller heap ceiling, no source maps). A gate that is red for the runner's reasons trains people to ignore it, so none of those fixes was optional.

Verify it yourself

  • The version endpoint, live
  • Run the probe matrix against productionnpm run probe:prod
  • Run the parity build: the host-only path, locally, then boot and probenpm run build:prod-parity
  • The harness docdocs/ops/HARNESS.md
  • The per-PR guardrail workflow.github/workflows/prod-parity.yml
  • The probe script and its exit codesscripts/probe.sh

If you ask me about this

Why booleans only in the version endpoint?
A diagnostic that prints a secret is a leak with a nicer name. Presence booleans localize a build-configuration bug in seconds without exposing a value, and the generator is fail-open so a diagnostic can never fail a deploy.
How do you know the gate would have caught it?
I checked out a pre-fix commit in a throwaway worktree and ran the parity build. Same command, same matrix, the exact middleware 500. On main, green.

Evidence

  1. fix(auth): stop edge middleware from 500ing the whole site (MIDDLEWARE_INVOCATION_FAILED)

    #1011 · 2026-06-11 · bugfix · +17 −1, 2 files

  2. 🚨 hotfix: prod outage root cause — Sentry middleware wrapper (MIDDLEWARE_INVOCATION_FAILED)

    #1015 · 2026-06-11 · feature · +12 −0, 1 file

  3. feat(ops): ops harness — version endpoint, prod-parity build, probe, serve/stop, CI guardrail

    #1016 · 2026-06-11 · feature · +644 −2, 14 files

  4. ci: raise prod-parity build heap to 6 GB to stop build-and-probe OOMs

    #1460 · 2026-06-20 · infra · +6 −5, 2 files

  5. ci: fix the prod-parity OOM by serializing static generation under CI

    #2255 · 2026-07-27 · bugfix · +44 −4, 5 files

  6. ci(prod-parity): drop source-map work in parity CI so the build fits the runner

    #2269 · 2026-07-28 · infra · +38 −16, 3 files

Receipts

Checked at build against the published corpus.

  • Every cited PR exists in the published corpus6 / 6
  • Pending PRs are named as pending, never passed off as mergedall merged
  • Cited PRs sit in the case's disciplinesDevOps, CI, General, Auth
  • Numbers with no source say so1 unmetered

www.jakelawrence.xyz/research/case-study-library/ops-harness

Cite: Lawrence, J. (2026). From one outage to a standing ops harness. jakelawrence.xyz case study library.

Hiring for an AI implementation role?

I make software work inside real organizations, and now that means AI systems a team can check: the buying, the guardrails, the training and the build. If you are filling a role like that, twenty minutes is the quickest way to see whether we fit.

Book a 20-minute call →Have a project instead? See freelance work →