As far as the second part of your message is concerned
(the one related to the suggestion for adding the "d") we
could think about splitting that rule in two: one for removing
unwanted eufoniche and one for adding legal eufoniche
IMHO, the two should be considered very different in terms of what can be done automatically.
Removing the D with such rules is so reliable, safe and recognized even by institutions like Accademia della Crusca, that you could IMHO safely run the rule on the entire Italian Wikipedia, and it would only get better. It might be an exciting test.
Adding a D automatically is usually neither good (it is generally not the problem that needs fixing), nor safe (human writers may intentionally have decided to avoid cacophonies, or to use a modern writing style, etc.) For example, "ad esempio" is allowed, but a modern writer or speaker could choose to write "a esempio". I will admit that it sounds strange to me (I too might use "ad esempio" or prefer "per esempio"), but I know some people who use "a esempio". Under a more modern style, an euphonic D might never be used with the "O" case. By "encouraging" additions, we risk confusing people or going backwards in time. In my experience, if a writer chose not to put a D, it is an annoyance to even mark that.
BTW, the rules we are discussing here are like these default settings used by Accenti, which were tested over the years against large corpora: