Skip to content

refactor(billing): consolidate billing_rail classification into one policy site - #15106

Closed
jaeone94 wants to merge 13 commits into
mainfrom
jaeone94/adr-billing-rail-routing
Closed

jaeone94 wants to merge 13 commits into
mainfrom
jaeone94/adr-billing-rail-routing

Conversation

@jaeone94

@jaeone94 jaeone94 commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

Two billing flows previously interpreted the server's billing mode independently. This PR gives them one shared lookup table, so each mode has one reviewable definition while existing routing behavior stays the same.

Motivation

After the billing rollout flags were retired, billing_rail became the deciding input for account routing and cancellation eligibility. #14645 — Consolidate billing_rail routing and document the legacy_stripe exit condition identified separate inline predicates whose handling could drift, especially when the backend adds another rail. Centralizing the mapping makes new generated rail values fail typechecking until they are classified, while preserving the current fail-open behavior for values an already-built frontend does not recognize.

Provenance

Reviewer context

Summary

  • Adds getBillingRailPolicy as the single classification site for known, absent, and unrecognized runtime rails.
  • Routes account-operation and cancellation decisions through explicit policy capabilities.
  • Uses satisfies never so a widened generated BillingRail union fails typechecking until classified.
  • Preserves the current behavior: absent or unrecognized runtime rails use workspace billing without Churnkey.

Test plan

  • Verify known, absent, and unrecognized rails in the focused policy tests.
  • Run targeted formatting and lint checks.
  • Run the full TypeScript check through the pre-commit hook.
  • Confirm the existing GitHub checks pass.

Fixes #14645

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

Labels

risk:xhigh PR risk grade (advisory shadow check; grader-owned) size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate billing_rail routing and document the legacy_stripe exit condition

3 participants