Task · TSO-0099

Services collector reports a complete host snapshot after cancelled dispatch

Description

Two findings from the post-Wave-3 sharded CodeRabbit pass, both in internal/collector/services/services.go and both about TSO-0037 work:

  1. Around line 218 the worker loop defers apistate.Observe until after the loop, aggregating results, where observing each API result as it returns would avoid the duplicate record the aggregate produces.
  2. Around lines 226-229 fetchHosts does not distinguish “all service requests completed” from “cancelled partway through dispatch”. Collect then emits docHostInfo from a partial result as though it were a full snapshot, so a cancellation during dispatch silently publishes an incomplete host inventory that looks authoritative.

The second is the one that matters: a host snapshot that is quietly partial is worse than one that is absent, because nothing downstream can tell. Have fetchHosts return an explicit completion state and skip the snapshot when it is incomplete, with a regression test covering cancellation after one job completes but before the rest are dispatched.

Acceptance Criteria

Definition of Done

Implementation Plan

Implementation Notes

Final Summary

Services host collection now returns an explicit dispatch-complete state and suppresses cancelled partial snapshots. The telemetry regression failed before the fix, passed after it, and remained stable across 20 race runs; per-result observation remains nonduplicating.

View the source file on GitHub