PM-1361 changed the protocol for index modifying commands on sharded collections to require shard versions and for the execution of these commands to be mutually exclusive with the migration critical section. To verify this, a dassert was added that there is not an active critical section when the corresponding opObserver method for each index command is run. This dassert is not valid for index commands run directly against a shard, because they will not contain a shard version. Some of our testing hooks, like checkReplDBHash, use a ReplSetTest method that runs noop collMods on every non-system collection to wait for background index activity to complete, which can trigger the dassert.
Restricting the dassert to only apply to commands sent on an internal connection (i.e. from a mongod or mongos) should avoid these failures while allowing it to serve its intended purpose.