You are correct in saying that the above progression is in D major. However, it is not written using the typical D major scale. Instead you are using a version (mode) of the major scale called mixolydian.
The notes in D major are:
D E F♯ G A B C♯ D
D mixolydian contains the notes:
D E F♯ G A B C D
D mixolydian is a mode of the G major scale meaning that ...
Mystery Solved. The final cadence of the piece had already occured 8 bars before the start of my attachment, which is just the end of the final tonic expansion. The cadence was a Bm11(b9)/A-E which is v11(inv)-I in E minor. So it is an inverted IAC.
In old counterpoint style, exemplified by Fux's species counterpoint, the cadence called a clausula vera did require contrary motion.
But the typical classical cadences do not have that requirement.
I think the simplest example that illustrates the point is the perfect authentic cadence using only treble and bass parts to show the essential voice leading:
the key is in technically Bbmin because he tunes his guitar down a halfstep but it seems most people keep it in standard so for the sake of argument lets call it Bm. in the key of Bm, E technically would be a minor chord but he plays an E7, this works because he adds the #9 on top (which is just a minor 3rd up an octave) and does not play the 5 allowing it ...