feat(billing): wire pack consolidation passes end-to-end
billing-constants.mjs: - PACK_CONSOLIDATIONS: { small: 50, medium: 150, large: 350 } - addonConsolidationsFromPackPriceId() resolves pack price → pass count
billing-logic.mjs: - pack_consolidation_passes_balance field in normalizeBillingUser + defaultUserRecord
billing-stripe.mjs: - On checkout.session.completed (payment mode), credit pack_consolidation_passes_balance atomically alongside pack_indexing_tokens_balance. - Also reads session.metadata.consolidation_passes for manual overrides.
billing-http.mjs: - pack_consolidation_passes_balance exposed in GET /api/v1/billing/summary.
billing-middleware.mjs: - Full consolidation quota enforcement when BILLING_ENFORCE=true: 1. Free tier → CONSOLIDATION_NOT_AVAILABLE (unchanged) 2. Paid tier within monthly cap → allowed 3. Monthly cap exceeded + pack passes available → deduct one pack pass + allow 4. Monthly cap exceeded + pack empty → roll back counter, 402 CONSOLIDATION_QUOTA_EXHAUSTED
hub.js: - Pack balance line now shows: "80M rollover tokens (≈ 1,600 index jobs or 80,000 searches) + 150 consolidation passes" - Pack row is shown whenever either token balance OR consolidation passes > 0.
test/billing-consolidation.test.mjs: - 16 new tests covering PACK_CONSOLIDATIONS values, addonConsolidationsFromPackPriceId, normalizeBillingUser field, defaultUserRecord field, and the full enforcement gate simulation (within cap, pack draw, pack empty, unlimited tier, multi-overage).
0 comments
muse hub commit comment sha256:feb68795e39b19fc64c3618cdd6225f8872ce3b5ba970d191a5ac13c0597a6de --body "your comment"
No comments yet. Be the first to start the discussion.