Ah, I see you are somebody who doesn't shy away from the math. Very good, I do have a document that I was working on (basically an augmented jupyter notebook using sage) but it got pushed to the sidelines a bit, mostly because there seemed to be little interest from the community and the basics have been covered by the document by rudi dupreez you referenced above. My idea was to focus more on how to get the kinematic formulas to work properly with the linuxcnc interface when the machine reference point does not coincide with the center of the rotary assembly. I'll have to work on the document a bit an will post it here in a couple of days.
Coincidentally I have been thinking about a 'generic' 5 axis kinematic component as well. Something that the commercial controllers offer where the specific machine kinematic can be defined by parameters. For this I would think that the matrix manipulations would need to happen in the kinematics module. A symbolic solution (like in the 'trt' and my 'tdr' kins would become impossibly unwieldy). Maybe a nummerical approach would be the way to go? Also note that one can use the Jacobian matrix to calculate an approximation to the inverse kinematic which is what is used in the 'genserkins' model, I think.
Also I have found that this ties into my current project of tilted work planes as one needs to calculate the joint position of the particular machine at hand to orient the tool to the requested tool-orientation vector. Something that is usually done by the CAM. This is probably more of interest for machines with tool-side rotations like my head rotating/nutating example above.
Tracking the work-offset when switching between tool coordinates and machine coordinates is also something that needs to be considered.
Another question would be just how generic one could build a universal 5-axis kinematic. Do we assume the rotary joints to be perfectly perpendicular or would the rotation matrices be of the general form that can represent rotations around any vector in space?
Something I need to look at is if it would make more sense to use quaternions for all this rather than the transformation matrices.