pub async fn serve_until(opts: Opts, stop: Stop) -> Result<()>Expand description
serve, but stopping when stop is set as well as on Ctrl-C.
Neither a signal nor a stop abandons a run in flight. Killing the graph
mid-node leaves worktrees, branches and agent sessions behind, and every
agent call already paid for is lost; finishing the run costs the operator a
wait and saves them a cleanup. A stop therefore only sets a flag: the
current execute runs to its terminal status, the task’s outcome is
recorded, and only then does the loop return. That window is what
Stop::finishing is for. An operator who genuinely wants the run dead
still has a second Ctrl-C, which the runtime turns into a process kill —
and the task left Running then tells the next daemon, and the next human,
where to look.
While the queue is empty the stop is honoured within one wakeup rather than
one poll interval: the wait is a select! against Stop’s notify, so a
caller that taps stop does not sit through the remainder of a sleep.