I've checked npc_faction in EQEmuAdmin and all the values seem to be assigned to the right NPCs. So it isn't that that's causing the problem.
The strange thing is it seems to be random which factions work and which don't, for example shadowed men and skeletons both have a default faction value of -1000 with no modifiers, but shadowmen are KOS as they should be, whilst skellies are allied to you. (and seem rather more efficient than most of the guards at actually attacking things that are chasing you

)
Anyone else having problems like this? I'd like to know whether it's a problem in my DB that I need to fix, or simply a bug in EQEmu.