Don’t misunderstand: it is absolutely legal for cops to observe matters in public places. It’s usually legal for them to film things in public too, so long as it’s not done in an intimidating fashion.
And, it’s legal for cops to go undercover, although when they do so implicates matters of priorities and good taste; some political demos may not be the wisest choices for undercover work.
But what’s not legal is for the cops to act as agents provocateurs. The New York Times never uses that phrase, but it’s the all-but-inevitable one to use to name the behaviors described in New York Police Covertly Join In at Protest Rallies.
One more leaf from the Nixon / Kruschev playbook?