Telemetry and Persistence

How AutoDoctor builds telemetry, writes SQLite rows, stores metadata, generates report artifacts, and keeps API/dashboard reads consistent with current run context.

Who This Is For

  • Developers troubleshooting missing dashboard data.
  • Operators validating write/read consistency.

Telemetry Collection Flow

  1. Invoke-AutoDoctorTelemetryCollection builds telemetry object.
  2. JSON file is written as UTF-8 without BOM.
  3. Write-AutoDoctorTelemetry inserts module and system snapshot rows into SQLite.
  4. Baseline and trend tables are updated from the current snapshot.
  5. Report generation writes HTML, JSON, and Markdown outputs, plus PDF when Chromium is available.

Key telemetry object sections:

  • RunID, GeneratedAt, Hostname, AutoDoctorVersion
  • ExecutionStats
  • System
  • Modules

DB Write Flow

Diagnostics

Write-AutoDoctorDiagnostics inserts per-module status and summary into diagnostics.

Remediation

Write-AutoDoctorRemediation inserts remediation module status into remediation.

Telemetry

Write-AutoDoctorTelemetry writes:

  • module-level status and keys into telemetry_modules
  • derived system snapshot into system_info
  • current trend snapshot into telemetry_trends
  • rolling baseline aggregates into telemetry_baselines

Alerts

Write-AutoDoctorAlerts maps root-cause detected issues into alerts with severity.

Report Read Models

AutoDoctor writes multiple report artifacts that act as read-friendly views over the same run:

  • AutoDoctor_Report.html: interactive operational report
  • AutoDoctor_Report.json: structured summary used by /api/dashboard/summary
  • AutoDoctor_Report.md: lightweight text export
  • AutoDoctor_Report.pdf: optional print-friendly export

This means the dashboard can combine:

  • SQLite for historical charts and counts
  • report JSON for high-level reasoning and grouped findings

Metadata File for Dashboard

latest_run.json is written at:

  • server/latest_run.json

Fields:

  • run_id
  • host_name
  • generated_time

The API endpoint /api/dashboard/meta reads this file and provides fallbacks if missing/corrupt.

The endpoint /api/dashboard/summary combines this metadata with AutoDoctor_Report.json.

Concurrency Notes

API DB connections set:

  • PRAGMA journal_mode=WAL
  • PRAGMA busy_timeout=5000

This supports concurrent writer/reader behavior between agent and API.

Validation Queries

SELECT COUNT(*) FROM diagnostics;
SELECT COUNT(*) FROM alerts;
SELECT COUNT(*) FROM telemetry_modules;
SELECT * FROM system_info ORDER BY timestamp DESC LIMIT 5;
SELECT * FROM telemetry_trends ORDER BY timestamp DESC LIMIT 5;
SELECT * FROM telemetry_baselines ORDER BY updated_at DESC LIMIT 8;

Next Steps