fix: preserve daemon ownership through startup and cleanup

Closed
TH
2mo ago
+300-69

Summary

Fixes seven review findings in the daemon ownership stack. A startup contender waits for a live winner to become ready before applying takeover policy. Stop, exit confirmation, registration parsing and lock ownership share one native-PID validator; invalid identity cannot authorize deletion. Test cleanup joins both its observed child and a registered successor before deleting their directory.

Timeout diagnostics report retained state from the retirement result. Fixture waits observe their own child's exit and clear their timers. Fixture directories remain owned by runner cleanup until journal writes settle. Startup deadline tests advance directly to the deadline boundary, preserving the 15-second budget while avoiding coverage-dependent polling timeouts. Manual stop loads retirement lazily, preserving CLI startup closure.

Depends on #3132; addresses comments on #3124, #3130 and #3131. Ref #3116. Twenty-one files, 379 gross changed lines.

Validation

Tested 5411c0bb96a070eac1cdcb6266d88d60912fdfbf:

  • 113 focused tests pass with zero skips, including actual socket/HTTP requests and owned children.
  • Removing native-PID range validation causes six failures, including live-child state retention. Removing startup readiness, successor joining or truthful timeout reporting each fails its regression control.
  • CLI import closure passes; independent read-only review has no remaining findings.
  • Quick checks and Fallow pass. Exact-head affected checks pass: 768 files, 6,241 tests; zero skips.
  • CI-owned coverage, provider and device checks remain pending. The coverage failures on the lower startup layers are addressed by the deadline test correction here.