Files
AutopilotMonitor/src/Agent/AutopilotMonitor.Agent.V2.Core.Tests
Oliver Kieselbach b3954b7b4d feat(agent+web): agent_late_start + script_timeout_suspected detectors + per-script run duration
Born from /session-debug analysis of f148976f: a customer platform script
(c3e0124c) hung for the full ~30-min IME script-execution timeout, blocking
IME's serial platform-script queue, so the Autopilot-Monitor bootstrap +
agent only started ~34 min after boot (right as ESP hit its own 30-min
SyncFailureTimeout). The agent observed only the already-decided end-state
and lived ~30s — a session that looks like a normal multi-minute failure but
had near-zero coverage of the actual failure window.

Two detectors classify this automatically:

- agent_late_start (Warning, EnrollmentTerminationHandler): fires when the
  agent started >=10 min after boot AND lived <=5 min before a terminal
  outcome. Device boot via GetTickCount64 P/Invoke (net48 has no
  Environment.TickCount64), monotonic / clock-jump-resistant. Shared gate in
  Termination/ObservationCoverage.cs (DRY with the builder). final-status.json
  gains bootToAgentStartSeconds + lowObservationCoverage (FinalStatusBuilder
  stays pure via an optional deviceBootUtc param).

- script_timeout_suspected (Warning, ImeLogTrackerAdapter): a platform script
  that ran >=25 min AND ended Failed -> one-shot per policyId, naming it as the
  likely enrollment-pipeline blocker. Works on replay (StartedAtUtc from the
  CMTrace source timestamp), so it fires even when the script ran before the
  agent launched.

Plus per-script run duration for all platform scripts: new
ScriptExecutionState.StartedAtUtc -> durationSeconds on every
script_completed/script_failed -> Web ScriptExecutions renders "Duration"
(amber past 10 min) so slow/inefficient scripts surface generally.

Scope: platform scripts only (remediation/health-script duration deferred --
the multi-source HS reducer makes clean attribution fragile). No ConfigVersion
bump, no backend code (ingest is event-agnostic). New event types wired through
the mandatory dual-sync: Constants.EventTypes -> MCP resource-catalog ->
Web eventTypes (drift tests enforce).

Tests: V2.Core 1536 (+88), MCP drift 6, MCP/Web tsc 0, Web 84. The f148976f
case is reproduced in unit tests (ObservationCoverage 34min/30s; adapter
c3e0124c 30min/Failed). Inert until redeploy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 12:44:53 +02:00
..