fix(daemon): replace fixed 15s startup kill with progress-aware startup budget

Merged
TH
1mo ago
+1827-673

Summary

Closes #3782. Local startup previously killed healthy daemons after 15 seconds on loaded hosts (#3342). CLI, MCP, and Node now share a 120-second ceiling and a 60-second window without progress.

AGENT_DEVICE_DAEMON_STARTUP_TIMEOUT_MS=180000 agent-device devices

The setting requires positive integer milliseconds. Invalid values fail with INVALID_ARGS before spawn, only when a daemon must start. Attach and reuse ignore it. Actual exits fail fast. Typed reasons distinguish startup-exited, startup-stalled, and startup-ceiling. A live competing startup is preserved.

One module owns startup records and their cleanup. The entry and runtime use the same captured environment and cwd. Registration imports the dead-PID sweep.

Scope: 22 files, 1,827 added and 673 removed lines. The startup owner leaves the lifecycle module. iOS preflight measures a fresh SDK start.

Validation

Head 0295ee5f23; base 0fb25c474a. Independent review is complete. No findings remain.

Receipt run-Q4YXDq passed: exactCommit=true, checkoutChanged=false. The known host SDK variables were unset. All required CI passes. iOS attempt 1 hit the unrelated #3800 failure; the single unchanged-head rerun passed.

The instrumented real SDK run returned started:true after 81,529 ms. Two external pauses lasted about 40 seconds each. All six production markers reached the client-read directory; every phase gap stayed below 60 seconds. The daemon stopped gracefully. The controller's final print failed after successful SDK exit and cleanup.

The branch is CLEAN and mergeable. No inline threads remain open.