Description
Two findings from the post-Wave-3 sharded CodeRabbit pass, both in internal/collector/services/services.go and both about TSO-0037 work:
- 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.
- 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
- #1 fetchHosts returns an explicit completion state and Collect emits the host snapshot only when dispatch completed
- #2 A regression test cancels after one job completes but before the remainder are dispatched, and asserts no snapshot is emitted
- #3 Per-result observation replaces the aggregate record, or the duplicate is shown not to occur
Definition of Done
- #1 just check passes (the full gate; it is what CI enforces)
- #2 just gen leaves no diff (only if a generated artifact’s inputs changed)
- #3 just –fmt –check passes and every new recipe has a # doc comment and a [group(…)]
Implementation Plan
- Reproduce the cancelled-dispatch partial host snapshot through emitted telemetry.
- Fix the services collector to publish only a complete snapshot.
- Run targeted tests and return changed paths plus evidence without committing.
Implementation Notes
fetchHostsnow reports whether dispatch completed; a cancelled partial host enumeration is discarded rather than emitted as a completehost.infosnapshot.- The telemetry regression failed before the fix by emitting one partial snapshot, then passed with no snapshot emitted.
- Replaced a
runtime.Goschedhint with explicit cancellation-observation synchronization after CodeRabbit flagged nondeterminism; repeated the regression 20 times under race. - Final CodeRabbit services shard completed with 0 findings.
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.