Scottish ministers threatened with legal action over 'state guardian' plans