I would expect my company to be unhappy if I were to consult for a competitor on the side. There's probably language in the employment agreement that prohibits that, and even if there isn't, it's still the kind of thing you should avoid due to conflict of interest.
But I'm not sure about an agreement not to take a similar role. If the employment agreement says that, I'm not sure that it's legally binding. Even if it is, you may be able to weasel around it with "but it's consulting, not a full-time position".
Note well: IANAL. If you're concerned, get advice from a lawyer rather than from some rando on the internet.
I doubt the person they are searching for is currently in a similar role. They want domain specific knowledge about a stable and _old_ codebase. They want the person around as a teacher mentor, and the first gig is something the business needs but would prefer to sub out. Seems like a normal accepted practice when defined that way.