Skip to main content
← All Posts

2,491 passing tests and a 16% mutation score

I spent July taking EchoQuest apart instead of adding to it.

admin.js had turned into the file I’d open and then close again. One module, hundreds of routes, every admin feature in the game dumped in the same place because that’s where the last one went. It’s now 57 lines that mount eleven sub-routers, and the 360 routes that used to live in it are in routes/admin/, one file per thing they deal with. game.js got the same treatment — combat, crafting, quests, catalog and save are their own modules now, and the socket handlers came out into theirs.

You can’t see any of that if you play the game. It’s why the rest of this happened, though.

Where the 16% came from

I set up Stryker to run mutation testing. It edits your code on purpose — flips a < to a <=, deletes a line, swaps a plus for a minus — then checks whether any of your tests notice.

First run against balanceMath.js, which owns the XP curve and every damage formula in the game, came back at 16.34%. Coverage had been telling me that file was tested. What it was actually telling me was that the lines ran, not that anything checked the answer.

It took seventy new tests to get it to 97.23%, killing 384 of 394 mutants. Going after the survivors turned up code that was never going to do anything. Two local variables in calculateSecondaryStats get calculated and then thrown away. A branch in stringMaxLength can’t be reached at all — there’s no input that gets you there. Both had been sitting in a file with 2,491 tests around them.

I did the same thing to the validation chain afterwards and took it from 65.68% to just over 81%, across 708 mutants, with 45 new tests written specifically to kill survivors.

A coverage number tells you your tests ran. A mutation score tells you they’d actually complain about something. I’d been reading the first one as if it meant the second.

The admin panel cached a web page as a stylesheet

My favourite bug of the month, mostly because of how stuck it got.

A deploy went out with a page referencing a CSS file that didn’t exist yet. Ask a single-page app for a path it doesn’t know and it hands you index.html with a 200. So the browser asked for a stylesheet, got a web page back, and filed that page in cache under a URL marked immutable — which it then honoured.

Clearing your cache doesn’t help, because the thing in cache was never a broken stylesheet. It was a completely valid response to a request for a file that wasn’t there.

I’m suspicious of any 200 from a static host now. It tells you the server answered. It doesn’t tell you it answered with what you asked for.

The admin tool got the worst review of the month

I put the admin CMS through an adversarial security review and it came out badly — a cluster of findings across input handling, permission checks and audit logging. All of them are fixed, each with a test that fails if the fix is undone.

I’m not going to enumerate the specifics on a live product. The part worth passing on is why it was the worst-reviewed thing I own: it’s a tool only I use, so it had never been looked at the way the player-facing surfaces had. “Only I use it” describes today, not the day I add a community moderator, and internal tools reach straight into the same database as everything else.

I nearly shipped a login you could spoof

EchoQuest logins now resolve to one canonical EchoForge account shared across every product, with entitlements written to both sides and a GDPR deletion fan-out on the other end.

My first version matched accounts on a claim from the token that the caller can influence, rather than on the one field an identity provider guarantees. Security review caught it before it merged, and it resolves on the guaranteed field alone now.

The general lesson is worth more than the specific bug: when you link two accounts, the only thing you can safely match on is the field the issuer controls end to end. Anything a caller can shape is an input, not an identity.

That one was mine and it was close. So was the boot crash I shipped into two test builds, where entityScale.js read a layout constant at module scope before anything had set it. It never reached production, but it told me the dedup work was less finished than I’d decided it was.

Where that left things

2,491 unit tests passing, coverage gates ratcheted up so they can’t slide back down, validation schemas across the world, dungeon, monetization, NPC, GM and debug routes, and two new documents — ARCHITECTURE.md and CONVENTIONS.md — written from what the code actually does rather than what I remember it doing.

Nothing in it for players. The homestead work that came next needed a server I could find things in.

— Bruno