I think you're getting into the area of legitimate defence or legitimate excuse because one would expect even an undercover officer to identify himself as a peace officer, as a law enforcement officer, at the time that he's interacting with a private citizen. If I happen to say, “Stop, police,” and I happen to be accompanied by this dog, there's a certain knowledge that's communicated by the fact that the police officer has said, “Stop, police.”
On April 27th, 2015. See this statement in context.