A subscription's next reconcile confers its tier again over the operator's grant that replaced it, and ends the grant #212

Closed
opened 2026-10-09 16:08:24 +00:00 by cgalo5758 · 2 comments
Owner

What happens

An operator can issue a grant to an organization whose tier on a ladder is paid for by a subscription. (A ladder is a sequence of tiers such as Plus, Pro and Max. An organization holds one tier on each ladder at a time, from a subscription or from a grant.) The grant's conferral, core.confer, ends the subscription's provision, and the grant takes the ladder. The issue form says the subscription keeps billing until it is changed in the billing view.

The subscription's next reconcile undoes this. reconcileItems compares the products on the Stripe subscription with the subscription's provisions that have not ended. The grant ended the subscription's provision, so its product reads as missing, and the reconcile calls core.confer for it. That conferral ends the grant's provision and puts the subscription's tier back on the ladder. Nothing asks whether another source took the ladder from the subscription.

Any reconcile of an active subscription does this: the customer.subscription.updated event at each renewal or after any other edit, the invoice reconcile, and the sweep's reconcile of a period-end downgrade. A subscription that was past due when the grant was issued does the same when it recovers. SyncSourceStatus resumes nothing, as it should, and the item pass that follows confers the tier again. The test for that case calls SyncSourceStatus directly, so it never runs the item pass.

A grant that is not marked to resume stays recorded as active and never delivers again, even after the subscription ends. A grant marked to resume is recorded as replaced by the subscription, so it comes back only when the subscription is canceled.

#202 is a race in the member's plan change whose last step is this same reconcile. Closing that race leaves this case open.

What should happen

A grant that replaced a subscription's tier keeps the ladder until it ends or is revoked, and the subscription keeps billing, as the issue form says. The subscription management spec says the same for the past-due case: the subscription does not regain the superseded position. A reconcile leaves a ladder alone when another source ended the subscription's provision on it.

Where

internal/fulfillment/reconcile.go: reconcileItems, which lists the subscription's provisions through GetLivePoolProvisionsBySubscriptionID and calls Confer for every product with none. core.confer is in internal/db/migrations/00023_grant_resumption.sql.

Steps

  1. An organization pays for Plus through a subscription.
  2. An operator issues a Max grant to the organization. Max replaces Plus on the ladder.
  3. The subscription renews, and its customer.subscription.updated event is reconciled. Its items have not changed.
  4. Tier changes shows Max ended and a downgrade to Plus by the webhook. The organization is back on Plus, and the Max grant delivers nothing.

A grant of the subscription's own tier ends the same way.

Why it matters

An operator's grant over a paid tier lasts only until the subscription's next event, usually within one billing period, and a grant that is not marked to resume is lost without anyone revoking it.

## What happens An operator can issue a grant to an organization whose tier on a ladder is paid for by a subscription. (A ladder is a sequence of tiers such as Plus, Pro and Max. An organization holds one tier on each ladder at a time, from a subscription or from a grant.) The grant's conferral, `core.confer`, ends the subscription's provision, and the grant takes the ladder. The issue form says the subscription keeps billing until it is changed in the billing view. The subscription's next reconcile undoes this. `reconcileItems` compares the products on the Stripe subscription with the subscription's provisions that have not ended. The grant ended the subscription's provision, so its product reads as missing, and the reconcile calls `core.confer` for it. That conferral ends the grant's provision and puts the subscription's tier back on the ladder. Nothing asks whether another source took the ladder from the subscription. Any reconcile of an active subscription does this: the `customer.subscription.updated` event at each renewal or after any other edit, the invoice reconcile, and the sweep's reconcile of a period-end downgrade. A subscription that was past due when the grant was issued does the same when it recovers. `SyncSourceStatus` resumes nothing, as it should, and the item pass that follows confers the tier again. The test for that case calls `SyncSourceStatus` directly, so it never runs the item pass. A grant that is not marked to resume stays recorded as active and never delivers again, even after the subscription ends. A grant marked to resume is recorded as replaced by the subscription, so it comes back only when the subscription is canceled. #202 is a race in the member's plan change whose last step is this same reconcile. Closing that race leaves this case open. ## What should happen A grant that replaced a subscription's tier keeps the ladder until it ends or is revoked, and the subscription keeps billing, as the issue form says. The subscription management spec says the same for the past-due case: the subscription does not regain the superseded position. A reconcile leaves a ladder alone when another source ended the subscription's provision on it. ## Where `internal/fulfillment/reconcile.go`: `reconcileItems`, which lists the subscription's provisions through `GetLivePoolProvisionsBySubscriptionID` and calls `Confer` for every product with none. `core.confer` is in `internal/db/migrations/00023_grant_resumption.sql`. ## Steps 1. An organization pays for Plus through a subscription. 2. An operator issues a Max grant to the organization. Max replaces Plus on the ladder. 3. The subscription renews, and its `customer.subscription.updated` event is reconciled. Its items have not changed. 4. Tier changes shows Max ended and a downgrade to Plus by the webhook. The organization is back on Plus, and the Max grant delivers nothing. A grant of the subscription's own tier ends the same way. ## Why it matters An operator's grant over a paid tier lasts only until the subscription's next event, usually within one billing period, and a grant that is not marked to resume is lost without anyone revoking it.
cgalo5758 added the
kind
bug
area/entitlementsarea/billing
labels 2026-10-09 16:08:24 +00:00
Author
Owner

The same re-conferral happens when the subscription's provision was ended by the subscription itself. A subscription can carry two items whose products are two tiers of one ladder. The console never creates one, but an edit at Stripe can, as #200 describes.

convergeConferrals (internal/fulfillment/reconcile.go:638-668, called from reconcileItems) reads the subscription's live provisions once, then confers each desired product that has none. core.confer ends every provision on a ladder the new product sits on, the subscription's own provision of the other tier included. So:

  • On the first reconcile neither tier is live. Both are conferred, and the second conferral ends the first. Which tier wins depends on the order Go iterates the desired map (line 658), which can differ from run to run.
  • On every later reconcile of the active subscription, the tier that lost reads as missing and is conferred again, which ends the other. The organization's tier on that ladder alternates, each switch writes tier-change rows, and the pool's entitlements move between the two tiers' limits.

I have read this, not run it. A fix that leaves a ladder alone only when a different source ended the subscription's provision does not cover this case. The reconcile needs a rule for a subscription that pays for two tiers of one ladder, for example conferring only the higher-ranked tier and logging the other, and it should walk desired in a fixed order either way.

The same re-conferral happens when the subscription's provision was ended by the subscription itself. A subscription can carry two items whose products are two tiers of one ladder. The console never creates one, but an edit at Stripe can, as #200 describes. `convergeConferrals` (`internal/fulfillment/reconcile.go:638-668`, called from `reconcileItems`) reads the subscription's live provisions once, then confers each desired product that has none. `core.confer` ends every provision on a ladder the new product sits on, the subscription's own provision of the other tier included. So: - On the first reconcile neither tier is live. Both are conferred, and the second conferral ends the first. Which tier wins depends on the order Go iterates the `desired` map (line 658), which can differ from run to run. - On every later reconcile of the active subscription, the tier that lost reads as missing and is conferred again, which ends the other. The organization's tier on that ladder alternates, each switch writes tier-change rows, and the pool's entitlements move between the two tiers' limits. I have read this, not run it. A fix that leaves a ladder alone only when a different source ended the subscription's provision does not cover this case. The reconcile needs a rule for a subscription that pays for two tiers of one ladder, for example conferring only the higher-ranked tier and logging the other, and it should walk `desired` in a fixed order either way.
cgalo5758 added this to the Public launch milestone 2026-10-20 23:14:01 +00:00
Author
Owner

A grant that replaced a subscription's tier now keeps the ladder until it ends or is revoked. (A ladder is a sequence of tiers such as Plus, Pro and Max; an organization holds one tier on each ladder at a time, from a subscription or from a grant.)

The subscription reconcile now checks, for each product the subscription pays for, whether another plan took one of that product's ladders from the subscription and still holds it. It reads this from the tier-change history: the subscription's last position on the ladder ended in a supersession, and the plan that took it is not the subscription. While a plan other than the organization type's default holds that ladder, the reconcile confers nothing there and logs it. The subscription keeps billing, as the issue form says, and nothing is sent to Stripe. Once the grant ends and only the default holds the ladder, or nothing does, the subscription's next reconcile puts its tier back.

This holds on every path that reconciles a subscription: renewals and other edits, the checkout return, the invoice reconcile, the sweeper's runs, and a member's move on another ladder of the same subscription. A subscription that recovers from past due goes through the same check, so the recovery no longer takes the ladder back. A downgrade that lands while a grant holds the ladder is recorded as applied, and its tier is not conferred. A new purchase over a grant still replaces the grant.

The case in the comment above is fixed as well: a subscription that carries two tiers of one ladder gets the higher-ranked one, and the other is logged as a warning, so the tier no longer alternates. The reconcile now confers in a fixed order, by product id. Two subscriptions of one organization on one ladder no longer alternate either: the later one keeps the ladder.

On the organization page, the Billing card's Subscriptions row now shows a "Not delivering" badge beside the subscription's state when a subscription keeps billing while another plan holds one of its ladders. The text shown on the badge when the pointer rests on it names the ladder and what holds it (a grant, another subscription, or another plan), for example "Billing continues while a grant holds Hosting." The subscription's row in the operator's subscriptions list carries the same badge, and the list and the card apply the same check. The Issue grant form's warning now says that the subscription keeps billing and delivers nothing on that ladder until the grant ends, instead of pointing at the billing views, which cannot change a subscription.

Not changed here: the subscription keeps billing while the grant holds the ladder, and the member's Products page says nothing new about it; pausing its collection, and what the member then sees, is #269. A subscription delivers again at its next reconcile after the grant ends, not at the moment the grant ends (#270).

Commits: 16cc1de6 (the reconcile takes the pool row first in every branch, #193), bb90c5fa, 1b1ab1d8, 8181d546, 76ff9d69, e3f3ec56, 04862abe, 335aa857, 2f1803d1.

A grant that replaced a subscription's tier now keeps the ladder until it ends or is revoked. (A ladder is a sequence of tiers such as Plus, Pro and Max; an organization holds one tier on each ladder at a time, from a subscription or from a grant.) The subscription reconcile now checks, for each product the subscription pays for, whether another plan took one of that product's ladders from the subscription and still holds it. It reads this from the tier-change history: the subscription's last position on the ladder ended in a supersession, and the plan that took it is not the subscription. While a plan other than the organization type's default holds that ladder, the reconcile confers nothing there and logs it. The subscription keeps billing, as the issue form says, and nothing is sent to Stripe. Once the grant ends and only the default holds the ladder, or nothing does, the subscription's next reconcile puts its tier back. This holds on every path that reconciles a subscription: renewals and other edits, the checkout return, the invoice reconcile, the sweeper's runs, and a member's move on another ladder of the same subscription. A subscription that recovers from past due goes through the same check, so the recovery no longer takes the ladder back. A downgrade that lands while a grant holds the ladder is recorded as applied, and its tier is not conferred. A new purchase over a grant still replaces the grant. The case in the comment above is fixed as well: a subscription that carries two tiers of one ladder gets the higher-ranked one, and the other is logged as a warning, so the tier no longer alternates. The reconcile now confers in a fixed order, by product id. Two subscriptions of one organization on one ladder no longer alternate either: the later one keeps the ladder. On the organization page, the Billing card's Subscriptions row now shows a "Not delivering" badge beside the subscription's state when a subscription keeps billing while another plan holds one of its ladders. The text shown on the badge when the pointer rests on it names the ladder and what holds it (a grant, another subscription, or another plan), for example "Billing continues while a grant holds Hosting." The subscription's row in the operator's subscriptions list carries the same badge, and the list and the card apply the same check. The Issue grant form's warning now says that the subscription keeps billing and delivers nothing on that ladder until the grant ends, instead of pointing at the billing views, which cannot change a subscription. Not changed here: the subscription keeps billing while the grant holds the ladder, and the member's Products page says nothing new about it; pausing its collection, and what the member then sees, is #269. A subscription delivers again at its next reconcile after the grant ends, not at the moment the grant ends (#270). Commits: 16cc1de6 (the reconcile takes the pool row first in every branch, #193), bb90c5fa, 1b1ab1d8, 8181d546, 76ff9d69, e3f3ec56, 04862abe, 335aa857, 2f1803d1.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wiki-cafe/member-console#212