Skip to content

Revert "Revert "fix(cost-insights): decouple usage rollups and gate plan suggestions""#4596

Merged
jeanduplessis merged 1 commit into
mainfrom
revert-4594-revert-4588-fix/usage-rollup-contention
Jul 16, 2026
Merged

Revert "Revert "fix(cost-insights): decouple usage rollups and gate plan suggestions""#4596
jeanduplessis merged 1 commit into
mainfrom
revert-4594-revert-4588-fix/usage-rollup-contention

Conversation

@jeanduplessis

Copy link
Copy Markdown
Contributor

Reverts #4594

@jeanduplessis jeanduplessis merged commit 7d2104c into main Jul 16, 2026
10 checks passed
@jeanduplessis jeanduplessis deleted the revert-4594-revert-4588-fix/usage-rollup-contention branch July 16, 2026 15:47
if (await repairClaimedDailyUsageRollup(database, row)) {
summary.repaired += 1;
} else {
await failDailyUsageRollupRepair(database, row, 'daily_usage_rollup_repair_deferred');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Deferred repairs are not counted in the summary

When repairClaimedDailyUsageRollup returns false (claim lost / advisory lock contended), the row is requeued via failDailyUsageRollupRepair, but it is not added to summary.failed. Callers that assume claimed === repaired + failed.length will silently undercount outstanding/backlogged repairs (e.g. { claimed: 5, repaired: 3, failed: [] } while 2 rows were actually deferred). Consider recording deferred rows in the summary as well so monitoring/alerting reflects the true outstanding backlog.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/usage-daily-rollup-repairs.ts 313 Deferred repairs (claim lost / lock contended) are not recorded in summary.failed, causing claimed to not equal repaired + failed.length and undercounting the outstanding repair backlog
Files Reviewed (15 files)
  • apps/web/src/app/api/cron/cost-insights-hourly/route.ts
  • apps/web/src/app/api/cron/cost-insights-hourly/route.test.ts
  • apps/web/src/lib/ai-gateway/processUsage.ts
  • apps/web/src/lib/ai-gateway/processUsage.test.ts
  • apps/web/src/lib/ai-gateway/usage-daily-rollup-repairs.ts - 1 issue
  • apps/web/src/lib/ai-gateway/usage-daily-rollup-repairs.test.ts
  • apps/web/src/lib/coding-plans/index.test.ts
  • apps/web/src/lib/coding-plans/pricing.ts
  • apps/web/src/lib/cost-insights/evaluation.ts
  • apps/web/src/lib/cost-insights/jobs.ts
  • apps/web/src/lib/cost-insights/suggestion-eligibility.ts
  • apps/web/src/lib/cost-insights/suggestion-eligibility.test.ts
  • dev/seed/cost-insights/spend-evidence.ts
  • packages/db/src/migrations/0188_unusual_titanium_man.sql
  • packages/db/src/schema.ts

(packages/db/src/migrations/meta/0188_snapshot.json and meta/_journal.json are generated files and were excluded from review.)

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 32 · Output: 11K · Cached: 730.8K

Review guidance: REVIEW.md from base branch main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants