Case Study: Groovy → Go Migration

Case Study

Modernize Legacy App

A Regen Story

100
Endpoints
10
We Needed
0
Specs Written
2018

crm-api was born

Built before standards existed. But it became the backbone of our relationship with Itaú.

The Team?

GONE

And with them went the knowledge of what actually mattered.

Three Challenges

1

Too Much Docs

100 endpoints documented. We only needed 10.

2

Complex Endpoints

The 10 we needed were the most complex.

3

Language Change

Groovy to Go. Different paradigms.

SECURITY ALERT

CVE Vulnerability

Groovy runtime. Cannot be patched.

Migration is now mandatory.

The Code We Found

InvoiceProcessor.groovy
def calculateTax(amount) {
    // TODO: review this later
    return amount * 0.0825
}

8.25% — Why that specific value? Nobody could tell us.

The Reality

100
Endpoints
27K
Lines of Code
90%
Was Noise

Signal lost in noise.

We Tried Everything

More developers ✗ Failed
Manual reverse engineering ✗ Failed
Writing specs from code ✗ Failed
Traditional TDD ✗ Failed

Uncertainty doesn't shrink with headcount.

What if we stopped trying to

understand the code?

AI Spec TDD

🔍
Probe Legacy
📋
Capture Tests
🤖
Generate Code
Verify Match

The running system IS the specification.

Capturing Behavior

probe-legacy.sh
$ curl legacy-api/calculate?amount=1000
{
  "tax": 82.50,
  "total": 1082.50
}

# → Golden test case captured

Each response becomes a golden test case.

Claude Generates

Legacy Groovy
def calculateTax(amount) {
  return amount * 0.0825
}
Modern Go
func CalculateTax(amount float64) float64 {
  return amount * 0.0825
}

The AI figured out that magic tax rate just from input-output pairs.

Here's what surprised us

The AI replicated
the bugs

Like-for-like means bugs too. We weren't fixing the system.
We were replicating it exactly.

The Moment of Truth

verify.sh
Testing: /calculate?amount=1000
  Legacy:  { tax: 82.50, total: 1082.50 }
  Modern:  { tax: 82.50, total: 1082.50 }
  ✓ EXACT MATCH

Testing: /invoice/lookup/INV-2024-001
  Legacy:  { status: "paid", amount: 5000 }
  Modern:  { status: "paid", amount: 5000 }
  ✓ EXACT MATCH
MODERNIZATION COMPLETE

All Behaviors Preserved

98.5%
Traffic Migrated
0
Specs Written
100%
Fidelity

We didn't understand the logic.

We captured it.

The running system was the specification all along.

Thank you.

AI-Driven Development Series

1 / 17