(#18211) Refactor daemon run loop

This adds a Scheduler module to puppet to handle the daemon run loop. The loop
involves two separate wakeup cycles, in which one can adjust the interval for
both. Refactoring into classes makes it easier to reason about and test the
correctness of scheduling. This should fix #18211.