1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Small, pure daemon state types plus the switch-backoff schedule. Extracted
//! from `mod.rs` to keep the run-loop module focused; re-exported from `super`
//! so callers (tick.rs, the inline tests) reference them unchanged.
/// Retry/backoff state for a persistently-failing switch. Without it, a switch
/// that can't land (keychain denial, diverged active, busy target) re-queued
/// and logged ~1/s forever, ballooning the daemon log and burying the signal.
/// This dedups the log (emit only when the reason changes) and spaces retries
/// with exponential backoff once a target has failed repeatedly.
pub
/// Base backoff after a switch has failed enough times to warrant spacing.
const SWITCH_BACKOFF_BASE_MS: u64 = 2_000;
/// Ceiling so a permanently-stuck target still gets an occasional retry.
const SWITCH_BACKOFF_MAX_MS: u64 = 60_000;
/// Backoff (ms) before the next attempt after `attempts` consecutive failures.
/// The first two failures retry immediately (`0`) so the common brief-fetch case
/// still lands the instant the target goes idle (preserves the re-queue
/// behavior); only a persistently-failing switch backs off, exponentially, capped.
/// Pure so the schedule is unit-testable.
pub