Call it a coup, an insurrection, a riot, a siege: Whatever else Wednesday’s brief takeover of the U.S. Capitol by pro-Trump extremists looked like, it was also a profound failure of policing. Despite the presence of both Vice President Pence and House Speaker Nancy Pelosi — second and third in the presidential line of succession — and despite the hundreds of members of Congress gathered in joint session, angry Trump supporters were able to breach perimeter after perimeter, at times simply walking past Capitol Police officers who made no apparent effort to stop them. Members of the mob scaled walls, smashed doors and windows, vandalized works of art, and stole laptops, correspondence and personal items from offices, forcing the emergency evacuation of lawmakers and staff. It was the largest assault on the Capitol since the British attack during the War of 1812.

By day’s end, four people were dead, and many more, including more than 50 police officers, were injured. One officer injured Wednesday died Thursday. Yet only a handful of the rioters were arrested: Most simply strolled out of the Capitol — some proudly displaying stolen items — as easily as they had strolled in.

 The failure of the Capitol Police to anticipate, prevent and respond to the violence is baffling and appalling. But in many ways, it’s a direct consequence of the way the police agency that protects the legislative branch is organized, with far too little accountability or diversity, jumbled oversight, and too many opportunities for politics to creep into its mission.

There was every reason to expect that the pro-Trump rallies planned for Wednesday would turn ugly and violent, probably with threats to Congress. In September, the FBI and the Department of Homeland Security warned that white-supremacist groups — not foreign organizations or left-wing extremists — presented the gravest terrorist threat within the United States. Acting deputy homeland security secretary Ken Cuccinelli testified at a Sept. 24 Senate hearing about the high “lethality” of white-supremacist groups, noting, “It isn’t a belief, it’s just looking at the data.” The next week, an FBI intelligence report noted the increased threat of violent extremism posed by right-wing groups aligned with the “boogaloo” movement.

And there were numerous, specific warning signs about Wednesday’s pro-Trump gatherings, which were timed to protest the joint session of Congress at which President-elect Joe Biden would be formally certified as the winner of the electoral college vote. Previous marches by many of the same organizations and individuals involved in Wednesday’s protests had erupted into chaos. Earlier in the week, D.C. police arrested the leader of the Proud Boys for his role in vandalizing the property of historic Black churches during a Dec. 12 protest that also saw four people stabbed and more than 30 others arrested. In the days leading up to Wednesday, scores of media reports highlighted the growing threat of violence from far-right actors.

In his own remarks around noon on Wednesday, President Trump called on his supporters to go to the Capitol to protest what he falsely claimed was an “egregious assault on our democracy” — the certification of a legitimate election result — advising them, “You will never take back our country with weakness.” By 1:10 p.m., just minutes after the joint session began, the pro-Trump crowd was shoving past police and onto the grounds of the Capitol.

Yet the Capitol Police, which has exclusive jurisdiction over the Capitol and its grounds, appears to have been caught entirely flat-footed. Video footage shows only a handful of officers — in ordinary uniforms, not riot gear — at the outer perimeters of the Capitol, the first line of defense against trespassers. (On Thursday, after most of the rioters were long gone, a by-then-unnecessary security fence started going up around the Capitol.) When crowds pressed toward them, many officers simply retreated, not making any apparent effort to physically block protesters from pushing past the gates.

That led many on Twitter to accuse at least some officers of being in cahoots with the mob. It’s too soon to say whether there’s any truth to the charge of active complicity, but it can’t be dismissed out of hand; watchdog groups and the FBI have warned for years of efforts by white supremacists and other right-wing extremists to infiltrate law enforcement.

The apparent acquiescence of some Capitol Police officers to the insurrection may have been nothing more than a tactical decision (wise or unwise) to bow to realities on the ground: The mob outnumbered the police, and efforts to halt the assault by force might have escalated the violence and led to more deaths. But with the abundance of evidence that the protests might turn violent, why were the perimeters so lightly guarded in the first place?

It’s hard to avoid the conclusion that racial bias made it difficult for Capitol Police officials to perceive the largely White crowds as the threat that they were. Nearly 60 percent of sworn Capitol Police officers are White, in contrast to the D.C. police, where just 36 percent of sworn officers are White, and the senior command staff of the Capitol Police is even more skewed toward White men. As countless commentators have already noted, the light police presence on Wednesday stood in stark contrast to the heavily armed National Guard units and federal riot police who greeted Black Lives Matter racialjustice protesters in June — and regardless of the underlying motivations, the message received by millions of Americans was one about unequal justice.

Even after pro-Trump protesters began to breach outer perimeters, the Capitol Police appear to have delayed requesting backup from other local and federal law enforcement agencies. By midafternoon, the department had invoked a mutual-aid agreement and D.C. police, FBI units and officers from surrounding counties had arrived to help clear the Capitol, but by then it was too late: The mob was already ransacking the building.

The U.S. Capitol Police is an odd entity: Unlike other federal law enforcement agencies, which are part of the executive branch, it is overseen directly by Congress. Because it is part of the legislative branch, the Capitol Police is exempt from the requirements of the Freedom of Information Act, which means that internal reports and studies, including those from the agency’s inspector general, are not available to the public. The department is overseen by a small executive board made up of the Senate and House sergeants at arms and the architect of the Capitol, and it receives broad instructions and funding from the Senate Committee on Rules and Administration, the Committee on House Administration, and the Senate and House appropriations subcommittees that deal with the legislative branch. With responsibility divided among multiple committees and left to elected officials whose primary concerns may involve what plays well with constituents back in Mississippi or Missouri, it’s little wonder that oversight of the Capitol Police has been inconsistent or that the department is the subject of frequent citizen complaints.

Perhaps Wednesday’s anemic Capitol Police response also had something to do with the fact that numerous GOP lawmakers signaled their support for the pro-Trump rallies in the days, hours and minutes before the mob stormed the building: Sen. Josh Hawley (Mo.) raised his fist in solidarity with the crowd as he entered the Capitol, for instance. Several other Republican senators, including Sen. Ted Cruz (Tex.), were among the 147 members of Congress who voted — even after the siege — to oppose certification of the electoral college votes because of Trump’s false claims of voter fraud.

Regardless of the causes, the effect of Wednesday’s police failures was to jeopardize the lives of hundreds of members of Congress, congressional staffers and journalists and to bring a temporary halt to an essential democratic process: the certification of the presidential election results. Still worse, the listless response will cement in the minds of millions the conviction that American police handle violent right-wing White protesters with kid gloves, even as peaceful Black protesters are met with tear gas, batons and bullets.

The riot will reverberate around the globe as well: The United States just let the world — including adversarial states and foreign terrorist groups — know that we’re incapable of protecting our elected leaders or ensuring a peaceful transfer of power. (And the takeaway for foreign terrorists was clear: Be White and carry a Confederate flag, and you can waltz past security with impunity, even in the heart of the U.S. government.)

Can anything be done to remedy these catastrophic failures?

First and foremost, the leaders of the new Congress can investigate what went wrong, hold accountable those within the department who were responsible for its missteps Wednesday, and identify changes to address the agency’s long-standing problems. Capitol Police Chief Steven Sund will resign as a result of his mishandling of Wednesday’s events, but a small number of symbolic resignations won’t address broader failings of oversight and structure. For that reason, investigations of the Capitol Police cannot be purely internal: No organization should investigate itself, so Congress should couple hearings with an external probe of the department. The new Congress should also examine those senators and representatives who helped incite the mob. Trump’s role, too, should be the subject of congressional action; already, calls are mounting for a second impeachment. The president’s words and actions in the past week alone seem to more than merit impeachment proceedings, despite his short time left in office.

The incoming Biden administration also has a role to play: Besides moving forward aggressively on broader initiatives to ensure police accountability and address racially biased and abusive policing practices, federal law enforcement agencies can make it an urgent priority to identify, arrest and prosecute all those who incited, organized or participated in Wednesday’s violence. The Justice Department should not hesitate to also investigate — and if warranted, prosecute — elected officials for their roles in these shameful events.

None of this will undo the damage. But maybe — just maybe — prompt action can ensure that nothing like Wednesday’s assault on Congress will ever happen again.

Twitter: @brooks_rosa