--- title: Self-update poll loop modified: 2026-06-04 tags: - how-to status: active requires: - release-poll-version-check - self-update-opt-in-flag --- # Self-update poll loop The background task that ties the flag to the version check. This card alone yields a working **notify-only** daemon ("update available: vX.Y.Z" in the log) — the apply path layers on after. ## Deliverables - Spawn a `tokio` task modelled on `spawn_sync_loop` (`crates/hephd/src/server.rs`): `tokio::time::interval` ticking at the configured cadence, guarded so it's a no-op unless `--self-update` is set. - Each tick: run the [[release-poll-version-check]]. On "newer available", log it (and, once the apply path exists, hand off to [[cargo-install-from-tag]]). - Errors (forge unreachable, bad JSON) are logged and the loop continues — same resilience pattern the sync loop uses. A flaky forge must never crash or block the daemon. ## Done when With `--self-update` on and a stubbed/real "newer" release, the daemon logs an update-available line once per detection; with the flag off, no task runs. Requires [[release-poll-version-check]] and [[self-update-opt-in-flag]]. Part of [[hephd-self-update]].