Skip to content

fix: reconcile usage allowance subscriptions#20684

Merged
hulh122 merged 4 commits into
mainfrom
feat/usage-allowance
Jul 9, 2026
Merged

fix: reconcile usage allowance subscriptions#20684
hulh122 merged 4 commits into
mainfrom
feat/usage-allowance

Conversation

@hulh122

@hulh122 hulh122 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Stripe-backed usage allowance subscription fields and webhook handling
  • refresh expired usage allowance entitlements from Stripe on request and cron paths
  • keep allowance subscription cancellation/payment-failure behavior aligned with pro/team handling

Tests

  • pnpm -F api check-types
  • pnpm -F @vm0/db check-types
  • pnpm -F @vm0/api-contracts check-types

Comment thread turbo/apps/api/src/signals/services/webhooks-stripe.service.ts Fixed
@hulh122 hulh122 force-pushed the feat/usage-allowance branch 2 times, most recently from 8631b9f to 3cae5da Compare July 8, 2026 12:01
@github-actions github-actions Bot temporarily deployed to app/preview/feat/usage-allowance July 8, 2026 12:02 Destroyed
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to api/preview/feat/usage-allowance July 8, 2026 12:04 Destroyed
trackClassName: "bg-red-500/15",
};
}
if (remainingPercent !== null && remainingPercent < 50) {
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

API preview: https://pr-20684-api.vm6.ai

@hulh122 hulh122 force-pushed the feat/usage-allowance branch from b5130b2 to 17dcdc4 Compare July 9, 2026 06:58
@hulh122 hulh122 force-pushed the feat/usage-allowance branch from 17dcdc4 to 5c2a11f Compare July 9, 2026 07:08
@hulh122

hulh122 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Code Review: PR #20684 (Round 1) - LGTM

Summary

Reviewed the usage allowance billing changes after resolving the rebase conflict. I found and fixed one high-priority allowance eligibility edge case before posting this review: settlement/firewall allowance lookup now requires the run to be a vm0 run and reads windows issued for the run creation time, so canceled entitlements still honor already-created runs while non-vm0 runs inside active windows do not consume vm0 allowance.

Testing Review

Coverage now includes:

  • allowance before credits, short/weekly caps, window refresh, zero-credit admission, exhausted allowance rejection
  • non-vm0 runs both without windows and inside existing vm0 windows
  • older runs after new allowance grant
  • run created before entitlement cancellation still consuming issued windows
  • new run after cancellation not consuming allowance

Verification

  • pnpm -F api exec vitest run src/signals/routes/__tests__/usage-allowance.test.ts src/signals/routes/__tests__/zero-billing-status.test.ts
  • pnpm -F api exec vitest run src/signals/routes/__tests__/webhooks-callbacks.bdd.test.ts -t "usage allowance entitlements"
  • pnpm -F @vm0/app exec vitest run src/views/zero-page/__tests__/personal-usage-tab.test.tsx src/views/zero-page/__tests__/org-usage-tab.test.tsx src/signals/chat-page/__tests__/run-group-folding.test.ts
  • pnpm turbo run lint
  • pnpm check-types
  • pnpm knip --workspace apps/api

Verdict: LGTM

No remaining P0/P1 issues found.


Completed after 1 round of automated review-fix loop

@hulh122 hulh122 added this pull request to the merge queue Jul 9, 2026
Merged via the queue into main with commit 3849bcd Jul 9, 2026
92 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in VM0 Kanban Jul 9, 2026
This was referenced Jul 9, 2026
@github-actions github-actions Bot deleted the feat/usage-allowance branch July 10, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant