Our code golf solutions do not work in the case where two boxes arrive close together on the belt that is upstream from the staging belt. That may never happen, but if it does then we need to also control when the upstream belt is runs.
My first attempt's logic does that, but inefficiently as it stops the upstream belt any time the gap is being generated, even if there is no box on the upstream belt. The logic could instead be running the upstream belt, concurrently with running the staging belt, to get the next box into position.