You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Never-expiring grants (null expires_at) | Always active |
349
+
| Multiple grant types aggregation | Correct breakdown by type |
350
+
| Skips organization grants for personal context | isPersonalContext flag works |
351
+
| Uses shared grant ordering | GRANT_ORDER_BY constant verified |
352
+
353
+
**Review Findings (from 4 CLI agents):**
354
+
- ✅ Financial calculations verified EXACTLY equivalent to original implementations
355
+
- ✅ Debt settlement math correct (settlementAmount = Math.min(debt, positive))
356
+
- ✅ isPersonalContext flag correctly skips organization grants
357
+
- ✅ Backwards compatibility maintained via re-exports
358
+
- ✅ Type safety preserved
359
+
- ⚠️ Pre-existing issue: balance.breakdown not adjusted after settlement (NOT introduced by this change)
360
+
- ⚠️ Pre-existing issue: mid-cycle expired grants not counted (NOT introduced by this change)
361
+
362
+
**Test Results:**
363
+
- 62 billing tests pass (up from 53)
364
+
- 146 expect() calls (up from 102)
365
+
- TypeScript compiles cleanly
366
+
367
+
**Pre-existing Issue Fixes:**
368
+
369
+
During Commit 2.4 review, two pre-existing issues were identified and fixed:
370
+
371
+
| Issue | Problem | Solution |
372
+
|-------|---------|----------|
373
+
|**breakdown not adjusted after settlement**| After debt settlement, `sum(breakdown) ≠ totalRemaining` because breakdown wasn't reduced | Documented the semantics: breakdown shows pre-settlement database values, totalRemaining is post-settlement effective balance. Added JSDoc to `CreditBalance` interface. |
374
+
|**Mid-cycle expired grants not counted**| Query used `gt(expires_at, now)`, excluding grants that expired after quota reset but before now | Added `includeExpiredSince?: Date` parameter to `getOrderedActiveGrantsForOwner()`. Callers pass `quotaResetDate` to include mid-cycle expired grants. |
375
+
376
+
**Additional Fixes Applied:**
377
+
| Fix | Description |
378
+
|-----|-------------|
379
+
| Edge case: `>` to `>=`| Changed `gt()` to `gte()` in grant expiration query to include grants expiring exactly at threshold |
380
+
| Edge case: usage calculation | Changed `grant.expires_at > quotaResetDate` to `>=` for boundary condition |
0 commit comments