Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix v6 dry run backend contract regressions

rcourtmanc4a4d175cedb
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index b8e00c78e8..8d5e01ab96 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -119,6 +119,11 @@ an add-only capacity posture.
## Extension Points
1. Add or change install-command generation, canonical /api/auto-register behavior, or installer download behavior through the owned `internal/api/` files above.
+ Canonical `/api/auto-register` auth is split by intent: when the setup-token
+ bootstrap path succeeds, lifecycle clients must complete registration with
+ the one-time `authToken` only and must not also send the long-lived
+ `X-API-Token` header. The header-backed `agent:report` fallback exists only
+ for update-only re-registration when setup-token fetch is unavailable.
That same shared `internal/api/` adjacency does not transfer ownership of
Patrol quickstart bootstrap or mobile Patrol-provider bridging:
`internal/api/ai_handlers.go` and `internal/api/chat_service_adapter.go`
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index be22947373..f9597efdce 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -212,6 +212,14 @@ Community limit enforcement.
also reopen that compare-plans prompt by default for expired or no-paid
self-hosted installs, so `Plans & Billing` remains actionable even when the
operator arrives without an explicit `intent=self_hosted_plan` link.
+ That same self-hosted commercial boundary also owns legacy migration
+ continuity semantics: `legacy_migration_fallback` may preserve
+ `plan_limit` and `grandfathered_floor` for support/audit context, but
+ self-hosted v6 monitoring remains uncapped. The canonical contract is
+ therefore `status.max_monitored_systems = 0`, no enforced
+ `max_monitored_systems` entitlement row, and
+ `monitored_system_capacity.mode = unlimited` once runtime usage is
+ available.
24. Keep public-demo dashboard bootstrap route-owned on the adjacent
commercial/runtime boundary. `frontend-modern/src/useAppRuntimeState.ts`
may prewarm shared infrastructure summary caches for non-dashboard routes,
@@ -274,12 +282,25 @@ Insights`, rather than reviving generic `AI Patrol` or `AI ... analysis`
`pkg/licensing/models.go`, and downstream runtime entitlement evaluation
must strip that stored cap before enforcement so active recurring
grandfathered continuity remains uncapped until cancellation.
-8. Before GA, treat self-hosted core monitoring as free for homelab use:
+8. Keep legacy migration fallback continuity audit-only on self-hosted v6:
+ `legacy_migration_fallback` may preserve `plan_limit`,
+ `grandfathered_floor`, and related support telemetry, but runtime status
+ and entitlement enforcement must keep self-hosted monitoring uncapped.
+ The canonical contract is `status.max_monitored_systems = 0`, no enforced
+ `max_monitored_systems` entitlement row, and
+ `monitored_system_capacity.mode = unlimited` once runtime usage is
+ available.
+9. Keep the maintained Pulse Account portal bundle source-synced with
+ `internal/cloudcp/portal/frontend/`: any slice that changes the portal
+ frontend hash or emitted manifest must rebuild
+ `internal/cloudcp/portal/dist/build_manifest.json` and keep
+ `internal/cloudcp/portal/frontend_sync_test.go` green in the same change.
+10. Before GA, treat self-hosted core monitoring as free for homelab use:
monitored systems remain the canonical counted unit, but self-hosted paid
value must come from optional extras, hosted convenience, business
workflow, support, or similar non-core surfaces rather than using
monitored-system volume itself as the primary paid gate.
-9. Keep migrated self-hosted Community/free billing state uncapped even when
+11. Keep migrated self-hosted Community/free billing state uncapped even when
the persisted file still carries legacy v5 commercial limit keys:
`pkg/licensing/billing_state_normalization.go` and
`pkg/licensing/database_source.go` must scrub stale
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index a56b403ee6..c647320a71 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -5767,17 +5767,17 @@ func TestContract_LegacyMigrationGrandfatherFloorFallbackJSONSnapshot(t *testing
"status":{
"tier":"pro",
"plan_version":"legacy_migration_fallback",
- "max_monitored_systems":23,
+ "max_monitored_systems":0,
"valid":true,
- "monitored_system_continuity":{"plan_limit":10,"grandfathered_floor":23,"effective_limit":23,"capture_pending":false,"captured_at":123}
+ "monitored_system_continuity":{"plan_limit":10,"grandfathered_floor":23,"effective_limit":0,"capture_pending":false,"captured_at":123}
},
"entitlements":{
"tier":"pro",
"plan_version":"legacy_migration_fallback",
"subscription_state":"active",
- "limits":[{"key":"max_monitored_systems","limit":23,"current":23,"current_available":true,"state":"enforced"}],
- "monitored_system_continuity":{"plan_limit":10,"grandfathered_floor":23,"effective_limit":23,"capture_pending":false,"captured_at":123},
- "monitored_system_capacity":{"mode":"at_limit_blocking_new","urgency":"enforced","current":23,"limit":23,"current_available":true,"available_slots":0,"overage":0,"reason":"limit_reached","blocks_new_systems":true,"existing_monitoring_continues":true}
+ "limits":[],
+ "monitored_system_continuity":{"plan_limit":10,"grandfathered_floor":23,"effective_limit":0,"capture_pending":false,"captured_at":123},
+ "monitored_system_capacity":{"mode":"unlimited","urgency":"ok","current":23,"limit":0,"current_available":true,"available_slots":0,"overage":0,"blocks_new_systems":false,"existing_monitoring_continues":true}
}
}`
diff --git a/internal/api/licensing_handlers_auto_migrate_test.go b/internal/api/licensing_handlers_auto_migrate_test.go
index 494219bcc7..d69bf9fcd2 100644
--- a/internal/api/licensing_handlers_auto_migrate_test.go
+++ b/internal/api/licensing_handlers_auto_migrate_test.go
@@ -399,8 +399,8 @@ func TestGetTenantComponents_AutoExchangeGrandfathersObservedMonitoredSystems(t
if !svc.IsActivated() {
t.Fatal("expected persisted legacy JWT to auto-exchange into activation state")
}
- if got := svc.Status().MaxMonitoredSystems; got != 23 {
- t.Fatalf("status.MaxMonitoredSystems=%d, want 23", got)
+ if got := svc.Status().MaxMonitoredSystems; got != 0 {
+ t.Fatalf("status.MaxMonitoredSystems=%d, want 0 for uncapped self-hosted continuity", got)
}
if activationState, err := persistence.LoadActivationState(); err != nil {
t.Fatalf("load activation state: %v", err)
@@ -475,8 +475,8 @@ func TestGetTenantComponents_BackfillsGrandfatherFloorAfterRestoreWhenMonitorArr
if svc == nil {
t.Fatal("expected non-nil service")
}
- if got := svc.Status().MaxMonitoredSystems; got != 10 {
- t.Fatalf("initial status.MaxMonitoredSystems=%d, want 10 before floor capture", got)
+ if got := svc.Status().MaxMonitoredSystems; got != 0 {
+ t.Fatalf("initial status.MaxMonitoredSystems=%d, want 0 before floor capture for uncapped self-hosted continuity", got)
}
handlers.SetMonitors(buildGrandfatherFloorMonitor(23), nil)
@@ -511,8 +511,8 @@ func TestGetTenantComponents_BackfillsGrandfatherFloorAfterRestoreWhenMonitorArr
if loaded.Continuity.GrandfatheredMonitoredSystemsCapturedAt == 0 {
t.Fatal("expected captured timestamp after late monitor restore")
}
- if got := svc.Status().MaxMonitoredSystems; got != 23 {
- t.Fatalf("status.MaxMonitoredSystems=%d, want 23 after late monitor capture", got)
+ if got := svc.Status().MaxMonitoredSystems; got != 0 {
+ t.Fatalf("status.MaxMonitoredSystems=%d, want 0 after late monitor capture for uncapped self-hosted continuity", got)
}
handlers.StopAllBackgroundLoops()
@@ -686,8 +686,8 @@ func TestActivateLicenseKey_GrandfathersObservedMonitoredSystemsForLegacyMigrati
if svc == nil {
t.Fatal("expected non-nil service")
}
- if got := svc.Status().MaxMonitoredSystems; got != 23 {
- t.Fatalf("status.MaxMonitoredSystems=%d, want 23", got)
+ if got := svc.Status().MaxMonitoredSystems; got != 0 {
+ t.Fatalf("status.MaxMonitoredSystems=%d, want 0 for uncapped self-hosted continuity", got)
}
}
@@ -794,13 +794,13 @@ func TestGetTenantComponents_DelaysGrandfatherFloorUntilSupplementalInventorySet
}
status := readStatus()
- if got := status.MaxMonitoredSystems; got != 10 {
- t.Fatalf("initial status.MaxMonitoredSystems=%d, want 10 while supplemental inventory is unsettled", got)
+ if got := status.MaxMonitoredSystems; got != 0 {
+ t.Fatalf("initial status.MaxMonitoredSystems=%d, want 0 while supplemental inventory is unsettled for uncapped self-hosted continuity", got)
}
if status.MonitoredSystemContinuity == nil || !status.MonitoredSystemContinuity.CapturePending {
t.Fatalf("expected pending continuity in status payload, got %+v", status.MonitoredSystemContinuity)
}
- if status.MonitoredSystemContinuity.PlanLimit != 10 || status.MonitoredSystemContinuity.EffectiveLimit != 10 {
+ if status.MonitoredSystemContinuity.PlanLimit != 10 || status.MonitoredSystemContinuity.EffectiveLimit != 0 {
t.Fatalf("unexpected pending continuity status payload: %+v", status.MonitoredSystemContinuity)
}
@@ -808,14 +808,23 @@ func TestGetTenantComponents_DelaysGrandfatherFloorUntilSupplementalInventorySet
if payload.MonitoredSystemContinuity == nil || !payload.MonitoredSystemContinuity.CapturePending {
t.Fatalf("expected pending continuity in entitlements payload, got %+v", payload.MonitoredSystemContinuity)
}
- if len(payload.Limits) != 1 {
- t.Fatalf("expected one monitored-system limit, got %+v", payload.Limits)
+ if len(payload.Limits) != 0 {
+ t.Fatalf("expected no enforced monitored-system limit for uncapped continuity, got %+v", payload.Limits)
}
- if payload.Limits[0].CurrentAvailable == nil || *payload.Limits[0].CurrentAvailable {
- t.Fatalf("expected unavailable monitored-system usage while supplemental inventory is unsettled, got %+v", payload.Limits[0])
+ if payload.MonitoredSystemCapacity == nil {
+ t.Fatal("expected monitored-system capacity payload")
}
- if payload.Limits[0].CurrentUnavailableReason != "supplemental_inventory_unsettled" {
- t.Fatalf("CurrentUnavailableReason=%q, want %q", payload.Limits[0].CurrentUnavailableReason, "supplemental_inventory_unsettled")
+ if payload.MonitoredSystemCapacity.Mode != "usage_unavailable" {
+ t.Fatalf("expected usage_unavailable monitored-system capacity while supplemental inventory is unsettled, got %+v", payload.MonitoredSystemCapacity)
+ }
+ if payload.MonitoredSystemCapacity.Limit != 0 {
+ t.Fatalf("monitored_system_capacity.limit=%d, want 0 for uncapped continuity", payload.MonitoredSystemCapacity.Limit)
+ }
+ if payload.MonitoredSystemCapacity.CurrentAvailable {
+ t.Fatalf("expected unavailable monitored-system usage while supplemental inventory is unsettled, got %+v", payload.MonitoredSystemCapacity)
+ }
+ if payload.MonitoredSystemCapacity.CurrentUnavailableReason != "supplemental_inventory_unsettled" {
+ t.Fatalf("CurrentUnavailableReason=%q, want %q", payload.MonitoredSystemCapacity.CurrentUnavailableReason, "supplemental_inventory_unsettled")
}
activationState, err := persistence.LoadActivationState()
@@ -831,14 +840,14 @@ func TestGetTenantComponents_DelaysGrandfatherFloorUntilSupplementalInventorySet
provider.settle(23)
status = readStatus()
- if got := status.MaxMonitoredSystems; got != 10 {
- t.Fatalf("stale supplemental store should not capture grandfather floor yet, got %d", got)
+ if got := status.MaxMonitoredSystems; got != 0 {
+ t.Fatalf("stale supplemental store should keep uncapped self-hosted status, got %d", got)
}
monitor.SetSupplementalRecordsProvider(unifiedresources.SourceTrueNAS, provider)
status = readStatus()
- if got := status.MaxMonitoredSystems; got != 10 {
- t.Fatalf("status read should not capture grandfather floor directly after canonical store rebuild, got %d", got)
+ if got := status.MaxMonitoredSystems; got != 0 {
+ t.Fatalf("status read should not reintroduce a monitored-system cap directly after canonical store rebuild, got %d", got)
}
deadline := time.Now().Add(8 * time.Second)
@@ -859,13 +868,13 @@ func TestGetTenantComponents_DelaysGrandfatherFloorUntilSupplementalInventorySet
}
status = readStatus()
- if got := status.MaxMonitoredSystems; got != 23 {
- t.Fatalf("status.MaxMonitoredSystems=%d, want 23 after async grandfather capture", got)
+ if got := status.MaxMonitoredSystems; got != 0 {
+ t.Fatalf("status.MaxMonitoredSystems=%d, want 0 after async grandfather capture for uncapped self-hosted continuity", got)
}
if status.MonitoredSystemContinuity == nil || status.MonitoredSystemContinuity.CapturePending {
t.Fatalf("expected settled continuity in status payload after async capture, got %+v", status.MonitoredSystemContinuity)
}
- if status.MonitoredSystemContinuity.GrandfatheredFloor != 23 || status.MonitoredSystemContinuity.EffectiveLimit != 23 {
+ if status.MonitoredSystemContinuity.GrandfatheredFloor != 23 || status.MonitoredSystemContinuity.EffectiveLimit != 0 {
t.Fatalf("unexpected settled continuity status payload: %+v", status.MonitoredSystemContinuity)
}
@@ -873,11 +882,14 @@ func TestGetTenantComponents_DelaysGrandfatherFloorUntilSupplementalInventorySet
if payload.MonitoredSystemContinuity == nil || payload.MonitoredSystemContinuity.CapturePending {
t.Fatalf("expected settled continuity in entitlements payload after async capture, got %+v", payload.MonitoredSystemContinuity)
}
- if len(payload.Limits) != 1 || payload.Limits[0].Current != 23 {
- t.Fatalf("expected settled monitored-system usage in entitlements payload, got %+v", payload.Limits)
+ if len(payload.Limits) != 0 {
+ t.Fatalf("expected no enforced monitored-system limit in entitlements payload after async capture, got %+v", payload.Limits)
+ }
+ if payload.MonitoredSystemCapacity == nil {
+ t.Fatal("expected monitored-system capacity payload after async capture")
}
- if payload.Limits[0].CurrentAvailable == nil || !*payload.Limits[0].CurrentAvailable {
- t.Fatalf("expected available monitored-system usage after async capture, got %+v", payload.Limits[0])
+ if payload.MonitoredSystemCapacity.Mode != "unlimited" || payload.MonitoredSystemCapacity.Current != 23 {
+ t.Fatalf("expected unlimited monitored-system capacity with current=23 after async capture, got %+v", payload.MonitoredSystemCapacity)
}
}
diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.json
index fd44588fbe..b9242e5a81 100644
--- a/internal/cloudcp/portal/dist/build_manifest.json
+++ b/internal/cloudcp/portal/dist/build_manifest.json
@@ -1,5 +1,5 @@
{
- "source_hash": "efda54137fc74a40c6af35cdd3e0c00fcd1864a4ea4d7eedd1c27bacaa957b15",
+ "source_hash": "d2bcdf7f2c1910ca61deb35e6a85ea869d524c63c1bc8d0faba74e66ba62c4c1",
"build_inputs": [
"package.json",
"tsconfig.json",
diff --git a/internal/cloudcp/portal/frontend_sync_test.go b/internal/cloudcp/portal/frontend_sync_test.go
index a1508551e9..111938ac8a 100644
--- a/internal/cloudcp/portal/frontend_sync_test.go
+++ b/internal/cloudcp/portal/frontend_sync_test.go
@@ -14,7 +14,9 @@ type portalFrontendManifest struct {
BuildInputs []string `json:"build_inputs"`
}
-func TestPulseAccountFrontendBundleStaysInSync(t *testing.T) {
+func readPortalFrontendManifest(t *testing.T) portalFrontendManifest {
+ t.Helper()
+
manifestPath := filepath.Join("dist", "build_manifest.json")
manifestBytes, err := os.ReadFile(manifestPath)
if err != nil {
@@ -31,6 +33,27 @@ func TestPulseAccountFrontendBundleStaysInSync(t *testing.T) {
if len(manifest.BuildInputs) == 0 {
t.Fatal("portal frontend manifest missing build_inputs")
}
+ return manifest
+}
+
+func TestPulseAccountFrontendManifestListsCanonicalInputs(t *testing.T) {
+ manifest := readPortalFrontendManifest(t)
+
+ requiredInputs := map[string]struct{}{
+ "build_config.mjs": {},
+ "src/styles.css": {},
+ }
+
+ for _, relativePath := range manifest.BuildInputs {
+ delete(requiredInputs, relativePath)
+ }
+ if len(requiredInputs) > 0 {
+ t.Fatalf("portal frontend manifest missing canonical inputs: %v", mapsKeys(requiredInputs))
+ }
+}
+
+func TestPulseAccountFrontendBundleStaysInSync(t *testing.T) {
+ manifest := readPortalFrontendManifest(t)
requiredInputs := map[string]struct{}{
"build_config.mjs": {},
diff --git a/internal/hostagent/proxmox_setup.go b/internal/hostagent/proxmox_setup.go
index 5642864eb1..f5c88f3056 100644
--- a/internal/hostagent/proxmox_setup.go
+++ b/internal/hostagent/proxmox_setup.go
@@ -649,7 +649,7 @@ func (p *ProxmoxSetup) checkRegistrationWithPulse(ctx context.Context, ptype pro
return false, fmt.Errorf("create registration-check request: %w", err)
}
req.Header.Set("Content-Type", "application/json")
- if token := strings.TrimSpace(p.apiToken); token != "" {
+ if token := autoRegisterAPITokenHeader(p.apiToken, setupToken); token != "" {
req.Header.Set("X-API-Token", token)
}
@@ -1219,13 +1219,20 @@ func autoRegisterResponseMatchesCandidateHost(responseHost string, candidateHost
return false
}
-func (p *ProxmoxSetup) doRegisterRequest(ctx context.Context, body []byte, expectedType proxmoxProductType, expectedSource autoRegisterSource, expectedHosts []string, expectedTokenID, expectedTokenValue string) (autoRegisterResponse, error) {
+func autoRegisterAPITokenHeader(apiToken, setupToken string) string {
+ if strings.TrimSpace(setupToken) != "" {
+ return ""
+ }
+ return strings.TrimSpace(apiToken)
+}
+
+func (p *ProxmoxSetup) doRegisterRequest(ctx context.Context, body []byte, setupToken string, expectedType proxmoxProductType, expectedSource autoRegisterSource, expectedHosts []string, expectedTokenID, expectedTokenValue string) (autoRegisterResponse, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodPost, p.pulseURL+"/api/auto-register", bytes.NewReader(body))
if err != nil {
return autoRegisterResponse{}, &permanentError{fmt.Errorf("create request: %w", err)}
}
req.Header.Set("Content-Type", "application/json")
- if token := strings.TrimSpace(p.apiToken); token != "" {
+ if token := autoRegisterAPITokenHeader(p.apiToken, setupToken); token != "" {
req.Header.Set("X-API-Token", token)
}
@@ -1450,7 +1457,7 @@ func (p *ProxmoxSetup) registerWithPulse(ctx context.Context, ptype proxmoxProdu
return autoRegisterResponse{}, fmt.Errorf("marshal payload: %w", err)
}
- parsed, err := p.doRegisterRequest(ctx, body, ptype, autoRegisterSourceAgent, candidateHosts, tokenID, tokenValue)
+ parsed, err := p.doRegisterRequest(ctx, body, setupToken, ptype, autoRegisterSourceAgent, candidateHosts, tokenID, tokenValue)
if err == nil {
if attempt > 0 {
p.logger.Info().Int("attempt", attempt+1).Str("type", string(ptype)).Msg("Proxmox auto-registration succeeded after retry")
diff --git a/internal/hostagent/proxmox_setup_test.go b/internal/hostagent/proxmox_setup_test.go
index f2acf44825..c3f61f07e8 100644
--- a/internal/hostagent/proxmox_setup_test.go
+++ b/internal/hostagent/proxmox_setup_test.go
@@ -180,6 +180,15 @@ func TestRegisterWithPulse_Payload(t *testing.T) {
}
}
+func TestAutoRegisterAPITokenHeader(t *testing.T) {
+ if got := autoRegisterAPITokenHeader(" api-token ", "setup-token"); got != "" {
+ t.Fatalf("autoRegisterAPITokenHeader()=%q, want empty when setup token is present", got)
+ }
+ if got := autoRegisterAPITokenHeader(" api-token ", " "); got != "api-token" {
+ t.Fatalf("autoRegisterAPITokenHeader()=%q, want %q when falling back to agent API token auth", got, "api-token")
+ }
+}
+
func TestRegisterWithPulse_AcceptsServerSelectedFallbackHost(t *testing.T) {
var gotPayload autoRegisterRequest
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
diff --git a/pkg/licensing/activation_types.go b/pkg/licensing/activation_types.go
index c97c8f65f8..14bf2c1391 100644
--- a/pkg/licensing/activation_types.go
+++ b/pkg/licensing/activation_types.go
@@ -2,6 +2,7 @@ package licensing
import (
"encoding/json"
+ "strings"
"time"
"github.com/rs/zerolog/log"
@@ -94,6 +95,19 @@ func applyActivationContinuityToClaims(claims *Claims, continuity ActivationCont
}
}
+func grantClaimsUseUncappedCoreMonitoring(gc *GrantClaims) bool {
+ if gc == nil {
+ return false
+ }
+
+ switch Tier(strings.TrimSpace(gc.Tier)) {
+ case TierFree, TierRelay, TierPro, TierProPlus, TierProAnnual, TierLifetime:
+ return true
+ default:
+ return false
+ }
+}
+
// GrantClaims are the claims parsed from a relay grant JWT payload.
// The grant is a short-lived JWT (72h TTL) issued by the license server.
type GrantClaims struct {
@@ -135,15 +149,16 @@ func grantClaimsToClaims(gc *GrantClaims) Claims {
func grantClaimsToClaimsWithContinuity(gc *GrantClaims, continuity ActivationContinuity) Claims {
c := Claims{
- LicenseID: gc.LicenseID,
- Email: gc.Email,
- Tier: Tier(gc.Tier),
- IssuedAt: gc.IssuedAt,
- ExpiresAt: gc.ExpiresAt,
- Features: gc.Features,
- MaxMonitoredSystems: gc.MaxMonitoredSystems,
- MaxGuests: gc.MaxGuests,
- PlanVersion: gc.PlanKey,
+ LicenseID: gc.LicenseID,
+ Email: gc.Email,
+ Tier: Tier(gc.Tier),
+ IssuedAt: gc.IssuedAt,
+ ExpiresAt: gc.ExpiresAt,
+ Features: gc.Features,
+ MaxMonitoredSystems: gc.MaxMonitoredSystems,
+ MaxGuests: gc.MaxGuests,
+ PlanVersion: gc.PlanKey,
+ CoreMonitoringUncapped: grantClaimsUseUncappedCoreMonitoring(gc),
}
// Map grant state to subscription state. Fail closed: unknown states
diff --git a/pkg/licensing/activation_types_test.go b/pkg/licensing/activation_types_test.go
index 8699ded957..ef565a5ffb 100644
--- a/pkg/licensing/activation_types_test.go
+++ b/pkg/licensing/activation_types_test.go
@@ -197,6 +197,9 @@ func TestGrantClaimsToClaimsWithContinuityAppliesGrandfatherFloor(t *testing.T)
// The raw MaxMonitoredSystems field still records the continuity floor, but
// self-hosted Pro is uncapped, so EffectiveLimits must not surface a cap.
+ if !claims.CoreMonitoringUncapped {
+ t.Fatal("expected grant-backed self-hosted continuity claims to carry the uncapped core monitoring marker")
+ }
if claims.MaxMonitoredSystems != 23 {
t.Fatalf("MaxMonitoredSystems = %d, want 23", claims.MaxMonitoredSystems)
}
@@ -223,6 +226,9 @@ func TestGrantClaimsToClaimsWithContinuityDoesNotLowerGrantLimit(t *testing.T) {
// Floor of 10 is below grant's 15, so the raw field is left at 15. Either
// way, self-hosted Pro is uncapped so EffectiveLimits does not surface a cap.
+ if !claims.CoreMonitoringUncapped {
+ t.Fatal("expected grant-backed self-hosted continuity claims to carry the uncapped core monitoring marker")
+ }
if claims.MaxMonitoredSystems != 15 {
t.Fatalf("MaxMonitoredSystems = %d, want 15", claims.MaxMonitoredSystems)
}
diff --git a/pkg/licensing/models.go b/pkg/licensing/models.go
index 7b6dd30b11..a64f71555a 100644
--- a/pkg/licensing/models.go
+++ b/pkg/licensing/models.go
@@ -39,6 +39,12 @@ type Claims struct {
MetersEnabled []string `json:"meters_enabled,omitempty"`
PlanVersion string `json:"plan_version,omitempty"`
SubState SubscriptionState `json:"subscription_state,omitempty"`
+
+ // CoreMonitoringUncapped is a local runtime marker used when a self-hosted
+ // activation/grant should remain uncapped even if stale legacy limit fields
+ // are still present in the persisted claims. It is intentionally excluded
+ // from the JWT/storage wire contract.
+ CoreMonitoringUncapped bool `json:"-"`
}
// UnmarshalJSON implements custom JSON unmarshaling for Claims to handle the
@@ -68,18 +74,20 @@ func (c Claims) EffectiveCapabilities() []string {
return DeriveCapabilitiesFromTier(c.Tier, c.Features)
}
-// isSelfHostedUncappedTier reports whether a tier is a self-hosted tier that
-// must remain uncapped for core monitoring regardless of any persisted limit.
-// Cloud and MSP tiers resolve their limits from plan version, so they are
-// excluded. Enterprise is excluded because its claims carry explicit per-deal
-// limits that must be honored.
-func isSelfHostedUncappedTier(tier Tier) bool {
- switch tier {
- case TierFree, TierRelay, TierPro, TierProPlus, TierProAnnual, TierLifetime:
+func (c Claims) shouldScrubLegacyCommercialCaps() bool {
+ if c.CoreMonitoringUncapped {
+ return true
+ }
+ if c.Tier == TierLifetime {
+ return true
+ }
+ if IsSelfHostedCommunityPlanVersion(c.PlanVersion) {
+ return true
+ }
+ if IsGrandfatheredRecurringV5PlanVersion(c.PlanVersion) {
return true
- default:
- return false
}
+ return false
}
// EffectiveLimits returns explicit limits when present; otherwise limits derived from legacy fields.
@@ -94,12 +102,10 @@ func (c Claims) EffectiveLimits() map[string]int64 {
limits["max_guests"] = int64(c.MaxGuests)
}
}
- if isSelfHostedUncappedTier(c.Tier) || IsGrandfatheredRecurringV5PlanVersion(c.PlanVersion) {
- // Self-hosted tiers are uncapped for core monitoring, and grandfathered
- // recurring v5 migrations must remain uncapped too. Older tokens or
- // migrated activation records may still carry historical per-tier limits
- // (e.g. a v5-migrated Community install persisted max_monitored_systems=1);
- // scrub them so the current tier policy wins.
+ if c.shouldScrubLegacyCommercialCaps() {
+ // Local activation migrations and grandfathered continuity may still
+ // carry legacy monitored-system caps in stale claim fields. Scrub those
+ // caps only when the canonical contract says core monitoring is uncapped.
delete(limits, MaxMonitoredSystemsLicenseGateKey)
delete(limits, "max_guests")
}
diff --git a/pkg/licensing/models_test.go b/pkg/licensing/models_test.go
index 0564bb99b0..c4a304a1e8 100644
--- a/pkg/licensing/models_test.go
+++ b/pkg/licensing/models_test.go
@@ -118,9 +118,10 @@ func TestClaims_EffectiveLimits(t *testing.T) {
expected: map[string]int64{},
},
{
- name: "free_strips_legacy_v5_cap_after_upgrade",
+ name: "community_plan_strips_legacy_v5_cap_after_upgrade",
claims: Claims{
Tier: TierFree,
+ PlanVersion: "community",
Limits: map[string]int64{"max_monitored_systems": 1, "max_guests": 5},
MaxMonitoredSystems: 1,
MaxGuests: 5,
@@ -128,39 +129,23 @@ func TestClaims_EffectiveLimits(t *testing.T) {
expected: map[string]int64{},
},
{
- name: "relay_strips_legacy_cap",
- claims: Claims{
- Tier: TierRelay,
- Limits: map[string]int64{"max_monitored_systems": 8},
- MaxMonitoredSystems: 8,
- },
- expected: map[string]int64{},
- },
- {
- name: "pro_strips_legacy_cap",
+ name: "generic_self_hosted_claims_preserve_explicit_limits_without_uncapped_marker",
claims: Claims{
Tier: TierPro,
Limits: map[string]int64{"max_monitored_systems": 15, "max_guests": 100},
MaxMonitoredSystems: 15,
MaxGuests: 100,
},
- expected: map[string]int64{},
+ expected: map[string]int64{"max_monitored_systems": 15, "max_guests": 100},
},
{
- name: "pro_plus_strips_legacy_cap",
+ name: "grant_backed_self_hosted_uncapped_marker_strips_legacy_cap",
claims: Claims{
- Tier: TierProPlus,
- Limits: map[string]int64{"max_monitored_systems": 50},
- MaxMonitoredSystems: 50,
- },
- expected: map[string]int64{},
- },
- {
- name: "pro_annual_strips_legacy_cap",
- claims: Claims{
- Tier: TierProAnnual,
- Limits: map[string]int64{"max_monitored_systems": 15},
- MaxMonitoredSystems: 15,
+ Tier: TierPro,
+ CoreMonitoringUncapped: true,
+ Limits: map[string]int64{"max_monitored_systems": 15, "max_guests": 100},
+ MaxMonitoredSystems: 15,
+ MaxGuests: 100,
},
expected: map[string]int64{},
},