Deemwar Monads & Abstractions

The Coding Hospital

Source: Five months treating bugs like patients and coding agents like a medical team, by Adam Storm and Rafi Shamim

A coding agent can write the wrong fix and still get the tests green. Cockroach Labs ran its agents for five months as a teaching hospital: issues are patients, merging is discharge. Every change passes three gates before it reaches main.

1,238 PRs merged
7 reverted
92 issues reached a human
~$84 per issue

The ward round

Each role is an agent with its own prompt. The Review Attending is always a different instance from the Fellow who did the work.

  1. 1

    Admit or reject

    Triage Nurse

    Reads the incoming issue, classifies severity and complexity, and admits or rejects it.

  2. 2

    Workup and treatment plan

    Fellow

    Reproduces the bug, narrows the cause, and posts a plan: diagnosis, files to change, tests to add, risks, open questions.

  3. 3

    Plan review

    Review Attending

    A prompt built to find fault, not to fix. Approves or rejects the plan before any code exists. Rejects under 10% of plans.

  4. reject → back to 2 · scope change during treatment → new plan, back to 3
  5. 4

    Treatment

    Fellow

    Implements the approved plan. If stuck, writes an I-PASS handoff and escalates instead of trying harder.

  6. 5

    Code review

    Review Attending

    Starts by disabling the change. Every new test must then fail; a test that still passes is out of scope or wrong.

  7. requested changes → back to 4
  8. 6

    Discharge

    Discharge Nurse

    Does not re-review the code. Audits that the review happened: an approval exists, the template is filled, no unresolved threads, CI is green, history is clean. Posts the checklist.

  9. any box unchecked → discharge fails, box annotated · red CI → back to 4
  10. 7

    Merge

    GitHub Actions

    The patient goes home. A stuck stage goes up to the Chief of Medicine, a human.

Labels are the state machine

Everything runs on GitHub Actions. A label on the issue starts a stage; when the agent finishes it writes a label out, which is the next stage’s label in. Notes go into the issue’s chart with a sentinel such as SINAI:TREATMENT_PLAN so later agents can parse them.

label out = next label in · dashed lines send the patient back

House rules

No code before a planAnd no plan without review.
Don’t improviseScope changes mid-treatment mean a revised plan and a new review.
Tests stay as writtenNo disabling, skipping or weakening. A test change is its own commit, reviewed separately.
Never flailStuck agents write an I-PASS handoff; the receiver restates it before starting.
Precedents before the ChiefRead the append-only log of human rulings; cite a matching one instead of escalating.

What five months showed

RunLessonRule now
Db2 supportUnder two days, $4,172 in tokens. 32 sub-issues, 27 merged PRs, 55 send-backs, 9 escalations, 2 to a human.Large asks are decomposed into a dependency graph of sub-issues.
Plan reviewRejects under 10% of plans, yet caught a telemetry fix that still leaked a hostname.Rework moves to the earliest, cheapest point.
First weekAutonomous merges were not enough to ship to customers.Human approval mode: every merge gets human eyes.
Own backlog1,299 issues were filed by agents for other agents.A human decides what gets admitted.
July audit25 skill files, ~100,000 words; 23% removable without changing a gate.Prune prompts like code; a linter is planned.

Caveats

Read more

Five months treating bugs like patients, Cockroach Labs.

Discussion on Hacker News.

Sources: every number is from the Cockroach Labs post (Adam Storm, Rafi Shamim, 9 October 2026), results table for April 21 to September 11 and the “What it cost” section.