I had tried my best to show another approach which I think is more advanced, it is bug free and takes care of everything and at the same time can be modeled for vertical texts as well.
If you think that the current bidirectional algorithm of LuaTeX is just fine, then this will be my last email.
Find your ideal job with SEEK Time for change?