C++ fleet client never sends: start() spawns no heartbeat/controller thread (Python parity)

Summary

The C++ variant of the fleet client never transmits anything. StatusMonitor::start() / FleetMonitorClient::start() are effectively no-ops — they record start_time and clear the stop flag but spawn no background thread, and the one method that actually sends (StatusMonitor::sendAll() → FleetMonitorClient::sendHeartbeat()/sendDiagnostics()) is never called anywhere in the C++ tree.

Result: a consuming app logs "Fleet reporting started" but zero heartbeats/diagnostics/status reach fleet.brinkhaus-gmbh.de, with no error (because post() is never reached).

The Python variant is correct — its start() methods spawn the background loops. This is a behavioral parity bug in the C++ port; the wire protocol/payloads are fine.

Evidence

  • Real consumer: DigitalWay samplingbackend, customer dw, machine test.
  • Server-side (ssh root@berlin, docker logs fleetmanager): 0 POST /api/ingest/dw/... in 3h and over a 75s live tail, while other customers (gmn/brinkhaus/uttec) send 200 OK continuously. The dw/test instance shows RED/overdue.
  • A manual curl POST /api/ingest/dw/test/samplingbackend/heartbeat with the real bearer token returned {"ok":true} 200 and turned the machine green → token, customer, path and server are all fine. Only the C++ client doesn't send.

Root cause (C++ vs Python)

Aspect Python (correct) C++ (broken)
FleetMonitorClient.start() spawns _heartbeat_loop thread (python/.../fleet/client.py:146-158) + sends initial status=running only sets start_time_, no thread (cpp/src/fleet_monitor_client.cpp:92-95)
StatusMonitor.start() spawns _controller_loop thread → diagnostics+status every 60s (python/.../fleet/monitor.py:94-105) only calls client_->start() (cpp/src/status_monitor.cpp:54); sendAll() never invoked
connection state → diagnosis _on_connection_change → notify/clear code 7002 (monitor.py:220) not wired
config retry _try_reload_config (monitor.py:146) missing
initial/final status running on start, stopped on stop none
TLS urllib + default SSL ctx (verified, system/certifi CAs) libcurl without CURLOPT_CAINFO/SSL_VERIFYPEER (fleet_monitor_client.cpp:225-231) → may fail silently on Windows/OpenSSL builds

Proposed fix (C++)

  1. FleetMonitorClient::start(): spawn a heartbeat thread sending every heartbeat_interval (mirror Python _heartbeat_loop); send initial running status.
  2. StatusMonitor::start(): spawn a controller thread sending diagnostics + snapshot/status every 60s, with config-retry, and mirror connection state into SelfDiagnosisEngine (codes 7001 config-missing, 7002 connection-error).
  3. Set CURLOPT_CAINFO to a bundled CA (or build libcurl with Schannel) so HTTPS verification matches Python.

Keep the variants compatible (process)

The shared test-fixtures/ + schemas/ only validate payload shape, not runtime behavior — which is why this slipped through.

  • Add a language-agnostic behavior spec (alongside architecture/fleet-protocol.md): start() MUST start the send loop; intervals; diagnosis codes 7001/7002; initial/final status. Make start() semantics explicit so a porter can't stub it.
  • Add a behavioral conformance test in CI for every variant: point the monitor at a mock ingest server, assert ≥1 heartbeat + diagnostics + status arrive within ~2× interval, schema-valid, correct path segments. (Would have caught this immediately.)
  • Track behavior parity per variant in docs/api-overview.md and gate releases on it.
  • Designate Python as the reference implementation; behavior changes land in reference + spec + fixtures first, then ports.

Affected downstream

brinkhauslib / samplingBackend (Digital Way): fleet reporting silently does nothing. Workaround until fixed: call fleetMonitor->sendAll() on a 60s timer in the app, and set a real machineName (currently the placeholder your-machine-name).