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.
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
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


2026-09-20 to 2026-09-20 · the same viewport, nothing staged
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
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 production
npm run probe:prod - Run the parity build: the host-only path, locally, then boot and probe
npm run build:prod-parity - The harness doc
docs/ops/HARNESS.md - The per-PR guardrail workflow
.github/workflows/prod-parity.yml - The probe script and its exit codes
scripts/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
fix(auth): stop edge middleware from 500ing the whole site (MIDDLEWARE_INVOCATION_FAILED)
#1011 · 2026-06-11 · bugfix · +17 −1, 2 files
🚨 hotfix: prod outage root cause — Sentry middleware wrapper (MIDDLEWARE_INVOCATION_FAILED)
#1015 · 2026-06-11 · feature · +12 −0, 1 file
feat(ops): ops harness — version endpoint, prod-parity build, probe, serve/stop, CI guardrail
#1016 · 2026-06-11 · feature · +644 −2, 14 files
ci: raise prod-parity build heap to 6 GB to stop build-and-probe OOMs
#1460 · 2026-06-20 · infra · +6 −5, 2 files
ci: fix the prod-parity OOM by serializing static generation under CI
#2255 · 2026-07-27 · bugfix · +44 −4, 5 files
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.