Tag database sanity checker

Has anyone ever put together any sort of tag database sanity checker?

I was poking around in the guts of config.idb and noticed some oddities in the TAGCONFIG table like records that had clearly been in a sub-folder of our tag tree, but the folderid value they referenced was no longer in the table.

It got me wondering if there were any other “wrong” things that I could look for in that table (or the config DB in general) and potentially fix.

Has anyone ever pondered this and tried to put something together?