fix: join contending daemon startups before reuse

Closed
TH
2mo ago
+618-373

Summary

Daemon startup now joins a child that explicitly reports lock contention before admitting another daemon. It waits for daemon or client holders, reapplies version/code/policy checks to a published winner, and relaunches only after release or proven abandonment. All attempts share the original 15-second admission deadline. Late takeovers preserve the winner; cleanup has its own bounded exit/join waits.

Fatal probing of a private startup retires and joins it before returning the original error. Stale metadata cannot bypass a different publishing owner. Legacy lock state is retained with upgrade guidance. This removes client-side stale-lock deletion.

8 files; 987 changed lines. Part of #3116, based on #3129. Timeout retirement and the session migration follow separately.

flowchart TD
    L[Launch] --> E{Monitored child result}
    E -->|still running| O[Probe this launch only]
    E -->|busy and joined| I[Inspect registration]
    E -->|other exit| F[Retire captured attempt]
    I -->|healthy winner| A[Apply reuse policy]
    I -->|held or publishing| I
    I -->|released or proven dead| L
    I -->|unproven| R[Retain and report]

Validation

Commit 180ee97381: 95 focused tests passed without skips; quick and Fallow checks passed. Mutation controls failed for adopting before joining, treating generic exits as contention, restarting the deadline, and skipping cleanup after a probe error. Real children and temporary filesystem claims exercised the changed paths; every child was joined.

Exact-head affected checks passed, including 955 tests across 139 files and unchanged RPC compatibility. Provider, coverage and native CI remain authoritative. This slice makes no device-performance claim.