Skip to content

fix(billing): bound the enterprise preflight's workflow run count to the preview budget - #9673

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/enterprise-preview-run-budget
Nov 4, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/enterprise-preview-run-budget

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The enterprise issuance preflight counted the organization's billable workflow runs under the ledger's default 60s bound. It is the same COUNT(DISTINCT execution_id) the organization detail page already caps at 5s, because on a large payer it can outlast the admin proxy's request timeout and fail the whole preview.
  • The preflight now reads it through getBillingPeriodWorkflowRunCountWithinBudget, which returns null past WORKFLOW_RUN_COUNT_BUDGET_MS (5s) so the preview still loads. The preview contract already declares workflowRuns nullable, and the admin UI's formatCount renders null.
  • The budget and the over-budget classification (isLedgerReadOverBudget: read deadline or statement_timeout) move next to readLedgerBounded, shared by the detail page and the preflight instead of duplicated.
  • The preview still counts billable runs only (it excludes unbilled categories, unlike the detail page's all-runs count); unchanged here.

Type of Change

  • Bug fix

Testing

  • usage-log.integration.ts: reports a workflow run count as unknown once it outlasts the preview budget counts runs normally, then returns null while usage_log is held under an exclusive lock (red without the budget: the read waits out the 20s test timeout). 23/23.
  • usage-log.test.ts, enterprise-provisioning.test.ts, lib/admin unit suites: 95/95
  • lint and type-check (pre-push hooks); remaining audits in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…the preview budget

The enterprise issuance preflight counted the organization's billable workflow runs under the
ledger's default 60s bound, the same COUNT DISTINCT the organization detail page already caps at
5s because it can outlast the admin proxy's request timeout on a large payer. The preflight now
reads it through getBillingPeriodWorkflowRunCountWithinBudget, which reports null past the shared
WORKFLOW_RUN_COUNT_BUDGET_MS, so the preview still loads; the contract already allows null. The
over-budget classification moves next to readLedgerBounded as isLedgerReadOverBudget, shared by
both callers.
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 4, 2026 10:54am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Bounds the enterprise preview’s workflow count to five seconds and returns null when it takes too long.

  • Enterprise previews stop waiting on workflow-run counts after five seconds.

Reviews (1) · Last reviewed commit: "fix(billing): bound the enterprise prefl..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit b8b7201 into staging Nov 4, 2026
80 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/enterprise-preview-run-budget branch November 4, 2026 18:13

This branch was previously deployed

1 inactive deployment
Preview — a97389d6 Deployed Nov 4, 2026 by vercel[bot]
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.

1 participant