The finale runs a whole scripted system through the supervisor - a service that crash-loops until it is given up on, and one that waits on a dependency - and asserts the exact state timeline and final states. Every layer you built proves itself at once.
Run a scripted multi-service timeline and assert every state transition and the final states exactly.
This is the promise the whole project was built to keep: a real process
supervisor. The script exercises every layer at once. Dependency ordering holds
web down until db is genuinely Running, not merely spawned. The restart policy
and backoff bring flaky back after each crash - at t=1, t=3, then t=7, the
intervals 1, 2, 4 seconds apart exactly as the doubling predicts. And crash-loop
protection ends the madness: after three restarts inside the window, the fourth crash
does not schedule a fifth attempt - flaky is given up as Failed, permanently. The
exact final Status is only reachable if the state machine, the policies, the clock,
the backoff, the window, and the ordering all agree.
Then the shutdown closes the loop: SIGTERM to the running services in reverse
dependency order, web before db, flaky skipped because a Failed service has
nothing to stop, and both reaped cleanly to Stopped. From a bare service record
that only knew its own name, you have built the honest core of a real supervisor - a
six-state lifecycle over an injectable runtime, four restart policies, exponential
backoff with crash-loop give-up, a dependency graph with topological start and
reverse-order shutdown, and a reconcile loop - the same design that sits inside
runit, supervisord, and systemd, minus the operating-system layer that fork/execs
real processes and delivers real signals. That layer is the runnable entry point
this reference adds on top; the engine underneath is yours, and it is exact.
sup.StartAll() // db, flaky Starting; web heldsup.MarkReady("db"); sup.MarkReady("flaky")sup.StartAll(); sup.MarkReady("web") // web released -> Runningsup.Reap("flaky", 1) // crash 1 -> backoff 1sfor _, t := range []int{1, 3, 7} { // restarts 1,2,3 then give upclock.Advance(untilT(t)); sup.Tick()sup.MarkReady("flaky"); sup.Reap("flaky", 1)}sup.Shutdown(); sup.Reap("web", 0); sup.Reap("db", 0)// flaky Failed(3); Status() == ["db stopped 0","web stopped 0","flaky failed 3"]