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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Measure aggregate reporting outcomes and repeat use
rcourtmana224a1a1957f
diff --git a/docs/PRIVACY.md b/docs/PRIVACY.mdindex ad6d6a5c35..800b9ed511 100644--- a/docs/PRIVACY.md+++ b/docs/PRIVACY.md@@ -40,7 +40,7 @@ Every field is listed below with the reason it exists. Nothing else is included| Field | Example | Purpose ||-------|---------|---------|-| Schema version | `19` | Identify the exact payload contract so old and new signals are not mixed silently |+| Schema version | `20` | Identify the exact payload contract so old and new signals are not mixed silently || Sent at | `2026-07-23T08:30:00Z` | Date the individual heartbeat without sending a history of client activity || Install ID | `a1b2c3d4-...` | Distinguish active installations within one rotation window without tying telemetry to an account or person || Version | `6.0.0-rc.1` | Track the canonical release identity currently deployed |@@ -147,7 +147,32 @@ Every field is listed below with the reason it exists. Nothing else is included| Audit reads 30d | `41` | Count how many times an entitled operator opened or exported the audit log in the current 30-day telemetry window, without sending query filters, actors, ranges, or any audit event || Report schedules | `5` | Count configured scheduled reports without sending schedule names, report scope, formats, or delivery recipients || Report schedules enabled | `4` | Count scheduled reports that are switched on, without sending schedule names, scope, or recipients |-| Report schedules run 30d | `2` | Count scheduled reports that last ran inside the current 30-day telemetry window, without sending run times, report contents, or delivery results |+| Report schedules run 30d | `2` | Count scheduled reports that last ran inside the current 30-day telemetry window, without sending run times or report contents; this legacy field counts recent attempts, not confirmed success |+| Reporting generated resources 30d (`reporting_generated_resources_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting generated vm inventory 30d (`reporting_generated_vm_inventory_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting generated backup health 30d (`reporting_generated_backup_health_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting generated patrol digest 30d (`reporting_generated_patrol_digest_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting successful resources periods 30d (`reporting_successful_resources_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting successful vm inventory periods 30d (`reporting_successful_vm_inventory_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting successful backup health periods 30d (`reporting_successful_backup_health_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting successful patrol digest periods 30d (`reporting_successful_patrol_digest_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting repeat resources periods 30d (`reporting_repeat_resources_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting repeat vm inventory periods 30d (`reporting_repeat_vm_inventory_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting repeat backup health periods 30d (`reporting_repeat_backup_health_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting repeat patrol digest periods 30d (`reporting_repeat_patrol_digest_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting saved 30d (`reporting_saved_30d`) | `1` | Successfully saved scheduled report files, including separate retry attempts |+| Reporting email accepted 30d (`reporting_email_accepted_30d`) | `1` | Scheduled email attempts accepted by SMTP; this does not establish inbox receipt |+| Reporting delivery failed 30d (`reporting_delivery_failed_30d`) | `1` | Scheduled delivery attempts with a definite failure, including preflight failures and attempts later retried |+| Reporting delivery unconfirmed 30d (`reporting_delivery_unconfirmed_30d`) | `1` | Scheduled delivery attempts with uncertain acceptance, including interrupted sending recovered after restart |+| Reporting data complete 30d (`reporting_data_complete_30d`) | `1` | Generated backup-health reports with complete source data |+| Reporting data incomplete 30d (`reporting_data_incomplete_30d`) | `1` | Generated backup-health reports with partial or incomplete source data |+| Reporting data unavailable 30d (`reporting_data_unavailable_30d`) | `1` | Generated backup-health reports with unavailable source data |+| Reporting telemetry available (`reporting_telemetry_available`) | `true`/`false` | Whether the local aggregate tally could be read and retained; false means unmeasured, not zero usage |+| Reporting observation days (`reporting_observation_days`) | `1` | Elapsed UTC days since the local tally began, capped at 30; this does not imply continuous uptime |+| Reporting resources active days 30d (`reporting_resources_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days |+| Reporting vm inventory active days 30d (`reporting_vm_inventory_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days |+| Reporting backup health active days 30d (`reporting_backup_health_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days |+| Reporting patrol digest active days 30d (`reporting_patrol_digest_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days || Agent profiles | `9` | Count configured agent profiles without sending profile names, targets, or profile contents || Update attempts 30d | `2` | Count update attempts recorded in the current 30-day telemetry window without sending download URLs, logs, or command output || Update successes 30d | `1` | Count successful update attempts in the current 30-day telemetry window |@@ -312,7 +337,7 @@ occurrence exists, leaving no trustworthy fired-alert denominator. Detectedflapping episodes are not reported because their diagnostic event path may bedropped under pressure. Configuration adoption is reported instead.-The current telemetry contract is schema version 19. Schema v16 adds four+The current telemetry contract is schema version 20. Schema v16 adds fourworkload-history adoption counts. The browsersends only one closed milestone name to the local Pulse server and deduplicateseach milestone once per browser session. Pulse stores bounded UTC-day counts@@ -320,6 +345,31 @@ locally and includes only their rolling 30-day totals in the existing heartbeat;there is no browser identifier, raw event stream, guest identity, selectedrange, cursor coordinate, value, route, or interaction timing.+Schema v20 adds the reporting fields listed above. Counters cover the current+UTC day and previous 29 UTC days and travel only in the existing startup/daily+heartbeat when usage statistics are enabled. There is no extra remote event+stream. Generated reports and delivery outcomes count separate attempts. A+successful period requires a saved schedule's final successful state to be+persisted. Repeat use requires another distinct reporting window for that same+saved schedule within 90 days. Retries and reruns of the same window do not+qualify, and monthly schedules can qualify after more than 30 days.+The per-kind active-day counters also cover repeat manual use: successful+downloads or scheduled generations on different UTC days, with each day counted+once regardless of same-day attempts.++Pulse retains daily aggregate counts and opaque SHA-256 schedule/period markers+locally, using the existing configuration encryption boundary when configured.+Markers expire after 90 days and never leave the installation. Only the listed+scalar counters, availability flag and elapsed observation days are sent. No+report contents, names, recipients, resource identifiers, organization identifiers,+schedule identifiers, period markers, reporting ranges, raw errors or run times+are transmitted. Local tally errors never stop report delivery. A missing or+unreadable tally is unmeasured, rather than evidence of no use. SMTP acceptance+is not proof that an email reached an inbox. These aggregate installation-level+signals cannot establish how many paying customers use reporting or what they+would pay for it. Pricing, license checks, customer entitlements, existing+opt-out controls and receiver retention are unchanged.+Schema v17 adds four closed Patrol posture fields and thirteen outcome counts.The provider class says only how the Patrol model is reached (local,bring-your-own-key cloud, CLI subscription, the retired hosted route, or none);@@ -406,6 +456,7 @@ Every change to the payload bumps the schema version, is listed here with its da| Schema | Date | Change ||--------|------|--------|+| 20 | 2026-10-17 | Content-free aggregate report generation, delivery outcomes, source-data states and distinct-period repeat use, with measurement availability and elapsed observation days || 19 | 2026-10-16 | Content-free rolling count of successful metric-history responses that return data older than seven days || 18 | 2026-09-27 | Effective update channel, closed outcome of the last update check on that channel, and whether it offered a newer release || 17 | 2026-09-02 | Closed Patrol provider class, effective Patrol autonomy level, coarse 30-day Patrol token buckets, and per-outcome investigation counts |diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 42d9993eb3..1a1edcbf43 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -9979,3 +9979,10 @@ quality is independent of delivery status. `reporting_backup_health_test.go`covers current scope, missing history, unchanged entitlement rejection and retryafter handler recreation. Collection and persistence proofs remain owned bymonitoring and storage-recovery.++Reporting outcome telemetry in the shared API observes completed response writes,+file saves, SMTP outcomes and persisted successful schedule windows. Its local+opaque period markers add no agent identity, enrollment, command or remediation+path. Failure to retain a tally cannot stop delivery. The real scheduler retry,+handler recreation and unreadable-tally cases in `reporting_activity_test.go`+verify that measurement remains subordinate to the existing report lifecycle.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex fa29dccbbb..d6b68f088c 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -21,6 +21,26 @@## Purpose+### Reporting telemetry observes canonical generation and delivery boundaries++`internal/api/reporting_activity.go` records best-effort content-free events to+the root config persistence wired through the existing settings-store boundary.+Organization context contributes only to a local opaque deduplication key. Direct+resource and VM inventory downloads count only a full successful response write,+excluding HEAD, cancellation and short writes. Distinct generation days cover+returning manual use without retaining download identities. Scheduled report generation, file+saving and existing SMTP transport outcomes each contribute their own counter.+A successful reporting period is recorded only after final schedule state saves.+Interrupted email recovery records uncertainty after persisting that outcome.+Retries still use the same scheduling/delivery system and frozen reporting window.++No endpoint, report payload, delivery state, retry policy, pricing or entitlement+changes. The activity adapter cannot block a report on tally failure. Scheduler+restart/retry, distinct-period reuse, complete download and mock-suppression proof+lives in `internal/api/reporting_activity_test.go`. Notifications retains SMTP+acceptance authority, and the activity recorder never claims inbox delivery.++### Container verification distinguishes transitional healthBoth agent and independent lifecycle readbacks classify a running container'sdiff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex c1dafa1efe..e084399e37 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -15,6 +15,28 @@## Purpose+### Reporting measurement precedes commercial feature decisions++Schema-v20 reporting usage exports only aggregate generation by closed report+kind, distinct successful-generation days for manual and scheduled use, file-save+and SMTP outcomes, backup source-data states, distinct successful+saved-schedule periods and repeat periods, plus measurement availability and+elapsed observation days. The receiver admits these fields only for schema v20+or later with an available tally and positive observation days. It bounds counts+and repeat/success relationships without changing billing, pricing, grants,+customer entitlements or existing opt-out behavior.++The public adoption report uses each recent active published non-mock rotating+ID's latest rolling counts. Old senders, missing receiver columns and unavailable+tallies are unmeasured, not zero usage. Partial elapsed observation is explicit.+Neither rotating installation IDs nor the coarse nonfree flag establish paying+customer identity, demand or willingness to pay. No join to license keys,+accounts, purchases or support is introduced. `pulse-pro:license-server/telemetry_test.go`+verifies receiver round-trip, schema/availability gates and bounds. Public+snapshot, privacy and adoption-query tests verify the shared semantics. Receiver+deployment and a client release are necessary before collecting fleet evidence.++### Opt-in confirmed-operation transport keeps paid contexts unchangedThe shared frontend client adds expectedOrgID and retry:false for the existingdiff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex 1e7c547c61..a65840abb7 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -15,7 +15,7 @@```## Purpose-### Schema-v19 release disclosure follows receiver compatibility+### Telemetry schema release disclosures follow receiver compatibility`docs/releases/TELEMETRY_SCHEMA_V19.md` carries the extended-history telemetry notice forinclusion in the first release containing schema v19. Source landing neither@@ -23,6 +23,12 @@ deploys the compatible license-server receiver nor releases upgraded clients.The reporter exposes missing receiver columns and pre-v19 clients as unknowncoverage, never as evidence of zero use. Existing telemetry opt-out, ID rotationand retention are unchanged. Payload details belong to security-privacy.+`docs/releases/TELEMETRY_SCHEMA_V20.md` likewise carries the reporting outcome+and repeat-use notice for the first schema-v20 release. Schema and tally+availability gate measurement, including unknown old receivers and clients.+The telemetry privacy tests pin both notices. These disclosure files use the+telemetry release-disclosure proof route, rather than changing release promotion,+artifact dispatch, opt-out, pricing or customer entitlements.diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex fc745678e9..99586dd542 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -2864,6 +2864,19 @@"exact_files": [],"require_explicit_path_policy_coverage": true,"path_policies": [+ {+ "id": "reporting-activity",+ "label": "reporting aggregate outcome proof",+ "match_prefixes": [],+ "match_files": [+ "internal/api/reporting_activity.go"+ ],+ "allow_same_subsystem_tests": false,+ "test_prefixes": [],+ "exact_files": [+ "internal/api/reporting_activity_test.go"+ ]+ },{"id": "client-backup-health-reports","label": "client-scoped backup health rendering and schedule proof",@@ -3281,6 +3294,7 @@"internal/api/report_schedule_delivery_test.go","internal/api/report_schedule_inventory_test.go","internal/api/report_schedules_test.go",+ "internal/api/reporting_activity_test.go","internal/api/reporting_backup_health_test.go","internal/config/report_schedule_delivery_test.go"]@@ -3298,6 +3312,7 @@"test_prefixes": [],"exact_files": ["internal/api/report_schedule_inventory_test.go",+ "internal/api/reporting_activity_test.go","internal/api/reporting_availability_test.go","internal/api/reporting_backup_health_test.go","internal/api/reporting_handlers_test.go",@@ -4842,11 +4857,12 @@]},{- "id": "telemetry-schema-v19-release-disclosure",- "label": "telemetry schema v19 release disclosure proof",+ "id": "telemetry-schema-release-disclosures",+ "label": "telemetry schema release disclosure proof","match_prefixes": [],"match_files": [- "docs/releases/TELEMETRY_SCHEMA_V19.md"+ "docs/releases/TELEMETRY_SCHEMA_V19.md",+ "docs/releases/TELEMETRY_SCHEMA_V20.md"],"allow_same_subsystem_tests": false,"test_prefixes": [],@@ -7771,6 +7787,7 @@"internal/cloudcp/auth/magiclink_store.go","internal/config/config.go","internal/config/history_read_activity.go",+ "internal/config/reporting_activity.go","internal/config/watcher.go","internal/crypto/crypto.go","internal/logging/logging.go",@@ -7847,6 +7864,7 @@"docs/PRIVACY.md","frontend-modern/public/docs/PRIVACY.md","internal/config/history_read_activity.go",+ "internal/config/reporting_activity.go","internal/telemetry/service_health.go","internal/telemetry/telemetry.go","pkg/server/service_health.go",@@ -7859,9 +7877,11 @@"test_prefixes": [],"exact_files": ["frontend-modern/src/stores/__tests__/systemSettings.test.ts",+ "internal/api/reporting_activity_test.go","internal/api/system_settings_telemetry_test.go","internal/api/telemetry_history_reads_test.go","internal/config/history_read_activity_test.go",+ "internal/config/reporting_activity_test.go","internal/telemetry/service_health_test.go","internal/telemetry/telemetry_test.go","pkg/server/service_health_test.go",diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.mdindex beff7134e9..b6b71720dd 100644--- a/docs/release-control/v6/internal/subsystems/security-privacy.md+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md@@ -18,6 +18,37 @@## Purpose+### Reporting usage remains content-free and distinguishable from missing measurements++`internal/config/reporting_activity.go` is the canonical durable count store.+It retains 30 UTC-day buckets of closed report kinds and outcomes. Local opaque+schedule/period SHA-256 markers expire after 90 days and use existing config+storage encryption when configured. No raw report, recipient, schedule, scope,+organization identifier, range or error content enters the tally. Only schema+v20 scalar counters, measurement availability and elapsed observation days leave+the installation through the existing opt-out-controlled heartbeat. Local tally+errors never fail reporting. Mock mode never records real reporting activity.++Generation counts include separate attempts and complete direct response writes.+Distinct successful-generation days also measure returning manual use, with+same-day attempts counted once. Saved files, SMTP acceptance, definite failures+and uncertain acceptance remain+separate. Persisted successful saved-schedule windows count once. Repeat use+requires a different window on that schedule within 90 days, including monthly+reuse, so retries and same-period reruns do not inflate adoption. The aggregate+query uses only each eligible rotating ID's latest counts and marks old-schema,+missing-column and unavailable-tally data unmeasured. Elapsed observation days do+not establish continuous uptime, and SMTP acceptance does not prove inbox receipt.+No customer/account joins or paying-customer census are permitted.++`internal/config/reporting_activity_test.go`,+`internal/api/reporting_activity_test.go`, the telemetry payload/disclosure tests,+the server snapshot tests and the adoption-report tests verify this boundary.+Both privacy document copies and `docs/releases/TELEMETRY_SCHEMA_V20.md` disclose+the payload. Client source landing and compatible receiver activation remain+separate from release and installed fleet measurement.++### Investigation evidence retains tenant and runtime-source boundariesRecovery HTTP and tool reads share `Manager.ListPointsForOrg`: a nonblank tenantdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 174bbf7654..7ae4b3701f 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -7037,3 +7037,11 @@ for existing and future monitors. Configuration reload must not silently stopdurable task collection while reporting continues reading the original store.`internal/api/recovery_monitor_reload_test.go` and a live connection-reload reportexercise dependency retention and actual history persistence.++Reporting telemetry counts generated backup-health documents by their existing+complete, incomplete or unavailable source-data state. It never reinterprets+those counts as backup success, protection, retention or restorability. The+separate SMTP and saved-file counters describe report delivery only. Only daily+aggregate counts leave the installation, with no workload, task, repository,+client scope or reporting range. Recovery evidence, observation coverage and+collection checkpoints remain owned by the existing recovery store.diff --git a/docs/releases/TELEMETRY_SCHEMA_V20.md b/docs/releases/TELEMETRY_SCHEMA_V20.mdnew file mode 100644index 0000000000..2d53a101d0--- /dev/null+++ b/docs/releases/TELEMETRY_SCHEMA_V20.md@@ -0,0 +1,17 @@+# Pending release notes++## Telemetry++When usage statistics are enabled, schema v20 adds aggregate reporting+telemetry: successful generation by report kind, saved files, SMTP acceptance,+definite and uncertain delivery outcomes, backup-report missing-data states,+distinct active reporting days (including manual downloads),+and successful and repeat reporting periods. Retries do not count as repeat+use. No report contents, recipients, customer identifiers or schedule identifiers+are sent. Existing opt-out, pricing and customer entitlements are unchanged.+See [Privacy](../PRIVACY.md) for every field and its limits.++Include this notice in the first release carrying schema v20. The compatible+receiver must be deployed before interpreting these signals. Source landing+alone does not activate collection. Receiver deployment and a client release+are required before fleet measurement.diff --git a/frontend-modern/browser-verification/69c9bc8ef9344873.json b/frontend-modern/browser-verification/69c9bc8ef9344873.jsonnew file mode 100644index 0000000000..f0935b1ab3--- /dev/null+++ b/frontend-modern/browser-verification/69c9bc8ef9344873.json@@ -0,0 +1,62 @@+{+ "version": 1,+ "base_sha": "0d5b87742514571594773cb69001c018c3277c30",+ "verified_at": "2026-10-17T20:09:41Z",+ "result": "passed",+ "changed_paths": [+ "docs/PRIVACY.md",+ "frontend-modern/public/docs/PRIVACY.md",+ "internal/api/metrics_reporting_handlers.go",+ "internal/api/report_schedules.go",+ "internal/api/reporting_activity.go",+ "internal/api/reporting_inventory_handlers.go",+ "internal/config/reporting_activity.go",+ "internal/telemetry/telemetry.go",+ "pkg/server/telemetry_licensed_features.go"+ ],+ "content_sha256": {+ "docs/PRIVACY.md": "3bce3d47526225387890d07cc9e0eebedf8601faa3a39c3d903b48b6a8b82e13",+ "frontend-modern/public/docs/PRIVACY.md": "3bce3d47526225387890d07cc9e0eebedf8601faa3a39c3d903b48b6a8b82e13",+ "internal/api/metrics_reporting_handlers.go": "805b09b2e1b990d8521378b43c911c1556b952be19228610e5f238ce50f7dfb3",+ "internal/api/report_schedules.go": "5a214f79a7af6b523b1cb6b7ecdfa8f2a9a072e02dabd88d8ad3104fbda016aa",+ "internal/api/reporting_activity.go": "65b4133c68f90fa1552934a5aee6c3d34938da6fda4730382bb440fe6be0f44c",+ "internal/api/reporting_inventory_handlers.go": "467bed9ab76bcdf7b2ccfe0de86c4b37de9a115bdb613dfb3426518be11e36e8",+ "internal/config/reporting_activity.go": "5ddff0fe857b7e5b66c7add5be231c3163a9ec70067cf4b6ce251995fc72d494",+ "internal/telemetry/telemetry.go": "08d34b879a387f56c76c43e57ef69c69017fa79b22b18bbc9df82db5ca774e31",+ "pkg/server/telemetry_licensed_features.go": "4afa566c4ac00ae7bb87aed8066ee6e2729871b94326becdfe0fdfaaf72e1492"+ },+ "routes": [+ "/settings/system-general",+ "/docs/PRIVACY"+ ],+ "viewports": [+ {+ "width": 1280,+ "height": 800+ },+ {+ "width": 390,+ "height": 844+ },+ {+ "width": 768,+ "height": 1024+ }+ ],+ "states": [+ "Job: see exactly which reporting usage Pulse sends and keep outbound telemetry off when chosen. Final public task source matched all 24 SHA256 entries before and after browser execution.",+ "Owned worker core runtime, current production frontend build, mock monitoring, isolated storage and a loopback-only telemetry linker override. No production telemetry or customer infrastructure traffic. The managed backend was stopped after every run.",+ "Schema20 preview exposes generation by report kind, distinct successful and repeat periods, saved files, SMTP accepted/failed/unconfirmed outcomes, backup source-data counts, availability, elapsed observation days and per-kind active days. Mock reporting counts remain zero and availability is true with one observation day.",+ "The editable outbound telemetry control saved enabled and disabled preferences across page reload. The separate pixel review set the initial enabled state to off through the real control, reloaded it and inspected the actual off control, including above the fixed narrow navigation footer.",+ "Current privacy document shows the reporting field rows and schema20 explanation. At390 the existing table scrolls horizontally to reveal readable descriptions without page overflow. At1280 and768 the new table rows and descriptions render in the normal document layout.",+ "Raw JSON preview retains horizontal scrolling on390 for long keys and values, with no horizontal document overflow. At1280 and768 reporting keys and counts remain readable. Actual pixels were reviewed for the preview, opt-out control and privacy table across all three widths.",+ "The three telemetry disclosure tests passed. A separate scratch interaction probe passed for centered control pixels, table descriptions and horizontal preview scrolling. Captures retained in the task reporting-telemetry-20261017 browser-evidence directory on the Development volume."+ ],+ "interactions": [+ "Opened Preview payload with keyboard focus and Enter, checked the schema and aggregate fields, refreshed the payload, reset the rotating install ID and verified a new ID with unchanged zero mock counts.",+ "Toggled the unlocked outbound usage telemetry control on and off by keyboard, waited for persistence, reloaded each state and inspected the saved off control at1280,390 and768 widths.",+ "Opened Full details from General settings, inspected the shipped privacy popup and reporting disclosure, closed the popup and returned to settings.",+ "Scrolled to reporting field rows and schema20 semantics, horizontally scrolled the narrow privacy table to its description column, and horizontally scrolled the narrow raw JSON pane to its values.",+ "Inspected current screenshots with the native image viewer after the final application-source change. No application-source edits followed this browser pass."+ ]+}diff --git a/frontend-modern/public/docs/PRIVACY.md b/frontend-modern/public/docs/PRIVACY.mdindex ad6d6a5c35..800b9ed511 100644--- a/frontend-modern/public/docs/PRIVACY.md+++ b/frontend-modern/public/docs/PRIVACY.md@@ -40,7 +40,7 @@ Every field is listed below with the reason it exists. Nothing else is included| Field | Example | Purpose ||-------|---------|---------|-| Schema version | `19` | Identify the exact payload contract so old and new signals are not mixed silently |+| Schema version | `20` | Identify the exact payload contract so old and new signals are not mixed silently || Sent at | `2026-07-23T08:30:00Z` | Date the individual heartbeat without sending a history of client activity || Install ID | `a1b2c3d4-...` | Distinguish active installations within one rotation window without tying telemetry to an account or person || Version | `6.0.0-rc.1` | Track the canonical release identity currently deployed |@@ -147,7 +147,32 @@ Every field is listed below with the reason it exists. Nothing else is included| Audit reads 30d | `41` | Count how many times an entitled operator opened or exported the audit log in the current 30-day telemetry window, without sending query filters, actors, ranges, or any audit event || Report schedules | `5` | Count configured scheduled reports without sending schedule names, report scope, formats, or delivery recipients || Report schedules enabled | `4` | Count scheduled reports that are switched on, without sending schedule names, scope, or recipients |-| Report schedules run 30d | `2` | Count scheduled reports that last ran inside the current 30-day telemetry window, without sending run times, report contents, or delivery results |+| Report schedules run 30d | `2` | Count scheduled reports that last ran inside the current 30-day telemetry window, without sending run times or report contents; this legacy field counts recent attempts, not confirmed success |+| Reporting generated resources 30d (`reporting_generated_resources_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting generated vm inventory 30d (`reporting_generated_vm_inventory_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting generated backup health 30d (`reporting_generated_backup_health_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting generated patrol digest 30d (`reporting_generated_patrol_digest_30d`) | `1` | Successful generation attempts for this report kind, including retry generations and fully written direct downloads |+| Reporting successful resources periods 30d (`reporting_successful_resources_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting successful vm inventory periods 30d (`reporting_successful_vm_inventory_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting successful backup health periods 30d (`reporting_successful_backup_health_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting successful patrol digest periods 30d (`reporting_successful_patrol_digest_periods_30d`) | `1` | Distinct reporting windows of saved schedules whose successful final state was persisted, for this report kind |+| Reporting repeat resources periods 30d (`reporting_repeat_resources_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting repeat vm inventory periods 30d (`reporting_repeat_vm_inventory_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting repeat backup health periods 30d (`reporting_repeat_backup_health_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting repeat patrol digest periods 30d (`reporting_repeat_patrol_digest_periods_30d`) | `1` | Those successful windows with another distinct successful window on the same schedule observed within 90 days; retries and same-period reruns are excluded |+| Reporting saved 30d (`reporting_saved_30d`) | `1` | Successfully saved scheduled report files, including separate retry attempts |+| Reporting email accepted 30d (`reporting_email_accepted_30d`) | `1` | Scheduled email attempts accepted by SMTP; this does not establish inbox receipt |+| Reporting delivery failed 30d (`reporting_delivery_failed_30d`) | `1` | Scheduled delivery attempts with a definite failure, including preflight failures and attempts later retried |+| Reporting delivery unconfirmed 30d (`reporting_delivery_unconfirmed_30d`) | `1` | Scheduled delivery attempts with uncertain acceptance, including interrupted sending recovered after restart |+| Reporting data complete 30d (`reporting_data_complete_30d`) | `1` | Generated backup-health reports with complete source data |+| Reporting data incomplete 30d (`reporting_data_incomplete_30d`) | `1` | Generated backup-health reports with partial or incomplete source data |+| Reporting data unavailable 30d (`reporting_data_unavailable_30d`) | `1` | Generated backup-health reports with unavailable source data |+| Reporting telemetry available (`reporting_telemetry_available`) | `true`/`false` | Whether the local aggregate tally could be read and retained; false means unmeasured, not zero usage |+| Reporting observation days (`reporting_observation_days`) | `1` | Elapsed UTC days since the local tally began, capped at 30; this does not imply continuous uptime |+| Reporting resources active days 30d (`reporting_resources_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days |+| Reporting vm inventory active days 30d (`reporting_vm_inventory_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days |+| Reporting backup health active days 30d (`reporting_backup_health_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days |+| Reporting patrol digest active days 30d (`reporting_patrol_digest_active_days_30d`) | `2` | Distinct UTC days with successful generation for this kind, including direct downloads; multiple same-day attempts count once, with a maximum of 30 days || Agent profiles | `9` | Count configured agent profiles without sending profile names, targets, or profile contents || Update attempts 30d | `2` | Count update attempts recorded in the current 30-day telemetry window without sending download URLs, logs, or command output || Update successes 30d | `1` | Count successful update attempts in the current 30-day telemetry window |@@ -312,7 +337,7 @@ occurrence exists, leaving no trustworthy fired-alert denominator. Detectedflapping episodes are not reported because their diagnostic event path may bedropped under pressure. Configuration adoption is reported instead.-The current telemetry contract is schema version 19. Schema v16 adds four+The current telemetry contract is schema version 20. Schema v16 adds fourworkload-history adoption counts. The browsersends only one closed milestone name to the local Pulse server and deduplicateseach milestone once per browser session. Pulse stores bounded UTC-day counts@@ -320,6 +345,31 @@ locally and includes only their rolling 30-day totals in the existing heartbeat;there is no browser identifier, raw event stream, guest identity, selectedrange, cursor coordinate, value, route, or interaction timing.+Schema v20 adds the reporting fields listed above. Counters cover the current+UTC day and previous 29 UTC days and travel only in the existing startup/daily+heartbeat when usage statistics are enabled. There is no extra remote event+stream. Generated reports and delivery outcomes count separate attempts. A+successful period requires a saved schedule's final successful state to be+persisted. Repeat use requires another distinct reporting window for that same+saved schedule within 90 days. Retries and reruns of the same window do not+qualify, and monthly schedules can qualify after more than 30 days.+The per-kind active-day counters also cover repeat manual use: successful+downloads or scheduled generations on different UTC days, with each day counted+once regardless of same-day attempts.++Pulse retains daily aggregate counts and opaque SHA-256 schedule/period markers+locally, using the existing configuration encryption boundary when configured.+Markers expire after 90 days and never leave the installation. Only the listed+scalar counters, availability flag and elapsed observation days are sent. No+report contents, names, recipients, resource identifiers, organization identifiers,+schedule identifiers, period markers, reporting ranges, raw errors or run times+are transmitted. Local tally errors never stop report delivery. A missing or+unreadable tally is unmeasured, rather than evidence of no use. SMTP acceptance+is not proof that an email reached an inbox. These aggregate installation-level+signals cannot establish how many paying customers use reporting or what they+would pay for it. Pricing, license checks, customer entitlements, existing+opt-out controls and receiver retention are unchanged.+Schema v17 adds four closed Patrol posture fields and thirteen outcome counts.The provider class says only how the Patrol model is reached (local,bring-your-own-key cloud, CLI subscription, the retired hosted route, or none);@@ -406,6 +456,7 @@ Every change to the payload bumps the schema version, is listed here with its da| Schema | Date | Change ||--------|------|--------|+| 20 | 2026-10-17 | Content-free aggregate report generation, delivery outcomes, source-data states and distinct-period repeat use, with measurement availability and elapsed observation days || 19 | 2026-10-16 | Content-free rolling count of successful metric-history responses that return data older than seven days || 18 | 2026-09-27 | Effective update channel, closed outcome of the last update check on that channel, and whether it offered a newer release || 17 | 2026-09-02 | Closed Patrol provider class, effective Patrol autonomy level, coarse 30-day Patrol token buckets, and per-outcome investigation counts |diff --git a/internal/api/metrics_reporting_handlers.go b/internal/api/metrics_reporting_handlers.goindex d285868bf4..362f2376e9 100644--- a/internal/api/metrics_reporting_handlers.go+++ b/internal/api/metrics_reporting_handlers.go@@ -820,7 +820,8 @@ func (h *ReportingHandlers) HandleGenerateReport(w http.ResponseWriter, r *http.safeResourceID := sanitizeFilename(resourceID)filename := definition.SingleAttachmentFilename(safeResourceID, time.Now().UTC(), format)w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))- w.Write(data)+ written, writeErr := w.Write(data)+ h.recordReportingDownload(r, config.ReportScheduleKindResources, written, writeErr, len(data))}// sanitizeFilename removes or replaces characters that could cause issues in filenames or headers@@ -1365,7 +1366,8 @@ func (h *ReportingHandlers) HandleGenerateMultiReport(w http.ResponseWriter, r *w.Header().Set("Content-Type", report.ContentType)w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", report.Filename))- w.Write(report.Data)+ written, writeErr := w.Write(report.Data)+ h.recordReportingDownload(r, config.ReportScheduleKindResources, written, writeErr, len(report.Data))}// enrichContainerReport adds container-specific data to the report requestdiff --git a/internal/api/report_schedules.go b/internal/api/report_schedules.goindex 7fad0c7192..4685410cf0 100644--- a/internal/api/report_schedules.go+++ b/internal/api/report_schedules.go@@ -422,7 +422,11 @@ func (h *ReportingHandlers) executeReportSchedule(ctx context.Context, persistenupdated.LastSuccessAt = &completed}store.Schedules[index] = updated- return result, updated, persistence.SaveReportScheduleStore(*store)+ if err := persistence.SaveReportScheduleStore(*store); err != nil {+ return result, updated, err+ }+ h.recordReportingSuccessfulPeriod(ctx, updated, result.usagePeriod, completed)+ return result, updated, nil}func (h *ReportingHandlers) prepareReportSchedule(ctx context.Context, schedule config.ReportSchedule, now time.Time, statusOnly bool) (config.ReportSchedule, error) {@@ -640,8 +644,9 @@ func resourceHasAnyReportScheduleTag(resource unifiedresources.Resource, tags ma}type reportScheduleRunResult struct {- path string- email string+ path string+ email string+ usagePeriod string}func (h *ReportingHandlers) runReportSchedule(ctx context.Context, persistence *config.ConfigPersistence, schedule config.ReportSchedule, now time.Time, manual bool, occurrenceKey string) (reportScheduleRunResult, config.ReportSchedule) {@@ -666,7 +671,9 @@ func (h *ReportingHandlers) runReportSchedule(ctx context.Context, persistence *}if schedule.Delivery.Method == config.ReportScheduleDeliveryEmail {if _, err := scheduledReportEmailManager(persistence, schedule); err != nil {- return result, markReportScheduleDeliveryFailed(schedule, now, err)+ failed := markReportScheduleDeliveryFailed(schedule, now, err)+ h.recordReportingDeliveryFailure(schedule.Kind, failed.LastDeliveryStatus, now)+ return result, failed}}@@ -674,12 +681,15 @@ func (h *ReportingHandlers) runReportSchedule(ctx context.Context, persistence *if err != nil {return result, markReportScheduleFailed(schedule, now, err)}+ h.recordReportingActivity(config.ReportingActivityEvent{At: now, Kind: schedule.Kind, Event: "generated", DataState: report.DataState})+ result.usagePeriod = reportingActivityPeriod(schedule, report.Start, report.End, now)path, err := saveGeneratedReport(persistence, schedule, report)if err != nil {return result, markReportScheduleFailed(schedule, now, err)}result.path = path+ h.recordReportingActivity(config.ReportingActivityEvent{At: now, Kind: schedule.Kind, Event: "saved"})schedule.LastReportDataState = report.DataStateschedule.LastReportDataMessage = report.DataMessageschedule.LastReportPath = path@@ -688,10 +698,13 @@ func (h *ReportingHandlers) runReportSchedule(ctx context.Context, persistence *if schedule.Delivery.Method == config.ReportScheduleDeliveryEmail {emailStatus, err := sendScheduledReportEmail(persistence, schedule, report, path)if err != nil {- return result, markReportScheduleDeliveryFailed(schedule, now, err)+ failed := markReportScheduleDeliveryFailed(schedule, now, err)+ h.recordReportingDeliveryFailure(schedule.Kind, failed.LastDeliveryStatus, now)+ return result, failed}result.email = emailStatusschedule.LastDeliveryStatus = emailStatus+ h.recordReportingActivity(config.ReportingActivityEvent{At: now, Kind: schedule.Kind, Event: "email_accepted"})}schedule.LastRunStatus = config.ReportScheduleLastRunOK@@ -1226,6 +1239,9 @@ func (h *ReportingHandlers) runDueReportSchedulesForOrg(ctx context.Context, orgif !save(i, schedule) {return}+ if schedule.LastRunStatus == config.ReportScheduleLastRunUnconfirmed {+ h.recordReportingDeliveryFailure(schedule.Kind, schedule.LastDeliveryStatus, now)+ }}if !schedule.Enabled {if schedule.RetryAt != nil {@@ -1329,12 +1345,19 @@ func (h *ReportingHandlers) runPatrolDigestSchedule(ctx context.Context, persist}manager, err := scheduledReportEmailManager(persistence, schedule)if err != nil {- return result, markReportScheduleDeliveryFailed(schedule, now, err)+ failed := markReportScheduleDeliveryFailed(schedule, now, err)+ h.recordReportingDeliveryFailure(schedule.Kind, failed.LastDeliveryStatus, now)+ return result, failed}subject, htmlBody, textBody := renderPatrolDigestEmail(digest, h.patrolDigestPublicURL())+ h.recordReportingActivity(config.ReportingActivityEvent{At: now, Kind: schedule.Kind, Event: "generated"})+ result.usagePeriod = reportingActivityPeriod(schedule, time.Time{}, time.Time{}, now)if err := manager.SendEmailWithRetry(subject, htmlBody, textBody); err != nil {- return result, markReportScheduleDeliveryFailed(schedule, now, err)+ failed := markReportScheduleDeliveryFailed(schedule, now, err)+ h.recordReportingDeliveryFailure(schedule.Kind, failed.LastDeliveryStatus, now)+ return result, failed}+ h.recordReportingActivity(config.ReportingActivityEvent{At: now, Kind: schedule.Kind, Event: "email_accepted"})result.email = "sent"schedule.LastRunStatus = config.ReportScheduleLastRunOKschedule.LastError = ""diff --git a/internal/api/reporting_activity.go b/internal/api/reporting_activity.gonew file mode 100644index 0000000000..12ae03e58e--- /dev/null+++ b/internal/api/reporting_activity.go@@ -0,0 +1,80 @@+package api++import (+ "context"+ "crypto/sha256"+ "encoding/hex"+ "net/http"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/config"+ "github.com/rcourtman/pulse-go-rewrite/internal/mock"+ "github.com/rs/zerolog/log"+)++type reportingActivityRecorder interface {+ RecordReportingActivity(config.ReportingActivityEvent) error+}++func (h *ReportingHandlers) recordReportingActivity(event config.ReportingActivityEvent) {+ if h == nil || mock.IsMockEnabled() {+ return+ }+ recorder, ok := h.settingsStore.(reportingActivityRecorder)+ if !ok {+ return+ }+ if err := recorder.RecordReportingActivity(event); err != nil {+ // No report, scope, recipient, schedule or error content enters this log.+ log.Debug().Msg("Unable to retain aggregate reporting activity")+ }+}++func (h *ReportingHandlers) recordReportingDownload(r *http.Request, kind string, count int, err error, expected int) {+ if r == nil || r.Method == http.MethodHead || r.Context().Err() != nil || err != nil || count != expected {+ return+ }+ h.recordReportingActivity(config.ReportingActivityEvent{At: time.Now().UTC(), Kind: kind, Event: "generated"})+}++func reportingActivityDigest(value string) string {+ sum := sha256.Sum256([]byte(value))+ return hex.EncodeToString(sum[:])+}++func reportingActivityPeriod(schedule config.ReportSchedule, start, end time.Time, now time.Time) string {+ if start.IsZero() || end.IsZero() {+ anchor := now+ if schedule.RunWindowEnd != nil {+ anchor = *schedule.RunWindowEnd+ }+ var err error+ start, end, err = reportScheduleWindow(schedule, anchor, schedule.RunManual)+ if err != nil {+ return ""+ }+ }+ location, err := reportScheduleLocation(schedule.Cadence.Timezone)+ if err != nil || !end.After(start) {+ return ""+ }+ // Day boundaries describe the reporting window. A retry or same-day rerun+ // cannot become repeat use merely because its clock time changed.+ return reportingActivityDigest(start.In(location).Format(time.DateOnly) + "\x00" + end.In(location).Format(time.DateOnly))+}++func (h *ReportingHandlers) recordReportingSuccessfulPeriod(ctx context.Context, schedule config.ReportSchedule, period string, at time.Time) {+ if schedule.ID == "" || period == "" || schedule.LastRunStatus != config.ReportScheduleLastRunOK {+ return+ }+ key := reportingActivityDigest(GetOrgID(ctx) + "\x00" + schedule.Kind + "\x00" + schedule.ID)+ h.recordReportingActivity(config.ReportingActivityEvent{At: at, Kind: schedule.Kind, Event: "successful_period", ScheduleKey: key, PeriodKey: period})+}++func (h *ReportingHandlers) recordReportingDeliveryFailure(kind string, status string, at time.Time) {+ event := "delivery_failed"+ if status == "unconfirmed" {+ event = "delivery_unconfirmed"+ }+ h.recordReportingActivity(config.ReportingActivityEvent{At: at, Kind: kind, Event: event})+}diff --git a/internal/api/reporting_activity_test.go b/internal/api/reporting_activity_test.gonew file mode 100644index 0000000000..fd02aea882--- /dev/null+++ b/internal/api/reporting_activity_test.go@@ -0,0 +1,168 @@+package api++import (+ "context"+ "errors"+ "net/http"+ "net/http/httptest"+ "os"+ "path/filepath"+ "testing"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/config"+ "github.com/rcourtman/pulse-go-rewrite/internal/testutil"+ "github.com/stretchr/testify/require"+)++func TestReportingActivityDownloadRequiresCompleteResponse(t *testing.T) {+ testutil.SetMockMode(t, false)+ p := config.NewConfigPersistence(t.TempDir())+ h := NewReportingHandlers(nil, nil)+ h.SetSystemSettingsStore(p)+ r := httptest.NewRequest(http.MethodGet, "/report", nil)+ h.recordReportingDownload(r, config.ReportScheduleKindResources, 12, nil, 12)+ h.recordReportingDownload(r, config.ReportScheduleKindResources, 6, nil, 12)+ h.recordReportingDownload(r, config.ReportScheduleKindResources, 0, errors.New("private-error"), 12)+ h.recordReportingDownload(httptest.NewRequest(http.MethodHead, "/report", nil), config.ReportScheduleKindResources, 12, nil, 12)+ ctx, cancel := context.WithCancel(r.Context())+ cancel()+ h.recordReportingDownload(r.WithContext(ctx), config.ReportScheduleKindResources, 12, nil, 12)+ got, err := p.ReportingActivitySnapshot(time.Now())+ require.NoError(t, err)+ require.Equal(t, 1, got.Counts.Generated[0])+}++func TestReportingActivityRealSchedulerRetriesAndReuse(t *testing.T) {+ testutil.SetMockMode(t, false)+ h, p, _, ctx, s := reportDeliveryFixture(t)+ h.SetSystemSettingsStore(p)+ cfg, attempts := reportSMTP(t, []int{451, 250, 250}, nil)+ require.NoError(t, p.SaveEmailConfig(cfg))+ require.NoError(t, p.SaveReportScheduleStore(config.ReportScheduleStore{Schedules: []config.ReportSchedule{s}}))+ now := time.Date(2026, 10, 19, 9, 0, 1, 0, time.UTC)+ h.runDueReportSchedulesForOrg(ctx, "default", now)+ first := storedReport(t, p)+ require.Equal(t, "retrying", first.LastRunStatus)+ restarted := NewReportingHandlers(h.reportMonitorManager(), nil)+ restarted.SetSystemSettingsStore(p)+ restarted.runDueReportSchedulesForOrg(ctx, "default", first.RetryAt.Add(time.Second))+ require.Equal(t, "ok", storedReport(t, p).LastRunStatus)+ restarted.runDueReportSchedulesForOrg(ctx, "default", now.Add(time.Hour))+ require.EqualValues(t, 2, attempts.Load())+ got, err := p.ReportingActivitySnapshot(now.Add(time.Hour))+ require.NoError(t, err)+ require.Equal(t, 2, got.Counts.Generated[0])+ require.Equal(t, 2, got.Counts.Saved)+ require.Equal(t, 1, got.Counts.DeliveryFailed)+ require.Equal(t, 1, got.Counts.EmailAccepted)+ require.Equal(t, 1, got.Counts.Successful[0])+ require.Zero(t, got.Counts.Repeated[0])+ restarted.runDueReportSchedulesForOrg(ctx, "default", now.AddDate(0, 0, 7))+ got, err = p.ReportingActivitySnapshot(now.AddDate(0, 0, 7))+ require.NoError(t, err)+ require.Equal(t, 2, got.Counts.Successful[0])+ require.Equal(t, 1, got.Counts.Repeated[0])+}++func TestReportingActivityPeriodsIgnoreSameDayRerunsAndIsolateOrganizations(t *testing.T) {+ testutil.SetMockMode(t, false)+ p := config.NewConfigPersistence(t.TempDir())+ h := NewReportingHandlers(nil, nil)+ h.SetSystemSettingsStore(p)+ s := validReportSchedulePayload()+ s.ID = "private-schedule"+ s.LastRunStatus = config.ReportScheduleLastRunOK+ s.Kind = config.ReportScheduleKindResources+ now := time.Date(2026, 10, 17, 12, 0, 0, 0, time.UTC)+ start := now.AddDate(0, 0, -7)+ period := reportingActivityPeriod(s, start, now, now)+ require.Equal(t, period, reportingActivityPeriod(s, start.Add(time.Minute), now.Add(time.Minute), now))+ for _, org := range []string{"private-org-a", "private-org-a", "private-org-b"} {+ h.recordReportingSuccessfulPeriod(orgScopeContext(org), s, period, now)+ }+ got, err := p.ReportingActivitySnapshot(now)+ require.NoError(t, err)+ require.Equal(t, 2, got.Counts.Successful[0])+ require.Zero(t, got.Counts.Repeated[0])+ s.LastRunStatus = config.ReportScheduleLastRunFailed+ h.recordReportingSuccessfulPeriod(context.Background(), s, reportingActivityDigest("other-period"), now)+ got, err = p.ReportingActivitySnapshot(now)+ require.NoError(t, err)+ require.Equal(t, 2, got.Counts.Successful[0])+}++func TestReportingActivityUnconfirmedDeliveryAndUnreadableTally(t *testing.T) {+ testutil.SetMockMode(t, false)+ for _, unreadable := range []bool{false, true} {+ t.Run(map[bool]string{false: "SMTP uncertainty", true: "unreadable tally"}[unreadable], func(t *testing.T) {+ h, p, _, ctx, s := reportDeliveryFixture(t)+ recorder := config.NewConfigPersistence(t.TempDir())+ if unreadable {+ require.NoError(t, os.Mkdir(filepath.Join(recorder.GetConfigDir(), "reporting_activity.json"), 0700))+ }+ h.SetSystemSettingsStore(recorder)+ replies := []int{0}+ if unreadable {+ replies = []int{250}+ }+ cfg, _ := reportSMTP(t, replies, nil)+ require.NoError(t, p.SaveEmailConfig(cfg))+ require.NoError(t, p.SaveReportScheduleStore(config.ReportScheduleStore{Schedules: []config.ReportSchedule{s}}))+ now := time.Date(2026, 10, 19, 9, 0, 1, 0, time.UTC)+ h.runDueReportSchedulesForOrg(ctx, "default", now)+ stored := storedReport(t, p)+ if unreadable {+ require.Equal(t, "ok", stored.LastRunStatus)+ got, err := recorder.ReportingActivitySnapshot(now)+ require.Error(t, err)+ require.False(t, got.Available)+ return+ }+ require.Equal(t, "unconfirmed", stored.LastRunStatus)+ got, err := recorder.ReportingActivitySnapshot(now)+ require.NoError(t, err)+ require.Equal(t, 1, got.Counts.DeliveryUnconfirmed)+ require.Zero(t, got.Counts.EmailAccepted)+ require.Zero(t, got.Counts.Successful[0])+ })+ }+}++func TestReportingActivityCountsServedHandlersAndExcludesDeniedReads(t *testing.T) {+ testutil.SetMockMode(t, false)+ recorder := config.NewConfigPersistence(t.TempDir())+ h := newReportingOrgScopeFixture(t)+ h.SetSystemSettingsStore(recorder)+ for _, resource := range []string{"node-b", "node-a"} {+ r := httptest.NewRequest(http.MethodGet, "/api/admin/reports/generate?format=csv&resourceType=node&metricType=cpu&resourceId="+resource, nil).WithContext(orgScopeContext("org-b"))+ w := httptest.NewRecorder()+ h.HandleGenerateReport(w, r)+ if resource == "node-b" {+ require.Equal(t, http.StatusOK, w.Code)+ } else {+ require.Equal(t, http.StatusNotFound, w.Code)+ }+ }+ inventory, _, ctx, _, _ := inventoryScheduleFixture(t)+ inventory.SetSystemSettingsStore(recorder)+ w := httptest.NewRecorder()+ inventory.HandleExportVMInventory(w, httptest.NewRequest(http.MethodGet, "/api/admin/reports/inventory/vms/export", nil).WithContext(ctx))+ require.Equal(t, http.StatusOK, w.Code)+ got, err := recorder.ReportingActivitySnapshot(time.Now())+ require.NoError(t, err)+ require.Equal(t, 1, got.Counts.Generated[0])+ require.Equal(t, 1, got.Counts.Generated[1])+ require.Equal(t, [4]int{}, got.Counts.Successful)+}++func TestReportingActivityMockDownloadsAreSuppressed(t *testing.T) {+ testutil.SetMockMode(t, true)+ p := config.NewConfigPersistence(t.TempDir())+ h := NewReportingHandlers(nil, nil)+ h.SetSystemSettingsStore(p)+ h.recordReportingDownload(httptest.NewRequest(http.MethodGet, "/report", nil), config.ReportScheduleKindResources, 12, nil, 12)+ got, err := p.ReportingActivitySnapshot(time.Now())+ require.NoError(t, err)+ require.Zero(t, got.Counts.Generated[0])+}diff --git a/internal/api/reporting_inventory_handlers.go b/internal/api/reporting_inventory_handlers.goindex d039ef1f2f..154bfd64b0 100644--- a/internal/api/reporting_inventory_handlers.go+++ b/internal/api/reporting_inventory_handlers.go@@ -5,6 +5,7 @@ import ("net/http""time"+ "github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources""github.com/rcourtman/pulse-go-rewrite/pkg/reporting")@@ -42,7 +43,8 @@ func (h *ReportingHandlers) HandleExportVMInventory(w http.ResponseWriter, r *htw.Header().Set("Content-Type", report.ContentType)w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", report.Filename))- _, _ = w.Write(report.Data)+ written, writeErr := w.Write(report.Data)+ h.recordReportingDownload(r, config.ReportScheduleKindVMInventory, written, writeErr, len(report.Data))}// Both downloads and schedules use the same current-state projection and CSVdiff --git a/internal/config/reporting_activity.go b/internal/config/reporting_activity.gonew file mode 100644index 0000000000..d5c5af3b80--- /dev/null+++ b/internal/config/reporting_activity.go@@ -0,0 +1,297 @@+package config++import (+ "encoding/json"+ "fmt"+ "os"+ "path/filepath"+ "regexp"+ "time"+)++const reportingActivityFile = "reporting_activity.json"+const reportingActivityLimit = 100000++// The array order is fixed by ReportingActivityKindIndex, never by user input.+// Daily buckets retain counts only. Opaque period markers stay local and use+// the same encryption boundary as report schedule configuration.+type ReportingActivityCounts struct {+ Generated [4]int `json:"generated"`+ Successful [4]int `json:"successful_periods"`+ Repeated [4]int `json:"repeat_periods"`+ Saved int `json:"saved"`+ EmailAccepted int `json:"email_accepted"`+ DeliveryFailed int `json:"delivery_failed"`+ DeliveryUnconfirmed int `json:"delivery_unconfirmed"`+ DataComplete int `json:"data_complete"`+ DataIncomplete int `json:"data_incomplete"`+ DataUnavailable int `json:"data_unavailable"`+}++type ReportingActivitySummary struct {+ ActiveDays [4]int+ Available bool+ ObservationDays int+ Counts ReportingActivityCounts+}++type ReportingActivityEvent struct {+ At time.Time+ Kind string+ Event string+ DataState string+ // Only SHA-256 tokens are accepted here. No raw schedule/tenant identifier,+ // report period, recipient, scope or contents are retained in this tally.+ ScheduleKey string+ PeriodKey string+}++type reportingActivityStore struct {+ Version int `json:"version"`+ ObservedSince string `json:"observed_since"`+ Daily map[string]ReportingActivityCounts `json:"daily"`+ Periods map[string]map[string]string `json:"periods"`+}++var reportingActivityToken = regexp.MustCompile(`^[a-f0-9]{64}$`)++func ReportingActivityKindIndex(kind string) (int, bool) {+ switch kind {+ case ReportScheduleKindResources:+ return 0, true+ case ReportScheduleKindVMInventory:+ return 1, true+ case ReportScheduleKindBackupHealth:+ return 2, true+ case ReportScheduleKindPatrolDigest:+ return 3, true+ default:+ return 0, false+ }+}++func (c *ConfigPersistence) loadReportingActivityLocked(now time.Time) (*reportingActivityStore, error) {+ store := &reportingActivityStore{Version: 1, ObservedSince: now.UTC().Format(time.DateOnly), Daily: map[string]ReportingActivityCounts{}, Periods: map[string]map[string]string{}}+ raw, err := c.fs.ReadFile(filepath.Join(c.configDir, reportingActivityFile))+ if os.IsNotExist(err) {+ return store, nil+ }+ if err != nil {+ return nil, err+ }+ if c.crypto != nil {+ raw, err = c.crypto.Decrypt(raw)+ if err != nil {+ return nil, fmt.Errorf("decrypt reporting activity: %w", err)+ }+ }+ // Defaults apply only to a genuinely absent file. An incomplete existing+ // file must not become apparently measured zero usage.+ store = &reportingActivityStore{}+ if err := json.Unmarshal(raw, store); err != nil {+ return nil, err+ }+ if store.Version != 1 {+ return nil, fmt.Errorf("unsupported reporting activity version")+ }+ if _, err := time.Parse(time.DateOnly, store.ObservedSince); err != nil {+ return nil, fmt.Errorf("invalid reporting observation day")+ }+ if store.Daily == nil || store.Periods == nil {+ return nil, fmt.Errorf("incomplete reporting activity store")+ }+ return store, nil+}++func pruneReportingActivity(store *reportingActivityStore, now time.Time) {+ day := now.UTC().Format(time.DateOnly)+ first := now.UTC().AddDate(0, 0, -29).Format(time.DateOnly)+ previous := now.UTC().AddDate(0, 0, -90).Format(time.DateOnly)+ if store.ObservedSince > day {+ store.ObservedSince = day+ }+ for date := range store.Daily {+ if _, err := time.Parse(time.DateOnly, date); err != nil || date < first || date > day {+ delete(store.Daily, date)+ }+ }+ for key, periods := range store.Periods {+ if !reportingActivityToken.MatchString(key) {+ delete(store.Periods, key)+ continue+ }+ for period, date := range periods {+ if _, err := time.Parse(time.DateOnly, date); err != nil || date < previous || date > day || !reportingActivityToken.MatchString(period) {+ delete(periods, period)+ }+ }+ if len(periods) == 0 {+ delete(store.Periods, key)+ }+ }+}++func (c *ConfigPersistence) saveReportingActivityLocked(store *reportingActivityStore) error {+ raw, err := json.Marshal(store)+ if err != nil {+ return err+ }+ if c.crypto != nil {+ raw, err = c.crypto.Encrypt(raw)+ if err != nil {+ return err+ }+ }+ if err := c.fs.MkdirAll(c.configDir, 0700); err != nil {+ return err+ }+ return c.writeConfigFileLocked(filepath.Join(c.configDir, reportingActivityFile), raw, 0600)+}++func reportingCountIncrement(value *int) {+ if *value < 0 {+ *value = 0+ }+ if *value < reportingActivityLimit {+ *value+++ }+}++// RecordReportingActivity stores only closed kinds/outcomes and local opaque+// deduplication tokens. Repeated successes require another distinct reporting+// period on the same saved schedule, observed in the preceding 90 days. This+// allows monthly schedules to qualify without mistaking retries for reuse.+func (c *ConfigPersistence) RecordReportingActivity(event ReportingActivityEvent) error {+ if c == nil || c.configDir == "" || event.At.IsZero() {+ return nil+ }+ index, ok := ReportingActivityKindIndex(event.Kind)+ if !ok {+ return fmt.Errorf("unrecognized reporting activity kind")+ }+ switch event.Event {+ case "generated", "saved", "email_accepted", "delivery_failed", "delivery_unconfirmed", "successful_period":+ default:+ return fmt.Errorf("unrecognized reporting activity outcome")+ }+ if event.Event == "successful_period" && (!reportingActivityToken.MatchString(event.ScheduleKey) || !reportingActivityToken.MatchString(event.PeriodKey)) {+ return fmt.Errorf("invalid reporting period marker")+ }+ c.mu.Lock()+ defer c.mu.Unlock()+ store, err := c.loadReportingActivityLocked(event.At)+ if err != nil {+ return err+ }+ // Concurrent completions can arrive out of order across midnight. Prune+ // against the newest retained day rather than deleting a later completion.+ anchor := event.At.UTC()+ for day := range store.Daily {+ if retained, err := time.Parse(time.DateOnly, day); err == nil && retained.After(anchor) {+ anchor = retained+ }+ }+ pruneReportingActivity(store, anchor)+ day := event.At.UTC().Format(time.DateOnly)+ if day < anchor.AddDate(0, 0, -29).Format(time.DateOnly) {+ return nil+ }+ if day < store.ObservedSince {+ store.ObservedSince = day+ }+ counts := store.Daily[day]+ switch event.Event {+ case "generated":+ reportingCountIncrement(&counts.Generated[index])+ switch event.DataState {+ case "complete":+ reportingCountIncrement(&counts.DataComplete)+ case "partial", "incomplete":+ reportingCountIncrement(&counts.DataIncomplete)+ case "unavailable":+ reportingCountIncrement(&counts.DataUnavailable)+ }+ case "saved":+ reportingCountIncrement(&counts.Saved)+ case "email_accepted":+ reportingCountIncrement(&counts.EmailAccepted)+ case "delivery_failed":+ reportingCountIncrement(&counts.DeliveryFailed)+ case "delivery_unconfirmed":+ reportingCountIncrement(&counts.DeliveryUnconfirmed)+ case "successful_period":+ periods := store.Periods[event.ScheduleKey]+ if periods == nil {+ periods = map[string]string{}+ store.Periods[event.ScheduleKey] = periods+ }+ if _, seen := periods[event.PeriodKey]; !seen {+ if len(periods) > 0 {+ reportingCountIncrement(&counts.Repeated[index])+ }+ reportingCountIncrement(&counts.Successful[index])+ periods[event.PeriodKey] = day+ }+ }+ store.Daily[day] = counts+ return c.saveReportingActivityLocked(store)+}++func reportingCountAdd(dst *int, value int) {+ if value <= 0 {+ return+ }+ if value > reportingActivityLimit {+ value = reportingActivityLimit+ }+ if *dst > reportingActivityLimit-value {+ *dst = reportingActivityLimit+ } else {+ *dst += value+ }+}++// ReportingActivitySnapshot returns aggregate counts for the current UTC day+// and previous 29 UTC days. An unreadable tally is unavailable, never evidence+// of zero usage. The first observation day is persisted even before first use.+func (c *ConfigPersistence) ReportingActivitySnapshot(now time.Time) (ReportingActivitySummary, error) {+ var result ReportingActivitySummary+ if c == nil || c.configDir == "" {+ return result, nil+ }+ c.mu.Lock()+ defer c.mu.Unlock()+ store, err := c.loadReportingActivityLocked(now)+ if err != nil {+ return result, err+ }+ pruneReportingActivity(store, now)+ if err := c.saveReportingActivityLocked(store); err != nil {+ return result, err+ }+ start, _ := time.Parse(time.DateOnly, store.ObservedSince)+ end, _ := time.Parse(time.DateOnly, now.UTC().Format(time.DateOnly))+ result.Available = true+ result.ObservationDays = int(end.Sub(start)/(24*time.Hour)) + 1+ if result.ObservationDays > 30 {+ result.ObservationDays = 30+ }+ for _, daily := range store.Daily {+ for i := range daily.Generated {+ if daily.Generated[i] > 0 {+ result.ActiveDays[i]+++ }+ reportingCountAdd(&result.Counts.Generated[i], daily.Generated[i])+ reportingCountAdd(&result.Counts.Successful[i], daily.Successful[i])+ reportingCountAdd(&result.Counts.Repeated[i], daily.Repeated[i])+ }+ reportingCountAdd(&result.Counts.Saved, daily.Saved)+ reportingCountAdd(&result.Counts.EmailAccepted, daily.EmailAccepted)+ reportingCountAdd(&result.Counts.DeliveryFailed, daily.DeliveryFailed)+ reportingCountAdd(&result.Counts.DeliveryUnconfirmed, daily.DeliveryUnconfirmed)+ reportingCountAdd(&result.Counts.DataComplete, daily.DataComplete)+ reportingCountAdd(&result.Counts.DataIncomplete, daily.DataIncomplete)+ reportingCountAdd(&result.Counts.DataUnavailable, daily.DataUnavailable)+ }+ return result, nil+}diff --git a/internal/config/reporting_activity_test.go b/internal/config/reporting_activity_test.gonew file mode 100644index 0000000000..a52de55732--- /dev/null+++ b/internal/config/reporting_activity_test.go@@ -0,0 +1,144 @@+package config_test++import (+ "os"+ "path/filepath"+ "strings"+ "sync"+ "testing"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/config"+)++func TestReportingActivityMonthlyReuseSurvivesRestartAndDeduplicates(t *testing.T) {+ dir := t.TempDir()+ p := config.NewConfigPersistence(dir)+ first := time.Date(2026, 8, 1, 9, 0, 0, 0, time.UTC)+ key, period := strings.Repeat("a", 64), strings.Repeat("b", 64)+ event := config.ReportingActivityEvent{At: first, Kind: config.ReportScheduleKindBackupHealth, Event: "successful_period", ScheduleKey: key, PeriodKey: period}+ for i := 0; i < 3; i++ {+ if err := p.RecordReportingActivity(event); err != nil {+ t.Fatal(err)+ }+ }+ p = config.NewConfigPersistence(dir)+ event.At = first.AddDate(0, 1, 0)+ event.PeriodKey = strings.Repeat("c", 64)+ for i := 0; i < 3; i++ {+ if err := p.RecordReportingActivity(event); err != nil {+ t.Fatal(err)+ }+ }+ got, err := p.ReportingActivitySnapshot(event.At)+ if err != nil {+ t.Fatal(err)+ }+ if !got.Available || got.ObservationDays != 30 || got.Counts.Successful[2] != 1 || got.Counts.Repeated[2] != 1 {+ t.Fatalf("snapshot: %+v", got)+ }+ // Beyond marker retention, the old schedule is no longer repeat evidence.+ event.At = event.At.AddDate(0, 0, 91)+ event.PeriodKey = strings.Repeat("d", 64)+ if err := p.RecordReportingActivity(event); err != nil {+ t.Fatal(err)+ }+ got, err = p.ReportingActivitySnapshot(event.At)+ if err != nil || got.Counts.Successful[2] != 1 || got.Counts.Repeated[2] != 0 {+ t.Fatalf("expired repeat: %+v %v", got, err)+ }+ info, err := os.Stat(filepath.Join(dir, "reporting_activity.json"))+ if err != nil || info.Mode().Perm() != 0600 {+ t.Fatalf("permissions: %v %v", info, err)+ }+}++func TestReportingActivityCountsOutOfOrderUTCCompletionsAndConcurrentEvents(t *testing.T) {+ p := config.NewConfigPersistence(t.TempDir())+ now := time.Date(2026, 10, 17, 0, 0, 1, 0, time.UTC)+ var wg sync.WaitGroup+ for i := 0; i < 16; i++ {+ wg.Add(1)+ go func(i int) {+ defer wg.Done()+ at := now+ if i%2 == 0 {+ at = now.Add(-2 * time.Second)+ }+ if err := p.RecordReportingActivity(config.ReportingActivityEvent{At: at, Kind: config.ReportScheduleKindResources, Event: "generated"}); err != nil {+ t.Error(err)+ }+ }(i)+ }+ wg.Wait()+ got, err := p.ReportingActivitySnapshot(now)+ if err != nil || got.Counts.Generated[0] != 16 || got.ObservationDays != 2 || got.ActiveDays[0] != 2 {+ t.Fatalf("out-of-order counts: %+v %v", got, err)+ }+ got, err = p.ReportingActivitySnapshot(now.AddDate(0, 0, 29))+ if err != nil || got.Counts.Generated[0] != 8 || got.ActiveDays[0] != 1 {+ t.Fatalf("UTC retention: %+v %v", got, err)+ }+}++func TestReportingActivityAvailabilityClosedFieldsAndOutcomes(t *testing.T) {+ dir := t.TempDir()+ p := config.NewConfigPersistence(dir)+ now := time.Now().UTC()+ empty, err := p.ReportingActivitySnapshot(now)+ if err != nil || !empty.Available || empty.ObservationDays != 1 {+ t.Fatalf("empty observed: %+v %v", empty, err)+ }+ for _, event := range []string{"saved", "email_accepted", "delivery_failed", "delivery_unconfirmed"} {+ if err := p.RecordReportingActivity(config.ReportingActivityEvent{At: now, Kind: config.ReportScheduleKindVMInventory, Event: event}); err != nil {+ t.Fatal(err)+ }+ }+ for _, state := range []string{"complete", "partial", "unavailable", "private-content"} {+ if err := p.RecordReportingActivity(config.ReportingActivityEvent{At: now, Kind: config.ReportScheduleKindBackupHealth, Event: "generated", DataState: state}); err != nil {+ t.Fatal(err)+ }+ }+ if err := p.RecordReportingActivity(config.ReportingActivityEvent{At: now, Kind: "private-customer", Event: "generated"}); err == nil {+ t.Fatal("accepted arbitrary kind")+ }+ if err := p.RecordReportingActivity(config.ReportingActivityEvent{At: now, Kind: config.ReportScheduleKindResources, Event: "private-error"}); err == nil {+ t.Fatal("accepted arbitrary event")+ }+ if err := p.RecordReportingActivity(config.ReportingActivityEvent{At: now, Kind: config.ReportScheduleKindResources, Event: "successful_period", ScheduleKey: "customer", PeriodKey: "date"}); err == nil {+ t.Fatal("accepted raw identifiers")+ }+ got, err := p.ReportingActivitySnapshot(now)+ if err != nil || got.Counts.Generated[2] != 4 || got.Counts.DataComplete != 1 || got.Counts.DataIncomplete != 1 || got.Counts.DataUnavailable != 1 || got.Counts.Saved != 1 || got.Counts.EmailAccepted != 1 || got.Counts.DeliveryFailed != 1 || got.Counts.DeliveryUnconfirmed != 1 {+ t.Fatalf("outcomes: %+v %v", got, err)+ }+ raw, err := os.ReadFile(filepath.Join(dir, "reporting_activity.json"))+ if err != nil {+ t.Fatal(err)+ }+ for _, forbidden := range []string{"private-content", "private-customer", "private-error"} {+ if strings.Contains(string(raw), forbidden) {+ t.Fatalf("retained %q", forbidden)+ }+ }+ if err := os.WriteFile(filepath.Join(dir, "reporting_activity.json"), []byte("corrupt"), 0600); err != nil {+ t.Fatal(err)+ }+ got, err = p.ReportingActivitySnapshot(now)+ if err == nil || got.Available {+ t.Fatalf("corrupt is unmeasured: %+v %v", got, err)+ }+}++func TestReportingActivityIncompleteStoresRemainUnmeasured(t *testing.T) {+ for _, raw := range []string{"null", "{}", `{"version":1,"observed_since":"2026-10-17"}`, `{"version":1,"observed_since":"2026-10-17","daily":null,"periods":{}}`} {+ p := config.NewConfigPersistence(t.TempDir())+ if err := os.WriteFile(filepath.Join(p.GetConfigDir(), "reporting_activity.json"), []byte(raw), 0600); err != nil {+ t.Fatal(err)+ }+ got, err := p.ReportingActivitySnapshot(time.Date(2026, 10, 17, 12, 0, 0, 0, time.UTC))+ if err == nil || got.Available {+ t.Fatalf("%s must remain unmeasured: %+v %v", raw, got, err)+ }+ }+}diff --git a/internal/telemetry/telemetry.go b/internal/telemetry/telemetry.goindex 46bf6bedb6..02c4b29b84 100644--- a/internal/telemetry/telemetry.go+++ b/internal/telemetry/telemetry.go@@ -227,7 +227,8 @@ const (// updates. No version, URL, or error text is exported.// Schema v19 adds only the rolling count of successfully served metric// history responses containing data older than seven days.- TelemetrySchemaVersion = 19+ // Schema v20 adds aggregate reporting outcomes and distinct-period reuse.+ TelemetrySchemaVersion = 20)type installIDRecord struct {@@ -553,6 +554,33 @@ type Ping struct {PulseIntelligenceApprovedActionRefusalsOther30d int `json:"pulse_intelligence_approved_action_refusals_other_30d"`PulseIntelligenceVerifiedFindingResolutions30d int `json:"pulse_intelligence_verified_finding_resolutions_30d"`PulseIntelligenceApprovedActionLastFailureReason30d string `json:"pulse_intelligence_approved_action_last_failure_reason_30d,omitempty"`++ // Content-free reporting outcomes and measurement coverage.+ ReportingGeneratedResources30d int `json:"reporting_generated_resources_30d"`+ ReportingGeneratedVMInventory30d int `json:"reporting_generated_vm_inventory_30d"`+ ReportingGeneratedBackupHealth30d int `json:"reporting_generated_backup_health_30d"`+ ReportingGeneratedPatrolDigest30d int `json:"reporting_generated_patrol_digest_30d"`+ ReportingSuccessfulResourcesPeriods30d int `json:"reporting_successful_resources_periods_30d"`+ ReportingSuccessfulVMInventoryPeriods30d int `json:"reporting_successful_vm_inventory_periods_30d"`+ ReportingSuccessfulBackupHealthPeriods30d int `json:"reporting_successful_backup_health_periods_30d"`+ ReportingSuccessfulPatrolDigestPeriods30d int `json:"reporting_successful_patrol_digest_periods_30d"`+ ReportingRepeatResourcesPeriods30d int `json:"reporting_repeat_resources_periods_30d"`+ ReportingRepeatVMInventoryPeriods30d int `json:"reporting_repeat_vm_inventory_periods_30d"`+ ReportingRepeatBackupHealthPeriods30d int `json:"reporting_repeat_backup_health_periods_30d"`+ ReportingRepeatPatrolDigestPeriods30d int `json:"reporting_repeat_patrol_digest_periods_30d"`+ ReportingSaved30d int `json:"reporting_saved_30d"`+ ReportingEmailAccepted30d int `json:"reporting_email_accepted_30d"`+ ReportingDeliveryFailed30d int `json:"reporting_delivery_failed_30d"`+ ReportingDeliveryUnconfirmed30d int `json:"reporting_delivery_unconfirmed_30d"`+ ReportingDataComplete30d int `json:"reporting_data_complete_30d"`+ ReportingDataIncomplete30d int `json:"reporting_data_incomplete_30d"`+ ReportingDataUnavailable30d int `json:"reporting_data_unavailable_30d"`+ ReportingTelemetryAvailable bool `json:"reporting_telemetry_available"`+ ReportingObservationDays int `json:"reporting_observation_days"`+ ReportingResourcesActiveDays30d int `json:"reporting_resources_active_days_30d"`+ ReportingVMInventoryActiveDays30d int `json:"reporting_vm_inventory_active_days_30d"`+ ReportingBackupHealthActiveDays30d int `json:"reporting_backup_health_active_days_30d"`+ ReportingPatrolDigestActiveDays30d int `json:"reporting_patrol_digest_active_days_30d"`}// Snapshot holds the dynamic state gathered at ping time.@@ -757,6 +785,33 @@ type Snapshot struct {PulseIntelligenceApprovedActionRefusalsOther30d intPulseIntelligenceVerifiedFindingResolutions30d intPulseIntelligenceApprovedActionLastFailureReason30d string++ // Content-free reporting outcomes and measurement coverage.+ ReportingGeneratedResources30d int+ ReportingGeneratedVMInventory30d int+ ReportingGeneratedBackupHealth30d int+ ReportingGeneratedPatrolDigest30d int+ ReportingSuccessfulResourcesPeriods30d int+ ReportingSuccessfulVMInventoryPeriods30d int+ ReportingSuccessfulBackupHealthPeriods30d int+ ReportingSuccessfulPatrolDigestPeriods30d int+ ReportingRepeatResourcesPeriods30d int+ ReportingRepeatVMInventoryPeriods30d int+ ReportingRepeatBackupHealthPeriods30d int+ ReportingRepeatPatrolDigestPeriods30d int+ ReportingSaved30d int+ ReportingEmailAccepted30d int+ ReportingDeliveryFailed30d int+ ReportingDeliveryUnconfirmed30d int+ ReportingDataComplete30d int+ ReportingDataIncomplete30d int+ ReportingDataUnavailable30d int+ ReportingTelemetryAvailable bool+ ReportingObservationDays int+ ReportingResourcesActiveDays30d int+ ReportingVMInventoryActiveDays30d int+ ReportingBackupHealthActiveDays30d int+ ReportingPatrolDigestActiveDays30d int}// PulseIntelligenceActionSnapshot is the action-governance portion of the@@ -1298,6 +1353,36 @@ func BuildPingForSnapshot(s Snapshot) Ping {}// applySnapshot merges dynamic state into the base ping.+// applyReportingActivitySnapshot maps the reporting count family without+// adding identifiers or changing the heartbeat's existing opt-out boundary.+func applyReportingActivitySnapshot(ping *Ping, snapshot *Snapshot) {+ ping.ReportingGeneratedResources30d = snapshot.ReportingGeneratedResources30d+ ping.ReportingGeneratedVMInventory30d = snapshot.ReportingGeneratedVMInventory30d+ ping.ReportingGeneratedBackupHealth30d = snapshot.ReportingGeneratedBackupHealth30d+ ping.ReportingGeneratedPatrolDigest30d = snapshot.ReportingGeneratedPatrolDigest30d+ ping.ReportingSuccessfulResourcesPeriods30d = snapshot.ReportingSuccessfulResourcesPeriods30d+ ping.ReportingSuccessfulVMInventoryPeriods30d = snapshot.ReportingSuccessfulVMInventoryPeriods30d+ ping.ReportingSuccessfulBackupHealthPeriods30d = snapshot.ReportingSuccessfulBackupHealthPeriods30d+ ping.ReportingSuccessfulPatrolDigestPeriods30d = snapshot.ReportingSuccessfulPatrolDigestPeriods30d+ ping.ReportingRepeatResourcesPeriods30d = snapshot.ReportingRepeatResourcesPeriods30d+ ping.ReportingRepeatVMInventoryPeriods30d = snapshot.ReportingRepeatVMInventoryPeriods30d+ ping.ReportingRepeatBackupHealthPeriods30d = snapshot.ReportingRepeatBackupHealthPeriods30d+ ping.ReportingRepeatPatrolDigestPeriods30d = snapshot.ReportingRepeatPatrolDigestPeriods30d+ ping.ReportingSaved30d = snapshot.ReportingSaved30d+ ping.ReportingEmailAccepted30d = snapshot.ReportingEmailAccepted30d+ ping.ReportingDeliveryFailed30d = snapshot.ReportingDeliveryFailed30d+ ping.ReportingDeliveryUnconfirmed30d = snapshot.ReportingDeliveryUnconfirmed30d+ ping.ReportingDataComplete30d = snapshot.ReportingDataComplete30d+ ping.ReportingDataIncomplete30d = snapshot.ReportingDataIncomplete30d+ ping.ReportingDataUnavailable30d = snapshot.ReportingDataUnavailable30d+ ping.ReportingTelemetryAvailable = snapshot.ReportingTelemetryAvailable+ ping.ReportingObservationDays = snapshot.ReportingObservationDays+ ping.ReportingResourcesActiveDays30d = snapshot.ReportingResourcesActiveDays30d+ ping.ReportingVMInventoryActiveDays30d = snapshot.ReportingVMInventoryActiveDays30d+ ping.ReportingBackupHealthActiveDays30d = snapshot.ReportingBackupHealthActiveDays30d+ ping.ReportingPatrolDigestActiveDays30d = snapshot.ReportingPatrolDigestActiveDays30d+}+func applySnapshot(base Ping, fn SnapshotFunc) Ping {ping := baseif fn == nil {@@ -1348,6 +1433,8 @@ func applySnapshot(base Ping, fn SnapshotFunc) Ping {ping.ReportSchedules = s.ReportSchedulesping.ReportSchedulesEnabled = s.ReportSchedulesEnabledping.ReportSchedulesRun30d = s.ReportSchedulesRun30d+ applyReportingActivitySnapshot(&ping, &s)+ping.AgentProfiles = s.AgentProfilesping.UpdateAttempts30d = s.UpdateAttempts30dping.UpdateSuccesses30d = s.UpdateSuccesses30ddiff --git a/internal/telemetry/telemetry_test.go b/internal/telemetry/telemetry_test.goindex 04008b647d..851da081a3 100644--- a/internal/telemetry/telemetry_test.go+++ b/internal/telemetry/telemetry_test.go@@ -337,57 +337,57 @@ func TestApplySnapshot(t *testing.T) {snap := func() Snapshot {return Snapshot{- PVENodes: 3,- VMs: 10,- Containers: 5,- AgentHosts: 2,- DockerContainers: 12,- KubernetesPods: 18,- StoragePools: 4,- PhysicalDisks: 9,- TrueNASSystems: 1,- TrueNASApps: 3,- VMwareHosts: 2,- AvailabilityTargets: 6,- AIEnabled: true,- PatrolEnabled: true,- DiscoveryEnabled: true,- NotificationsEnabled: true,- AIActionsEnabled: true,- AlertAIEnabled: true,- ActiveAlerts: 2,- PaidLicense: true,- HasAPITokens: true,- RBACCustomRoles: 3,- RBACUserAssignments: 7,- AuditReads30d: 41,- ReportSchedules: 5,- ReportSchedulesEnabled: 4,- ReportSchedulesRun30d: 2,- AgentProfiles: 9,- UpdateAttempts30d: 4,- UpdateSuccesses30d: 2,- UpdateFailures30d: 1,- UpdateLastFailureCategory: "download",- ActiveAlertsCritical: 2,- ActiveAlertsAge1h24h: 2,- AlertsFiredCritical30d: 5,- AlertsResolvedCritical30d: 3,- AlertsResolution1h24h30d: 3,- AlertsRepeatOccurrences30d: 2,- AlertsSnoozedOccurrences30d: 2,- AlertsResolvedWhileSnoozed30d: 1,- AlertManagerTenants: 2,- AlertDeliveryActiveTenants: 1,- AlertFlappingEnabledTenants: 2,- AlertIntentPolicyConfiguredTenants: 1,- AlertEventHistoryAuthoritativeTenants: 2,- AlertActiveStateAuthoritativeTenants: 2,- PulseIntelligenceLoopConfigured: true,- PulseIntelligenceLoopActive30d: true,- PulseIntelligenceCompleteOperationsLoop30d: true,- PulseIntelligenceApprovedExecutionLoop30d: true,- PulseIntelligenceResolvedOperationsLoop30d: true,+ PVENodes: 3,+ VMs: 10,+ Containers: 5,+ AgentHosts: 2,+ DockerContainers: 12,+ KubernetesPods: 18,+ StoragePools: 4,+ PhysicalDisks: 9,+ TrueNASSystems: 1,+ TrueNASApps: 3,+ VMwareHosts: 2,+ AvailabilityTargets: 6,+ AIEnabled: true,+ PatrolEnabled: true,+ DiscoveryEnabled: true,+ NotificationsEnabled: true,+ AIActionsEnabled: true,+ AlertAIEnabled: true,+ ActiveAlerts: 2,+ PaidLicense: true,+ HasAPITokens: true,+ RBACCustomRoles: 3,+ RBACUserAssignments: 7,+ AuditReads30d: 41,+ ReportSchedules: 5,+ ReportSchedulesEnabled: 4,+ ReportSchedulesRun30d: 2,+ AgentProfiles: 9,+ UpdateAttempts30d: 4,+ UpdateSuccesses30d: 2,+ UpdateFailures30d: 1,+ UpdateLastFailureCategory: "download",+ ActiveAlertsCritical: 2,+ ActiveAlertsAge1h24h: 2,+ AlertsFiredCritical30d: 5,+ AlertsResolvedCritical30d: 3,+ AlertsResolution1h24h30d: 3,+ AlertsRepeatOccurrences30d: 2,+ AlertsSnoozedOccurrences30d: 2,+ AlertsResolvedWhileSnoozed30d: 1,+ AlertManagerTenants: 2,+ AlertDeliveryActiveTenants: 1,+ AlertFlappingEnabledTenants: 2,+ AlertIntentPolicyConfiguredTenants: 1,+ AlertEventHistoryAuthoritativeTenants: 2,+ AlertActiveStateAuthoritativeTenants: 2,+ PulseIntelligenceLoopConfigured: true,+ PulseIntelligenceLoopActive30d: true,+ PulseIntelligenceCompleteOperationsLoop30d: true,+ PulseIntelligenceApprovedExecutionLoop30d: true,+ PulseIntelligenceResolvedOperationsLoop30d: true,PulseIntelligencePatrolControlCompletedOperationsLoop30d: true,PulseIntelligencePatrolControlResolvedOperationsLoop30d: true,PulseIntelligencePatrolControlPaidCompletedOperationsLoop30d: true,@@ -1462,3 +1462,150 @@ func TestSendAllowsRedirectedEndpointUnderTest(t *testing.T) {t.Fatalf("redirected endpoint received %d pings, want 1", got)}}++func TestReportingTelemetryPayloadMappingAndBudget(t *testing.T) {+ snap := Snapshot{+ ReportingGeneratedResources30d: 100000,+ ReportingGeneratedVMInventory30d: 100000,+ ReportingGeneratedBackupHealth30d: 100000,+ ReportingGeneratedPatrolDigest30d: 100000,+ ReportingSuccessfulResourcesPeriods30d: 100000,+ ReportingSuccessfulVMInventoryPeriods30d: 100000,+ ReportingSuccessfulBackupHealthPeriods30d: 100000,+ ReportingSuccessfulPatrolDigestPeriods30d: 100000,+ ReportingRepeatResourcesPeriods30d: 100000,+ ReportingRepeatVMInventoryPeriods30d: 100000,+ ReportingRepeatBackupHealthPeriods30d: 100000,+ ReportingRepeatPatrolDigestPeriods30d: 100000,+ ReportingSaved30d: 100000,+ ReportingEmailAccepted30d: 100000,+ ReportingDeliveryFailed30d: 100000,+ ReportingDeliveryUnconfirmed30d: 100000,+ ReportingDataComplete30d: 100000,+ ReportingDataIncomplete30d: 100000,+ ReportingDataUnavailable30d: 100000,+ ReportingTelemetryAvailable: true,+ ReportingObservationDays: 30,+ }+ // Exercise the receiver's count ceiling across the entire snapshot, not+ // just the added fields, to keep the existing 16 KiB request limit intact.+ values := reflect.ValueOf(&snap).Elem()+ for i := 0; i < values.NumField(); i++ {+ if values.Field(i).Kind() == reflect.Int {+ values.Field(i).SetInt(100000)+ }+ }+ snap.ReportingObservationDays = 30+ snap.ReportingResourcesActiveDays30d = 30+ snap.ReportingVMInventoryActiveDays30d = 30+ snap.ReportingBackupHealthActiveDays30d = 30+ snap.ReportingPatrolDigestActiveDays30d = 30+ preview, err := BuildPreview(Config{Version: "6.6.0", DataDir: t.TempDir(), GetSnapshot: func() Snapshot { return snap }})+ if err != nil {+ t.Fatal(err)+ }+ raw, err := json.Marshal(preview)+ if err != nil {+ t.Fatal(err)+ }+ if len(raw) > 16*1024 {+ t.Fatalf("payload %d exceeds receiver limit", len(raw))+ }+ var payload map[string]interface{}+ if err := json.Unmarshal(raw, &payload); err != nil {+ t.Fatal(err)+ }+ if got := payload["reporting_generated_resources_30d"]; got != float64(100000) {+ t.Errorf("reporting_generated_resources_30d = %v", got)+ }+ if got := payload["reporting_generated_vm_inventory_30d"]; got != float64(100000) {+ t.Errorf("reporting_generated_vm_inventory_30d = %v", got)+ }+ if got := payload["reporting_generated_backup_health_30d"]; got != float64(100000) {+ t.Errorf("reporting_generated_backup_health_30d = %v", got)+ }+ if got := payload["reporting_generated_patrol_digest_30d"]; got != float64(100000) {+ t.Errorf("reporting_generated_patrol_digest_30d = %v", got)+ }+ if got := payload["reporting_successful_resources_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_successful_resources_periods_30d = %v", got)+ }+ if got := payload["reporting_successful_vm_inventory_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_successful_vm_inventory_periods_30d = %v", got)+ }+ if got := payload["reporting_successful_backup_health_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_successful_backup_health_periods_30d = %v", got)+ }+ if got := payload["reporting_successful_patrol_digest_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_successful_patrol_digest_periods_30d = %v", got)+ }+ if got := payload["reporting_repeat_resources_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_repeat_resources_periods_30d = %v", got)+ }+ if got := payload["reporting_repeat_vm_inventory_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_repeat_vm_inventory_periods_30d = %v", got)+ }+ if got := payload["reporting_repeat_backup_health_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_repeat_backup_health_periods_30d = %v", got)+ }+ if got := payload["reporting_repeat_patrol_digest_periods_30d"]; got != float64(100000) {+ t.Errorf("reporting_repeat_patrol_digest_periods_30d = %v", got)+ }+ if got := payload["reporting_saved_30d"]; got != float64(100000) {+ t.Errorf("reporting_saved_30d = %v", got)+ }+ if got := payload["reporting_email_accepted_30d"]; got != float64(100000) {+ t.Errorf("reporting_email_accepted_30d = %v", got)+ }+ if got := payload["reporting_delivery_failed_30d"]; got != float64(100000) {+ t.Errorf("reporting_delivery_failed_30d = %v", got)+ }+ if got := payload["reporting_delivery_unconfirmed_30d"]; got != float64(100000) {+ t.Errorf("reporting_delivery_unconfirmed_30d = %v", got)+ }+ if got := payload["reporting_data_complete_30d"]; got != float64(100000) {+ t.Errorf("reporting_data_complete_30d = %v", got)+ }+ if got := payload["reporting_data_incomplete_30d"]; got != float64(100000) {+ t.Errorf("reporting_data_incomplete_30d = %v", got)+ }+ if got := payload["reporting_data_unavailable_30d"]; got != float64(100000) {+ t.Errorf("reporting_data_unavailable_30d = %v", got)+ }+ if got := payload["reporting_telemetry_available"]; got != true {+ t.Errorf("reporting_telemetry_available = %v", got)+ }+ if got := payload["reporting_observation_days"]; got != float64(30) {+ t.Errorf("reporting_observation_days = %v", got)+ }++ if got := payload["reporting_resources_active_days_30d"]; got != float64(30) {+ t.Errorf("reporting_resources_active_days_30d = %v", got)+ }+ if got := payload["reporting_vm_inventory_active_days_30d"]; got != float64(30) {+ t.Errorf("reporting_vm_inventory_active_days_30d = %v", got)+ }+ if got := payload["reporting_backup_health_active_days_30d"]; got != float64(30) {+ t.Errorf("reporting_backup_health_active_days_30d = %v", got)+ }+ if got := payload["reporting_patrol_digest_active_days_30d"]; got != float64(30) {+ t.Errorf("reporting_patrol_digest_active_days_30d = %v", got)+ }+ for _, forbidden := range []string{"schedule_id", "recipient", "report_contents", "org_id", "period_key"} {+ if _, ok := payload[forbidden]; ok {+ t.Errorf("identifier field %s", forbidden)+ }+ }+}++func TestTelemetryPrivacyReleaseNoticeCoversReporting(t *testing.T) {+ raw, err := os.ReadFile(filepath.Join("..", "..", "docs", "releases", "TELEMETRY_SCHEMA_V20.md"))+ if err != nil {+ t.Fatal(err)+ }+ for _, required := range []string{"schema v20", "repeat reporting periods", "Retries do not count as repeat", "customer identifiers", "opt-out", "pricing", "entitlements", "receiver", "client release"} {+ if !strings.Contains(string(raw), required) {+ t.Errorf("reporting release notice must disclose %q", required)+ }+ }+}diff --git a/pkg/server/telemetry_licensed_features.go b/pkg/server/telemetry_licensed_features.goindex f745b37c74..48b28dd598 100644--- a/pkg/server/telemetry_licensed_features.go+++ b/pkg/server/telemetry_licensed_features.go@@ -31,6 +31,34 @@ func applyLicensedFeatureConfigSnapshot(snap *telemetry.Snapshot, persistence *c}}+ if activity, err := persistence.ReportingActivitySnapshot(now); err == nil {+ snap.ReportingGeneratedResources30d = activity.Counts.Generated[0]+ snap.ReportingGeneratedVMInventory30d = activity.Counts.Generated[1]+ snap.ReportingGeneratedBackupHealth30d = activity.Counts.Generated[2]+ snap.ReportingGeneratedPatrolDigest30d = activity.Counts.Generated[3]+ snap.ReportingSuccessfulResourcesPeriods30d = activity.Counts.Successful[0]+ snap.ReportingSuccessfulVMInventoryPeriods30d = activity.Counts.Successful[1]+ snap.ReportingSuccessfulBackupHealthPeriods30d = activity.Counts.Successful[2]+ snap.ReportingSuccessfulPatrolDigestPeriods30d = activity.Counts.Successful[3]+ snap.ReportingRepeatResourcesPeriods30d = activity.Counts.Repeated[0]+ snap.ReportingRepeatVMInventoryPeriods30d = activity.Counts.Repeated[1]+ snap.ReportingRepeatBackupHealthPeriods30d = activity.Counts.Repeated[2]+ snap.ReportingRepeatPatrolDigestPeriods30d = activity.Counts.Repeated[3]+ snap.ReportingSaved30d = activity.Counts.Saved+ snap.ReportingEmailAccepted30d = activity.Counts.EmailAccepted+ snap.ReportingDeliveryFailed30d = activity.Counts.DeliveryFailed+ snap.ReportingDeliveryUnconfirmed30d = activity.Counts.DeliveryUnconfirmed+ snap.ReportingDataComplete30d = activity.Counts.DataComplete+ snap.ReportingDataIncomplete30d = activity.Counts.DataIncomplete+ snap.ReportingDataUnavailable30d = activity.Counts.DataUnavailable+ snap.ReportingTelemetryAvailable = activity.Available+ snap.ReportingObservationDays = activity.ObservationDays+ snap.ReportingResourcesActiveDays30d = activity.ActiveDays[0]+ snap.ReportingVMInventoryActiveDays30d = activity.ActiveDays[1]+ snap.ReportingBackupHealthActiveDays30d = activity.ActiveDays[2]+ snap.ReportingPatrolDigestActiveDays30d = activity.ActiveDays[3]+ }+if profiles, err := persistence.LoadAgentProfiles(); err == nil {snap.AgentProfiles = len(profiles)}diff --git a/pkg/server/telemetry_licensed_features_test.go b/pkg/server/telemetry_licensed_features_test.goindex bb712eaa3e..86256ddae2 100644--- a/pkg/server/telemetry_licensed_features_test.go+++ b/pkg/server/telemetry_licensed_features_test.go@@ -80,3 +80,18 @@ func TestApplyLicensedFeatureConfigSnapshotIncludesSuccessfulExtendedHistoryReadt.Fatalf("extended history reads = %d, want 1", snap.SuccessfulHistoryReadsOver7d30d)}}++func TestApplyLicensedFeatureConfigSnapshotReportingOutcomes(t *testing.T) {+ p := config.NewConfigPersistence(t.TempDir())+ now := time.Now().UTC()+ for _, event := range []string{"generated", "saved", "email_accepted", "delivery_failed", "delivery_unconfirmed"} {+ if err := p.RecordReportingActivity(config.ReportingActivityEvent{At: now, Kind: config.ReportScheduleKindBackupHealth, Event: event, DataState: "partial"}); err != nil {+ t.Fatal(err)+ }+ }+ var snap telemetry.Snapshot+ applyLicensedFeatureConfigSnapshot(&snap, p, now)+ if !snap.ReportingTelemetryAvailable || snap.ReportingObservationDays != 1 || snap.ReportingGeneratedBackupHealth30d != 1 || snap.ReportingBackupHealthActiveDays30d != 1 || snap.ReportingSaved30d != 1 || snap.ReportingEmailAccepted30d != 1 || snap.ReportingDeliveryFailed30d != 1 || snap.ReportingDeliveryUnconfirmed30d != 1 || snap.ReportingDataIncomplete30d != 1 {+ t.Fatalf("reporting snapshot: %+v", snap)+ }+}diff --git a/scripts/telemetry_adoption_report.py b/scripts/telemetry_adoption_report.pyindex efd888aa8a..9bf5945757 100644--- a/scripts/telemetry_adoption_report.py+++ b/scripts/telemetry_adoption_report.py@@ -1059,6 +1059,33 @@ ALERT_QUALITY_COUNT_FIELDS = (("alert_active_state_authoritative_tenants", "Authoritative active-state tenants"),("alert_active_state_persistence_degraded_tenants", "Degraded active-state tenants"),)+REPORTING_USAGE_COUNT_FIELDS = (+ "reporting_generated_resources_30d",+ "reporting_generated_vm_inventory_30d",+ "reporting_generated_backup_health_30d",+ "reporting_generated_patrol_digest_30d",+ "reporting_successful_resources_periods_30d",+ "reporting_successful_vm_inventory_periods_30d",+ "reporting_successful_backup_health_periods_30d",+ "reporting_successful_patrol_digest_periods_30d",+ "reporting_repeat_resources_periods_30d",+ "reporting_repeat_vm_inventory_periods_30d",+ "reporting_repeat_backup_health_periods_30d",+ "reporting_repeat_patrol_digest_periods_30d",+ "reporting_saved_30d",+ "reporting_email_accepted_30d",+ "reporting_delivery_failed_30d",+ "reporting_delivery_unconfirmed_30d",+ "reporting_data_complete_30d",+ "reporting_data_incomplete_30d",+ "reporting_data_unavailable_30d",+ "reporting_resources_active_days_30d",+ "reporting_vm_inventory_active_days_30d",+ "reporting_backup_health_active_days_30d",+ "reporting_patrol_digest_active_days_30d",+)+REPORTING_USAGE_FIELDS = (*REPORTING_USAGE_COUNT_FIELDS, "reporting_telemetry_available", "reporting_observation_days")+REPORT_ROW_COLUMNS = tuple(dict.fromkeys((@@ -1074,6 +1101,7 @@ REPORT_ROW_COLUMNS = tuple("platform","notification_failures_7d","successful_history_reads_over_7d_30d",+ *REPORTING_USAGE_FIELDS,*(key for key, _ in ALERT_QUALITY_COUNT_FIELDS),*(key for key, _ in ADOPTION_COUNT_FIELDS),*(key for key, _ in FEATURE_BOOL_FIELDS),@@ -2847,6 +2875,59 @@ def summarize_extended_history_usage("cohorts": cohorts}+def summarize_reporting_usage(+ latest_by_install: dict[str, dict[str, Any]],+ published_versions: set[str], *, now: datetime,+ unavailable_columns: Iterable[str] = (),+) -> dict[str, Any]:+ """Latest rolling counters per rotating ID, never a customer census."""+ source_available = not set(REPORTING_USAGE_FIELDS).intersection(unavailable_columns)+ cohorts = {+ posture: {"reporting_ids": 0, "covered_ids": 0, "unmeasured_ids": 0,+ "partial_observation_ids": 0, "full_30d_observation_ids": 0,+ "ids_with_generated_reports": 0, "ids_with_repeat_periods": 0, "ids_with_repeat_use": 0,+ "counts": dict.fromkeys(REPORTING_USAGE_COUNT_FIELDS, 0)}+ for posture in ("nonfree", "free", "unknown")+ }+ excluded = 0+ for row in latest_by_install.values():+ age = now - parse_received_at(str(row["received_at"]))+ if age < timedelta(0) or age > timedelta(days=7):+ continue+ identity = classify_row_version(row, published_versions)+ if (is_mock_fleet_row(row) or identity.is_development+ or not identity.is_published_release+ or not parse_optional_bool(row.get("monitoring_active"))):+ excluded += 1+ continue+ paid = parse_optional_bool(row.get("paid_license"))+ cohort = cohorts["nonfree" if paid is True else "free" if paid is False else "unknown"]+ cohort["reporting_ids"] += 1+ days = parse_optional_nonnegative_int(row.get("reporting_observation_days"))+ if (not source_available or any(field not in row for field in REPORTING_USAGE_FIELDS)+ or parse_optional_nonnegative_int(row.get("schema_version")) < 20+ or parse_optional_bool(row.get("reporting_telemetry_available")) is not True+ or not 1 <= days <= 30):+ cohort["unmeasured_ids"] += 1+ continue+ cohort["covered_ids"] += 1+ cohort["full_30d_observation_ids" if days == 30 else "partial_observation_ids"] += 1+ counts = {field: min(100000, parse_optional_nonnegative_int(row.get(field)))+ for field in REPORTING_USAGE_COUNT_FIELDS}+ for field, count in counts.items():+ cohort["counts"][field] += count+ if any(count for field, count in counts.items() if field.startswith("reporting_generated_")):+ cohort["ids_with_generated_reports"] += 1+ if any(count for field, count in counts.items() if field.startswith("reporting_repeat_")):+ cohort["ids_with_repeat_periods"] += 1+ if (any(count for field, count in counts.items() if field.startswith("reporting_repeat_"))+ or any(count > 1 for field, count in counts.items() if "_active_days_" in field)):+ cohort["ids_with_repeat_use"] += 1+ return {"window": "7d", "minimum_schema_version": 20,+ "counter_window_utc_days": 30, "repeat_marker_retention_days": 90,+ "source_available": source_available, "excluded_ids": excluded, "cohorts": cohorts}++def analyze_target_release_rows(rows: Iterable[dict[str, Any]],published_versions: set[str],@@ -3458,6 +3539,10 @@ def summarize_rows("installs": len(mock_fleet_installs),},"latest_install_windows": latest_install_windows,+ "reporting_usage_7d": summarize_reporting_usage(+ latest_by_install, published_versions, now=current_time,+ unavailable_columns=unavailable_columns,+ ),"extended_history_usage_7d": summarize_extended_history_usage(latest_by_install, published_versions, now=current_time,unavailable_columns=unavailable_columns,@@ -3696,6 +3781,33 @@ def format_text(summary: dict[str, Any], repo: str, since_days: int) -> str:"An upgrade starts measurement, so a zero is not a full 30-day observation.")+ reporting = summary.get("reporting_usage_7d")+ if reporting:+ lines.extend(["", "Reporting outcomes (active production reporting IDs, 7d):"])+ for posture, cohort in reporting["cohorts"].items():+ lines.append(+ f"- {posture}: {cohort['covered_ids']} measured, "+ f"{cohort['unmeasured_ids']} unmeasured, "+ f"{cohort['full_30d_observation_ids']} with 30 elapsed observation days, "+ f"{cohort['ids_with_generated_reports']} generating reports, "+ f"{cohort['ids_with_repeat_periods']} with repeat reporting periods, "+ f"{cohort['ids_with_repeat_use']} with repeat use"+ )+ for field, count in cohort["counts"].items():+ lines.append(f" - {field}: {count}")+ lines.append(+ "- interpretation: schema v20+ and available tally only. Missing measurements are unknown, "+ "not zero use. Latest rolling 30 UTC-day totals only, never summed heartbeats. "+ "Active-day counts show distinct UTC days with successful generation, including manual downloads. "+ "Multiple attempts in one day count as one active day. "+ "Generation and delivery counts include separate attempts. Successful periods require a persisted "+ "successful saved-schedule run. Repeat periods require another distinct window on the same schedule "+ "within 90 days, so retries and same-period reruns do not qualify. "+ "SMTP acceptance does not establish inbox receipt. Observation days are elapsed days since tally "+ "initialization, not proof of continuous uptime. Rotating IDs are not people or subscriptions. "+ "The nonfree flag does not verify paying customers or willingness to pay."+ )+pulse_loop = summary.get("pulse_intelligence_value_loop_7d")if pulse_loop:lines.extend(diff --git a/scripts/tests/test_telemetry_adoption_report.py b/scripts/tests/test_telemetry_adoption_report.pyindex ed288d1d9d..95d44e4fec 100644--- a/scripts/tests/test_telemetry_adoption_report.py+++ b/scripts/tests/test_telemetry_adoption_report.py@@ -24,6 +24,40 @@ import telemetry_adoption_report as reportclass TelemetryAdoptionReportTest(unittest.TestCase):+ def test_reporting_usage_requires_measurement_and_counts_latest_only(self) -> None:+ now = datetime(2026, 10, 17, 12, tzinfo=timezone.utc)+ base = {"received_at": "2026-10-17 11:00:00", "version": "6.6.0",+ "monitoring_active": 1, "schema_version": 20, "paid_license": 1,+ **dict.fromkeys(report.REPORTING_USAGE_COUNT_FIELDS, 0),+ "reporting_telemetry_available": 1, "reporting_observation_days": 30,+ "reporting_generated_backup_health_30d": 4,+ "reporting_backup_health_active_days_30d": 2,+ "reporting_repeat_backup_health_periods_30d": 1}+ rows = [{**base, "install_id": "measured"},+ {**base, "install_id": "measured", "received_at": "2026-10-16 11:00:00", "reporting_generated_backup_health_30d": 3},+ {**base, "install_id": "new", "reporting_observation_days": 1},+ {**base, "install_id": "legacy", "schema_version": 19},+ {**base, "install_id": "unavailable", "reporting_telemetry_available": 0},+ {**base, "install_id": "inactive", "monitoring_active": 0},+ {**base, "install_id": "dev", "version_is_development": 1}]+ usage = report.summarize_rows({}, rows, {"6.6.0"}, now=now)["reporting_usage_7d"]+ cohort = usage["cohorts"]["nonfree"]+ self.assertEqual((cohort["covered_ids"], cohort["unmeasured_ids"]), (2, 2))+ self.assertEqual((cohort["full_30d_observation_ids"], cohort["partial_observation_ids"]), (1, 1))+ self.assertEqual(cohort["counts"]["reporting_generated_backup_health_30d"], 8)+ self.assertEqual(cohort["ids_with_repeat_periods"], 2)+ self.assertEqual(cohort["ids_with_repeat_use"], 2)+ manual = {**base, "install_id": "manual", "reporting_repeat_backup_health_periods_30d": 0}+ manual_cohort = report.summarize_reporting_usage(+ {"manual": manual}, {"6.6.0"}, now=now)["cohorts"]["nonfree"]+ self.assertEqual(manual_cohort["ids_with_repeat_periods"], 0)+ self.assertEqual(manual_cohort["ids_with_repeat_use"], 1)+ self.assertEqual(usage["excluded_ids"], 2)+ unavailable = report.summarize_rows({}, rows, {"6.6.0"}, now=now,+ unavailable_columns=["reporting_saved_30d"])["reporting_usage_7d"]+ self.assertFalse(unavailable["source_available"])+ self.assertEqual(unavailable["cohorts"]["nonfree"]["covered_ids"], 0)+def test_extended_history_reports_coverage_and_latest_rolling_count(self) -> None:now = datetime(2026, 10, 16, 12, tzinfo=timezone.utc)base = {"received_at": "2026-10-16 11:00:00", "version": "6.6.0",@@ -61,6 +95,7 @@ class TelemetryAdoptionReportTest(unittest.TestCase):conn.execute("INSERT INTO telemetry_pings VALUES (datetime('now'), 'fixture', '6.6.0')")source = report.fetch_rows_local(db_path, 7)self.assertIn("successful_history_reads_over_7d_30d", source["unavailable_columns"])+ self.assertIn("reporting_telemetry_available", source["unavailable_columns"])self.assertEqual(source["rows"][0]["successful_history_reads_over_7d_30d"], 0)def test_normalize_reported_version_strips_v_prefix(self) -> None:diff --git a/tests/integration/tests/19-telemetry-disclosure.spec.ts b/tests/integration/tests/19-telemetry-disclosure.spec.tsindex 03d0aa1111..ac77abffb8 100644--- a/tests/integration/tests/19-telemetry-disclosure.spec.ts+++ b/tests/integration/tests/19-telemetry-disclosure.spec.ts@@ -10,7 +10,7 @@ import {import { createAuthenticatedStorageState } from "./helpers";const __dirname = path.dirname(fileURLToPath(import.meta.url));-const EXPECTED_TELEMETRY_SCHEMA_VERSION = 19;+const EXPECTED_TELEMETRY_SCHEMA_VERSION = 20;type WorkerFixtures = {authStorageStatePath: string;@@ -55,7 +55,8 @@ async function expectPopupDoc(await expect(popup.locator("body")).toContainText(expectedText);await expect(popup.locator("body")).toContainText("successful_history_reads_over_7d_30d");await expect(popup.locator("body")).toContainText("Selecting a long range alone does not count");- await popup.getByText("Schema v19 adds", { exact: false }).scrollIntoViewIfNeeded();+ await expect(popup.locator("body")).toContainText("reporting_repeat_backup_health_periods_30d");+ await popup.getByText("Schema v20 adds", { exact: false }).scrollIntoViewIfNeeded();await popup.screenshot({ path: test.info().outputPath("privacy-history-counter.png") });await popup.close();}@@ -74,16 +75,19 @@ async function readTelemetryPreview(page: Page) {update_check_outcome: string;update_available: boolean;successful_history_reads_over_7d_30d: number;+ reporting_generated_backup_health_30d: number;+ reporting_telemetry_available: boolean;+ reporting_observation_days: number;};}async function showExtendedHistoryCount(page: Page) {await page.locator('pre[aria-label="Telemetry payload preview"]').evaluate((pre) => {const node = pre.firstChild!;- const offset = (node.textContent ?? "").indexOf("successful_history_reads_over_7d_30d");+ const offset = (node.textContent ?? "").indexOf("reporting_generated_backup_health_30d");const range = document.createRange();range.setStart(node, offset);- range.setEnd(node, offset + "successful_history_reads_over_7d_30d".length);+ range.setEnd(node, offset + "reporting_generated_backup_health_30d".length);for (let parent = pre.parentElement; parent; parent = parent.parentElement) {if (parent.scrollHeight > parent.clientHeight && /auto|scroll/.test(getComputedStyle(parent).overflowY)) {parent.scrollTop += range.getBoundingClientRect().top - parent.getBoundingClientRect().top - parent.clientHeight / 2;@@ -91,7 +95,7 @@ async function showExtendedHistoryCount(page: Page) {}const rect = range.getBoundingClientRect();if (rect.top < 60 || rect.bottom > window.innerHeight - 60) {- throw new Error("Extended history count must be in the visible preview before capture");+ throw new Error("Reporting count must be in the visible preview before capture");}});}@@ -136,6 +140,36 @@ test.describe("Telemetry disclosure", () => {);});+ test("reporting telemetry preserves the saved opt-out", async ({ page }) => {+ await page.setViewportSize({ width: 1280, height: 800 });+ await page.goto("/settings/system-general", { waitUntil: "domcontentloaded" });+ const toggle = page.getByRole("button", { name: "Outbound usage telemetry", exact: true });+ await expect(toggle).toBeVisible();+ // Environment overrides intentionally lock the existing control. The+ // task-specific browser server also exercises the unlocked saved preference.+ if (await toggle.isDisabled()) {+ await expect(toggle).toBeDisabled();+ return;+ }+ const original = await toggle.getAttribute("aria-pressed");+ for (const state of ["true", "false"]) {+ if ((await toggle.getAttribute("aria-pressed")) !== state) {+ await toggle.focus();+ await toggle.press("Enter");+ }+ await expect(toggle).toHaveAttribute("aria-pressed", state);+ await expect(toggle).toBeEnabled();+ await page.reload({ waitUntil: "domcontentloaded" });+ await expect(toggle).toHaveAttribute("aria-pressed", state);+ }+ await page.screenshot({ path: test.info().outputPath("reporting-telemetry-opted-out.png") });+ if (original === "true") {+ await toggle.click();+ await expect(toggle).toHaveAttribute("aria-pressed", "true");+ await expect(toggle).toBeEnabled();+ }+ });+test("general settings lets operators preview and rotate the telemetry payload", async ({page,}, testInfo) => {@@ -183,6 +217,9 @@ test.describe("Telemetry disclosure", () => {]).toContain(initialPreview.update_check_outcome);expect(typeof initialPreview.update_available).toBe("boolean");expect(initialPreview.successful_history_reads_over_7d_30d).toBe(0);+ expect(initialPreview.reporting_generated_backup_health_30d).toBe(0);+ expect(initialPreview.reporting_telemetry_available).toBe(true);+ expect(initialPreview.reporting_observation_days).toBeGreaterThanOrEqual(1);await page.getByRole("button", { name: "Refresh payload" }).click();expect((await readTelemetryPreview(page)).successful_history_reads_over_7d_30d).toBe(0);// Fixture data must not create real extended-history usage.@@ -213,5 +250,8 @@ test.describe("Telemetry disclosure", () => {expect((await readTelemetryPreview(page)).successful_history_reads_over_7d_30d).toBe(0);await showExtendedHistoryCount(page);await page.screenshot({ path: testInfo.outputPath("telemetry-preview-narrow.png") });+ await page.setViewportSize({ width: 768, height: 1024 });+ await showExtendedHistoryCount(page);+ await page.screenshot({ path: testInfo.outputPath("telemetry-preview-intermediate.png") });});});