Thanks Xinhuan and thanks for the input Adirelle, but there are a few flaws with that.
ACTIVE_TALENT_GROUP_CHANGED probably won't fire when changing from bear to cat spec.
It doesn't account for example, a raid leader changing someones role because they want the player to go X role, but then change their mind, and want them to stay Y role without changing the role back. Hence mine triggers when you enter combat in an instance.
You can set your role fine in Combat.
It's better having "specific" not set than set to unknown until it is set.
Anyway I've updated my original post with draft 2 and included it here: http://paste.wowace.com/3353/ Includes your suggestion of doing a check when entering a raid.
As you can see it isn't anything complex, it simply sets your role automatically when you're in a raid, according to your spec. Then the only thing the addon needs to worry about is calling the Blizz role API.
As well as input on the idea itself, I'd like some input on the best way to expose the "specific" variable (The variable is either "melee" or "ranged"). I figured this might be needed for some more advanced addons, and wondered if it would be best to make it a specifically named global variable, or a call to the library itself.