logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·30.10.26
← Back to news

Five months treating bugs like patients and coding agents like a medical team

Original article
cockroachlabs.com|197 points|90 comments|by rafiss|Oct 9, 2026

Five Months Treating Bugs Like Patients and Coding Agents Like a Medical Team

By Adam Storm and Rafi Shamim | Published October 9, 2026

📌 Executive Summary

To maintain enterprise-grade reliability while leveraging AI, we implemented a coding agent pipeline modeled after a teaching hospital. By utilizing specialized roles—such as Triage Nurses, Fellows, Review Attendings, and Discharge Nurses—we enforced a culture of mandatory planning, rigorous peer review, and strict safety guardrails.

The Results:

  • Volume: Over 1,000,000 lines of code processed.
  • Stability: Only 7 total reverts.
  • Outcome: Successfully deployed the Migration Assistant and complex database migrations with minimal regressions.

🚀 The "Impossible" Sprint: Adding Db2 Support

In April, between a Wednesday evening and Friday afternoon, MOLT (the Cockroach Labs tool for migrating databases to CockroachDB) gained full support for IBM Db2.

Db2 is a formidable target due to its:

  1. Intricate SQL dialect.
  2. Complex type system.
  3. Proprietary native wire protocol.

The Scope of Work

To make this happen, the system had to generate:

  • A brand new schema converter.
  • A Fetch path for row extraction and ingestion.
  • A Verify path for post-load data validation.
  • A vendored ANTLR grammar.
  • A dedicated Docker image for CI/CD.
  • ≈10,000+\approx 10,000+≈10,000+ lines of test fixtures.

A Tale of Two Implementations

The difference in efficiency between human-led and agent-led development was staggering:

FeatureOracle Support (2024)Db2 Support (2026)
Timeline9 Months<2< 2<2 Days
Human EffortHigh (Engineering Team)Zero (No human wrote code)
Estimated Cost\approx \160,000$Negligible compute cost

🛠️ The Agentic Workflow in Action

The process began with a single GitHub issue. Rather than attempting a "big bang" implementation, a planning agent decomposed the request into a structured dependency graph.

The Iterative Cycle:

  • Decomposition: Some sub-issues were too complex and were further split.
  • Self-Correction: Agents identified their own mistakes, filing a dozen additional issues for fixture gaps, type-mapping bugs, and isolation-level fixes.
  • The Final Tally:
    • 32 sub-issues opened.
    • 27 merged Pull Requests (PRs).
    • 55 instances of work being sent back for revision.
    • 9 escalations (only 2 required human intervention).

The resulting test coverage was mathematically equivalent to PostgreSQL, our gold standard: CoverageDb2≈CoveragePostgres\text{Coverage}_{\text{Db2}} \approx \text{Coverage}_{\text{Postgres}}CoverageDb2​≈CoveragePostgres​


🏥 Introducing "MOLT Sinai"

To ensure this quality, we didn't just build a script; we built a coding hospital called MOLT Sinai (a play on the famous teaching hospitals in New York and Toronto).

"Agents writing code quickly isn't the innovation. The innovation is the rigorous structure we placed between the agents and the main branch."

Why a Teaching Hospital?

Most AI coding experiments focus on throughput →\rightarrow→ reliability. While tools like Gas Town or Cursor's SQLite experiment prioritize speed and volume, CockroachDB builds a distributed SQL database. In our world, a minor bug can lead to catastrophic data corruption.

We traded speed for safety. We would rather an agent take 10×10\times10× longer to complete a task than risk a single customer's data integrity.

The Medical Staff (Agent Roles)

We modeled our pipeline on a hierarchy of oversight:

  • Triage Nurses: Initial assessment and issue decomposition.
  • Fellows: The primary "surgeons" writing the code.
  • Review Attendings: Senior oversight ensuring the code meets production standards.
  • Discharge Nurses: Final verification and merging.

Specialized Support Staff:

  • Charge Nurse: Rounds every 30 minutes to identify and unstick "stalled patients" (blocked issues).
  • Infection Control: A kill-switch agent that locks all workflows if the main branch breaks.
  • Safety Department: Conducts weekly process audits and post-incident reviews.
  • Research Department: Continuously optimizes the underlying prompts and models.

⚙️ Technical Implementation

The system operates as a series of GitHub workflows triggered by labels.

# Conceptual logic of the MOLT Sinai handoff
if issue.label == "label_in_triage":
    run_triage_agent()
    issue.add_label("label_out_triage")
    issue.remove_label("label_in_triage")
    # This triggers the next stage: Fellow

Workflow Diagram

The Feedback Loop: Work does not move linearly. If a Review Attending finds a flaw, the work is sent back to the Fellow. If the CI fails, it returns to Treatment. If a stage is completely stuck, it is escalated to the Chief.

Db2 Issue Example

📈 Cost and Efficiency

While the "hospital" approach is slower than a "swarm," it is economically viable and technically superior for high-stakes software.

Cost Chart