fix(billing): make quota seed and column names match the product SSOT

The product plan is the only source for quota numbers, but the 0001 seed
used a second set (agent_chat 20/50, tryon hard 10) and omitted hairstyle,
hd_export and report regen. Migration 0003 replaces the seed and renames
points_reserved → quota_reserved and bonus_value → bonus_granted so the
docs and the schema stop contradicting each other.

Effective limit now clips at hard_cap. CI runs the integration slice
against the Postgres/Redis services it already starts.
This commit is contained in:
xsl
2026-08-14 11:28:35 +08:00
parent c97f8ae3e1
commit 2009aa938c
11 changed files with 179 additions and 16 deletions
+9
View File
@@ -109,3 +109,12 @@ def test_ledger_can_recompute_the_balance() -> None:
state = quota.refund(state, 1)
deltas.append(1)
assert state.used == -sum(deltas)
def test_hard_cap_clips_base_plus_bonus() -> None:
# 产品方案 §3.2:有效额度 = min(base + bonus, hard_cap)
state = quota.QuotaState(used=0, base_limit=10, bonus=10, hard_cap=40)
assert state.effective_limit == 20
clipped = quota.QuotaState(used=0, base_limit=10, bonus=40, hard_cap=40)
assert clipped.effective_limit == 40
assert not quota.evaluate(clipped, 41).allowed