A buyer may have five payments waiting on their bank (maxUnfinished). The
cap counted every unsettled pending-intent row however old, and the only
thing that closes an abandoned one is reconcileIntents, which runs only
inside RenewDue, the renewal sweep. A deployment that never runs that
sweep keeps every abandoned payment open for good. Testnet has no
schedules (universe hanzo-testnet/cloud.yaml: "absent: key:schedules"),
so the cloud release's own test buyer has been refused every top-up with
429 "too many payments are waiting on your bank" since 2026-11-16, and no
release has reached production since.
atCap now counts only the payments commerce is still waiting on: a row
past its deadline holds no place, whether or not the sweep has closed it.
The deadline is the sweep's own, now one function (abandonsAt) that
reconcileIntent and atCap both read: a card's 48 hours, a delayed
method's eight days, a locked quote's lock. A wire has none and still
counts, as before. pendingintent.CountOpen becomes OpenOf (its one
caller needs the rows, not the count).
Nothing else changes: an abandoned row stays open until the sweep cancels
it at Stripe and closes it, and its webhook still credits it if it
succeeds late.
Testing: TestAPaymentPastItsDeadlineHoldsNoPlaceUnderTheCap fails on main
(five card payments past 48 hours still fill the cap) and passes here;
it also holds the 47-hour, delayed-method and lapsed-quote edges. The
whole ./api/billing package passes with CI's go-unit skip list (the
live-Stripe tests need Stripe test keys); go vet clean on api/billing
and models/pendingintent. Run against the cached zap-proto/zip v1.37.44
(go.mod wants v1.37.43, not fetchable on this machine; go.mod/go.sum
untouched).
Risk: on a deployment whose sweep never runs, a buyer can now open new
payments beside abandoned ones, so its open rows can grow past five;
each is one more row the sweep reads when it does run (bounded per sweep
by perOrgPerSweep/perSweep). Where the renewal sweep runs (cloud's hourly
billing-renew in production), a row past its deadline is closed within
the hour anyway, so the cap reads the same there.
How to revert: git revert this commit; the cap counts every open row
again.
Co-authored-by: Claude Opus 5.5 <[email protected]>