Skip to main content
← All Posts

Nothing was checking what our API actually sent back

August on Steward was mostly one piece of work and it’s hard to make it sound interesting. Every route used to validate its own inputs its own way, and the front end used to decide per hook whether it was talking to real data or test fixtures, with a branch in the middle to pick.

Now there’s one contract. Every operation is defined once, in a shared package, with its input and output shapes. Two adapters implement it — one speaks HTTP to the real worker, one serves fixtures — and they’re interchangeable because they satisfy the same definition. Twenty-two hook modules lost their fixture branching entirely. And there’s a gate that fails the build if any operation in the catalog doesn’t resolve on both adapters.

It paid off within days.

Rotate succeeded, client threw

Rotating a webhook secret worked perfectly on the server. The secret rotated, the response came back 200, everything correct.

Then the page threw.

Every other webhook mutation returns the full row. Rotate returned a trimmed object — the id, the new version, the secret, nothing else. The client’s normalizer assumed what every other response had taught it to assume and called JSON.parse on an events field that wasn’t in the payload. Parse undefined and you get an exception, immediately after a completely successful operation.

No test caught it because no test had ever done rotate-and-then-reload. Each half worked. The server test checked the server. The client test used a fixture with the full shape, because we wrote that fixture by copying another one.

The contract work found it the moment real responses started getting validated against the same schema the fixtures use. That’s the whole value in one bug: a wire-shape mismatch stopped being something a customer discovers and became something the build refuses to accept. The fix was one line. Finding it was the point.

Breaking up the big file

The per-tenant Durable Object had become the file we didn’t want to open. Import and ingest, reports, enrichment and work-item handling all moved into companion files — 768 lines out of the core, with the external surface unchanged, so nothing calling it had to know.

We do this on a schedule now instead of when it hurts. Files don’t announce that they’ve got too big. They just gradually become the place you stop reading carefully.

Enrichment from public filings

The feature we enjoyed most this month. Steward can pull firmographic data from SEC EDGAR and, for non-profits, IRS 990 filings, as a propose-confirm-apply flow. It suggests, you approve, then it writes. Nothing lands in your data because a third party asserted it.

The part we didn’t expect to work as well as it does: SEC insider forms list actual named people with actual roles, and those come in as contacts. So for a public company the buying committee partly assembles itself out of public filings. It’s the only enrichment we’ve built where the source is a legal document rather than a data broker’s guess.

Alongside it: MEDDIC qualification fields, deal stakeholders, product line items on deals. And on the privacy side, a proper data-subject export and hard delete for contacts, audited and permission-gated, because “we’ll add that when someone asks” is a bad plan for a request that arrives with a deadline attached.

Smaller, faster, newer

The main JavaScript bundle went from 530.70 kB to 399.62 kB raw, about 24.7% off, and 146.36 kB to 113.41 kB gzipped. Health trends are backed by snapshots now instead of recomputing from full history on every read. Audit and rule-firing tables got bounded retention so they stop growing forever.

Sessions moved from a fixed twelve-hour expiry to a sliding seven-day window, which is friendlier and, with rotation, not actually weaker. Security headers across the board, PII stripped from email logs, dependency scanning and secret scanning on.

React 19, TypeScript 7, Vite 8. Big version jumps, done in one month on purpose: a toolchain you upgrade continuously costs a day of annoyance, and one you upgrade every two years costs a fortnight of archaeology.

Two we broke ourselves

Clearing sample data threw foreign-key violations if you’d edited any of it first, because the clear didn’t cascade to case notes, stakeholders, line items or revenue events. Caught before it was in front of many people, but it was in front of some.

And CI had to swap one install command for another after a lockfile generated on Windows left out Linux-only native bindings. Which means the lockfile isn’t locking what we thought it was locking, depending on which machine wrote it. That one’s still open and it bothers us more than the bug we fixed.

Billing is still on hold. Google and Microsoft sign-in, still on hold. Fifteen placeholder markers still sitting in the legal documents, which isn’t a code problem and is still our problem.

— Bruno