Cory Doctorow is among the best of the current practitioners of near-future speculative fiction, standing shoulder-to-shoulder with such superlative peers as Bruce Sterling, Kim Stanley Robinson, Charles Stross and Justina Robson. As with these fellow writers, he takes the chance of having his day-after-tomorrow literary forecasts superseded by swiftly mutating reality. The fallout, when it happens, does not invalidate his tales any more than post-1968 history rendered Stanley Kubrick’s “2001: A Space Odyssey” less of an eternal masterpiece.

When he issued “Little Brother” in 2008, the events in that tale of adolescent monkey-wrenching and protest had a sense of plausible inevitability. Starting with an all-too-likely terrorist attack on San Francisco and segueing into an examination of the surveillance state, the book served as a vibrant model of what might soon be.

The 2013 sequel, “Homeland,” hewed to the same imaginary timeline, venturing into the Edward Snowden/Julian Assange/Chelsea Manning whistleblowers scene, again deploying logical sequelae to present events. But already Doctorow’s timeline had begun to deviate more radically from history.

Now comes “Attack Surface,” the third book in the series, and it’s plain that Doctorow’s “future history,” however many clever and insightful resonances it maintains with current headlines, is no longer a plausible near-term guide for the world, but rather the events of a counterfactual “stub” (to employ William Gibson’s handy term for such deviant continuums). The coronavirus pandemic, not to mention the unpredictable and ever-destabilizing actions of President Trump and his opponents, have conspired to make Doctorow’s scenario an alternate history; his tale has escaped the framework of the near-future subgenre. What we enjoy instead is political cyberthriller, vigorous, bold and savvy about the limits of revolution and resistance, even if it’s no longer precisely contoured to our actual dilemmas.

The first two books in this series centered on Marcus Yallow, a naive teenager, then a wiser young man, of above-average intelligence, focused on social activism against a burgeoning police state. A peripheral but consequential figure in his circle was a woman not much older than he, named Masha Maximow. At first working for the establishment “bad guys,” she eventually had a change of heart and facilitated Marcus’s anti-authoritarian moves. Now she strides confidently onto center stage, and we plunge deeply into her life, both past and present. (Large chunks of the text involve her backstory since “Little Brother” in a kind of “Rashomon” retelling.)

Chapter 1 opens in real time and discloses Masha, our narrator, working for a Blackwater-style security firm named Xoth Intelligence. She’s in an unnamed Eastern European county she dubs “Slovstakia,” installing software for the dictator. But her sentiments are really with the rebels, and so she attempts a double game. (This thread captures real world events in Hong Kong and Belarus with eerie fidelity.) When found out, she’s fired from Xoth and flees the country, albeit well-supplied with cash.

She heads back to her native San Francisco, to crash on the couch of her childhood bestie, Tanisha, one of the main organizers in the Black-Brown Alliance, the street-fighting heir to the BLM movement. When Tanisha is arrested, Masha — now reunited with Marcus and his wife, Ange — must shift into high gear to free her friend and aid her cause. Beyond that goal, they have to work to take down Zyz, yet another of Masha’s ethically compromised ex-employers, with a lock on San Francisco’s law-enforcement outsourcing. (Both Zyz and Xoth are run by ultracompetent women, giving the triangular conflict between the two corporations and Masha a matriarchal telenovela “Game of Thrones”-“Dynasty” vibe.)

Doctorow relentlessly builds Masha’s character into a deep portrait of a damaged personality. Despite — or because of — all her gifts, she’s borderline psychopathic, as her Xoth boss Ilsa openly tells her, yet also on the verge of a nervous breakdown because of many unresolved issues. Her allegiances are shifting and often self-serving. As Doctorow says in his afterword, “This is a book about how people rationalize themselves into doing things they are ashamed of.” Despite these traits, Masha becomes a protagonist worth rooting for, and one whose inner conflicts and cognitive dissonances propel her to surprising, even heroic actions. A first-class geek, Masha also offers copious and frequent jargon-filled info dumps. Your entertainment mileage may vary on these passages.

Doctorow’s allegiances lie with the rebels and underdogs — he sketches the heroics of the protesters and the kinetic tumult of the riots with evident verve and sympathetic exegesis — but he also gives Masha good arguments for her complicity with the establishment.

Doctorow’s world might no longer map our current events, but it still charts the universal currents of the human heart and soul with precision.

Paul Di Filippo’s most recent novel is “The Deadly Kiss-Off.”

Attack Surface

By Cory Doctorow

Tor. 384 pp. $26.99