Expose pricing plan resolution and provenance helpers#23
Conversation
PR Review: Add pricing plan resolution provenance helpersOverall this is a clean, well-motivated addition. The Bug risk: |
| Addressed the substantive inactive-subscription concern in
The code path itself was already filtering to active / trial / grace subscriptions inside On the remaining review notes:
Re-ran |
PR Review: Expose pricing plan resolution and provenance helpersThis is a solid refactor with good test coverage and a clean API. The single-resolution-path design is an improvement over the old multi-path approach. A few things worth addressing before merging: Bugs / CorrectnessPlanOwner#current_pricing_plan_source triggers a double resolution Any caller that uses both Unaddressed parallel bug in PaySupport#subscription_active_for? (line 18) The PR correctly fixes DesignPlanResolution is a mutable Struct
to_h is fragile and will miss new fields The custom PlanResolver.plan_key_for is now redundant The old MinorResidual debug log The What is good
|
| Follow-up for the latest review in Addressed:
Intentionally not changed:
Re-ran |
PR Review: Expose pricing plan resolution and provenance helpersOverall this is a clean, well-motivated PR. The Bug / Behavioral Change
The old For users with Pay configured but no active subscription, every The tests currently pass because the test doubles return Performance: No memoization on instance helpersdef current_pricing_plan_source current_pricing_plan_resolution.source # calls resolution_for → 1 DB query + Pay call endA user who calls both Consider memoizing at the instance level: def current_pricing_plan_resolution @current_pricing_plan_resolution ||= PlanResolver.resolution_for(self) endThe resolution is frozen and the sources it reads (assignment row, subscription) don't change mid-request in practice, so memoization is safe. You'd just need to clear it when |
| Follow-up for the latest review in Addressed:
Intentionally not changed:
Re-ran |
Review — v0.3.3 plan resolution provenanceThanks for the thorough follow-up across the prior rounds. The core struct is in good shape: frozen 1. |
| Compatibility note on the 0.3.3 change set: I did a final backward-compatibility pass against
Why I consider the upgrade safe for normal consumers:
Two caveats worth being explicit about:
So the compatibility claim I am comfortable making is: safe additive release for public API consumers, with the usual caveat that private/internal hooks were never part of the contract. |
- Clarify that each current_pricing_plan* call performs a database lookup - Document edge case: source can be :default with non-nil subscription Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review: Expose pricing plan resolution and provenance helpersOverall this is a well-designed, well-tested PR. The Performance regression in |
Summary
PricingPlans::PlanResolutionas the canonical result of plan resolutioncurrent_pricing_plan_resolutionandcurrent_pricing_plan_sourceon plan ownersPlanResolverto derive effective plan selection from a single resolution pathTesting
bundle exec rake test