fix(cost-insights): decouple usage rollups and gate plan suggestions#4588
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummarySince the last review, this branch was rebased onto a newer Files Reviewed (15 files)
Generated migration snapshot/journal files were excluded per review scope. Previous Review Summary (commit c4b3d25)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit c4b3d25)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the decoupling of daily usage rollups into a durable, claim-fenced async repair pipeline and the restriction of Coding Plan suggestions to eligible personal usage; the transaction-local idle timeout placement, claim/fencing/advisory-lock logic, UTC day bucketing, and eligibility gating all check out against the changed code with high confidence. Files Reviewed (15 files)
Generated migration snapshot/journal files were excluded per review scope. Reviewed by claude-sonnet-5 · Input: 48 · Output: 14K · Cached: 1.2M Review guidance: REVIEW.md from base branch |
c4b3d25 to
17ec279
Compare
17ec279 to
b1e104b
Compare
Summary
Make AI usage accounting resilient under contention and restrict Coding Plan suggestions to eligible personal usage.
Why this change is needed
Synchronous updates to hot
microdollar_usage_dailyrows caused usage transactions to wait on the same index tuple, exhaust the primary database pool, and fail unrelated routes. One pathological usage transaction also remained idle while holding locks for roughly 80 minutes.Coding Plan suggestions could also be generated for organization owners and unsupported provider/model combinations.
How this is addressed
Human Verification
microdollar_usage_dailyand applies the idle timeout before lock acquisition or usage writes.Reviewer Notes
Human Reviewer Flags
Code Reviewer Agent
Code Reviewer Notes