The secrets of calligraphy!

This is wrong. I just took a look how endofayah-ar followed by Arabic digits is solved in Adobe Naskh, and indeed it is done with contextual kerning.

The contextual kerning works just like any other kerning (if the app supports it). You have the use the value record syntax as with the normal RTL kerning instead of using single numbers as in some of the examples.