Skip to content

Calculate AI credit quotas as base × quantity - #520

Draft
mitchelljkotler wants to merge 1 commit into
masterfrom
credits-base-times-quantity
Draft

mitchelljkotler wants to merge 1 commit into
masterfrom
credits-base-times-quantity

Conversation

@mitchelljkotler

Copy link
Copy Markdown
Member

Calculates an organization's AI credit quota as base × quantity, the formula Squarelet's release 6 prepares for.

Do not merge until Squarelet's migrate_entitlement_shape has run on production (release 6, MuckRock/squarelet#805). Before it, a DocumentCloud credit pack's entitlement still holds its value in ai_credits_per_user with base_ai_credits 0, so this formula would grant pack holders nothing. After it, both formulas give the same number for every entitlement and quantity.

Fixes #491. Part of MuckRock/squarelet#769.

Behaviour changes

  • _calc_ent_ai_credits returns base_ai_credits × quantity. It no longer reads ai_credits_per_user or minimum_users. After release 6, every Squarelet entitlement has minimum_users: 1 and per_user = base (packs: base = per-unit value), which makes the two formulas identical. A plan is quantity 1; extra credits are a pack line, whose quantity is how many packs it holds.
  • No quota changes, once release 6 has run.
  • Tests: the factories take release 6's shape, and a credit pack factory is added. The old seat-quantity tests become pack quantities with the same numbers. The two "minimum users" tests become one "base × quantity" test and one pack-quantity test.

Migrations

None.

What to check

  • Release 6's migrate_entitlement_shape has run on production.
  • Squarelet has sent fresh entitlements (cache invalidation after release 6), so DocumentCloud isn't reading the old shape from cache.
  • After deploy: an Organization with credit packs shows the same ai_credits_per_month as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_0151rwxtvLg1vKEiz7XsJfzf

Squarelet's release 6 reshapes every entitlement so base x quantity
grants what base + extra users x per user did: a plan is quantity 1,
and extra credits are a pack line whose quantity is how many it holds.
The factories take that shape and the seat tests become pack
quantities, with the same numbers.

Deploy only after Squarelet's migrate_entitlement_shape has run on
production; before it, a credit pack grants nothing under this formula.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0151rwxtvLg1vKEiz7XsJfzf

This branch has not been deployed

No deployments
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.

Calculate quotas as base × quantity

1 participant