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.

Bound dev entitlements to runtime-enabled features

rcourtman94330b678756
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 282f20658f..44e9fe2c4d 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -321,6 +321,10 @@ backend feature gates are widened by `PULSE_DEV=true` or demo/mock mode,
`/api/license/entitlements` must advertise the same capability set in
`capabilities`; it must not leave frontend shells on stale free-tier gating
while backend `HasFeature()` already treats those features as available.
+That widening still has to respect runtime feature flags. A capability like
+`multi_tenant` must stay absent from dev/demo entitlement payloads until the
+process also has `PULSE_MULTI_TENANT_ENABLED=true`; otherwise admin shells
+drift into impossible routes that the same backend still rejects as disabled.
The `/api/resources` serializer now also refreshes canonical identity and
policy metadata through the shared unified-resource helper before it writes
the payload, so backend and frontend contract tests stay aligned on one
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index b5c8abb7ea..32e34557ec 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -29,53 +29,54 @@ agreement, and cloud-specific enforcement rules.
7. `pkg/licensing/token_source.go`
8. `pkg/licensing/entitlement_payload.go`
9. `pkg/licensing/hosted_subscription.go`
-10. `pkg/licensing/service.go`
-11. `pkg/licensing/grant_refresh.go`
-12. `pkg/licensing/revocation_poll.go`
-13. `pkg/licensing/license_server_client.go`
-14. `pkg/licensing/persistence.go`
-15. `pkg/licensing/activation_store.go`
-16. `pkg/licensing/trial_activation.go`
-17. `pkg/licensing/stripe_subscription.go`
-18. `pkg/licensing/monitored_system_limit.go`
-19. `internal/cloudcp/entitlements/service.go`
-20. `internal/cloudcp/registry/registry.go`
-21. `internal/cloudcp/account/tenant_handlers.go`
-22. `internal/cloudcp/portal/handlers.go`
-23. `internal/cloudcp/portal/page.go`
-24. `internal/cloudcp/routes.go`
-25. `internal/cloudcp/stripe/provisioner.go`
-26. `internal/hosted/provisioner.go`
-27. `frontend-modern/src/App.tsx`
-28. `frontend-modern/src/AppLayout.tsx`
-29. `frontend-modern/src/useAppRuntimeState.ts`
-30. `frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx`
-31. `frontend-modern/src/components/Dashboard/useRelayOnboardingCardState.ts`
-32. `frontend-modern/src/components/Commercial/MonitoredSystemDefinitionDisclosure.tsx`
-33. `frontend-modern/src/components/Settings/BillingAdminPanel.tsx`
-34. `frontend-modern/src/components/Settings/BillingAdminOrganizationsTable.tsx`
-35. `frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx`
-36. `frontend-modern/src/components/Settings/OrganizationBillingLoadingState.tsx`
-37. `frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx`
-38. `frontend-modern/src/components/Settings/ProLicensePanel.tsx`
-39. `frontend-modern/src/components/Settings/ProLicensePlanSection.tsx`
-40. `frontend-modern/src/components/Settings/CommercialBillingSections.tsx`
-41. `frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx`
-42. `frontend-modern/src/components/Settings/RelaySettingsPanel.tsx`
-43. `frontend-modern/src/components/Settings/RelayPairingSection.tsx`
-44. `frontend-modern/src/components/Settings/useBillingAdminPanelState.ts`
-45. `frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts`
-46. `frontend-modern/src/components/Settings/useProLicensePanelState.ts`
-47. `frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts`
-48. `frontend-modern/src/pages/CloudPricing.tsx`
-49. `frontend-modern/src/pages/PricingV6.tsx`
-50. `frontend-modern/src/utils/apiClient.ts`
-51. `frontend-modern/src/utils/cloudPlans.ts`
-52. `frontend-modern/src/utils/commercialBillingModel.ts`
-53. `frontend-modern/src/utils/monitoredSystemPresentation.ts`
-54. `frontend-modern/src/utils/selfHostedPlans.ts`
-55. `frontend-modern/src/utils/licensePresentation.ts`
-56. `frontend-modern/src/utils/upgradePresentation.ts`
+10. `pkg/licensing/dev_mode_features.go`
+11. `pkg/licensing/service.go`
+12. `pkg/licensing/grant_refresh.go`
+13. `pkg/licensing/revocation_poll.go`
+14. `pkg/licensing/license_server_client.go`
+15. `pkg/licensing/persistence.go`
+16. `pkg/licensing/activation_store.go`
+17. `pkg/licensing/trial_activation.go`
+18. `pkg/licensing/stripe_subscription.go`
+19. `pkg/licensing/monitored_system_limit.go`
+20. `internal/cloudcp/entitlements/service.go`
+21. `internal/cloudcp/registry/registry.go`
+22. `internal/cloudcp/account/tenant_handlers.go`
+23. `internal/cloudcp/portal/handlers.go`
+24. `internal/cloudcp/portal/page.go`
+25. `internal/cloudcp/routes.go`
+26. `internal/cloudcp/stripe/provisioner.go`
+27. `internal/hosted/provisioner.go`
+28. `frontend-modern/src/App.tsx`
+29. `frontend-modern/src/AppLayout.tsx`
+30. `frontend-modern/src/useAppRuntimeState.ts`
+31. `frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx`
+32. `frontend-modern/src/components/Dashboard/useRelayOnboardingCardState.ts`
+33. `frontend-modern/src/components/Commercial/MonitoredSystemDefinitionDisclosure.tsx`
+34. `frontend-modern/src/components/Settings/BillingAdminPanel.tsx`
+35. `frontend-modern/src/components/Settings/BillingAdminOrganizationsTable.tsx`
+36. `frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx`
+37. `frontend-modern/src/components/Settings/OrganizationBillingLoadingState.tsx`
+38. `frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx`
+39. `frontend-modern/src/components/Settings/ProLicensePanel.tsx`
+40. `frontend-modern/src/components/Settings/ProLicensePlanSection.tsx`
+41. `frontend-modern/src/components/Settings/CommercialBillingSections.tsx`
+42. `frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx`
+43. `frontend-modern/src/components/Settings/RelaySettingsPanel.tsx`
+44. `frontend-modern/src/components/Settings/RelayPairingSection.tsx`
+45. `frontend-modern/src/components/Settings/useBillingAdminPanelState.ts`
+46. `frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts`
+47. `frontend-modern/src/components/Settings/useProLicensePanelState.ts`
+48. `frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts`
+49. `frontend-modern/src/pages/CloudPricing.tsx`
+50. `frontend-modern/src/pages/PricingV6.tsx`
+51. `frontend-modern/src/utils/apiClient.ts`
+52. `frontend-modern/src/utils/cloudPlans.ts`
+53. `frontend-modern/src/utils/commercialBillingModel.ts`
+54. `frontend-modern/src/utils/monitoredSystemPresentation.ts`
+55. `frontend-modern/src/utils/selfHostedPlans.ts`
+56. `frontend-modern/src/utils/licensePresentation.ts`
+57. `frontend-modern/src/utils/upgradePresentation.ts`
## Shared Boundaries
@@ -92,7 +93,7 @@ agreement, and cloud-specific enforcement rules.
4. Add or change MSP account-scoped workspace provisioning entry handlers through `internal/cloudcp/account/tenant_handlers.go`
5. Add or change the hosted account portal API, browser shell, or account-scoped billing handoff through `internal/cloudcp/portal/handlers.go`, `internal/cloudcp/portal/page.go`, and `internal/cloudcp/routes.go`
6. Add or change Stripe provisioning plan resolution through `internal/cloudcp/stripe/provisioner.go`
-7. Add or change activation/grant lifecycle through `pkg/licensing/service.go`, `pkg/licensing/grant_refresh.go`, and `pkg/licensing/revocation_poll.go`
+7. Add or change activation/grant lifecycle or dev-mode capability widening through `pkg/licensing/dev_mode_features.go`, `pkg/licensing/service.go`, `pkg/licensing/grant_refresh.go`, and `pkg/licensing/revocation_poll.go`
8. Add or change license-server transport through `pkg/licensing/license_server_client.go`
9. Add or change encrypted activation persistence through `pkg/licensing/persistence.go` and `pkg/licensing/activation_store.go`
10. Add or change hosted trial token semantics through `pkg/licensing/trial_activation.go`
@@ -687,6 +688,10 @@ That same runtime surface must stay internally coherent in local dev mode. If
frontend-facing capability contract derived from that service must advertise
the same capability set instead of leaving paid surfaces artificially locked
behind stale free-tier capabilities.
+That dev widening is still bounded by runtime readiness rather than marketing
+intent: `multi_tenant` is not a valid advertised dev capability unless the
+process also has `PULSE_MULTI_TENANT_ENABLED=true`, because the org API surface
+is intentionally disabled otherwise.
Cloud/MSP live price IDs are no longer an open fill-in task either. The audit
record `docs/release-control/v6/records/cloud-msp-price-audit-2026-03-13.md`
verified that the 13 canonical Cloud/MSP v6 `price_*` IDs are present in the
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 5ace626ccb..528be0a4c2 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -1759,6 +1759,7 @@
"label": "activation service runtime proof",
"match_prefixes": [],
"match_files": [
+ "pkg/licensing/dev_mode_features.go",
"pkg/licensing/grant_refresh.go",
"pkg/licensing/revocation_poll.go",
"pkg/licensing/service.go"
diff --git a/internal/api/entitlement_handlers_test.go b/internal/api/entitlement_handlers_test.go
index 0f77348f50..4d142527ca 100644
--- a/internal/api/entitlement_handlers_test.go
+++ b/internal/api/entitlement_handlers_test.go
@@ -364,6 +364,7 @@ func TestEntitlementHandler_TrialEligibility_FreshOrgAllowed(t *testing.T) {
func TestEntitlementHandler_DevModeMirrorsFeatureGateCapabilities(t *testing.T) {
t.Setenv("PULSE_DEV", "true")
+ t.Setenv("PULSE_MULTI_TENANT_ENABLED", "")
baseDir := t.TempDir()
mtp := config.NewMultiTenantPersistence(baseDir)
@@ -386,6 +387,9 @@ func TestEntitlementHandler_DevModeMirrorsFeatureGateCapabilities(t *testing.T)
if !containsCapability(payload.Capabilities, license.FeatureAdvancedReporting) {
t.Fatalf("expected dev entitlements to include %q, got %v", license.FeatureAdvancedReporting, payload.Capabilities)
}
+ if containsCapability(payload.Capabilities, license.FeatureMultiTenant) {
+ t.Fatalf("expected dev entitlements to omit %q while runtime flag is disabled, got %v", license.FeatureMultiTenant, payload.Capabilities)
+ }
if len(payload.UpgradeReasons) != 0 {
t.Fatalf("expected no upgrade reasons in dev mode, got %v", payload.UpgradeReasons)
}
@@ -401,6 +405,33 @@ func TestEntitlementHandler_DevModeMirrorsFeatureGateCapabilities(t *testing.T)
}
}
+func TestEntitlementHandler_DevModeIncludesMultiTenantWhenRuntimeEnabled(t *testing.T) {
+ t.Setenv("PULSE_DEV", "true")
+ t.Setenv("PULSE_MULTI_TENANT_ENABLED", "true")
+
+ baseDir := t.TempDir()
+ mtp := config.NewMultiTenantPersistence(baseDir)
+ h := NewLicenseHandlers(mtp, false)
+
+ ctx := context.WithValue(context.Background(), OrgIDContextKey, "default")
+ req := httptest.NewRequest(http.MethodGet, "/api/license/entitlements", nil).WithContext(ctx)
+ rec := httptest.NewRecorder()
+ h.HandleEntitlements(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("status=%d, want %d: %s", rec.Code, http.StatusOK, rec.Body.String())
+ }
+
+ var payload EntitlementPayload
+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {
+ t.Fatalf("unmarshal payload failed: %v", err)
+ }
+
+ if !containsCapability(payload.Capabilities, license.FeatureMultiTenant) {
+ t.Fatalf("expected dev entitlements to include %q when runtime flag is enabled, got %v", license.FeatureMultiTenant, payload.Capabilities)
+ }
+}
+
func TestEntitlementHandler_TrialEligibility_AlreadyUsedDenied(t *testing.T) {
baseDir := t.TempDir()
mtp := config.NewMultiTenantPersistence(baseDir)
diff --git a/pkg/licensing/dev_mode_features.go b/pkg/licensing/dev_mode_features.go
new file mode 100644
index 0000000000..a5dbc5c92d
--- /dev/null
+++ b/pkg/licensing/dev_mode_features.go
@@ -0,0 +1,28 @@
+package licensing
+
+import (
+ "os"
+ "sort"
+ "strings"
+)
+
+func devModeFeatures() []string {
+ known := allKnownFeatures()
+ filtered := make([]string, 0, len(known))
+ for _, feature := range known {
+ if devModeFeatureEnabled(feature) {
+ filtered = append(filtered, feature)
+ }
+ }
+ sort.Strings(filtered)
+ return filtered
+}
+
+func devModeFeatureEnabled(feature string) bool {
+ switch feature {
+ case FeatureMultiTenant:
+ return strings.EqualFold(strings.TrimSpace(os.Getenv("PULSE_MULTI_TENANT_ENABLED")), "true")
+ default:
+ return true
+ }
+}
diff --git a/pkg/licensing/service.go b/pkg/licensing/service.go
index 28f71715a5..d8d5965530 100644
--- a/pkg/licensing/service.go
+++ b/pkg/licensing/service.go
@@ -469,7 +469,7 @@ func (s *Service) IsValid() bool {
func (s *Service) HasFeature(feature string) bool {
// In demo mode or dev mode, grant all Pro features
if isDemoMode() || isDevMode() {
- return true
+ return devModeFeatureEnabled(feature)
}
s.mu.Lock() // Need write lock since we may update grace period
@@ -634,7 +634,7 @@ func (s *Service) Status() *LicenseStatus {
}
}
if isDemoMode() || isDevMode() {
- status.Features = allKnownFeatures()
+ status.Features = devModeFeatures()
}
return status
}
@@ -692,7 +692,7 @@ func (s *Service) Status() *LicenseStatus {
}
if isDemoMode() || isDevMode() {
- status.Features = allKnownFeatures()
+ status.Features = devModeFeatures()
}
return status
diff --git a/pkg/licensing/service_activate_test.go b/pkg/licensing/service_activate_test.go
index d1ac9c2b40..545f915a3f 100644
--- a/pkg/licensing/service_activate_test.go
+++ b/pkg/licensing/service_activate_test.go
@@ -169,8 +169,9 @@ func TestServiceStatusMissingJWTCloudPlanFailsClosed(t *testing.T) {
}
}
-func TestServiceStatus_DevModeAdvertisesAllKnownFeaturesWithoutLicense(t *testing.T) {
+func TestServiceStatus_DevModeAdvertisesOnlyRuntimeEnabledFeaturesWithoutLicense(t *testing.T) {
t.Setenv("PULSE_DEV", "true")
+ t.Setenv("PULSE_MULTI_TENANT_ENABLED", "")
svc := NewService()
status := svc.Status()
@@ -182,11 +183,32 @@ func TestServiceStatus_DevModeAdvertisesAllKnownFeaturesWithoutLicense(t *testin
t.Fatalf("status.Tier=%q, want %q", status.Tier, TierFree)
}
- for _, feature := range allKnownFeatures() {
+ for _, feature := range devModeFeatures() {
if !containsStringValue(status.Features, feature) {
t.Fatalf("status.Features missing %q in dev mode: %v", feature, status.Features)
}
}
+ if svc.HasFeature(FeatureMultiTenant) {
+ t.Fatalf("HasFeature(%q)=true, want false when runtime flag is disabled", FeatureMultiTenant)
+ }
+ if containsStringValue(status.Features, FeatureMultiTenant) {
+ t.Fatalf("status.Features unexpectedly includes %q when runtime flag is disabled: %v", FeatureMultiTenant, status.Features)
+ }
+}
+
+func TestServiceStatus_DevModeIncludesMultiTenantWhenRuntimeEnabled(t *testing.T) {
+ t.Setenv("PULSE_DEV", "true")
+ t.Setenv("PULSE_MULTI_TENANT_ENABLED", "true")
+
+ svc := NewService()
+ status := svc.Status()
+
+ if !containsStringValue(status.Features, FeatureMultiTenant) {
+ t.Fatalf("status.Features missing %q when runtime flag is enabled: %v", FeatureMultiTenant, status.Features)
+ }
+ if !svc.HasFeature(FeatureMultiTenant) {
+ t.Fatalf("HasFeature(%q)=false, want true when runtime flag is enabled", FeatureMultiTenant)
+ }
}
func containsStringValue(values []string, want string) bool {