shep-daemon 0.15.2

The supervision engine behind shep: process spawning, restart policy, the log plane, watch and cron restarts, and the RPC server
Documentation
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
//! The actor tier: that the engine really arms and disarms at the
//! transitions, not just that the registry can.

use super::*;
use crate::sweep::{LambSignal, LambSnapshot, LambSweep, SignalError};

// `ProcessSelector::Name` matches a stopped sheep too, so a cron worker that
// keeps its schedule brings back a sheep the user stopped.
#[tokio::test(start_paused = true)]
async fn stopping_the_last_instance_stops_its_cron_worker() {
    let clock = Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z")));
    let h = harness_with_extras(vec![ProcScript::never_exits(); 12], |reports| Extras {
        clock: Arc::clone(&clock) as Arc<dyn Clock>,
        enforcer: Arc::new(RecordingEnforcer::default()),
        lamb_sweep: idle_sweep(),
        max_cron_sleep: DEFAULT_MAX_CRON_SLEEP,
        reports,
        stats: idle_stats(),
    });
    let mut rx = h.ctx.events.subscribe();
    h.ctx
        .supervisor
        .start(vec![app_with("web", |app| {
            app.cron_restart = Some("0 * * * *".to_string());
        })])
        .await
        .unwrap();

    wait_for_cron_worker(&clock).await;
    cross_one_hour().await;
    expect_restart(&mut rx, "web", EVENT_WAIT).await;

    h.ctx
        .supervisor
        .stop(ProcessSelector::Name("web".to_string()))
        .await
        .expect("the sheep stops");
    assert_no_restart_within(&mut rx, "web", PAST_THE_NEXT_OCCURRENCE).await;
    assert_eq!(h.ctx.supervisor.list().await[0].status, ProcStatus::Stopped);
}

/// Keyed by id and kind rather than by name: a swap puts two entries under
/// one name.
async fn expect_process_event(
    rx: &mut broadcast::Receiver<SharedEvent>,
    id: u32,
    kind: ProcessEventKind,
    window: Duration,
) {
    let wanted = async {
        loop {
            match rx.recv().await.map(|event| event.to_event()) {
                Ok(BusEvent::Process { event, info, .. }) if event == kind && info.id == id => {
                    return;
                }
                Ok(_) => continue,
                Err(broadcast::error::RecvError::Lagged(_)) => continue,
                Err(err) => panic!("event stream closed before {kind:?} for id {id}: {err}"),
            }
        }
    };
    if tokio::time::timeout(window, wanted).await.is_err() {
        panic!("timed out waiting for {kind:?} for id {id}");
    }
}

// The clock reading is the only observation out here: a rebuild re-spawns
// the cron worker, which reads the wall clock on its first poll.
// `max_cron_sleep` is 600s against a swap costing at most 11s of virtual
// time, so a surviving worker cannot wake inside the window and read too.
#[tokio::test(start_paused = true)]
async fn a_reload_leaves_the_name_groups_cron_worker_where_it_was() {
    let clock = Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z")));
    // Two procs, counted: the original and the one replacement a reload of
    // a one-instance app performs. A third is answered "script exhausted".
    let h = harness_with_extras(vec![ProcScript::never_exits(); 2], |reports| Extras {
        clock: Arc::clone(&clock) as Arc<dyn Clock>,
        enforcer: Arc::new(RecordingEnforcer::default()),
        lamb_sweep: idle_sweep(),
        max_cron_sleep: Duration::from_secs(600),
        reports,
        stats: idle_stats(),
    });
    let mut rx = h.ctx.events.subscribe();
    h.ctx
        .supervisor
        .start(vec![app_with("web", |app| {
            app.cron_restart = Some("0 * * * *".to_string());
        })])
        .await
        .unwrap();
    expect_process_event(&mut rx, 0, ProcessEventKind::Online, EVENT_WAIT).await;
    // Lets the armed worker reach its first poll before the count is taken.
    tokio::task::yield_now().await;

    let reads_before = clock.reads();
    assert_eq!(
        reads_before, 1,
        "fixture check: one armed cron worker takes exactly one reading, \
         so a rebuild's second one is a countable difference rather than \
         noise — and a count of 0 here would mean the worker had not run \
         yet, which would make the claim below vacuous"
    );

    h.ctx
        .supervisor
        .reload(ProcessSelector::Name("web".to_string()))
        .await
        .expect("the reload is accepted");
    expect_process_event(&mut rx, 1, ProcessEventKind::Online, EVENT_WAIT).await;
    expect_process_event(&mut rx, 0, ProcessEventKind::Delete, EVENT_WAIT).await;

    let listed = h.ctx.supervisor.list().await;
    assert_eq!(
        listed.iter().map(|info| info.id).collect::<Vec<_>>(),
        vec![1],
        "fixture check: the swap must have run to completion, or there was \
         never an overlap for the ordering to matter in"
    );
    assert_eq!(
        clock.reads(),
        reads_before,
        "the name group's cron worker must have been left where it was: a \
         rebuilt one reads the clock again to derive its next occurrence"
    );
}

/// A harness whose runner hands out one proc that exits at once and then
/// plenty that never do, plus a cron-restarting app that parks in a long
/// backoff after any exit.
///
/// The two cases below need a sheep in `WaitingRestart`, the one state that
/// reaches a terminal transition through `apply_immediate`.
fn backoff_harness(clock: &Arc<TestClock>) -> Harness {
    harness_with_extras(
        {
            let mut scripts = vec![ProcScript::never_exits()];
            scripts.push(ProcScript::const_exit(1));
            // Spare procs so a broken implementation has something to
            // respawn from: without them the supervisor emits `Errored` and
            // the negative assertions below pass vacuously.
            scripts.extend([ProcScript::never_exits(); 8]);
            scripts
        },
        |reports| Extras {
            clock: Arc::clone(clock) as Arc<dyn Clock>,
            enforcer: Arc::new(RecordingEnforcer::default()),
            lamb_sweep: idle_sweep(),
            max_cron_sleep: DEFAULT_MAX_CRON_SLEEP,
            reports,
            stats: idle_stats(),
        },
    )
}

/// The cron-restarting app the two backoff cases start, parked in a backoff
/// far longer than either case's own window, so its pending `RestartDue` can
/// never be what a restart came from.
fn backoff_app() -> shep_core::config::ResolvedApp {
    app_with("web", |app| {
        app.cron_restart = Some("0 * * * *".to_string());
        app.restart_delay = Some(UpDuration::from_millis(3 * 60 * 60 * 1_000));
    })
}

/// How long a settle wait may run on the real clock before it gives up.
/// Generous enough that a loaded runner cannot flake it, and spent only when
/// something is wrong: a wait returns the moment it is satisfied.
const SETTLE_DEADLINE: Duration = Duration::from_secs(10);

/// How far a settle wait may carry the paused clock. The rounds advance it
/// 1ms at a time when the runtime is idle, so without this a long real-time
/// wait would also run virtual time on, past a cron occurrence or a backoff
/// and into side effects the test is not about. Far below either, and far
/// above the few rounds a wait that is going to succeed needs.
const SETTLE_VIRTUAL_LIMIT: Duration = Duration::from_secs(5);

/// Waits until the armed cron worker has taken its first reading of `clock`.
///
/// The worker derives its occurrence from that reading, so time advanced
/// before it lands moves the occurrence out with it: a crossing that starts
/// early finds the schedule an hour further on, and the trigger never fires.
/// Call this between starting the app and [`cross_one_hour`].
///
/// Bounded on the real clock rather than in rounds, since how many rounds a
/// busy machine needs is not something a test can know.
async fn wait_for_cron_worker(clock: &TestClock) {
    let started = std::time::Instant::now();
    while clock.reads() == 0 {
        assert!(
            started.elapsed() < SETTLE_DEADLINE,
            "the cron worker never took its first clock reading"
        );
        tokio::time::sleep(Duration::from_millis(1)).await;
    }
}

/// Each `list()` is a full round trip through the actor's mailbox, so this
/// makes progress rather than merely observing it.
///
/// A round waits on the paused clock, not on `yield_now`: a stop's lamb walk
/// runs on the blocking pool, and the runtime holds the clock still until it
/// returns, where a yield would spend its rounds before the pool answers.
/// Bounded on both clocks: [`SETTLE_DEADLINE`] of real time, for a wait that
/// runs off the paused clock and so spends no virtual time while it lasts,
/// and [`SETTLE_VIRTUAL_LIMIT`] of paused time, so a wait that spins cannot
/// carry the clock past an occurrence. A satisfied wait returns on its first
/// round either way.
async fn settle_into(supervisor: &SupervisorHandle, id: u32, status: ProcStatus) {
    let started = std::time::Instant::now();
    let virtual_start = tokio::time::Instant::now();
    let mut last = Vec::new();
    while started.elapsed() < SETTLE_DEADLINE && virtual_start.elapsed() < SETTLE_VIRTUAL_LIMIT {
        tokio::time::sleep(Duration::from_millis(1)).await;
        last = supervisor.list().await;
        if last
            .iter()
            .any(|info| info.id == id && info.status == status)
        {
            return;
        }
    }
    // The status it did reach is the whole diagnosis: `Online` means the
    // trigger never fired, `Starting` means the spawn never finished, and no
    // entry at all means the id was never registered.
    let seen = last
        .iter()
        .filter(|info| info.id == id)
        .map(|info| {
            format!(
                "status={:?} restarts={} pid={:?}",
                info.status, info.restarts, info.pid
            )
        })
        .collect::<Vec<_>>()
        .join("; ");
    panic!(
        "id {id} never reached {status:?} (last listing: {})",
        if seen.is_empty() {
            "no entry with this id".to_string()
        } else {
            seen
        }
    );
}

// A sheep waiting out its restart backoff has no live task, so its stop
// never reaches `handle_exited`'s terminal branches, and
// `ProcessSelector::Name` matches a stopped sheep just as happily.
#[tokio::test(start_paused = true)]
async fn stopping_a_sheep_mid_backoff_still_stops_its_cron_worker() {
    let clock = Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z")));
    let h = backoff_harness(&clock);
    let mut rx = h.ctx.events.subscribe();
    h.ctx.supervisor.start(vec![backoff_app()]).await.unwrap();

    // The cron occurrence restarts it onto the immediately-exiting proc,
    // landing it in its three-hour backoff.
    wait_for_cron_worker(&clock).await;
    cross_one_hour().await;
    expect_restart(&mut rx, "web", EVENT_WAIT).await;
    settle_into(&h.ctx.supervisor, 0, ProcStatus::WaitingRestart).await;

    h.ctx
        .supervisor
        .stop(ProcessSelector::Name("web".to_string()))
        .await
        .expect("the sheep stops");
    assert_eq!(h.ctx.supervisor.list().await[0].status, ProcStatus::Stopped);
    // Spans the next occurrence, and stays well inside the three-hour
    // backoff, so a restart arriving here could only be the cron worker.
    assert_no_restart_within(&mut rx, "web", PAST_THE_NEXT_OCCURRENCE).await;
}

// Without a disarm the slot is deregistered while the name-group's cron
// worker keeps firing at a name nothing answers to.
#[tokio::test(start_paused = true)]
async fn deleting_a_sheep_mid_backoff_takes_its_cron_worker_with_it() {
    let clock = Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z")));
    let h = backoff_harness(&clock);
    let mut rx = h.ctx.events.subscribe();
    h.ctx.supervisor.start(vec![backoff_app()]).await.unwrap();

    wait_for_cron_worker(&clock).await;
    cross_one_hour().await;
    expect_restart(&mut rx, "web", EVENT_WAIT).await;
    settle_into(&h.ctx.supervisor, 0, ProcStatus::WaitingRestart).await;

    h.ctx
        .supervisor
        .delete(ProcessSelector::Name("web".to_string()))
        .await
        .expect("the sheep is deleted");
    assert!(h.ctx.supervisor.list().await.is_empty());
    // A surviving worker would `restart(Name("web"))`, find nothing, and log
    // at debug, emitting no bus event. The clock is the observable claim.
    let reads_after_delete = clock.reads();
    assert_no_restart_within(&mut rx, "web", PAST_THE_NEXT_OCCURRENCE).await;
    assert_eq!(
        clock.reads(),
        reads_after_delete,
        "a deleted sheep's cron worker must stop reading the clock, not merely stop finding sheep"
    );
}

// A cron occurrence reaches a group's instances through two doors: a running
// instance from `handle_exited`'s forced-restart branch, one sitting out its
// backoff from `apply_immediate`. Both must report `manually: false`.
#[tokio::test(start_paused = true)]
async fn a_cron_restart_is_never_reported_as_a_user_action() {
    let clock = Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z")));
    // The script pool makes the second half reachable: the first occurrence
    // respawns onto a proc that exits at once, and the spares behind it are
    // what the second respawns from.
    let h = backoff_harness(&clock);
    let mut rx = h.ctx.events.subscribe();
    h.ctx.supervisor.start(vec![backoff_app()]).await.unwrap();

    wait_for_cron_worker(&clock).await;
    cross_one_hour().await;
    let (running, manually) = expect_restart_event(&mut rx, "web", EVENT_WAIT).await;
    assert_eq!(running.restarts, 1);
    assert!(
        !manually,
        "a cron occurrence is nobody typing `shep restart`"
    );

    // That respawn exited into a three-hour backoff, so the next occurrence
    // is well inside it and finds no live task.
    settle_into(&h.ctx.supervisor, 0, ProcStatus::WaitingRestart).await;
    cross_one_hour().await;
    let (backing_off, manually) = expect_restart_event(&mut rx, "web", EVENT_WAIT).await;
    assert_eq!(backing_off.restarts, 2);
    assert!(
        !manually,
        "the same occurrence must answer the same way through `apply_immediate`"
    );
}

// `respawn`'s Err arm is reachable in an ordinary deploy: a binary replaced
// mid-deploy, or a cwd that is gone. A failed respawn emits `Errored` and
// never `Restart`, so a surviving worker leaves only its clock readings.
#[tokio::test(start_paused = true)]
async fn a_respawn_that_cannot_spawn_stops_the_name_groups_cron_worker() {
    let clock = Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z")));
    // Exactly one script: the initial start consumes it, so the cron
    // occurrence's respawn finds it exhausted and `respawn` takes its Err
    // arm.
    let h = harness_with_extras(vec![ProcScript::never_exits()], |reports| Extras {
        clock: Arc::clone(&clock) as Arc<dyn Clock>,
        enforcer: Arc::new(RecordingEnforcer::default()),
        lamb_sweep: idle_sweep(),
        max_cron_sleep: DEFAULT_MAX_CRON_SLEEP,
        reports,
        stats: idle_stats(),
    });
    let mut rx = h.ctx.events.subscribe();
    h.ctx
        .supervisor
        .start(vec![app_with("web", |app| {
            app.cron_restart = Some("0 * * * *".to_string());
        })])
        .await
        .unwrap();

    wait_for_cron_worker(&clock).await;
    cross_one_hour().await;
    settle_into(&h.ctx.supervisor, 0, ProcStatus::Errored).await;

    let reads_after_error = clock.reads();
    assert_no_restart_within(&mut rx, "web", PAST_THE_NEXT_OCCURRENCE).await;
    assert_eq!(
        clock.reads(),
        reads_after_error,
        "an errored sheep's cron worker must stop reading the clock"
    );
}

// The scripted table holds exactly one process, the pid the runner hands the
// first spawn, so an arming against any other number never breaches.
#[tokio::test(start_paused = true)]
async fn the_actor_arms_the_memory_limit_against_the_spawned_pid() {
    let mut h = harness_with_extras(vec![ProcScript::never_exits(); 4], |reports| {
        let sampler: Arc<dyn MemorySampler> =
            Arc::new(ScriptedSampler::new(vec![vec![ProcessRss {
                pid: 1000,
                parent: None,
                bytes: 900,
                cpu_ms: 0,
            }]]));
        let stats = Arc::new(StatsState::new(Arc::clone(&sampler)));
        Extras {
            clock: Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z"))),
            enforcer: Arc::new(PollingEnforcer::start(
                sampler,
                reports.breaches.clone(),
                Arc::clone(&stats),
            )),
            lamb_sweep: idle_sweep(),
            max_cron_sleep: DEFAULT_MAX_CRON_SLEEP,
            reports,
            stats,
        }
    });
    h.ctx
        .supervisor
        .start(vec![app_with("web", |app| {
            app.max_memory = Some(MemSize::from_bytes(500));
        })])
        .await
        .unwrap();
    let pid = h.ctx.supervisor.list().await[0]
        .pid
        .expect("a live sheep has a pid");

    let breach = match tokio::time::timeout(EVENT_WAIT, h.breaches.recv()).await {
        Ok(Some(breach)) => breach,
        Ok(None) => panic!("the breach channel closed before a breach arrived"),
        Err(_) => panic!("timed out waiting for a breach"),
    };

    assert_eq!(breach.id, 0);
    assert_eq!(
        breach.root_pid, pid,
        "the enforcer must be armed against the pid the sheep is actually running as"
    );
    assert_eq!(breach.observed.bytes(), 900);
}

// The gated one of `arm_extras`'s three transitions:
// `handle_ready_result`'s `went_online` reverted to a plain `emit` leaves
// every other case in this file green while every readiness-gated app loses
// all four extras. The readiness wait ends in a timeout, the same site.
#[tokio::test(start_paused = true)]
async fn the_actor_arms_a_readiness_gated_app_once_it_comes_online() {
    let mut h = harness_with_extras(vec![ProcScript::never_exits(); 4], |reports| {
        let sampler: Arc<dyn MemorySampler> =
            Arc::new(ScriptedSampler::new(vec![vec![ProcessRss {
                pid: 1000,
                parent: None,
                bytes: 900,
                cpu_ms: 0,
            }]]));
        let stats = Arc::new(StatsState::new(Arc::clone(&sampler)));
        Extras {
            clock: Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z"))),
            enforcer: Arc::new(PollingEnforcer::start(
                sampler,
                reports.breaches.clone(),
                Arc::clone(&stats),
            )),
            lamb_sweep: idle_sweep(),
            max_cron_sleep: DEFAULT_MAX_CRON_SLEEP,
            reports,
            stats,
        }
    });
    h.ctx
        .supervisor
        .start(vec![app_with("web", |app| {
            app.wait_ready = true;
            app.max_memory = Some(MemSize::from_bytes(500));
        })])
        .await
        .unwrap();
    let listing = h.ctx.supervisor.list().await;
    assert_eq!(
        listing[0].status,
        ProcStatus::Starting,
        "a gated app must not be Online when its Start reply lands"
    );
    let pid = listing[0].pid.expect("a spawned sheep has a pid");

    let breach = match tokio::time::timeout(EVENT_WAIT, h.breaches.recv()).await {
        Ok(Some(breach)) => breach,
        Ok(None) => panic!("the breach channel closed before a breach arrived"),
        Err(_) => panic!("timed out waiting for a breach"),
    };
    assert_eq!(breach.id, 0);
    assert_eq!(
        breach.root_pid, pid,
        "the gated path must arm against the pid the sheep is running as"
    );
}

// Real time and a real `OsProber`, because that is what the actor builds:
// the paused clock does not move a real TCP connect.
#[tokio::test]
async fn the_actor_arms_the_liveness_loop_against_the_spawned_pid() {
    // Reserve a port, then release it: nothing ever listens there, so every
    // probe fails with a connection refusal.
    let reserved = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
    let addr = reserved.local_addr().unwrap();
    drop(reserved);

    let mut h = harness(vec![ProcScript::never_exits(); 4]);
    h.ctx
        .supervisor
        .start(vec![app_with("web", |app| {
            app.liveness_probe = Some(ProbeConfig {
                failure_threshold: 1,
                interval: PROBE_INTERVAL,
                timeout: UpDuration::from_millis(500),
                ..probe_config(ProbeKind::Tcp, &addr.to_string())
            });
        })])
        .await
        .unwrap();
    let pid = h.ctx.supervisor.list().await[0]
        .pid
        .expect("a live sheep has a pid");

    let failure = expect_liveness(&mut h.liveness, LIVENESS_DEADLINE).await;
    assert_eq!(
        failure,
        LivenessReport {
            id: 0,
            pid,
            epoch: 1
        }
    );
}

/// A lamb sweep whose walk takes real time, as a stop's does on a busy host.
struct SlowWalk(Arc<dyn LambSweep>);

impl LambSweep for SlowWalk {
    fn snapshot(&self, root_pid: u32) -> LambSnapshot {
        std::thread::sleep(Duration::from_millis(100));
        self.0.snapshot(root_pid)
    }

    fn last_snapshot(&self, root_pid: u32) -> Option<LambSnapshot> {
        self.0.last_snapshot(root_pid)
    }

    fn survivors(&self, snapshot: &LambSnapshot) -> Vec<u32> {
        self.0.survivors(snapshot)
    }

    fn descendants(&self, roots: &[u32]) -> LambSnapshot {
        self.0.descendants(roots)
    }

    fn signal(&self, pid: u32, signal: LambSignal) -> Result<(), SignalError> {
        self.0.signal(pid, signal)
    }
}

// The cron restart stops the running sheep first, and that stop's lamb walk
// runs on the blocking pool. `settle_into` must wait out a walk that takes
// real time rather than spend its rounds before the pool answers.
#[tokio::test(start_paused = true)]
async fn a_respawn_waits_out_a_slow_lamb_walk_before_it_errors() {
    let clock = Arc::new(TestClock::starting_at(dt("2026-01-01T00:00:00Z")));
    let h = harness_with_extras(vec![ProcScript::never_exits()], |reports| Extras {
        clock: Arc::clone(&clock) as Arc<dyn Clock>,
        enforcer: Arc::new(RecordingEnforcer::default()),
        lamb_sweep: Arc::new(SlowWalk(idle_sweep())),
        max_cron_sleep: DEFAULT_MAX_CRON_SLEEP,
        reports,
        stats: idle_stats(),
    });
    h.ctx
        .supervisor
        .start(vec![app_with("web", |app| {
            app.cron_restart = Some("0 * * * *".to_string());
        })])
        .await
        .unwrap();

    wait_for_cron_worker(&clock).await;
    cross_one_hour().await;
    settle_into(&h.ctx.supervisor, 0, ProcStatus::Errored).await;
}