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.

feat(telemetry): add business_estate to the ping at schema v8

rcourtman5b07bdc3d8ea
diff --git a/docs/PRIVACY.md b/docs/PRIVACY.md
index f953af622e..827661007b 100644
--- a/docs/PRIVACY.md
+++ b/docs/PRIVACY.md
@@ -108,6 +108,7 @@ Every field is listed below with the reason it exists. Nothing else is included
| SSO enabled | `true`/`false` | See whether single-sign-on support is being used |
| Multi-tenant | `true`/`false` | See whether multi-tenant/runtime-org features are being used |
| Paid license | `true`/`false` | Distinguish free from paid posture without sending the exact commercial tier |
+| Business estate | `true`/`false` | Mark whether the resource counts above cross a business-scale threshold, derived on the install from counts already in this payload; no extra infrastructure detail is sent |
| Has API tokens | `true`/`false` | See whether token-based automation/integration is being used without sending token counts |
| RBAC custom roles | `3` | Count roles created by the operator, excluding the roles that ship built in, without sending role names, permissions, or scopes |
| RBAC user assignments | `7` | Count user-to-role assignments without sending usernames, role names, or permissions |
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 0794b05702..6d79a7edb0 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -5932,3 +5932,16 @@ ack invokes the hook — observer acks never steer the updater
`TestAgentSendReport_ObserverAckNeverInvokesCallback`).
`agentupdate.Config.InitialCheckDelay` overrides the five-second initial check
delay; zero keeps the default.
+### Session-capability estate classification delegates to monitoring
+
+The business-estate marker on the authenticated session-capability surface
+(`internal/api/security_status_capabilities.go`, an extension point of this
+subsystem's agent routes) no longer carries its own threshold constants:
+`businessScaleEstateCounts` now delegates to the monitoring-owned definition
+in `internal/monitoring/business_estate.go`, which the schema-v8 telemetry
+`business_estate` field also classifies against. Behavior is unchanged — the
+agent-host counting inputs (Docker hosts from read state, VMware agent-type
+unified resources) and the pinned thresholds
+(`TestContract_BusinessScaleEstateThresholds`) are identical; only the source
+of the numbers moved, so the card cohort and the telemetry cohort cannot
+drift.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index c8f46a3f5c..ee69e90899 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -8939,6 +8939,26 @@ together: `type Ping struct` in `internal/telemetry/telemetry.go`, the
Retired columns stay in the live receiver database rather than being dropped:
migrations only add, the columns hold real rows from the schema-v6 window, and
nothing writes them once the receiver struct loses the fields.
+### Telemetry payload parity spans three surfaces at schema v8
+
+The outbound telemetry contract stays defined in exactly three places that move
+together: `type Ping struct` in `internal/telemetry/telemetry.go`, the
+`var ping struct` receiver in the private license server, and
+`export interface TelemetryPingPreview` in
+`frontend-modern/src/api/settings.ts`, all checked by
+`scripts/check_telemetry_schema_parity.py`. Schema v8 adds `business_estate`,
+a boolean the install derives inside the `pkg/server` snapshot closure from
+the same `AggregateInstallSnapshotCounts` values the payload already carries.
+The thresholds (>=5 PVE nodes, >=10 Docker hosts, or >=3 VMware hosts) live in
+exactly one place, `internal/monitoring/business_estate.go`, and the
+session-capability surface that drives the in-product business-estate card
+(`internal/api/security_status_capabilities.go`) delegates to that same
+definition, so the card cohort and the telemetry cohort cannot drift apart
+(`TestContract_BusinessScaleEstateThresholds`,
+`TestInstallSnapshotCountsBusinessScaleEstate`). The flag reveals nothing the
+resource counts in the payload do not already reveal; it exists so
+receiver-side cohort queries keep a stable column even if the thresholds
+change in a later schema.
### Per-tenant resource stores are released on offboarding and shutdown
`ResourceHandlers.getStore` opens a SQLite handle per org and caches it for the
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 9be0c4ef7f..04c514466d 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -2848,3 +2848,20 @@ Known and deliberately unchanged: each changed guest still triggers a full-file
save, so one poll cycle over N changed guests performs N marshals and N atomic
writes that serialize on the store mutex. Coalescing them is a behavioural
change beyond the shutdown defect.
+### Business-scale estate classification is monitoring-owned
+
+`internal/monitoring/business_estate.go` holds the single definition of the
+business-scale estate thresholds (>=5 PVE nodes, >=10 Docker hosts, or >=3
+VMware hosts, from the 2026-08-07 telemetry segmentation): exported constants,
+`BusinessScaleEstateCounts`, and `InstallSnapshotCounts.BusinessScaleEstate`.
+Both consumers delegate here rather than restating numbers: the authenticated
+session-capability surface behind the in-product business-estate card
+(`internal/api/security_status_capabilities.go`) and the schema-v8 telemetry
+snapshot in `pkg/server`, which derives the `business_estate` boolean from the
+same `AggregateInstallSnapshotCounts` values the ping already carries. The
+counts-derived method is pinned by
+`TestInstallSnapshotCountsBusinessScaleEstate`
+(`internal/monitoring/canonical_guardrails_test.go`) and the threshold values
+by `TestContract_BusinessScaleEstateThresholds` in `internal/api`; the
+`pkg/server` wiring is pinned by
+`TestTelemetrySnapshotDerivesBusinessEstateFromAggregateCounts`.
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index bf2be4657c..1c4dc689d8 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -1926,6 +1926,20 @@ actor, and every audit row read stay on the install.
`TestWithAuditReadActivity_RecordIsContentFree` and
`TestRecordAuditReadActivity_RejectsUnknownActivity` pin both properties.
+### Business-estate telemetry is classification, not new information
+
+Schema v8's `business_estate` boolean is derived on the install, inside the
+`pkg/server` telemetry snapshot closure, from the same aggregate resource
+counts (`pve_nodes`, `docker_hosts`, `vmware_hosts`) the payload already
+sends; no additional infrastructure detail leaves the install. It is the
+telemetry counterpart of the authenticated
+`sessionCapabilities.businessEstate` marker and classifies against the same
+single threshold definition in `internal/monitoring/business_estate.go`. The
+authenticated-only tiering rule above is unaffected: telemetry pings are
+pseudonymous outbound payloads under the standing telemetry opt-out, not a
+pre-auth API surface. Both PRIVACY.md copies document the field alongside the
+counts it is derived from.
+
### Licensed-feature adoption fields must discriminate
`telemetry.LicensedFeatureAdoptionFields` registers every telemetry field whose
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 343696ecbf..8ecef4c5d8 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -5036,3 +5036,12 @@ running server's version at router wiring time
ingest path's persistence surface — agent-id continuity and host state — is
unchanged by the echo
(`TestHostAgentRemovalLifecycleThroughAuthenticatedRouterAndRestart`).
+### Estate-threshold delegation leaves capability persistence untouched
+
+`internal/api/security_status_capabilities.go` (named in this contract's
+extension points) changed only in where its business-estate thresholds live:
+it now delegates to `internal/monitoring/business_estate.go`, shared with the
+schema-v8 telemetry `business_estate` field. The capability read path stays a
+pure in-memory classification over monitor state — no storage surface, store
+handle, or persistence behavior is introduced or altered
+(`TestContract_BusinessScaleEstateThresholds` pins the unchanged thresholds).
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index b15c66b6b9..d450b722e7 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,18 +1,17 @@
{
"version": 1,
- "base_sha": "6a36b5f8ef34a87d613ff113712be758c7b9ceff",
- "verified_at": "2026-08-07T14:05:00Z",
"result": "passed",
+ "base_sha": "2aa43058b7bb700dcd19b8068178e92d14ded583",
+ "verified_at": "2026-08-07T14:03:33Z",
"changed_paths": [
- "frontend-modern/src/api/patrol.ts",
- "frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx"
+ "frontend-modern/src/api/settings.ts"
],
"content_sha256": {
- "frontend-modern/src/api/patrol.ts": "c15184ae7f1e0443d53ab54ab4d9349d349b0571042b84429cbee10c958dc11b",
- "frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx": "7cd20de990cab862718c7495e5314ab9143b3101fd565a1eaa4a273b4780ca88"
+ "frontend-modern/src/api/settings.ts": "de9f9d21e26270464bc7402a969dd56f356494e976e4bb483884850d8b148901"
},
"routes": [
- "/alerts/overview"
+ "/",
+ "/settings (System > General panel via settings search)"
],
"viewports": [
{
@@ -25,12 +24,13 @@
}
],
"states": [
- "Alerts Overview with seventeen active alerts on the live dev estate, each row offering the Have Patrol investigate primary action",
- "Post-click state after triggering a scoped Patrol run against the pve5 connectivity alert"
+ "free Community tier served by an isolated worktree backend (PULSE_MOCK_MODE=true, 6 mock PVE nodes) on port 7698",
+ "sessionCapabilities.businessEstate=true confirmed via /api/security/status after the threshold helper moved to internal/monitoring",
+ "telemetry preview payload rendered in Settings > System > General showing schema_version 8 with business_estate: true alongside pve_nodes: 6 and paid_license: false"
],
"interactions": [
- "Clicked Have Patrol investigate on the pve5 connectivity alert and captured the POST to /api/ai/patrol/run returning 200 with success true and message Triggered targeted Patrol check, where the same click previously returned 400 invalid_patrol_scope",
- "Confirmed the request body carried only resource_ids, alert_identifier, and alert_type",
- "Reloaded at 375x812 and confirmed the alerts surface renders with the investigate actions reachable"
+ "logged in as admin, opened Settings, searched for General, opened the Usage data and privacy section",
+ "clicked Preview payload and read the full rendered CURRENT HEARTBEAT PAYLOAD JSON including the new business_estate field",
+ "re-exercised the plan route and workspace at 375x812 to confirm the settings surfaces still render at narrow width"
]
}
diff --git a/frontend-modern/public/docs/PRIVACY.md b/frontend-modern/public/docs/PRIVACY.md
index f953af622e..827661007b 100644
--- a/frontend-modern/public/docs/PRIVACY.md
+++ b/frontend-modern/public/docs/PRIVACY.md
@@ -108,6 +108,7 @@ Every field is listed below with the reason it exists. Nothing else is included
| SSO enabled | `true`/`false` | See whether single-sign-on support is being used |
| Multi-tenant | `true`/`false` | See whether multi-tenant/runtime-org features are being used |
| Paid license | `true`/`false` | Distinguish free from paid posture without sending the exact commercial tier |
+| Business estate | `true`/`false` | Mark whether the resource counts above cross a business-scale threshold, derived on the install from counts already in this payload; no extra infrastructure detail is sent |
| Has API tokens | `true`/`false` | See whether token-based automation/integration is being used without sending token counts |
| RBAC custom roles | `3` | Count roles created by the operator, excluding the roles that ship built in, without sending role names, permissions, or scopes |
| RBAC user assignments | `7` | Count user-to-role assignments without sending usernames, role names, or permissions |
diff --git a/frontend-modern/src/api/__tests__/settings.test.ts b/frontend-modern/src/api/__tests__/settings.test.ts
index 8206b83726..c88b8041ab 100644
--- a/frontend-modern/src/api/__tests__/settings.test.ts
+++ b/frontend-modern/src/api/__tests__/settings.test.ts
@@ -63,6 +63,7 @@ const mockTelemetryPreviewPayload = {
sso_enabled: false,
multi_tenant: false,
paid_license: false,
+ business_estate: false,
has_api_tokens: true,
rbac_custom_roles: 0,
rbac_user_assignments: 0,
diff --git a/frontend-modern/src/api/settings.ts b/frontend-modern/src/api/settings.ts
index 3454c059d3..97b39a1a7b 100644
--- a/frontend-modern/src/api/settings.ts
+++ b/frontend-modern/src/api/settings.ts
@@ -64,6 +64,7 @@ export interface TelemetryPingPreview {
sso_enabled: boolean;
multi_tenant: boolean;
paid_license: boolean;
+ business_estate: boolean;
has_api_tokens: boolean;
rbac_custom_roles: number;
rbac_user_assignments: number;
diff --git a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
index 0db2ebeb30..bc04c49eb5 100644
--- a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
@@ -69,6 +69,7 @@ const buildTelemetryPreviewPayload = (
sso_enabled: false,
multi_tenant: false,
paid_license: false,
+ business_estate: false,
has_api_tokens: true,
rbac_custom_roles: 0,
rbac_user_assignments: 0,
diff --git a/internal/api/security_status_capabilities.go b/internal/api/security_status_capabilities.go
index c064b91ab1..41c48525a2 100644
--- a/internal/api/security_status_capabilities.go
+++ b/internal/api/security_status_capabilities.go
@@ -6,9 +6,9 @@ import (
"strings"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
+ "github.com/rcourtman/pulse-go-rewrite/internal/monitoring"
"github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
internalauth "github.com/rcourtman/pulse-go-rewrite/pkg/auth"
- pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing"
)
type securityStatusSettingsCapabilities struct {
@@ -274,7 +274,7 @@ func (r *Router) securityStatusSessionCapabilities(ctx context.Context) security
if r != nil && !demoMode && !r.hostedMode {
paidOrBranded := false
if svc := getLicenseServiceForContext(ctx); svc != nil {
- if lic := svc.Current(); lic != nil && lic.Claims.Tier != pkglicensing.TierFree {
+ if lic := svc.Current(); lic != nil && lic.Claims.Tier != licenseTierFreeValue {
paidOrBranded = true
}
if svc.HasFeature(featureWhiteLabelValue) {
@@ -292,20 +292,11 @@ func (r *Router) securityStatusSessionCapabilities(ctx context.Context) security
}
}
-// Business-scale estate thresholds. These mirror the segmentation used in the
-// 2026-08-07 telemetry read that motivated the commercial-surface revision:
-// installs at or above any one of these convert to paid at ~8x the rate of
-// smaller estates.
-const (
- businessEstateMinPVENodes = 5
- businessEstateMinDockerHosts = 10
- businessEstateMinVMwareHosts = 3
-)
-
+// businessScaleEstateCounts delegates to the canonical business-scale estate
+// definition in internal/monitoring, which the outbound telemetry snapshot
+// also classifies against.
func businessScaleEstateCounts(pveNodes, dockerHosts, vmwareHosts int) bool {
- return pveNodes >= businessEstateMinPVENodes ||
- dockerHosts >= businessEstateMinDockerHosts ||
- vmwareHosts >= businessEstateMinVMwareHosts
+ return monitoring.BusinessScaleEstateCounts(pveNodes, dockerHosts, vmwareHosts)
}
func (r *Router) businessScaleEstate(ctx context.Context) bool {
diff --git a/internal/monitoring/business_estate.go b/internal/monitoring/business_estate.go
new file mode 100644
index 0000000000..36d2beee6b
--- /dev/null
+++ b/internal/monitoring/business_estate.go
@@ -0,0 +1,27 @@
+package monitoring
+
+// Business-scale estate thresholds. These mirror the segmentation used in the
+// 2026-08-07 telemetry read that motivated the commercial-surface revision:
+// installs at or above any one of these convert to paid at ~8x the rate of
+// smaller estates. This is the single definition; the session capability
+// surface in internal/api and the outbound telemetry snapshot both classify
+// against it.
+const (
+ BusinessEstateMinPVENodes = 5
+ BusinessEstateMinDockerHosts = 10
+ BusinessEstateMinVMwareHosts = 3
+)
+
+// BusinessScaleEstateCounts reports whether the given counts cross any
+// business-scale estate threshold.
+func BusinessScaleEstateCounts(pveNodes, dockerHosts, vmwareHosts int) bool {
+ return pveNodes >= BusinessEstateMinPVENodes ||
+ dockerHosts >= BusinessEstateMinDockerHosts ||
+ vmwareHosts >= BusinessEstateMinVMwareHosts
+}
+
+// BusinessScaleEstate reports whether the install-wide aggregate counts cross
+// any business-scale estate threshold.
+func (c InstallSnapshotCounts) BusinessScaleEstate() bool {
+ return BusinessScaleEstateCounts(c.PVENodes, c.DockerHosts, c.VMwareHosts)
+}
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index 9831fb5daf..bb1ffb5baf 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -2813,3 +2813,29 @@ func TestMockGuestChartHistorySkipsMemoryUsedForNonProxmoxGuests(t *testing.T) {
}
}
}
+
+// The business-scale estate thresholds are monitoring-owned so the session
+// capability surface (internal/api) and the outbound telemetry snapshot
+// (pkg/server) classify against one definition. This pins the counts-derived
+// method used by telemetry; the API-side wrapper is pinned separately by
+// TestContract_BusinessScaleEstateThresholds in internal/api.
+func TestInstallSnapshotCountsBusinessScaleEstate(t *testing.T) {
+ cases := []struct {
+ name string
+ counts InstallSnapshotCounts
+ want bool
+ }{
+ {"empty estate", InstallSnapshotCounts{}, false},
+ {"homelab scale", InstallSnapshotCounts{PVENodes: 4, DockerHosts: 9, VMwareHosts: 2}, false},
+ {"pve threshold", InstallSnapshotCounts{PVENodes: 5}, true},
+ {"docker threshold", InstallSnapshotCounts{DockerHosts: 10}, true},
+ {"vmware threshold", InstallSnapshotCounts{VMwareHosts: 3}, true},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := tc.counts.BusinessScaleEstate(); got != tc.want {
+ t.Fatalf("BusinessScaleEstate() with %+v = %v, want %v", tc.counts, got, tc.want)
+ }
+ })
+ }
+}
diff --git a/internal/telemetry/telemetry.go b/internal/telemetry/telemetry.go
index e993ec79a9..6e313aa294 100644
--- a/internal/telemetry/telemetry.go
+++ b/internal/telemetry/telemetry.go
@@ -35,6 +35,7 @@
// - Whether SSO/OIDC is configured
// - Whether multi-tenant mode is enabled
// - Whether a paid license is active
+// - Whether the monitored estate crosses a business-scale threshold (a boolean derived from the resource counts above)
// - Whether any API tokens are configured
// - Aggregate alert fired/acknowledged/resolved counts over 30 days
// - Aggregate notification attempt/delivery/failure counts over seven days
@@ -147,7 +148,12 @@ const (
// count measured background write volume; neither discriminated an install
// that uses audit logging from one that merely has it. Reaching a
// license-gated audit read does.
- TelemetrySchemaVersion = 7
+ // Schema v8 adds business_estate, a server-derived boolean marking installs
+ // whose aggregate counts cross any business-scale estate threshold (the
+ // same single definition that drives the in-product business-estate card).
+ // The flag is derived from counts already present in the payload; it adds a
+ // stable cohort column so segmentation survives future threshold changes.
+ TelemetrySchemaVersion = 8
)
type installIDRecord struct {
@@ -233,6 +239,7 @@ type Ping struct {
SSOEnabled bool `json:"sso_enabled"`
MultiTenant bool `json:"multi_tenant"`
PaidLicense bool `json:"paid_license"`
+ BusinessEstate bool `json:"business_estate"`
HasAPITokens bool `json:"has_api_tokens"`
// Licensed-feature adoption. Counts only: no role names, schedule names,
@@ -382,6 +389,7 @@ type Snapshot struct {
SSOEnabled bool
MultiTenant bool
PaidLicense bool
+ BusinessEstate bool
HasAPITokens bool
RBACCustomRoles int
RBACUserAssignments int
@@ -972,6 +980,7 @@ func applySnapshot(base Ping, fn SnapshotFunc) Ping {
ping.SSOEnabled = s.SSOEnabled
ping.MultiTenant = s.MultiTenant
ping.PaidLicense = s.PaidLicense
+ ping.BusinessEstate = s.BusinessEstate
ping.HasAPITokens = s.HasAPITokens
ping.RBACCustomRoles = s.RBACCustomRoles
ping.RBACUserAssignments = s.RBACUserAssignments
diff --git a/internal/telemetry/telemetry_test.go b/internal/telemetry/telemetry_test.go
index 7186c5d9c1..46a840604e 100644
--- a/internal/telemetry/telemetry_test.go
+++ b/internal/telemetry/telemetry_test.go
@@ -355,6 +355,7 @@ func TestApplySnapshot(t *testing.T) {
AlertAIEnabled: true,
ActiveAlerts: 2,
PaidLicense: true,
+ BusinessEstate: true,
HasAPITokens: true,
RBACCustomRoles: 3,
RBACUserAssignments: 7,
@@ -464,6 +465,9 @@ func TestApplySnapshot(t *testing.T) {
if !ping.PaidLicense {
t.Fatal("PaidLicense should be true")
}
+ if !ping.BusinessEstate {
+ t.Fatal("BusinessEstate should be true")
+ }
if !ping.HasAPITokens {
t.Fatal("HasAPITokens should be true")
}
diff --git a/pkg/server/server.go b/pkg/server/server.go
index 1267deb1ed..bc886c88a9 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -551,6 +551,9 @@ func Run(ctx context.Context, version string) error {
snap.NotificationFailuresConfiguration7d = counts.NotificationFailuresConfiguration7d
snap.NotificationFailuresRejected7d = counts.NotificationFailuresRejected7d
snap.NotificationFailuresUnknown7d = counts.NotificationFailuresUnknown7d
+ // Coarse business-scale classification derived from the same
+ // aggregate counts; thresholds live in internal/monitoring.
+ snap.BusinessEstate = counts.BusinessScaleEstate()
snap.DiscoveryEnabled = currentCfg.DiscoveryEnabled
// Feature flags from persisted config (using pre-created persistence).
diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go
index 84e8ee74ce..015d66a894 100644
--- a/pkg/server/server_test.go
+++ b/pkg/server/server_test.go
@@ -375,3 +375,25 @@ func TestServerRun_RejectsWildcardTrustedProxyCIDR(t *testing.T) {
t.Fatalf("expected wildcard trusted proxy configuration to be rejected, got %v", err)
}
}
+
+// The telemetry snapshot closure in Run is not directly invocable, so this
+// pins the wiring: business_estate must be derived from the same
+// AggregateInstallSnapshotCounts values the payload already carries, via the
+// monitoring-owned threshold definition. The derivation itself is pinned in
+// internal/monitoring (TestInstallSnapshotCountsBusinessScaleEstate) and the
+// thresholds in internal/api (TestContract_BusinessScaleEstateThresholds).
+func TestTelemetrySnapshotDerivesBusinessEstateFromAggregateCounts(t *testing.T) {
+ source, err := os.ReadFile("server.go")
+ if err != nil {
+ t.Fatalf("read server.go: %v", err)
+ }
+ src := string(source)
+ if !strings.Contains(src, "snap.BusinessEstate = counts.BusinessScaleEstate()") {
+ t.Fatal("telemetry snapshot must derive BusinessEstate from AggregateInstallSnapshotCounts via counts.BusinessScaleEstate()")
+ }
+ counts := strings.Index(src, "reloadableMonitor.AggregateInstallSnapshotCounts()")
+ derived := strings.Index(src, "snap.BusinessEstate = counts.BusinessScaleEstate()")
+ if counts < 0 || derived < counts {
+ t.Fatal("BusinessEstate must be derived after the aggregate counts are captured in the snapshot closure")
+ }
+}