Skip to content

feat(billing): add usage summary reporting - #4839

Merged
pandemicsyn merged 10 commits into
mainfrom
spangle-class
Jul 28, 2026
Merged

feat(billing): add usage summary reporting#4839
pandemicsyn merged 10 commits into
mainfrom
spangle-class

Conversation

@pandemicsyn

@pandemicsyn pandemicsyn commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an admin-only Usage Summary for an exact user or organization over a bounded, half-open [start, end) window.
  • Aggregate accepted container seconds from metering segments, group results by immutable billing SKU, and calculate exact shadow estimated cents with PostgreSQL numeric arithmetic without debiting credits.
  • Scope the interval list and summary to the same subject and window, with client/server validation, precise report context, and accessible loading and result states.
  • Add structured, sanitized meter RPC and reconciliation outcome logs so the shadow-metering Axiom dashboard can track accepted, rejected, failed, deduplicated, and reconciled activity.

Verification

Visual Changes

SCR-20260728-meop

Reviewer Notes

  • Review the segment-time [start, end) boundary and PostgreSQL numeric estimate calculation closely; these define the shadow billing report.
  • Meter logs intentionally exclude subject IDs, instance IDs, metadata, and error messages. Existing producer logs remain the source for Cloud Agent delivery/retry failures.

Comment thread apps/web/src/routers/admin/cloud-billing-skus-router.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental change adds the previously-missing replaceCloseReasonParam(next.closeReason) call to the search form's submit handler, syncing the closeReason URL param to the applied filter on submit (not the draft dropdown value), which resolves the prior warning about lost deep-linking/bookmarking support.

Files Reviewed (1 file)
  • apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx
Previous Review Summaries (8 snapshots, latest commit e8fa105)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit e8fa105)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change is a pure layout rework of the search/filter row (alignment, spacer label) with no logic changes, so the Status/Close-reason onValueChange handlers still never call replaceCloseReasonParam, leaving the closeReason URL param out of sync with the selected filter.

Overview

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

WARNING

File Line Issue
apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx 458 Status and Close reason onValueChange handlers still don't call replaceCloseReasonParam, so the URL still doesn't reflect the selected close-reason filter (already tracked inline)
Files Reviewed (1 file)
  • apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx - 1 issue

Fix these issues in Kilo Cloud

Previous review (commit 182945e)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change reworks the usage search form into a two-row layout (primary search bar + wrapping filter row) but still never re-adds the replaceCloseReasonParam call to the Status/Close-reason onValueChange handlers, so the closeReason URL param still doesn't stay in sync with the selected filter.

Overview

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

WARNING

File Line Issue
apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx 449 Status and Close reason onValueChange handlers still don't call replaceCloseReasonParam, so the URL still doesn't reflect the selected close-reason filter
Files Reviewed (1 file)
  • apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx - 1 issue

Fix these issues in Kilo Cloud

Previous review (commit f34d814)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change reflows the usage search form into a 5-column grid and merges the Reset/Search action button block into the user/org and interval branches, but drops the replaceCloseReasonParam calls that kept the closeReason filter synced to the URL for deep-linking/bookmarking.

Overview

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

WARNING

File Line Issue
apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx 425 Status and Close reason onValueChange handlers no longer call replaceCloseReasonParam, so the URL no longer reflects the selected close-reason filter
Files Reviewed (1 file)
  • apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx - 1 issue

Fix these issues in Kilo Cloud

Previous review (commit b9d3b4a)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental change further reflows the usage search form grid (5-column layout with explicit col-start/row-start placement, full-width Reset/Search buttons) in UsageRecordsContent.tsx; no functional defects found in changed lines.

Files Reviewed (1 file)
  • apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx

Previous review (commit 7b1e007)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental change reorganizes the search form layout (grid columns, moved usage-window field, new Reset button) in UsageRecordsContent.tsx with no functional defects found in changed lines.

Files Reviewed (1 file)
  • apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx

Previous review (commit 2e3d6f3)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental change only adds test fixture data (segment inserts) to an existing test file to support prior assertions; no production code changed and no new issues found.

Files Reviewed (1 file)
  • apps/web/src/routers/admin/cloud-billing-skus-router.test.ts

Previous review (commit a681e50)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The previously flagged redundant totals query in getUsageSummary was fixed by using a PostgreSQL window aggregate (sum(sum(...)) over ()) within the existing grouped query; no new issues found in the incremental change.

Files Reviewed (1 file)
  • apps/web/src/routers/admin/cloud-billing-skus-router.ts

Previous review (commit 9d68f2c)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The new getUsageSummary router endpoint issues a redundant duplicate database query to compute totals that could be derived from its already-fetched per-SKU rows.

Overview

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

SUGGESTION

File Line Issue
apps/web/src/routers/admin/cloud-billing-skus-router.ts 366 Redundant second full join/query to compute totals that duplicate the already-grouped items query
Files Reviewed (7 files)
  • apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx
  • apps/web/src/routers/admin/cloud-billing-skus-router.test.ts
  • apps/web/src/routers/admin/cloud-billing-skus-router.ts - 1 issue
  • services/container-usage-meter/src/meter.test.ts
  • services/container-usage-meter/src/meter.ts
  • services/container-usage-meter/src/reconciliation.test.ts
  • services/container-usage-meter/src/reconciliation.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 20 · Output: 4.2K · Cached: 405K

Review guidance: REVIEW.md from base branch main

Comment thread apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx Outdated
Comment thread apps/web/src/app/admin/cloud-billing-skus/UsageRecordsContent.tsx
@pandemicsyn
pandemicsyn merged commit 28e45f4 into main Jul 28, 2026
20 checks passed
@pandemicsyn
pandemicsyn deleted the spangle-class branch July 28, 2026 19:10
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