Skip to content

feat(billing): give a self-serve company free capacity, then stop it - #350

Merged
artempartos merged 5 commits into
developfrom
artempartos/capacity-trial-billing
Sep 29, 2026
Merged

artempartos merged 5 commits into
developfrom
artempartos/capacity-trial-billing

Conversation

@artempartos

@artempartos artempartos commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

A company that signs itself up picks a number of sessions and starts running
them. Nobody has asked it for a card, nothing bounds what it may set, and the
/how-it-works calculator happily suggests nine queues — $32,400 a month — to
someone who has not paid us a penny. The moment to charge was not being missed
because it arrives late; it was being missed because nothing was watching for it.

What

A new workspace gets TRIAL_QUEUE_HOURS of capacity free (default 100) and
then stops until someone pays. Hosted deployments only: a self-hosted
operator pays nobody, and a Marketplace customer bought their capacity from AWS
before they ever reached us.

The limit stays the admin's throughout. The allowance is spent at whatever
rate the workspace runs: ten sessions at once uses ten queue-hours an hour, so
the same hundred hours that last one workspace four days last that one ten. A
bigger limit buys a shorter trial rather than a larger gift — a trade the person
making it can see, and one that keeps them evaluating the product they are
actually being sold rather than a capped version of it.

Known consequence, stated rather than guarded against: the overshoot is
bounded only by the metering interval. Nothing is checked between hourly runs, so
a workspace that sets a very high limit can spend past the allowance before the
next run stops it. Capping what a trialing workspace may set is the lever if
that ever matters; it is deliberately not pulled.

One number, two consumers

The drain hands out slots against Billing::EffectiveCapacity and the meter
measures the same value. A ceiling one honours and the other does not either
bills for capacity that was never available, or runs capacity nobody is billed
for. Today the only ceiling is nothing-at-all, for a company that has spent the
allowance.

Our own ledger

company_capacity_usages records what every company was offered, hour by
hour. The meter reports already held this, but as a jsonb blob keyed by company
inside an installation-wide row — enough to send a provider, useless for
answering "how much has this company used", which is where the free allowance and
every invoice conversation start.

It also means the allowance needs no counter: what a company has spent is a sum
over those rows, and a sum cannot drift from the thing it sums. Trial hours are
recorded and not invoiced — a provider is sent the billable companies alone.

What the workspace sees

A banner above the content on every signed-in page: what has been spent of the
allowance, and how long what is left lasts at the rate it is actually
running
. Forty queue-hours is four days at one session and four hours at ten,
and only the second number answers "when do I have to do something about this".
Without it, the end of the allowance arrives as sessions that silently never
start.

Stopping, and starting again

Running sessions are never killed; only nothing new starts. Stripe is not wired
up, so "someone is paying" is a platform administrator moving the company to
active from the admin (new field, new index filters, tested). Without that,
blocking would be a one-way door.

The whole arc has one test of its own (capacity_trial_end_to_end_test.rb): a
company spends the allowance, the hourly meter notices, the drain stops granting
including what was already queued, and moving the company on drains it again. A
blocking rule nothing enforces and an enforcement nothing blocks both pass their
own tests.

Left for the Stripe PR

Billing::Meter::Stripe#deliver is still the logging stub it was, and there is
still nowhere to enter a card. The shape the adapter needs — per-company
fractional quantities, hourly — is unchanged; what is new is that it now only
ever receives companies somebody is actually paying for.

Checks

rubocop (1742 files), tsc, eslint, steiger clean. Frontend 1693/1693.
Backend: the touched suites 236/236, run with DEPLOYMENT_MODE=self_hosted to
match CI. The full suite is left to CI, since a worktree run shares a Postgres
with the main checkout.

🤖 Generated with Claude Code

artempartos and others added 5 commits September 29, 2026 01:18
A company that signs itself up starts on TRIAL_QUEUE_HOURS of capacity, one
session at a time, and stops when it runs out. Hosted deployments only: a
self-hosted operator pays nobody, and a Marketplace customer bought their
capacity from AWS before they ever reached us.

THE ALLOWANCE IS A QUANTITY AND THE CUSTOMER SETS THE RATE IT BURNS AT, which is
the whole reason for the cap. Capacity is billed by the hour it is offered, so a
trial measured in days is priced by whoever set the limit — ten queues for a
fortnight is $16,800 of free capacity, chosen by the person receiving it. Capped
at one session, a hundred hours is the same gift to everyone and lasts about four
days rather than the hour it would last at the signup form's default of four.

ONE NUMBER, TWO CONSUMERS. The drain hands out slots against Billing::EffectiveCapacity
and the meter measures the same value, so a company capped to one is metered at
one. A ceiling one of them honours and the other does not either bills for
capacity that was never available or runs capacity nobody is billed for. A
company's own limit is untouched throughout — it is the plan it asked for, and it
takes effect the moment someone pays.

THE SPEND IS A SUM, NOT A COUNTER. company_capacity_usages records what every
company was offered each hour — ours to read, where the meter reports exist to be
sent and carry the split as a jsonb blob inside an installation-wide row. What a
company has used is a query over it, so nothing can drift from what was actually
offered, and "how much has this company used" stops being a question only Stripe
can answer.

Trial hours are recorded and not invoiced: a provider is sent the billable
companies alone, while the usage log covers everyone.

Stripe is still not wired up, so "someone is paying" is a platform administrator
moving the company to `active` from the admin. Without that, blocking would be a
one-way door.

Signed-off-by: Artem Petrov <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The signup form asks for a number of sessions and the pricing page quotes what
one costs, and neither said that the first hours are free. Someone deciding
whether to sign up was being shown only the bill.

Signed-off-by: Artem Petrov <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A blocking rule nothing enforces and an enforcement nothing blocks both pass
their own tests. This is the join: a company spends the allowance, the hourly
meter notices, and the drain stops granting — including what was already queued.

Signed-off-by: Artem Petrov <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The free allowance capped a workspace to one session however high it set its
limit. That made the allowance the same gift to everyone, and it also made the
product a smaller product for the whole of the trial: the customer evaluated
something other than the thing they were being sold.

Now the limit is theirs throughout and the allowance is spent at whatever rate
they run — ten sessions at once uses ten queue-hours an hour, so the same hundred
hours that last one workspace four days last that one ten. A bigger limit buys a
shorter trial rather than a larger gift, which is a trade the person making it
can see.

Only a company that has spent the allowance is capped, and it is capped to
nothing.

The consequence, stated rather than guarded against: the overshoot is now bounded
only by the metering interval. Nothing is checked between hourly runs, so a
workspace that sets a very high limit can spend past the allowance before the
next run stops it. Capping what a trialing workspace may SET is the lever if that
ever matters, and it is deliberately not pulled.

Signed-off-by: Artem Petrov <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A workspace on free capacity could only find out from the company settings
screen, which its admin has no reason to open and its members cannot. Everyone
else met the end of the allowance as sessions that silently never started.

The banner sits above the content on every signed-in page and carries both
numbers: what has been spent of the allowance, and — because the allowance is a
quantity and the workspace sets the rate — how long what is left lasts at the
rate it is actually running. Forty queue-hours is four days at one session and
four hours at ten, and only the second number answers "when do I have to do
something about this".

Fed by a shared Inertia prop that is only sent while an allowance is running or
spent, so it costs a query for the workspaces it is about and nothing for anyone
else. The duplicate notice on the settings screen goes: one source, one shape.

Signed-off-by: Artem Petrov <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@artempartos
artempartos merged commit d73ed0a into develop Sep 29, 2026
7 checks passed
artempartos pushed a commit that referenced this pull request Nov 26, 2026
Share the project assets drop zone as FileDropZone and use it in the card Assets tab. Upload new and the drop zone attach several files, three POSTs at a time, with one reload at the end.

Signed-off-by: Aixle Flow <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
artempartos pushed a commit that referenced this pull request Nov 26, 2026
Share the project assets drop zone as FileDropZone and use it in the card Assets tab. Upload new and the drop zone attach several files, three POSTs at a time, with one reload at the end.

Signed-off-by: Aixle Flow <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
artempartos added a commit that referenced this pull request Nov 26, 2026
* feat(tasks): bulk upload of card assets (#350)

Share the project assets drop zone as FileDropZone and use it in the card Assets tab. Upload new and the drop zone attach several files, three POSTs at a time, with one reload at the end.

Signed-off-by: Aixle Flow <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* fix(tasks): name the files a card upload refused

Each refused file raised the server's toast on its own ("File is too large"),
so in a batch nobody could tell which file it was about. The upload now
collects the refusals and shows one toast that names each file with its
reason, under "N of M files failed to upload" when several were sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

---------

Signed-off-by: Aixle Flow <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Co-authored-by: Aixle Flow <[email protected]>
Co-authored-by: Artem Petrov <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant