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.

Track v6 install version through licensing runtime

rcourtman7cac04e2ff85
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 7d3ac042c7..fd52f877c8 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -266,6 +266,13 @@ an add-only capacity posture.
code must treat the resulting activation-state callback as commercial
ownership cleanup only, not as install inventory proof or fleet enrollment
state.
+ That same adjacent commercial boundary also owns authenticated
+ install-version attribution for migrated installs: lifecycle surfaces may
+ observe versioned commercial status, but they must not treat
+ activation/exchange/refresh version fields as installer enrollment state,
+ invent a second fleet-version cache, or backfill install lineage from
+ local host inventory when the shared licensing runtime already sends the
+ canonical process version.
That same adjacent commercial boundary also owns internal demo-fixture
grants: lifecycle surfaces may observe that a governed demo runtime is
fixture-backed, but they must not mint, echo, or infer the internal
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 437fb01f44..fad68db3f1 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -124,6 +124,13 @@ Own canonical runtime payload shapes between backend and frontend.
37. `internal/api/enterprise_extension_rbac_admin.go` shared with `organization-settings`: RBAC admin extension endpoints are both an organization settings control surface and a canonical API payload contract boundary.
38. `internal/api/licensing_bridge.go` shared with `cloud-paid`: commercial licensing bridge handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
39. `internal/api/licensing_handlers.go` shared with `cloud-paid`: commercial licensing handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
+ That same shared licensing boundary also owns authenticated
+ install-version attribution: `internal/api/router.go` must hand the
+ canonical process `serverVersion` into `internal/api/licensing_handlers.go`,
+ and the shared licensing runtime must carry that exact value through
+ `/v1/activate`, `/v1/licenses/exchange`, and `/v1/grants/refresh` so
+ migrated installs can be attributed to exact builds without inventing a
+ second version source or trusting browser-supplied version hints.
40. `internal/api/notifications.go` shared with `notifications`: notification handlers are both a notification delivery control surface and a canonical API payload contract boundary.
41. `internal/api/org_handlers.go` shared with `organization-settings`: organization management handlers are both an organization settings control surface and a canonical API payload contract boundary.
42. `internal/api/org_lifecycle_handlers.go` shared with `organization-settings`: organization lifecycle handlers are both an organization settings control surface and a canonical API payload contract boundary.
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index ed94de7d29..4f199ba6c4 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -90,6 +90,13 @@ agreement, and cloud-specific enforcement rules.
1. `frontend-modern/src/components/Settings/MonitoredSystemAdmissionPreview.tsx` shared with `agent-lifecycle`: the monitored-system admission preview is both a platform-connections lifecycle surface and a canonical cloud-paid monitored-system presentation boundary.
2. `internal/api/licensing_bridge.go` shared with `api-contracts`: commercial licensing bridge handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
3. `internal/api/licensing_handlers.go` shared with `api-contracts`: commercial licensing handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
+ That same shared licensing boundary also owns installation-version
+ continuity for authenticated v6 installs: `internal/api/router.go` and
+ `internal/api/licensing_handlers.go` must hand the canonical process
+ version into `pkg/licensing/service.go` and `pkg/licensing/grant_refresh.go`,
+ and cloud-paid transport must send that value on activate, legacy exchange,
+ and grant refresh instead of inferring install version from browser state,
+ dev build metadata, or anonymous telemetry.
4. `internal/api/payments_webhook_handlers.go` shared with `api-contracts`: commercial payment webhook handlers carry both API payload contract and cloud-paid billing boundary ownership.
5. `internal/api/public_signup_handlers.go` shared with `api-contracts`: hosted signup handlers carry both API payload contract and cloud-paid hosted provisioning boundary ownership.
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 6194e7868e..d7caae776e 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -198,6 +198,12 @@ regression protection.
chart-transport hot paths, fold summary-card caching into commercial
callback behavior, or reuse those public auth endpoints as a justification
for relaxing the protected history payload budgets that belong elsewhere.
+ That same shared callback path must also keep install-version attribution
+ O(1): `internal/api/router.go` may pass the cached process
+ `serverVersion` into `internal/api/licensing_handlers.go`, but
+ performance work must not add filesystem reads, GitHub release lookups, or
+ other per-request version discovery on activation, legacy exchange, or
+ grant-refresh traffic just to stamp authenticated install metadata.
30. Keep dashboard summary-chart fetches scope-owned rather than page-churn-owned: `frontend-modern/src/hooks/useDashboardTrends.ts` must hydrate infrastructure and storage summaries once per org/range scope from the canonical summary caches and recompute card presentation locally as the compact dashboard overview changes, rather than refetching the infrastructure-summary transport in `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`, the dashboard storage-summary trend transport in `frontend-modern/src/utils/storageSummaryTrendCache.ts`, or the storage-page summary transport in `frontend-modern/src/utils/storageSummaryCache.ts` for every top-resource or card reshuffle on the same dashboard load. That dashboard infrastructure path must also request only the metrics it renders through the canonical infrastructure-summary route owned by `internal/api/router_routes_monitoring.go` and `internal/api/router.go`; the dashboard may not pay for disk or network summary series when it only renders CPU and memory. App-shell prewarm in `frontend-modern/src/useAppRuntimeState.ts` must not front-run that dashboard-specific route while the operator is already on the root dashboard route owned by `frontend-modern/src/App.tsx`.
The same hot path must keep mock/demo chart identity on the canonical
unified snapshot too: when mock mode is enabled, `internal/api/router.go`
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 717ebd26b8..8def93bfc6 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -278,6 +278,13 @@ querying, and the operator-facing storage health presentation layer.
must treat the resulting activation-state callback as commercial ownership
cleanup only, not as protected-inventory proof or recovery entitlement
state.
+ That same adjacent commercial boundary also owns authenticated
+ install-version attribution: storage and recovery may read the resulting
+ licensed build context as commercial metadata, but they must not cache a
+ second recovery-local version floor, derive restore eligibility from
+ activation-version payloads, or backfill release lineage from protected
+ inventory when the shared licensing runtime already sends the canonical
+ process version.
That same adjacent commercial boundary also owns internal demo-fixture
capability handling: storage and recovery may render the resulting demo
runtime as populated mock inventory, but they must not expose
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index cd4ec1f363..583f5a1cfa 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -5429,6 +5429,7 @@ func TestContract_EntitlementUsageSnapshotWaitsForSettledSupplementalInventory(t
func TestContract_LegacyMigrationGrandfatherFloorJSONSnapshot(t *testing.T) {
t.Setenv("PULSE_LICENSE_DEV_MODE", "false")
+ const expectedClientVersion = "6.0.0-rc.1"
grantJWT, grantPublicKey, err := pkglicensing.GenerateGrantJWTForTesting(pkglicensing.GrantClaims{
LicenseID: "lic_contract_floor",
@@ -5451,6 +5452,13 @@ func TestContract_LegacyMigrationGrandfatherFloorJSONSnapshot(t *testing.T) {
if r.URL.Path != "/v1/licenses/exchange" {
t.Fatalf("path = %q, want /v1/licenses/exchange", r.URL.Path)
}
+ var exchangeReq pkglicensing.ExchangeLegacyLicenseRequest
+ if err := json.NewDecoder(r.Body).Decode(&exchangeReq); err != nil {
+ t.Fatalf("decode exchange request: %v", err)
+ }
+ if exchangeReq.ClientVersion != expectedClientVersion {
+ t.Fatalf("exchange client version=%q, want %q", exchangeReq.ClientVersion, expectedClientVersion)
+ }
w.WriteHeader(http.StatusCreated)
_ = json.NewEncoder(w).Encode(pkglicensing.ActivateInstallationResponse{
License: pkglicensing.ActivateResponseLicense{
@@ -5494,6 +5502,7 @@ func TestContract_LegacyMigrationGrandfatherFloorJSONSnapshot(t *testing.T) {
}
handlers := NewLicenseHandlers(mtp, false)
+ handlers.SetRuntimeVersion(expectedClientVersion)
handlers.SetMonitors(buildGrandfatherFloorMonitor(23), nil)
t.Cleanup(handlers.StopAllBackgroundLoops)
diff --git a/internal/api/licensing_handlers.go b/internal/api/licensing_handlers.go
index b48f1f1f8f..e426fcae2a 100644
--- a/internal/api/licensing_handlers.go
+++ b/internal/api/licensing_handlers.go
@@ -71,6 +71,7 @@ type LicenseHandlers struct {
conversionHealth *conversionPipelineHealth
hostedLeaseRefresh sync.Map // map[string]*hostedEntitlementRefreshLoop
legacyGrandfatherReconcile sync.Map // map[string]*legacyGrandfatherReconcileLoop
+ runtimeVersion string
}
// NewLicenseHandlers creates a new license handlers instance.
@@ -117,6 +118,13 @@ func (h *LicenseHandlers) SetConfig(cfg *config.Config) {
h.cfg = cfg
}
+func (h *LicenseHandlers) SetRuntimeVersion(version string) {
+ if h == nil {
+ return
+ }
+ h.runtimeVersion = strings.TrimSpace(version)
+}
+
// SetConversionRecorder wires the conversion event recorder for backend-emitted
// conversion events (trial_started, license_activated, license_activation_failed).
func (h *LicenseHandlers) SetConversionRecorder(rec *conversionRecorder, health *conversionPipelineHealth) {
@@ -502,6 +510,7 @@ func (h *LicenseHandlers) getTenantComponents(ctx context.Context) (*licenseServ
// Check if service already exists
if v, ok := h.services.Load(orgID); ok {
svc := v.(*licenseService)
+ svc.SetClientVersion(h.runtimeVersion)
if err := h.ensureEvaluatorForOrg(orgID, svc); err != nil {
log.Warn().Str("org_id", orgID).Err(err).Msg("Failed to refresh license evaluator for org")
}
@@ -522,6 +531,7 @@ func (h *LicenseHandlers) getTenantComponents(ctx context.Context) (*licenseServ
}
service := newLicenseService()
+ service.SetClientVersion(h.runtimeVersion)
h.bindLegacyGrandfatherReconcileOwnership(orgID, service)
// Wire license server client and persistence so activation / refresh can use them.
diff --git a/internal/api/router.go b/internal/api/router.go
index c4b2c8db12..363e27229d 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -421,6 +421,7 @@ func (r *Router) setupRoutes() {
}
r.configProfileHandler = NewConfigProfileHandler(r.multiTenant)
r.licenseHandlers = NewLicenseHandlers(r.multiTenant, r.hostedMode, r.config)
+ r.licenseHandlers.SetRuntimeVersion(r.serverVersion)
r.licenseHandlers.SetMonitors(r.monitor, r.mtMonitor)
rbacProvider := NewTenantRBACProvider(r.config.DataPath)
r.rbacProvider = rbacProvider
diff --git a/pkg/licensing/grant_refresh.go b/pkg/licensing/grant_refresh.go
index 43f002fbb9..dbd0a16179 100644
--- a/pkg/licensing/grant_refresh.go
+++ b/pkg/licensing/grant_refresh.go
@@ -182,6 +182,7 @@ func (s *Service) refreshGrantOnce(ctx context.Context) error {
client := s.serverClient
state := s.activationState
persistence := s.persistence
+ clientVersion := s.clientVersion
s.mu.RUnlock()
if client == nil {
@@ -195,6 +196,7 @@ func (s *Service) refreshGrantOnce(ctx context.Context) error {
InstallationID: state.InstallationID,
InstanceFingerprint: state.InstanceFingerprint,
CurrentGrantJTI: state.GrantJTI,
+ ClientVersion: clientVersion,
}
resp, err := client.RefreshGrant(ctx, state.InstallationID, state.InstallationToken, req)
diff --git a/pkg/licensing/grant_refresh_test.go b/pkg/licensing/grant_refresh_test.go
index 57d6083398..620dec83aa 100644
--- a/pkg/licensing/grant_refresh_test.go
+++ b/pkg/licensing/grant_refresh_test.go
@@ -27,6 +27,7 @@ func TestGrantRefreshLoop_StartStop(t *testing.T) {
func TestGrantRefreshLoop_RefreshesGrant(t *testing.T) {
setupTestPublicKey(t)
+ const expectedClientVersion = "6.0.0-rc.1"
// Set up a mock license server that serves a new grant on refresh.
var refreshCount atomic.Int32
@@ -40,6 +41,13 @@ func TestGrantRefreshLoop_RefreshesGrant(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
refreshCount.Add(1)
+ var req RefreshGrantRequest
+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
+ t.Fatalf("decode refresh request: %v", err)
+ }
+ if req.ClientVersion != expectedClientVersion {
+ t.Fatalf("ClientVersion = %q, want %q", req.ClientVersion, expectedClientVersion)
+ }
json.NewEncoder(w).Encode(RefreshGrantResponse{
Grant: GrantEnvelope{
JWT: newGrantJWT,
@@ -61,6 +69,7 @@ func TestGrantRefreshLoop_RefreshesGrant(t *testing.T) {
svc := NewService()
svc.SetLicenseServerClient(NewLicenseServerClient(server.URL))
+ svc.SetClientVersion(expectedClientVersion)
svc.mu.Lock()
svc.activationState = &ActivationState{
InstallationID: "inst_test",
diff --git a/pkg/licensing/service.go b/pkg/licensing/service.go
index 1efb62e6ce..e2bd4727d1 100644
--- a/pkg/licensing/service.go
+++ b/pkg/licensing/service.go
@@ -95,6 +95,10 @@ type Service struct {
// Persistence reference for activation state save/load. Set via SetPersistence.
persistence *Persistence
+
+ // Canonical runtime version supplied by the owning process. This is used for
+ // authenticated installation/version attribution on activation and refresh.
+ clientVersion string
}
// DefaultGracePeriod is the duration after license expiration during which
@@ -230,6 +234,7 @@ func (s *Service) ActivateWithKey(activationKey string) (*License, error) {
s.mu.RLock()
client := s.serverClient
persistence := s.persistence
+ clientVersion := s.clientVersion
s.mu.RUnlock()
if client == nil {
@@ -247,6 +252,7 @@ func (s *Service) ActivateWithKey(activationKey string) (*License, error) {
ActivationKey: activationKey,
InstanceFingerprint: fingerprint,
InstanceName: hostname,
+ ClientVersion: clientVersion,
}
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
@@ -265,6 +271,7 @@ func (s *Service) ActivateLegacyLicense(legacyLicenseKey string) (*License, erro
s.mu.RLock()
client := s.serverClient
persistence := s.persistence
+ clientVersion := s.clientVersion
s.mu.RUnlock()
if client == nil {
@@ -281,6 +288,7 @@ func (s *Service) ActivateLegacyLicense(legacyLicenseKey string) (*License, erro
LegacyLicenseKey: legacyLicenseKey,
InstanceFingerprint: fingerprint,
InstanceName: hostname,
+ ClientVersion: clientVersion,
}
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
@@ -383,6 +391,14 @@ func (s *Service) SetLicenseServerClient(client *LicenseServerClient) {
s.serverClient = client
}
+// SetClientVersion records the canonical runtime version for authenticated
+// installation/version attribution on activation and grant refresh.
+func (s *Service) SetClientVersion(version string) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ s.clientVersion = strings.TrimSpace(version)
+}
+
// SetPersistence sets the persistence reference for activation state save/load.
func (s *Service) SetPersistence(p *Persistence) {
s.mu.Lock()
diff --git a/pkg/licensing/service_activate_test.go b/pkg/licensing/service_activate_test.go
index dad2184881..fb9c950d1c 100644
--- a/pkg/licensing/service_activate_test.go
+++ b/pkg/licensing/service_activate_test.go
@@ -13,6 +13,7 @@ import (
func TestServiceActivate_ExchangesLegacyJWTOutsideDevMode(t *testing.T) {
t.Setenv("PULSE_LICENSE_DEV_MODE", "false")
setupTestPublicKey(t)
+ const expectedClientVersion = "6.0.0-rc.1"
tests := []struct {
name string
@@ -52,6 +53,9 @@ func TestServiceActivate_ExchangesLegacyJWTOutsideDevMode(t *testing.T) {
if req.LegacyLicenseKey != licenseKey {
t.Fatalf("LegacyLicenseKey = %q, want %q", req.LegacyLicenseKey, licenseKey)
}
+ if req.ClientVersion != expectedClientVersion {
+ t.Fatalf("ClientVersion = %q, want %q", req.ClientVersion, expectedClientVersion)
+ }
w.WriteHeader(http.StatusCreated)
_ = json.NewEncoder(w).Encode(ActivateInstallationResponse{
@@ -75,6 +79,7 @@ func TestServiceActivate_ExchangesLegacyJWTOutsideDevMode(t *testing.T) {
defer server.Close()
svc.SetLicenseServerClient(NewLicenseServerClient(server.URL))
+ svc.SetClientVersion(expectedClientVersion)
lic, err := svc.Activate(licenseKey)
if err != nil {
@@ -95,6 +100,65 @@ func TestServiceActivate_ExchangesLegacyJWTOutsideDevMode(t *testing.T) {
}
}
+func TestServiceActivateWithKey_SendsClientVersion(t *testing.T) {
+ t.Setenv("PULSE_LICENSE_DEV_MODE", "false")
+ setupTestPublicKey(t)
+ const expectedClientVersion = "6.0.0-rc.1"
+
+ grantJWT := makeTestGrantJWT(t, &GrantClaims{
+ LicenseID: "lic_native",
+ Tier: "pro",
+ State: "active",
+ IssuedAt: time.Now().Unix(),
+ ExpiresAt: time.Now().Add(72 * time.Hour).Unix(),
+ })
+
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/v1/activate" {
+ t.Fatalf("Path = %q, want /v1/activate", r.URL.Path)
+ }
+
+ var req ActivateInstallationRequest
+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
+ t.Fatalf("decode request: %v", err)
+ }
+ if req.ActivationKey != "ppk_live_native_test" {
+ t.Fatalf("ActivationKey = %q, want ppk_live_native_test", req.ActivationKey)
+ }
+ if req.ClientVersion != expectedClientVersion {
+ t.Fatalf("ClientVersion = %q, want %q", req.ClientVersion, expectedClientVersion)
+ }
+
+ w.WriteHeader(http.StatusCreated)
+ _ = json.NewEncoder(w).Encode(ActivateInstallationResponse{
+ License: ActivateResponseLicense{
+ LicenseID: "lic_native",
+ State: "active",
+ Tier: "pro",
+ },
+ Installation: ActivateResponseInstallation{
+ InstallationID: "inst_native",
+ InstallationToken: "pit_live_native",
+ Status: "active",
+ },
+ Grant: GrantEnvelope{
+ JWT: grantJWT,
+ JTI: "grant_native",
+ ExpiresAt: time.Now().Add(72 * time.Hour).UTC().Format(time.RFC3339),
+ },
+ })
+ }))
+ defer server.Close()
+
+ svc := NewService()
+ svc.SetLicenseServerClient(NewLicenseServerClient(server.URL))
+ svc.SetClientVersion(expectedClientVersion)
+
+ if _, err := svc.Activate("ppk_live_native_test"); err != nil {
+ t.Fatalf("Activate: %v", err)
+ }
+}
+
func TestServiceActivate_AllowsLegacyJWTInDevMode(t *testing.T) {
t.Setenv("PULSE_LICENSE_DEV_MODE", "true")