If you want to know where a political party is heading, look at what's buoying the candidates who take on incumbents during primary season.

The long-shot victory of millennial heartthrob Alexandria Ocasio-Cortez over 15-year Capitol Hill veteran Rep. Joe Crowley, D-N.Y., for example, reveals a party barreling toward its democratic socialism moment. So what can we say about the temporally powerful yet electorally fragile GOP?

Its dystopian obsession with illegal immigration remains even more important, in some cases, than beating the hated Democrats.

Take a look at Tuesday's photo finish of a gubernatorial race in Kansas. As of this writing, incumbent Gov. Jeff Colyer trails his primary challenger, Kansas Secretary of State Kris Kobach, by a sliver of votes — under 200 — basically ensuring a recount. This despite general election polls showing Colyer with a 10-percentage-point advantage over Democratic nominee Laura Kelly, compared to just a 1-point margin for Kobach.

Pay close attention when a party's voters are willing to risk a loss in November to make a point in August. In 2010, Nevada Republicans took a flier on Sharron Angle, knowing full well that her erratic temperament and paranoid rhetoric about terrorist immigrants and sharia law could jeopardize a winnable Senate seat in a swing state. Angle lost, but her ideas spread within the GOP and now have a champion at 1600 Pennsylvania Ave.

“The court finds no credible evidence that a substantial number of noncitizens registered to vote,” Chief Judge Julie Robinson of the U.S. District Court for the District of Kansas ruled in June while striking down as unconstitutional Kobach's toughest-in-the-country election law, which had required proof of citizenship before registering to vote.

Having asked Kobach to provide documentation of fraud, the judge deemed that a maximum number of 39 noncitizens were discovered to have successfully registered to vote in Kansas since 1999. “And several” of those, she determined, “show errors on the part of state employees, and/or confusion on the part of applicants. They do not evidence intentional fraud.”

Like virtually all laws aimed at cracking down on immigrants in the country illegally, Kobach's voter registration system punished perfectly legal citizens. A reported 16,319 Kansans had their registrations canceled between the law's 2013 enactment and 2016 suspension, and 31,089 more were prevented from registering.

No amount of courtroom humiliation and professional failure seem to dim Kobach's allure in a Republican Party that for the last decade has taken a sharply nativist direction on immigration. ProPublica and the Kansas City Star last week documented how Kobach has built a lucrative legal practice talking cities into passing ordinances that punish landlords and employers who do business with undocumented immigrants, only to then lose in court when the laws are inevitably challenged.

So ham-fisted has Kobach's lawyering been that Judge Robinson mandated the secretary of state take six hours of remedial legal classes after repeatedly bungling his own voter-registration case.

Even the moment that should have been his career peak — being named by Donald Trump as vice chairman and de facto head of the Presidential Advisory Commission on Election Integrity — ended up in shambles. The president pulled the plug on the exercise just nine months later, after a series of increasingly bizarre missteps.

Kobach's resilience in the face of such defeats suggests that his factually untethered preoccupations meet a demonstrated market need among Republican voters.

This should give us all pause.

Years before Trump was anything besides a political punchline, GOP politicians discovered there was electoral gold to mine in exaggerating the depredations of the undocumented. Mitt Romney used the issue like a club in the 2008 presidential campaign, knocking out former New York Mayor Rudolph Giuliani over “sanctuary cities,” and nearly taking out Sen. John McCain for daring to propose immigration reform. Romney's infamous 2012 policy of “self-deportation” — which Trump after the election criticized as “maniacal” — was authored by none other than Kris Kobach.

Kobach may yet lose the gubernatorial primary, let alone the general election in November. And the near-term political prospects of such Trumpian nationalist candidates as Corey Stewart in Virginia look grim.

But unlike 2010, when the Sharron Angles of the world were also accompanied by a more interesting group of libertarian-leaning insurgents such as Mike Lee and Rand Paul — now Republican senators — the 2018 primary season shows little sign of producing healthy new ideas in the Grand Old Party.

Those of us who take comfort neither in democratic socialism nor mercantilist nativism will have to seek our electoral allies elsewhere.