Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Harden Patrol activation telemetry

Pulse Test473885e2ceba
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index d7ba402270..fd462b68d0 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5124,7 +5124,7 @@ projection (intentionally offline, never auto-remediate, active
maintenance window) and a `FindingOperationalMemory` projection
(regression count, previous resolved fix summary, times raised)
populated from fields the internal `Finding` already carries. The
-orchestrator (in pulse-pro) consumes these fields when reasoning
+orchestrator (in pulse-enterprise) consumes these fields when reasoning
about the next move — it does not need a separate read to get
the situated picture, and it can avoid proposing fixes the
operator has locked the resource against.
@@ -5142,6 +5142,12 @@ save, a transition into Watch Only, an unavailable orchestrator, or an
effective mode still clamped to `monitor`; activation must never create an
unbounded model-work burst or bypass suppression, snooze, cooldown, attempt,
terminal-outcome, operator-state, and concurrency gates.
+The enterprise orchestrator owns authoritative concurrency admission: it
+atomically checks and reserves a slot before beginning an investigation, while
+`CanStartInvestigation` remains advisory. Its running-count projection includes
+both in-memory reservations and persisted running sessions, so simultaneous
+activation, scheduled, alert-triggered, and manual callers cannot oversubscribe
+`MaxConcurrent` through a check-then-increment race.
`ResourceOperatorStateProjection` carries `NeverAutoRemediate`
and `Criticality` alongside `IntentionallyOffline` and `MaintenanceWindow` so the
diff --git a/frontend-modern/src/api/__tests__/settings.test.ts b/frontend-modern/src/api/__tests__/settings.test.ts
index 58e4ac06ed..49add8eaff 100644
--- a/frontend-modern/src/api/__tests__/settings.test.ts
+++ b/frontend-modern/src/api/__tests__/settings.test.ts
@@ -75,6 +75,8 @@ const mockTelemetryPreviewPayload = {
update_successes_30d: 0,
update_failures_30d: 0,
update_last_failure_category: undefined,
+ node_test_attempts_30d: 0,
+ node_test_failures_30d: 0,
alerts_fired_30d: 0,
alerts_acknowledged_30d: 0,
alerts_resolved_30d: 0,
@@ -128,6 +130,7 @@ const mockTelemetryPreviewPayload = {
pulse_intelligence_patrol_new_findings_30d: 0,
pulse_intelligence_patrol_investigations_30d: 0,
pulse_intelligence_patrol_resolved_findings_30d: 0,
+ pulse_intelligence_patrol_blocked_cause: undefined,
pulse_intelligence_external_agent_enabled: false,
pulse_intelligence_external_agent_used_30d: false,
pulse_intelligence_mcp_adapter_used_30d: false,
@@ -162,6 +165,7 @@ const mockTelemetryPreviewPayload = {
pulse_intelligence_approved_action_refusals_prerequisite_30d: 0,
pulse_intelligence_approved_action_refusals_contract_30d: 0,
pulse_intelligence_approved_action_refusals_other_30d: 0,
+ pulse_intelligence_approved_action_refusals_uncoded_30d: 0,
pulse_intelligence_verified_finding_resolutions_30d: 0,
pulse_intelligence_approved_action_last_failure_reason_30d: undefined,
} satisfies TelemetryPingPreview;
diff --git a/frontend-modern/src/api/settings.ts b/frontend-modern/src/api/settings.ts
index ac64366062..b30bd56b4a 100644
--- a/frontend-modern/src/api/settings.ts
+++ b/frontend-modern/src/api/settings.ts
@@ -76,6 +76,8 @@ export interface TelemetryPingPreview {
update_successes_30d: number;
update_failures_30d: number;
update_last_failure_category?: string;
+ node_test_attempts_30d: number;
+ node_test_failures_30d: number;
alerts_fired_30d: number;
alerts_acknowledged_30d: number;
alerts_resolved_30d: number;
@@ -129,6 +131,7 @@ export interface TelemetryPingPreview {
pulse_intelligence_patrol_new_findings_30d: number;
pulse_intelligence_patrol_investigations_30d: number;
pulse_intelligence_patrol_resolved_findings_30d: number;
+ pulse_intelligence_patrol_blocked_cause?: string;
pulse_intelligence_external_agent_enabled: boolean;
pulse_intelligence_external_agent_used_30d: boolean;
pulse_intelligence_mcp_adapter_used_30d: boolean;
@@ -163,6 +166,7 @@ export interface TelemetryPingPreview {
pulse_intelligence_approved_action_refusals_prerequisite_30d: number;
pulse_intelligence_approved_action_refusals_contract_30d: number;
pulse_intelligence_approved_action_refusals_other_30d: number;
+ pulse_intelligence_approved_action_refusals_uncoded_30d: number;
pulse_intelligence_verified_finding_resolutions_30d: number;
pulse_intelligence_approved_action_last_failure_reason_30d?: string;
}
diff --git a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
index 231ee28abf..6458c588d0 100644
--- a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
@@ -80,6 +80,8 @@ const buildTelemetryPreviewPayload = (
update_attempts_30d: 0,
update_successes_30d: 0,
update_failures_30d: 0,
+ node_test_attempts_30d: 0,
+ node_test_failures_30d: 0,
update_last_failure_category: undefined,
alerts_fired_30d: 0,
alerts_acknowledged_30d: 0,
@@ -134,6 +136,7 @@ const buildTelemetryPreviewPayload = (
pulse_intelligence_patrol_new_findings_30d: 0,
pulse_intelligence_patrol_investigations_30d: 0,
pulse_intelligence_patrol_resolved_findings_30d: 0,
+ pulse_intelligence_patrol_blocked_cause: undefined,
pulse_intelligence_external_agent_enabled: false,
pulse_intelligence_external_agent_used_30d: false,
pulse_intelligence_mcp_adapter_used_30d: false,
@@ -168,6 +171,7 @@ const buildTelemetryPreviewPayload = (
pulse_intelligence_approved_action_refusals_prerequisite_30d: 0,
pulse_intelligence_approved_action_refusals_contract_30d: 0,
pulse_intelligence_approved_action_refusals_other_30d: 0,
+ pulse_intelligence_approved_action_refusals_uncoded_30d: 0,
pulse_intelligence_verified_finding_resolutions_30d: 0,
pulse_intelligence_approved_action_last_failure_reason_30d: undefined,
...overrides,
diff --git a/internal/ai/patrol_activation_reconcile_test.go b/internal/ai/patrol_activation_reconcile_test.go
index d310539c36..b4bd04e853 100644
--- a/internal/ai/patrol_activation_reconcile_test.go
+++ b/internal/ai/patrol_activation_reconcile_test.go
@@ -1,6 +1,7 @@
package ai
import (
+ "sync/atomic"
"testing"
"time"
@@ -68,3 +69,27 @@ func TestReconcileActionableFindingBacklogDoesNothingInWatchOnly(t *testing.T) {
default:
}
}
+
+func TestReconcileActionableFindingBacklogUsesRemainingAdmissionCapacity(t *testing.T) {
+ persistence := config.NewConfigPersistence(t.TempDir())
+ service := NewService(persistence, nil)
+ service.cfg = &config.AIConfig{Enabled: true, PatrolAutonomyLevel: config.PatrolAutonomyApproval}
+ patrol := NewPatrolService(service, nil)
+ orchestrator := newIntegrationOrchestrator(true)
+ atomic.StoreInt32(&orchestrator.runningCount, maxPatrolActivationBacklogInvestigations-1)
+ patrol.SetInvestigationOrchestrator(orchestrator)
+
+ for _, id := range []string{"warning-1", "warning-2", "warning-3"} {
+ patrol.findings.Add(&Finding{
+ ID: id, Severity: FindingSeverityWarning, ResourceID: "vm-1", DetectedAt: time.Now().UTC(),
+ })
+ }
+
+ if got := patrol.ReconcileActionableFindingBacklog(); got != 1 {
+ t.Fatalf("ReconcileActionableFindingBacklog() = %d, want 1 remaining slot", got)
+ }
+ patrol.investigationWg.Wait()
+ if got := len(orchestrator.investigateCh); got != 1 {
+ t.Fatalf("started investigations = %d, want 1", got)
+ }
+}
diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.go
index 2bfc13debf..3eb28535dd 100644
--- a/internal/api/ai_handlers_test.go
+++ b/internal/api/ai_handlers_test.go
@@ -288,6 +288,29 @@ func TestMutatePatrolAutopilotConfigReconcilesBacklogOnlyWhenLeavingMonitor(t *t
t.Fatalf("no-op paid-mode save retriggered finding %q", findingID)
case <-time.After(50 * time.Millisecond):
}
+
+ setMonitor := func(cfg *config.AIConfig, _ unifiedresources.PatrolAutopilotServerPolicy) (bool, error) {
+ changed := cfg.PatrolAutonomyLevel != config.PatrolAutonomyMonitor
+ cfg.PatrolAutonomyLevel = config.PatrolAutonomyMonitor
+ return changed, nil
+ }
+ require.NoError(t, handler.mutatePatrolAutopilotConfig(context.Background(), setMonitor))
+ select {
+ case findingID := <-orchestrator.investigateCh:
+ t.Fatalf("demotion to Watch Only retriggered finding %q", findingID)
+ case <-time.After(50 * time.Millisecond):
+ }
+
+ updateBudget := func(cfg *config.AIConfig, _ unifiedresources.PatrolAutopilotServerPolicy) (bool, error) {
+ cfg.PatrolInvestigationBudget++
+ return true, nil
+ }
+ require.NoError(t, handler.mutatePatrolAutopilotConfig(context.Background(), updateBudget))
+ select {
+ case findingID := <-orchestrator.investigateCh:
+ t.Fatalf("Watch Only control update retriggered finding %q", findingID)
+ case <-time.After(50 * time.Millisecond):
+ }
}
func TestAISettingsProvidersProjectionCarriesSuggestedModelWireShape(t *testing.T) {
diff --git a/scripts/check_telemetry_schema_parity.py b/scripts/check_telemetry_schema_parity.py
index a0805e11d1..6ad7b40638 100644
--- a/scripts/check_telemetry_schema_parity.py
+++ b/scripts/check_telemetry_schema_parity.py
@@ -18,7 +18,10 @@ TYPESCRIPT_FIELD_RE = re.compile(
re.MULTILINE,
)
TYPESCRIPT_TO_GO = {"string": "string", "number": "int", "boolean": "bool"}
-LEGACY_RECEIVER_ONLY_FIELDS = {"license_tier", "api_tokens"}
+# Receiver-only operational fields are deliberately excluded from the public
+# heartbeat. deployment_proof marks synthetic operator verification traffic;
+# license_tier and api_tokens are receiver-derived compatibility inputs.
+RECEIVER_ONLY_FIELDS = {"license_tier", "api_tokens", "deployment_proof"}
def struct_body(source: str, marker: str) -> str:
@@ -76,9 +79,9 @@ def parity_errors(
if missing:
errors.append("receiver missing public fields: " + ", ".join(missing))
- unexpected = sorted(set(receiver) - set(public) - LEGACY_RECEIVER_ONLY_FIELDS)
+ unexpected = sorted(set(receiver) - set(public) - RECEIVER_ONLY_FIELDS)
if unexpected:
- errors.append("receiver-only fields outside the legacy allowlist: " + ", ".join(unexpected))
+ errors.append("receiver-only fields outside the allowlist: " + ", ".join(unexpected))
mismatched = sorted(
name
diff --git a/scripts/telemetry_adoption_report.py b/scripts/telemetry_adoption_report.py
index f92494403a..5dd13a822d 100644
--- a/scripts/telemetry_adoption_report.py
+++ b/scripts/telemetry_adoption_report.py
@@ -1677,6 +1677,14 @@ if any(name not in column_names for name in target_activity_columns):
raise ValueError("invalid target release activity projection")
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
+available_columns = {
+ row[1] for row in conn.execute("PRAGMA table_info(telemetry_pings)")
+}
+missing_columns = sorted(set(column_names) - available_columns)
+row_projections = [
+ name if name in available_columns else "0 AS " + name
+ for name in column_names
+]
db_stats_sql = (
"SELECT MAX(received_at) AS latest_ping, "
"COUNT(*) AS total_rows, "
@@ -1685,7 +1693,7 @@ db_stats_sql = (
)
rows_sql = (
"WITH ranked AS ("
- "SELECT " + ", ".join(column_names) + ", "
+ "SELECT " + ", ".join(row_projections) + ", "
"ROW_NUMBER() OVER ("
"PARTITION BY install_id ORDER BY received_at DESC, rowid DESC"
") AS latest_rank "
@@ -1701,11 +1709,12 @@ analysis_selects = [
"MIN(CASE WHEN paid_license = 1 THEN received_at END)",
]
for name in intelligence_columns:
+ signal_expression = name if name in available_columns else "0"
analysis_selects.append(
- "MAX(CASE WHEN " + name + " <> 0 THEN 1 ELSE 0 END)"
+ "MAX(CASE WHEN " + signal_expression + " <> 0 THEN 1 ELSE 0 END)"
)
analysis_selects.append(
- "MIN(CASE WHEN paid_license = 0 AND " + name +
+ "MIN(CASE WHEN paid_license = 0 AND " + signal_expression +
" <> 0 THEN received_at END)"
)
analysis_sql = (
@@ -1743,11 +1752,15 @@ if target_version:
"received_at",
"rowid AS source_rowid",
"TRIM(version) AS ordered_version",
- *target_activity_columns,
+ *(
+ name if name in available_columns else "0 AS " + name
+ for name in target_activity_columns
+ ),
"LAG(received_at) OVER install_order AS previous_received_at",
"LAG(TRIM(version)) OVER install_order AS previous_version",
*(
- "LAG(COALESCE(" + name + ", 0)) OVER install_order AS previous_" + name
+ "LAG(COALESCE(" + (name if name in available_columns else "0") +
+ ", 0)) OVER install_order AS previous_" + name
for name in target_activity_columns
),
]
@@ -1785,7 +1798,11 @@ def emit(value):
try:
db_stats = dict(conn.execute(db_stats_sql).fetchone())
- emit({"db_stats": db_stats, "row_columns": column_names})
+ emit({
+ "db_stats": db_stats,
+ "row_columns": column_names,
+ "unavailable_columns": missing_columns,
+ })
cutoff = f"-{since_days} days"
for row in conn.execute(analysis_sql, (cutoff,)):
first_paid_at = row[3]
@@ -1912,6 +1929,7 @@ finally:
"rows": rows,
"pulse_intelligence_analysis_facts": analysis_facts,
"target_release_analysis_facts": target_release_facts,
+ "unavailable_columns": header.get("unavailable_columns", []),
}
@@ -3122,6 +3140,13 @@ def format_text(summary: dict[str, Any], repo: str, since_days: int) -> str:
f"total distinct installs: {summary['db_stats'].get('total_distinct_installs', 0)}",
]
+ unavailable_columns = summary.get("source_schema", {}).get("unavailable_columns", [])
+ if unavailable_columns:
+ lines.append(
+ "source schema warning: unavailable fields defaulted to zero: "
+ + ", ".join(unavailable_columns)
+ )
+
exclusions = summary.get("mock_fleet_exclusions")
if exclusions:
if exclusions.get("enabled"):
@@ -3523,6 +3548,9 @@ def main(argv: list[str] | None = None) -> int:
"target_release_analysis_facts"
),
)
+ summary["source_schema"] = {
+ "unavailable_columns": source.get("unavailable_columns", []),
+ }
if args.format == "json":
print(json.dumps(summary, indent=2, sort_keys=True))
diff --git a/scripts/tests/test_telemetry_adoption_report.py b/scripts/tests/test_telemetry_adoption_report.py
index 2e69c4c527..376c59883a 100644
--- a/scripts/tests/test_telemetry_adoption_report.py
+++ b/scripts/tests/test_telemetry_adoption_report.py
@@ -71,6 +71,7 @@ class TelemetryAdoptionReportTest(unittest.TestCase):
{
"db_stats": db_stats,
"row_columns": list(report.REPORT_ROW_COLUMNS),
+ "unavailable_columns": [],
}
),
*(
@@ -140,6 +141,7 @@ class TelemetryAdoptionReportTest(unittest.TestCase):
"rows": expanded_rows,
"pulse_intelligence_analysis_facts": analysis_facts,
"target_release_analysis_facts": target_release_facts,
+ "unavailable_columns": [],
},
)
remote_script = run_mock.call_args.kwargs["input"].decode("utf-8")
@@ -163,6 +165,8 @@ class TelemetryAdoptionReportTest(unittest.TestCase):
self.assertIn("GROUP BY install_id", remote_script)
self.assertIn("MIN(CASE WHEN paid_license = 0", remote_script)
self.assertIn("target_analysis_sql", remote_script)
+ self.assertIn("PRAGMA table_info(telemetry_pings)", remote_script)
+ self.assertIn("0 AS \" + name", remote_script)
compile(remote_script, "<telemetry-remote-fetch>", "exec")
def test_report_projection_and_signal_specs_cover_recent_schema_fields(self) -> None: