23/27
Part 7 of 7 · Follow-upsLearn and do

What if a machine never answers?

A machine that crashed for good never answers, however often you ask. Retries alone make the count wait forever. In a real fleet, a machine is down somewhere almost all the time.

So add a deadline. After some number of ticks, a waiting machine stops waiting and answers with what it has. It must also say what's missing, or the root reports a number that looks complete and isn't. Each answer now carries a list of machines that never answered, and each parent passes its children's lists up with its own:

Machine 4 is down. What each machine answers at the deadline
1count 3, missing [4, 8]
3count 1, missing []
4never answers
5count 1, missing [8]
8never answers
answered in full partial down

Note what the root can't know: how many machines sit under a machine that's down. A missing machine counts as missing, never as 1.

The editor holds partial_answer(node_id, children, replies), where each reply is a child's count and its own missing list. Write it: the count so far, and the missing list in the order of children. It prints the root's answer from the figure.