Costa doesn’t hide her political allegiances, and her candor enhances rather than undermines the credibility of her report. Her parents were left-wing activists, persecuted and driven underground in the 1960s and ’70s. Her mother and Rousseff spent time in the same prison, and Costa’s access to and comfort with the upper echelons of the Workers’ Party is evident. But her family history also connects her with the business interests — the construction industry in particular — that she argues have warped Brazilian politics and undermined its democratic, egalitarian potential.

Lula is depicted as the flawed but nonetheless authentic embodiment of that potential, a leader whose down-to-earth charisma remains consistent whether he is addressing striking workers or presiding over affairs of state. But while Costa’s portrait of him, and of Rousseff, is admiring, it is hardly uncritical. What energizes her story is the fight to achieve a measure of analytical clarity in the midst of catastrophe. Rather than cloud her vision, her sympathies sharpen it.

What she sees — what she shows — is both a thriller and epic, a tale of conspiratorial, self-interested scheming that is at the same time a saga of large historical forces and epochal shifts in power and ideology. The charges brought against Rousseff and Lula are explained as a result of betrayals that feel almost Shakespearean, a judicial and legislative coup d’état accomplished through the weaponization of laws and institutions that were supposed to be neutral.

Costa’s villains are wealthy industrialists and members of Brazil’s centrist and right-of-center parties. But her heroes had collaborated with those same parties, and Lula’s success in the mid- and late-2000s — a period of economic growth and ambitious social reform — was to some degree enabled by his accommodation of business interests and cross-partisan cooperation. One of the implications of “The Edge of Democracy” is that as Lula and the Workers' Party lost touch with the mass movement that brought them to power and mastered the levers of the political system, they made themselves vulnerable to popular anger on the right. Corruption and back room dealing were longstanding norms of Brazilian governance that the party didn’t do much to challenge. Public frustration with government as a whole could thus be mobilized against Lula and Rousseff, whose effigies were paraded, dressed in prison stripes, at street rallies.

Footage of those rallies, and of counterdemonstrations against Rousseff’s impeachment and Lula’s arrest, suggest a ferociously polarized society, one in which the fundamental terms of national identity, collective history and truth itself are in dispute. “Order and Progress,” the idealistic slogan on the Brazilian flag, is so thoroughly mocked by this spectacle of chaos and regression that Costa finds herself wondering if the words have always been a joke.