Repository navigation
Billing audit (sc-9146): automatic packs and credit emails restored, opt-in; builds stop when credits run out; Free never owes; dead subscriptions move to Free - #199
Merged
Conversation
VisualCIdocspring/visualci · build #722 · 515 unchanged · no changes This PR vs base: 25 changed, 101 added since #541, across 4 builds docspring/visualci · journeys · build #721 · 50 unchanged · no changes This PR vs base: 1 changed, 8 added since #538, across 5 builds Updated as builds change. Agents can review with VisualCI's MCP tools. |
ndbroadbent
force-pushed
the
billing-audit
branch
from
December 4, 2026 10:04
c139d08 to
9459b9e
Compare
ndbroadbent
force-pushed
the
billing-audit
branch
from
December 4, 2026 12:51
9459b9e to
3bb6c23
Compare
…gain (lost in the Laravel Rust port), off until an admin turns them on; builds stop between batches when credits run out; Free never owes credits; a subscription Stripe gives up on moves to Free
…e it (no clock comparison: shared renders paid once, tests charge for diffs and pages); unpaid keeps the subscription with Pay the open invoice, incomplete_expired clears it; a pay call cut off after the charge credits the pack; checks again under the reload's claim; the build's check before billing's listeners; ledger row for forgiven balances
…en its build stops, is charged to the build that waits for it; the reload keeps its claim after an error (an unknown charge isn't tried again) and checks the plan under it; test callers fixed
ndbroadbent
force-pushed
the
billing-audit
branch
from
December 4, 2026 14:06
3bb6c23 to
69412e5
Compare
This was referenced Dec 4, 2026
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
… billing hears a build finish even when its check fails (#199) - A document's base drawn again with the head's settings is a render the build made that none of its snapshots points at; the charge counted only renders its snapshots point at, so those pages were never charged. It now counts every render the build made. - The part-way credit check ran every 200 snapshots, so a build of long documents could compare thousands of pages past its credits. It now counts pages (a document's from its render). - finished() returned early when BuildChanged's dispatch failed (a forge that's down), so CreditsSpent (low-credit emails, automatic packs) never ran. Both run now, and the first error is returned.
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
… billing hears a build finish even when its check fails (#199) - A document's base drawn again with the head's settings is a render the build made that none of its snapshots points at; the charge counted only renders its snapshots point at, so those pages were never charged. It now counts every render the build made. - The part-way credit check ran every 200 snapshots, so a build of long documents could compare thousands of pages past its credits. It now counts pages (a document's from its render). - finished() returned early when BuildChanged's dispatch failed (a forge that's down), so CreditsSpent (low-credit emails, automatic packs) never ran. Both run now, and the first error is returned.
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
… hears every finish (#199 leftovers) (#218) * Processing: redrawn bases are charged, the credit check counts pages, billing hears a build finish even when its check fails (#199) - A document's base drawn again with the head's settings is a render the build made that none of its snapshots points at; the charge counted only renders its snapshots point at, so those pages were never charged. It now counts every render the build made. - The part-way credit check ran every 200 snapshots, so a build of long documents could compare thousands of pages past its credits. It now counts pages (a document's from its render). - finished() returned early when BuildChanged's dispatch failed (a forge that's down), so CreditsSpent (low-credit emails, automatic packs) never ran. Both run now, and the first error is returned. * Tests: each test's pool holds at most 4 connections (sc-9385) The suite is one binary whose tests boot at once, each with its own pool of up to 10: a CI runner's threads asked Postgres for more than its 100 connections, and tests failed at boot with "pool timed out".
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
…under its claim (#199's weak and untested spots)
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
…check fails; a reused image diff shares its row (#199)
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
…under its claim (#199's weak and untested spots)
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
…check fails; a reused image diff shares its row (#199)
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
…under its claim (#199's weak and untested spots) (#226) * Tests: the shared render really is shared, and the reload's re-check under its claim (#199's weak and untested spots) * Tests: billing hears a finished build after its check, even when the check fails; a reused image diff shares its row (#199)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The must-fix half of the billing audit before sign-ups (sc-9146). The audit notes, with the should-fix items that come next, are in the story.
What was wrong
auto_reload, its out-of-credits email and the 80%/95% warnings, and nothing replaced them.CreditsSpent,CreditsRanOutandBuildStoppedForCredits, but nothing listened.unpaidonly set a notice, andcanceledandincomplete_expireddid nothing. The 1,000,000 allowance renewed every month.What changes
billing/reload.rsports the reload:invoice.paid;billing/listeners.rs:A listener failure is logged and never fails the build.
One-click buy: the out-of-credits email's button is "Buy a credit pack", linking to
billing?buy=pack. The billing page then goes straight on to Stripe's Checkout for someone who can pay. On Free, the button is "Upgrade to Team".Dead subscriptions:
unpaidmoves to Free and keeps the subscription, with a payment notice; the billing page shows "Pay the open invoice" (Stripe's portal), and paying brings Team back. Checkout refuses a second subscription with a message saying so;canceledandincomplete_expiredmove to Free and clear the subscription, so Upgrade starts a new one;past_due(Stripe still retrying) keeps Team with the notice.Overrun (Nathan's decision):
Opt-in (Nathan's decision). A migration sets the default to 0 and turns every organization's automatic packs off.
Docs and design:
docs/reference/credits.mdanddocs/design.mddescribe the new behaviour. Golden files change onlyauto_reload_packsfrom 4 to 0.Tests (failing first)
tests/automatic_packs.rs(8), plus one each intests/billing.rsandtests/processing.rs. Against main, all fail exceptoff_by_default_nothing_is_charged, a guard that passes because main never charged at all:The whole app suite, fmt, clippy and the frontend's
tsc -bpass.Second round (independent review, and the test harness gap)
made_by_build_id, a nullable column onrendersanddiffs), replacing "made after the build was created". That comparison mixed the app's clock with Postgres'snow(). Inside a test's transaction every row was stamped with the test's start, so no test ever charged for a diff or a page. In production, a render that one build queued and another build finished could be charged twice or not at all.