Skip to content

feat(coding-plans): add MiniMax token tiers#4269

Open
jeanduplessis wants to merge 1 commit into
mainfrom
jdp/minimax-token-plan-tiers
Open

feat(coding-plans): add MiniMax token tiers#4269
jeanduplessis wants to merge 1 commit into
mainfrom
jdp/minimax-token-plan-tiers

Conversation

@jeanduplessis

Copy link
Copy Markdown
Contributor

Summary

  • Add MiniMax Token Plan Max and Token Plan Ultra alongside Token Plan Plus, all using provider ID minimax and catalog feature metadata.
  • Enforce the required provider-level invariant in app code and the DB: one live Coding Plan subscription per (user_id, provider_id) for active or past_due rows.
  • Update admin inventory upload to require a BYOK provider ID plus catalog plan, persist both values, and show provider/plan in inventory and revocation views.
  • Update Subscription Center and BYOK copy so users see all MiniMax token plan cards and provider-level blocking guidance.

Verification

  • Manual browser validation was not run in this session. The changed flows require a seeded local web app and Docker-backed test database, and Docker is not reachable from this environment.

Visual Changes

No screenshots captured. UI changes are limited to existing Subscription Center and admin Coding Plans surfaces:

  • Subscription Center now renders Plus, Max, and Ultra cards from the catalog feature metadata.
  • Active MiniMax Coding Plan state disables MiniMax subscribe actions with cancel-and-wait guidance.
  • Admin Coding Plans upload now has Provider and Plan selectors, and inventory/revocation tables include provider plus plan.

Reviewer Notes

Local validation guide

  1. Start local dependencies and apply migrations:

    • docker compose -f dev/docker-compose.yml ps postgres
    • If Postgres is not already running, run pnpm test:db.
    • Confirm the generated migration adds UQ_coding_plan_sub_live_user_provider on (user_id, provider_id) for active and past_due.
  2. Run the targeted automated checks:

    • pnpm --filter web test -- apps/web/src/lib/coding-plans/index.test.ts apps/web/src/routers/coding-plans-router.test.ts apps/web/src/lib/coding-plans/billing-lifecycle-cron.test.ts apps/web/src/components/subscriptions/helpers.test.ts apps/web/src/routers/byok-router.test.ts packages/db/src/schema.test.ts
    • pnpm --filter @kilocode/db typecheck
    • pnpm --filter web typecheck
    • scripts/typecheck-all.sh --changes-only
    • pnpm format
  3. Validate catalog and pricing behavior:

    • Confirm the catalog returns minimax-token-plan-plus, minimax-token-plan-max, and minimax-token-plan-ultra.
    • Confirm all three plans have providerId: "minimax".
    • Confirm prices render as $20 /month, $50 /month, and $120 /month.
    • Confirm feature bullets include the correct token and agent copy: ~1.7B and 3-4, ~5.1B and 4-5, ~12.5B and 6-7.
  4. Validate purchase and exclusivity behavior:

    • Seed available inventory for at least two MiniMax plans.
    • Subscribe to Plus, then attempt Max or Ultra with a different idempotency key.
    • Confirm the second purchase is rejected before another charge or inventory assignment.
    • Mark the first subscription canceled or terminate it in the test DB, then confirm a fresh Max or Ultra subscription can be created.
    • Exercise concurrent cross-plan subscribe requests and confirm only one live MiniMax subscription persists.
  5. Validate BYOK blocking behavior:

    • Create or seed a personal MiniMax BYOK key, including a disabled key.
    • Attempt to subscribe to a MiniMax Coding Plan.
    • Confirm the flow blocks before charge/inventory assignment and the copy points the user to delete the existing MiniMax BYOK key first.
  6. Validate Admin UI upload behavior:

    • Start the local app with the normal dev workflow, for example pnpm dev:start.
    • Visit /admin/coding-plans as an admin.
    • Confirm Provider defaults to minimax and Plan offers Plus, Max, and Ultra filtered by provider.
    • Upload entries as <api key>::<upstream plan id>.
    • Confirm provider/plan mismatches are rejected by the API.
    • Confirm inventory counts show provider, plan, status, and count.
    • Confirm revocation queue rows show inventory ID, provider, Kilo plan ID, and upstream plan ID.
  7. Validate user UI behavior:

    • Visit /subscriptions#coding-plans.
    • Confirm all MiniMax token plan cards render even when the user has a live MiniMax Coding Plan.
    • Confirm subscribe actions for MiniMax plans are disabled while any live MiniMax Coding Plan exists, including pending cancellation.
    • Confirm the disabled-state copy says the user must cancel the current plan and wait until access ends before subscribing to another MiniMax Coding Plan.
    • Confirm sold-out plans still show the availability notification path and saved notification state.
  8. Validate renewal billing:

    • Force a Max subscription due for renewal and run the billing lifecycle cron path.
    • Confirm renewal charge snapshots 50_000_000 microdollars and description Coding plan renewal: MiniMax Token Plan Max.
    • Repeat equivalent initial purchase assertions for Ultra with 120_000_000 microdollars.

Checks run in this session

  • pnpm format
  • pnpm --filter web test -- apps/web/src/components/subscriptions/helpers.test.ts apps/web/src/lib/coding-plans/inventory-validation.test.ts --runInBand
  • pnpm --filter @kilocode/db typecheck
  • pnpm --filter web typecheck
  • scripts/typecheck-all.sh --changes-only
  • git diff --check

Not run here

  • The DB-backed Jest target from the plan was not run because Docker was unavailable in this environment. Both docker compose -f dev/docker-compose.yml ps postgres and pnpm test:db failed to connect to the Docker socket.
  • Manual browser validation was not run for the same reason; the local seeded DB was unavailable.

Implementation notes

  • provider_id is the exclusivity key; this branch does not add exclusive_group_id.
  • The older live (user_id, plan_id) partial unique index remains because Drizzle generated only the new provider-level index.
  • MiniMax plan changes remain cancel-and-resubscribe only. There is no mid-period upgrade or downgrade flow.
  • Token and agent counts are catalog/UI copy only. This branch does not add Kilo-side MiniMax token metering.
  • .plans/minimax-token-plan-tiers.md is saved locally as requested, but .plans/* is ignored by the repo and was not force-added.

@@ -0,0 +1 @@
CREATE UNIQUE INDEX "UQ_coding_plan_sub_live_user_provider" ON "coding_plan_subscriptions" USING btree ("user_id","provider_id") WHERE "coding_plan_subscriptions"."status" IN ('active', 'past_due'); No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Unique index migration will block writes on a populated table

CREATE UNIQUE INDEX takes a table lock that blocks writes while the index is built. Because coding_plan_subscriptions can already contain production rows, this migration should use a concurrent index build (and the matching non-transactional migration pattern) before it ships.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.


const entries = rawEntries.map(parseInventoryCredentialEntry);
const validateCredential = options.validateCredential ?? validateTokenPlanPlusCredential;
const validateCredential = options.validateCredential ?? validateMiniMaxCodingPlanCredential;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Tier validation is still provider-only

This new multi-tier upload path never passes the selected planId or upstreamPlanId into validation, so any working MiniMax key can be stored under Plus, Max, or Ultra. A mislabeled upload would then sell the wrong tier and assign the wrong upstream entitlement to subscribers. Please make the validator prove compatibility with the selected plan before the row becomes available.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/db/src/migrations/0173_common_switch.sql 1 Unique index migration is not concurrent and will block writes on a populated table.
apps/web/src/lib/coding-plans/index.ts 399 Inventory validation never verifies that a MiniMax credential matches the selected plan tier.
Files Reviewed (23 files)
  • .specs/coding-plans.md - 0 issues
  • .specs/subscription-center.md - 0 issues
  • apps/web/src/app/admin/coding-plans/CodingPlansOperationsContent.tsx - 0 issues
  • apps/web/src/components/organizations/byok/BYOKKeysManager.tsx - 0 issues
  • apps/web/src/components/subscriptions/coding-plans/CodingPlanDetail.tsx - 0 issues
  • apps/web/src/components/subscriptions/coding-plans/CodingPlansGroup.tsx - 0 issues
  • apps/web/src/components/subscriptions/helpers.test.ts - 0 issues
  • apps/web/src/components/subscriptions/helpers.ts - 0 issues
  • apps/web/src/lib/ai-gateway/byok/coding-plan-entitlement.test.ts - 0 issues
  • apps/web/src/lib/coding-plans/billing-lifecycle-cron.test.ts - 0 issues
  • apps/web/src/lib/coding-plans/index.test.ts - 0 issues
  • apps/web/src/lib/coding-plans/index.ts - 1 issue
  • apps/web/src/lib/coding-plans/inventory-validation.test.ts - 0 issues
  • apps/web/src/lib/coding-plans/inventory-validation.ts - 0 issues
  • apps/web/src/lib/coding-plans/pricing.ts - 0 issues
  • apps/web/src/routers/byok-router.test.ts - 0 issues
  • apps/web/src/routers/coding-plans-router.test.ts - 0 issues
  • apps/web/src/routers/coding-plans-router.ts - 0 issues
  • packages/db/src/migrations/0173_common_switch.sql - 1 issue
  • packages/db/src/migrations/meta/0173_snapshot.json - 0 issues
  • packages/db/src/migrations/meta/_journal.json - 0 issues
  • packages/db/src/schema.test.ts - 0 issues
  • packages/db/src/schema.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by gpt-5.4-20260305 · Input: 202.5K · Output: 23.7K · Cached: 2.1M

Review guidance: REVIEW.md from base branch main

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