Danielle Allen is a political theorist at Harvard University and a contributing columnist for The Post.

The Constitution requires that, upon assumption of the office, a president swear as follows: “I do solemnly swear (or affirm) that I will faithfully execute the Office of President of the United States, and will to the best of my Ability, preserve, protect and defend the Constitution of the United States.” In the face of an attack such as that perpetrated by Russian agents, now definitively recorded in the latest Mueller indictment, what would count as defending the Constitution? Nothing short of restoring the mystic chords of mutual understanding within the citizenry.

The attack against us was perpetrated not by assassination of any sitting officeholder, not by a bombing of a military installation, not by the direct obliteration of our laws, institutions, rules or procedures. We, the people, were attacked as a people; the tissue of our relations to one another was rent.

Strangely enough, there is a silver lining in all the detail that has emerged in the past few months about Russian shenanigans. It turns out that when this all started, we didn’t all hate each other as much as it has come to seem that we did.

When a Facebook group advocating Texas secession rallied in front of the Texas statehouse to “Stop Islamification of Texas” and a separate Facebook group counter-rallied in the same place at the same time under the banner “Save Islamic Knowledge,” it wasn’t actually us fighting. It was the Russians baiting us into fighting each other.

In November 2016, after the election, when a group rallied in New York under the banner “Show your support for President-Elect Trump,” and on the same day, also in New York, another group rallied to fly the flag, “Trump is NOT my President,” it wasn’t us. It was the Russians stoking up our antagonisms.

Of course, we fell for it. There was real division there, real antipathy, waiting to be activated. But the silver lining is real, too. While we were plenty het up with disagreements over health care, shootings by and of police, and immigration, we weren’t quite so inclined to face off in the streets. For the most part, one side at a time would come out in protest; we took our frustrations to town-hall meetings. Before they stuck their fingers in, we were in fact holding to a tenuous peace. It hadn’t occurred to us, ourselves, to get out in the streets and duke it out.

The first and most important job of the president, in confronting the threat presented by the Russian attack, is therefore to restore that peace. We the people are the foundation for the edifice that is the Constitution and its political institutions. Disagreement, debate, contention and contestation — all these are features of a healthy people. But strife at the level of routine counter-protests that descend into physical confrontations? These are symptoms of a people beginning to succumb to the problem of faction.

When 36-year-old James Madison and his colleagues designed the Constitution, one of their most important aspirations was to diminish the likelihood that faction would destabilize the new order. Their institutional design contained a two-part solution. The first notion was that representative systems of government would provide a structure for filtering and mediating extreme opinions so that debates in the councils of government would tack in a moderate direction. While this part of the solution is commonly taught; we have come to overlook the second part of the solution. Madison did not believe that the representative structures on their own would solve the problem of faction. Rather, he believed they would do so working in tandem with the physical geography of the country.

The country’s very size, its rivers and mountains, would disperse the population. The consequent difficulty of communication would ensure that those who held extreme views would be unlikely to find each other and coordinate. They would, as a result, be unable to achieve a degree of influence sufficient to distort and destabilize political processes.

This premise of Madison’s — that the very geography of the new country would help ward off the danger of faction — no longer holds.

The most important impact of social media on our political ecosystem is to have nullified the value of geography as a functional element of our institutional design. People with extreme views can now easily coordinate across the country. They can even be coordinated — before they have thought of doing so for themselves — from outside our borders. And without the assist from a geography that splinters us, our systems of representation don’t function to moderate polarization. Our representatives know this as they get bombarded by phone calls from people well outside their own constituency, intensifying their felt need to adhere to a strong ideological line.

If we wish to restore peace among us, we have to go back to Madison’s basic question. How do we build institutions that can ward off the threat of faction? We actually need to rethink our system of representation, perhaps adopting measures such as multi-member districts and ranked-choice voting to broaden representation. We can no longer rely on geography to take us halfway to the solution. Our institutional design puzzle is harder than Madison’s was.

We have our work cut out for us. And so does the president. We should judge our sitting president, and look toward 2020, with a clear-eyed recognition that to defend the Constitution, we need a president committed to cultivating peace within the American people.