polycratia

The rewrite passed every test I had, and two weeks later the balances started drifting.

I was carving a payments module out of an inherited monolith. I thought I'd done the homework: mapped the endpoints, read every migration, traced the call paths into the module, ran integration tests against production-shaped data.

What I hadn't asked was who else writes to those tables.

Turned out to be a nightly script with no owner, plus an admin panel action that updated rows directly instead of going through the module's logic. Both were invisible from inside the code I was replacing, because neither one called it. They went straight at the database.

So the new service became the authority for the logic while two other writers kept editing the state underneath it. No error surfaced. The numbers just quietly stopped agreeing, and working out which writer produced which row was manual.

Now the first question I ask before a rewrite isn't about the code. It's this: for every table this thing owns, list each process that writes to it. Cron counts. Admin tooling counts. So does the one-off script living in somebody's home directory.

More than one entry on that list and you're not extracting a service. You're splitting ownership of state, and that needs a decision before the first line gets written: who becomes the single writer, and what happens to the others during the overlap window.

The code you're rewriting is the part you can read. The writers you didn't inventory are the part that bites.

The silent writers are already somewhere in your system: cron, the admin panel, someone's psql session...

react

$ new-project --brief

or email hey@polycratia.com