The code looks very good. I am impressed how all the details of the
stepping algorithm and the Knuth elements have been implemented by
you. I am also impressed by the strength of the stepping
algorithm. The more I turn it around, the stronger it seems to be.
I found two small points:
1. A penalty for the header and footer is added at the last step; it
should be omitted.
2. When a grid unit is incomplete at the page break, it is not
rendered on the first page.