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(telemetry): suppress outbound pings while mock mode is enabled

rcourtman0f15de6a4ada
diff --git a/docs/PRIVACY.md b/docs/PRIVACY.md
index 1bab22298e..3fd7be4a82 100644
--- a/docs/PRIVACY.md
+++ b/docs/PRIVACY.md
@@ -18,6 +18,8 @@ Pulse includes outbound usage telemetry that is **enabled by default**. It sends
The telemetry payload does not include hostnames, credentials, infrastructure identifiers, IP addresses, prompts, chat messages, command text, action output, token values, names, email addresses, or account identifiers. See the full field list below.
+While mock/demo fixture mode is enabled, Pulse suppresses outbound telemetry entirely: a mock-mode instance reports a synthetic fixture fleet rather than a real installation, so it never pings.
+
#### How to disable
- **Settings → System → General → Outbound usage telemetry** (toggle off), or
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index dea13ec655..cd408a9d58 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -187,6 +187,12 @@ creation, unauthenticated delivery, raw SMTP secret exposure, or bypasses for
the `white_label` branding entitlement.
1. Change privacy disclosures, usage-data vocabulary, or outbound-data guarantees through `docs/PRIVACY.md`, `frontend-modern/public/docs/PRIVACY.md`, `internal/telemetry/telemetry.go`, and `pkg/server/telemetry_pulse_intelligence.go` together.
+ Mock/demo fixture mode is a hard suppression boundary for outbound usage
+ telemetry: while `internal/mock.IsMockEnabled()` reports true,
+ `internal/telemetry` must not send startup or heartbeat pings — the check
+ runs per event so runtime mock toggles take effect immediately — because a
+ mock-mode snapshot describes the synthetic fixture fleet rather than a real
+ installation.
Pulse Intelligence external-agent/MCP telemetry may expose only content-free
adapter-origin usage and capability-class counters for context, event
stream, provisioning, operator state, finding, and action requests. It must
@@ -303,6 +309,12 @@ the `white_label` branding entitlement.
security/privacy disclosures, token names, API field names, route/query keys,
and purchase-return state exactly.
6. Change operator-facing telemetry/adoption reporting through `scripts/telemetry_adoption_report.py` together with the privacy disclosure whenever release-identity interpretation changes.
+ The adoption report excludes mock-fixture-fleet-signature rows (120×N
+ Kubernetes pods with 7×N VMware hosts, the `internal/mock` template) from
+ adoption reads by default and must disclose the excluded row/install
+ counts, because versions that predate client-side mock suppression keep
+ pinging the synthetic fleet until upgraded; `--include-mock-fleet` remains
+ the audit path.
7. Change data-at-rest encryption-key or control-plane magic-link HMAC key and storage-root hardening semantics through `internal/crypto/crypto.go`, `internal/cloudcp/auth/magiclink.go`, `internal/cloudcp/auth/magiclink_store.go`, and `internal/securityutil/secure_storage_dir.go` together so writable-but-not-owned runtime storage mounts stay supported without weakening file-level secrecy.
Control-plane portal session lifetime rides on that same service: the auth
service session TTL is configurable (`CP_SESSION_TTL`, longer
diff --git a/frontend-modern/public/docs/PRIVACY.md b/frontend-modern/public/docs/PRIVACY.md
index 1bab22298e..3fd7be4a82 100644
--- a/frontend-modern/public/docs/PRIVACY.md
+++ b/frontend-modern/public/docs/PRIVACY.md
@@ -18,6 +18,8 @@ Pulse includes outbound usage telemetry that is **enabled by default**. It sends
The telemetry payload does not include hostnames, credentials, infrastructure identifiers, IP addresses, prompts, chat messages, command text, action output, token values, names, email addresses, or account identifiers. See the full field list below.
+While mock/demo fixture mode is enabled, Pulse suppresses outbound telemetry entirely: a mock-mode instance reports a synthetic fixture fleet rather than a real installation, so it never pings.
+
#### How to disable
- **Settings → System → General → Outbound usage telemetry** (toggle off), or
diff --git a/internal/telemetry/telemetry.go b/internal/telemetry/telemetry.go
index d7f185799d..d95500067b 100644
--- a/internal/telemetry/telemetry.go
+++ b/internal/telemetry/telemetry.go
@@ -52,6 +52,12 @@
//
// Set the environment variable PULSE_TELEMETRY=false, or toggle off
// "Outbound usage telemetry" in Settings → System → General.
+//
+// # Mock mode
+//
+// While mock/demo fixture mode is enabled, outbound pings are suppressed
+// entirely: a mock-mode boot (e2e, CI, qual runs, demo containers) would
+// otherwise report the synthetic fixture fleet as a real installation.
package telemetry
import (
@@ -69,6 +75,7 @@ import (
"time"
"github.com/google/uuid"
+ "github.com/rcourtman/pulse-go-rewrite/internal/mock"
"github.com/rcourtman/pulse-go-rewrite/internal/updates"
"github.com/rs/zerolog/log"
)
@@ -639,9 +646,7 @@ func Start(ctx context.Context, cfg Config) {
}
// Send startup ping with current snapshot.
- ping := applySnapshot(base, cfg.GetSnapshot)
- ping.Event = "startup"
- send(ctx, ping)
+ sendEvent(ctx, base, cfg.GetSnapshot, "startup")
// Daily heartbeat with jitter.
for {
@@ -651,9 +656,7 @@ func Start(ctx context.Context, cfg Config) {
timer.Stop()
return
case <-timer.C:
- ping = applySnapshot(base, cfg.GetSnapshot)
- ping.Event = "heartbeat"
- send(ctx, ping)
+ sendEvent(ctx, base, cfg.GetSnapshot, "heartbeat")
}
}
}()
@@ -918,6 +921,21 @@ func shouldKeepInstallIDRecord(record installIDRecord, now time.Time) bool {
return now.Sub(issuedAt) < installIDRotationWindow
}
+// sendEvent builds and sends one ping for the given event unless mock mode is
+// active. A mock-mode snapshot describes the synthetic fixture fleet, not a
+// real installation, so it must never reach the telemetry endpoint. The check
+// runs per event (not once at Start) because mock mode can be toggled at
+// runtime.
+func sendEvent(ctx context.Context, base Ping, fn SnapshotFunc, event string) {
+ if mock.IsMockEnabled() {
+ log.Debug().Str("event", event).Msg("Suppressing outbound telemetry ping while mock mode is enabled")
+ return
+ }
+ ping := applySnapshot(base, fn)
+ ping.Event = event
+ send(ctx, ping)
+}
+
// send posts a ping to the telemetry endpoint. Failures are silently ignored
// — telemetry must never interfere with normal operation.
func send(ctx context.Context, ping Ping) {
diff --git a/internal/telemetry/telemetry_test.go b/internal/telemetry/telemetry_test.go
index 354cdbd125..46ca3d4ae5 100644
--- a/internal/telemetry/telemetry_test.go
+++ b/internal/telemetry/telemetry_test.go
@@ -16,6 +16,7 @@ import (
"context"
"github.com/google/uuid"
+ "github.com/rcourtman/pulse-go-rewrite/internal/testutil"
"github.com/rcourtman/pulse-go-rewrite/internal/updates"
)
@@ -900,6 +901,55 @@ func TestJitteredHeartbeat_NotConstant(t *testing.T) {
}
}
+func TestSendEvent_SuppressedWhileMockModeEnabled(t *testing.T) {
+ var received atomic.Int32
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ received.Add(1)
+ w.WriteHeader(http.StatusNoContent)
+ }))
+ defer ts.Close()
+
+ origEndpoint := pingEndpoint
+ pingEndpoint = ts.URL
+ defer func() { pingEndpoint = origEndpoint }()
+
+ testutil.SetMockMode(t, true)
+
+ sendEvent(context.Background(), Ping{InstallID: uuid.New().String()}, nil, "startup")
+ sendEvent(context.Background(), Ping{InstallID: uuid.New().String()}, nil, "heartbeat")
+
+ if got := received.Load(); got != 0 {
+ t.Fatalf("expected no telemetry pings while mock mode is enabled, got %d", got)
+ }
+}
+
+func TestSendEvent_SendsWhenMockModeDisabled(t *testing.T) {
+ var received atomic.Int32
+ var lastPing Ping
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ body, _ := io.ReadAll(r.Body)
+ _ = json.Unmarshal(body, &lastPing)
+ received.Add(1)
+ w.WriteHeader(http.StatusNoContent)
+ }))
+ defer ts.Close()
+
+ origEndpoint := pingEndpoint
+ pingEndpoint = ts.URL
+ defer func() { pingEndpoint = origEndpoint }()
+
+ testutil.SetMockMode(t, false)
+
+ sendEvent(context.Background(), Ping{InstallID: uuid.New().String()}, nil, "heartbeat")
+
+ if got := received.Load(); got != 1 {
+ t.Fatalf("expected 1 telemetry ping with mock mode disabled, got %d", got)
+ }
+ if lastPing.Event != "heartbeat" {
+ t.Errorf("event = %q, want %q", lastPing.Event, "heartbeat")
+ }
+}
+
func TestStartStop_DisabledByDefault(t *testing.T) {
// Start should be a no-op when Enabled is false (the default).
Start(context.Background(), Config{
diff --git a/scripts/telemetry_adoption_report.py b/scripts/telemetry_adoption_report.py
index ca77118757..1f7fb21b7e 100644
--- a/scripts/telemetry_adoption_report.py
+++ b/scripts/telemetry_adoption_report.py
@@ -962,6 +962,25 @@ def parse_optional_nonnegative_int(value: Any) -> int:
return max(parsed, 0)
+# Mock fixture fleet signature: the internal/mock defaults ship 120 Kubernetes
+# pods (3 clusters × 40) alongside 7 VMware hosts (4 lab + 3 edge), and scaled
+# fixture configs multiply both together. Versions before client-side mock
+# suppression (6.1.0-rc.2 and earlier) sent telemetry from mock-mode boots
+# (e2e, CI, qual runs, demo containers), so matching rows are excluded from
+# adoption reads by default.
+MOCK_FLEET_KUBERNETES_PODS_PER_SCALE = 120
+MOCK_FLEET_VMWARE_HOSTS_PER_SCALE = 7
+
+
+def is_mock_fleet_row(row: dict[str, Any]) -> bool:
+ pods = parse_optional_nonnegative_int(row.get("kubernetes_pods"))
+ if pods <= 0 or pods % MOCK_FLEET_KUBERNETES_PODS_PER_SCALE != 0:
+ return False
+ scale = pods // MOCK_FLEET_KUBERNETES_PODS_PER_SCALE
+ vmware_hosts = parse_optional_nonnegative_int(row.get("vmware_hosts"))
+ return vmware_hosts == scale * MOCK_FLEET_VMWARE_HOSTS_PER_SCALE
+
+
def classify_row_version(row: dict[str, Any], published_versions: set[str]) -> ClassifiedVersion:
raw_version = str(row.get("version") or "")
identity = classify_reported_version(raw_version, published_versions)
@@ -1774,8 +1793,18 @@ def summarize_rows(
rows: Iterable[dict[str, Any]],
published_versions: set[str],
target_version: str | None = None,
+ include_mock_fleet: bool = False,
) -> dict[str, Any]:
- row_list = list(rows)
+ row_list: list[dict[str, Any]] = []
+ mock_fleet_rows = 0
+ mock_fleet_installs: set[str] = set()
+ for row in rows:
+ if not include_mock_fleet and is_mock_fleet_row(row):
+ mock_fleet_rows += 1
+ mock_fleet_installs.add(str(row["install_id"]))
+ continue
+ row_list.append(row)
+
latest_by_install: dict[str, dict[str, Any]] = {}
for row in row_list:
install_id = str(row["install_id"])
@@ -1794,6 +1823,11 @@ def summarize_rows(
return {
"db_stats": db_stats,
+ "mock_fleet_exclusions": {
+ "enabled": not include_mock_fleet,
+ "rows": mock_fleet_rows,
+ "installs": len(mock_fleet_installs),
+ },
"latest_install_windows": latest_install_windows,
"deep_signal_sources_7d": summarize_deep_signal_sources(
latest_by_install,
@@ -1890,6 +1924,16 @@ def format_text(summary: dict[str, Any], repo: str, since_days: int) -> str:
f"total distinct installs: {summary['db_stats'].get('total_distinct_installs', 0)}",
]
+ exclusions = summary.get("mock_fleet_exclusions")
+ if exclusions:
+ if exclusions.get("enabled"):
+ lines.append(
+ "mock fixture fleet excluded from window: "
+ f"{exclusions['rows']} row(s) across {exclusions['installs']} install(s)"
+ )
+ else:
+ lines.append("mock fixture fleet rows INCLUDED (--include-mock-fleet)")
+
for label, _ in DEFAULT_LATEST_INSTALL_WINDOWS:
window_summary = summary["latest_install_windows"][label]
lines.extend(
@@ -2060,6 +2104,14 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
"--target-version",
help="release version to highlight for per-signal coverage; defaults to the latest published RC",
)
+ parser.add_argument(
+ "--include-mock-fleet",
+ action="store_true",
+ help=(
+ "keep mock fixture fleet rows (120×N Kubernetes pods with 7×N VMware hosts) "
+ "instead of excluding them from adoption reads"
+ ),
+ )
parser.add_argument(
"--format",
choices=("text", "json"),
@@ -2082,7 +2134,13 @@ def main(argv: list[str] | None = None) -> int:
if args.ssh_host
else fetch_rows_local(args.db_path, args.since_days)
)
- summary = summarize_rows(source["db_stats"], source["rows"], published_versions, target_version=target_version)
+ summary = summarize_rows(
+ source["db_stats"],
+ source["rows"],
+ published_versions,
+ target_version=target_version,
+ include_mock_fleet=args.include_mock_fleet,
+ )
if args.format == "json":
print(json.dumps(summary, indent=2, sort_keys=True))
diff --git a/scripts/tests/test_telemetry_adoption_report.py b/scripts/tests/test_telemetry_adoption_report.py
index b5bd0123b4..05f0837bcd 100644
--- a/scripts/tests/test_telemetry_adoption_report.py
+++ b/scripts/tests/test_telemetry_adoption_report.py
@@ -1250,6 +1250,55 @@ class TelemetryAdoptionReportTest(unittest.TestCase):
self.assertEqual(stages["approved_action_success"]["observed_signal_free_starts"], 1)
self.assertEqual(stages["approved_action_success"]["observed_signal_free_to_paid"], 1)
+ def test_is_mock_fleet_row_matches_scaled_fixture_signature(self) -> None:
+ self.assertTrue(report.is_mock_fleet_row({"kubernetes_pods": 120, "vmware_hosts": 7}))
+ self.assertTrue(report.is_mock_fleet_row({"kubernetes_pods": 600, "vmware_hosts": 35}))
+ self.assertFalse(report.is_mock_fleet_row({"kubernetes_pods": 120, "vmware_hosts": 4}))
+ self.assertFalse(report.is_mock_fleet_row({"kubernetes_pods": 119, "vmware_hosts": 7}))
+ self.assertFalse(report.is_mock_fleet_row({"kubernetes_pods": 0, "vmware_hosts": 0}))
+ self.assertFalse(report.is_mock_fleet_row({}))
+
+ def test_summarize_rows_excludes_mock_fleet_rows_by_default(self) -> None:
+ now = datetime.now(timezone.utc).replace(microsecond=0)
+ real_row = {
+ "install_id": "install-real",
+ "version": "v6.1.0-rc.2",
+ "platform": "binary",
+ "received_at": (now - timedelta(hours=2)).strftime("%Y-%m-%d %H:%M:%S"),
+ "event": "heartbeat",
+ "kubernetes_pods": 37,
+ "vmware_hosts": 2,
+ }
+ mock_row = {
+ "install_id": "install-mock",
+ "version": "v6.1.0-rc.2",
+ "platform": "docker",
+ "received_at": (now - timedelta(hours=3)).strftime("%Y-%m-%d %H:%M:%S"),
+ "event": "heartbeat",
+ "kubernetes_pods": 240,
+ "vmware_hosts": 14,
+ "pve_nodes": 10,
+ }
+ db_stats = {"latest_ping": real_row["received_at"], "total_rows": 2, "total_distinct_installs": 2}
+
+ summary = report.summarize_rows(db_stats, [real_row, mock_row], published_versions=set())
+ self.assertEqual(summary["active_latest"]["active_24h"], 1)
+ self.assertEqual(
+ summary["mock_fleet_exclusions"],
+ {"enabled": True, "rows": 1, "installs": 1},
+ )
+ text = report.format_text(summary, "rcourtman/Pulse", 7)
+ self.assertIn("mock fixture fleet excluded from window: 1 row(s) across 1 install(s)", text)
+
+ included = report.summarize_rows(
+ db_stats, [real_row, mock_row], published_versions=set(), include_mock_fleet=True
+ )
+ self.assertEqual(included["active_latest"]["active_24h"], 2)
+ self.assertEqual(
+ included["mock_fleet_exclusions"],
+ {"enabled": False, "rows": 0, "installs": 0},
+ )
+
def test_format_text_includes_latest_install_windows(self) -> None:
summary = {
"db_stats": {