Files
Pulse/pkg/licensing/subscription_transitions.go
rcourtman 107c4e29f9 Make metric history free on every plan
Community installs already stored 90 days of daily metric averages and
366 days of availability history, but the chart, availability and agent
history reads refused anything past seven days, and lapsed paid installs
had history past seven days purged 60 days after a downgrade. Locking
users out of data on their own disk is the kind of limit that drew the
loudest complaints before (the monitored-system cap, SSO), and it is not
what people pay for: 12 of 88 covered paid installs read past seven days
in the last 30 days.

The history routes now serve every supported range on every plan, and
storage retention alone decides how far back the answer goes.
long_term_metrics moves into Community as a compatibility key with no
upgrade reason. TierHistoryDays, max_history_days and the downgrade
purge (DowngradeRetentionState, the metrics store commercial ceiling and
the generated-report purge) are removed, so nothing deletes history or
reports because a plan ended. The chart and drawer lock panels, the
history plan link, the billing summary row and the plan copy that sold
history go with them. Paying users lose nothing.

The public pricing pages and licence server copy in pulse-pro change
when the release carrying this ships.
2026-11-17 20:11:48 +00:00

42 lines
1.4 KiB
Go

package licensing
import "slices"
// Transition represents a valid state transition.
type Transition struct {
From SubscriptionState
To SubscriptionState
}
// validTransitions defines all allowed state transitions.
var validTransitions = map[Transition]bool{
{SubStateTrial, SubStateActive}: true, // Trial converted to paid
{SubStateTrial, SubStateExpired}: true, // Trial expired without conversion
{SubStateActive, SubStateGrace}: true, // Payment failed, entering grace
{SubStateActive, SubStateSuspended}: true, // Admin suspension
{SubStateGrace, SubStateActive}: true, // Payment recovered
{SubStateGrace, SubStateExpired}: true, // Grace period ended
{SubStateExpired, SubStateActive}: true, // Re-subscription
{SubStateSuspended, SubStateActive}: true, // Admin unsuspension
{SubStateSuspended, SubStateExpired}: true, // Suspension expired to full expiry
}
// CanTransition checks if a transition from one state to another is valid.
func CanTransition(from, to SubscriptionState) bool {
return validTransitions[Transition{from, to}]
}
// ValidTransitionsFrom returns all valid target states from the given state.
func ValidTransitionsFrom(from SubscriptionState) []SubscriptionState {
targets := make([]SubscriptionState, 0)
for t := range validTransitions {
if t.From == from {
targets = append(targets, t.To)
}
}
// Stabilize ordering for deterministic callers/tests.
slices.Sort(targets)
return targets
}