Brook is not the knight (Because Knight always tells the truth and if he is a Knight, He will not say that Alex is a knight). Accordingly it proves Brook is not a knight.

It came up with logic now. Not Assumption.

In similar way Cody is not the knight, since his statement would then be a lie.

Hence it proves that out of three Alex is a Knight and Knight always tells the truth So Alex statement is 'Cody is a Knave'.

Therefore Alex is the knight hence Cody is the knave and Brook is the spy.