personally i would prefer if this was kept "unexplained" and "random/magical" for the most part
for example, i mean during a gobbo attack a dwarven ghost could scare away the gobbos and such but it should be more up for chance and randomness then actually having a cause (even though the cause can still be represented in a way)
There's not much in a game like DF that can remain unexploitable for very long, especially given what the playerbase is just inherently like...
The game pretty much DEMANDS you be investigative and methodical in your approach to it, or else you'd never learn anything. The exploits are just the parts of the game that Toady didn't intend for us to learn, but which paradoxically are often easier to learn than the actual mechanics of the game we ARE supposed to learn.
Since ghosts haunt the spots they used to spend the most time, or where they died, someone noticed that a migrant he immediately atom-smashed would only hang around the bridge that atom-smashed him, since that was the only place he'd ever been.
So... just atom-smash migrants at the only approaches to your forts, the places where only invaders would come (if you have a merchant enterance that is separate, and has its own drawbridge you raise when the siegers come). Now, you have your own ghostly guards against sieges. That's without even implementing anything in this suggestion, and just exploiting what's already there.