feat minor billing feat/phase-2g-bundle
AI Agent git-import/068377df · 111 days ago · Apr 6, 2026 · Diff

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).

sha256:feb68795e39b19fc64c3618cdd6225f8872ce3b5ba970d191a5ac13c0597a6de sha
sha256:bbc34c63e1172287b86f6c5052c19310037ab9c104695994b0d2ab634e40e447 snapshot
← Older Oldest on feat/phase-2g-bundle
All commits
Newer → Latest on feat/phase-2g-bundle

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:feb68795e39b19fc64c3618cdd6225f8872ce3b5ba970d191a5ac13c0597a6de --body "your comment"