Spent, but not on anything

Every deposit required a texted code, and each code could be spent once. Nothing recorded which deposit spent it, so the dispute packet that cited those codes was counting texts, not approvals. Now each spent code carries the checkout it approved.

4 min readGoldVault · Identity stage

Before money moves, the customer types a code the platform has just texted to their phone. The code has two jobs. It is a step-up: whoever holds the session also holds the phone. And it is evidence: when a cardholder later disputes the charge, the packet the platform sends back says the phone's owner approved it. The first job is about a moment. The second is about one particular charge, weeks or months later, and that difference is the whole note.

The gate, closed in July

Until 5 July 2026 both jobs were weaker than they looked. The table of codes accepted writes from any signed-in browser, so a row could be marked verified with no text ever sent, and the deposit route checked a code only if one was supplied. One commit, following an internal audit, fixed both. Writes to the table went to the server alone, the code became required, and the route spent it with one conditional update that matches only a code that is verified, owned by this customer and not yet spent. A replay, or an id someone made up, finds no row and is refused. That half did what it said.

Spent, but not bound

The audit asked for one more thing: consume the code once, bound to this operation. The spending shipped. The binding did not. The route spent the code and then created the checkout, and nothing wrote one onto the other. The schema expected the link. The codes table had carried an operation id column since May, with an index on it, and a lookup documented as being for dispute evidence that nothing called. The app's code dialog sent no operation id, so the column stayed empty, and the newer purchase route copied the same spend and bound nothing either.

What the packet said

So the dispute packet did the next best thing, and said more than it knew. It listed the customer's ten most recently verified codes, under a sentence saying each transaction requires one, and its summary said the customer verified that many transactions by text. The number counted codes, not transactions. A code verified for a deposit the risk check then refused still counted, because the check runs before the spend and the query asked only whether a code was verified, not whether it was spent. A code verified the week after the disputed charge counted too. And the query stopped at ten, so the line written for a customer with more than ten could never print.

Found by reading

The anatomy row for this stage said the code was required and spent once, which was true, and it read as finished. Writing this note meant re-reading the route against the row on 10 November, and the gap between spending and binding showed up in the code before anything else did. The production read the next day confirmed it: the operation id column was empty on every one of its 116 rows. The same reading turned up an older deposit route that still took the code as optional and recorded a verification it never checked. Nothing in the app called it.

The fix

The spend now lives in one function that the deposit, purchase and cash-out routes all call, and it refuses a code past its expiry as well as one already spent. Once the checkout row exists, the code is written onto it. That write is logged rather than thrown if it fails, because the checkout is already real by then and the customer should not lose it over evidence. The dispute packet looks first for the code bound to the disputed charge, reached through the checkout the ledger row records, and presents it as the approval for that charge. When there is none, it lists codes that were verified and actually used on the account on or before the charge, and calls them that. The line for more than ten now prints. The old deposit route was deleted in the same pass. Seven tests cover the spend, the expiry and the binding, and the two that matter fail without the change. It merged on 12 November 2026. Codes spent before then carry no binding, so older disputes still get the honest list, not the single code.

What it still gets wrong

The consent record a customer gives before a deposit is filed under an id the route generates for it, not the checkout's, so the packet's search for the consent that goes with a disputed charge still comes back empty, and the consent section is left out of the packet. That is the next join to make, and it is the same shape as this one.

Why it belongs on this page

A control and the evidence of the control are two different things, and one fix can finish the first and leave the second where it was. The July commit was right about the gate, and its message says exactly what it closed. What it did not do was finish the sentence the column, the index and the lookup had started in May. Every piece of the link existed except the one line that writes it. That is the kind of gap that survives review, because each piece looks deliberate on its own.

More notes
  • The webhook that credits twiceA payment processor delivers every result at least once. The interesting engineering is in what happens when your side fails halfway through.
  • A ledger you can edit from a route handler is not a ledgerWhy every movement of value on the payments platform goes through a Postgres function, and what it costs to keep it that way.
  • Four rows that were not theirsHardening multi-tenant row-level security in four reversible phases, verified by impersonating a member and counting what they could see.
  • The bug inside the fixA payout race, the fix for it, the bug inside that fix, and why it is the best argument I have for one person owning the whole path.
  • The sale that arrives with no referrerA creator shares a link on Instagram, the buyer taps it, installs the app and purchases. Nothing in that chain carries the creator's name across. Here is what does.
  • The minimum that belongs to someone elseHeld commissions are released to creators once a brand's payout minimum is met. Group the money by creator, the obvious way, and one brand's minimum ends up holding another brand's money.
  • The commission that must not mint twiceA buyer pays and the platform owes a creator a commission. Between those two facts sit a colluding pair, a call that arrives twice, and a cart with three items on one payment.
  • The rule that has to be written twiceFirestore security rules do not cascade to subcollections. Forget that in one place and a single query returns every private message on the platform.
  • Thirty days in the ledgerSplitting a payment at charge time is simpler and wrong: a refund after the creator is paid is a clawback nobody enjoys. Holding the money creates a different set of problems, and each piece of machinery around the hold answers one of them.
  • Arbitrary but consistentA gym's assessment answers become rules that swap an exercise for a member before a session. Two rules can disagree about the same movement. The code says who wins, and the comment admits how.
  • The number that ducked every thresholdA deposit arrives from a browser carrying two numbers. The platform scored one of them and charged the other, and every limit it had was measuring the wrong figure.
  • The second one tells you the shapeHigh-risk merchants get dropped by processors, so the platform cannot be welded to one. The interface that makes a processor swappable could not be designed before the second one existed.
  • A key you did not makeA device fingerprint is a hash the browser computes and the server has to take on faith. The useful question is not whether to trust it, but what a server does once it accepts that it cannot.
  • The template never learns your nameA trainer builds a workout once and runs it for a room of people who are not the same. The data model that survived is three tables with a one-way street between them, and the model it replaced was the obvious one.
  • The copy that heals itselfA marketplace that sells a brand's products keeps a copy of the brand's store. The same codebase keeps that copy two different ways, and the slower one is the one that is right by morning.
  • The ledger was rightA team sale splits one commission between two people. The split was recorded correctly everywhere a person could look, and the code that sent the money would have paid the wrong one.
  • Zero was not a ceilingA creator can write their own commission rate, so the server caps it at what the brand agreed to. For most of the catalogue the cap never ran, because those products carried no commission of their own.
  • Smaller than it wasOn 27 September the gym's movement library lost 4,724 lines and gained one field. What came out was a theory of how movements relate. What replaced it was a trainer writing the relation down.
  • The toast that could not fireA trainer taps Mark All and the whole room's round is recorded. From October 2025, if every one of those saves failed, the app said nothing, because a failed save and a deliberate skip had become the same value.
  • The ceiling is a thousand rowsA comment beside the member totals names their ceiling: tens of thousands of sets, and then it gets slow. The query under it has no range, and the API it calls stops at a thousand rows without saying so.
  • No exceptions notedThe platform could generate a certificate of its own controls for underwriters, and every result in it was the same fixed string. Re-reading it for this page found that. It now counts what the guard actually decided.