Neat! In case it helps, you may also be interested in my (now very out of date) mails at [1] and [2].
Thanks for the pointers! I'll definitely dig into those threads.
At one point I was also working on an independent implementation of the preferment rules, to make it easier for developers to intuit how matches were made, but I can't find that email at the moment. This may have some overlap with "state visualization" for the engine? I have a 3k-line patch based on top of v22 of the patchset as of September 2024, if there is interest in that, but no promises on quality -- I would have posted it if I thought it was ready for review :D
I'd definitely be interested in seeing it, rough edges and all. I haven't tackled the PostgreSQL integration design yet, so understanding how preferment rules map to the existing infrastructure would be very helpful. (Tatsuo found that email, by the way.)