Among the many annoying, tiresome shortages here, last spring's scarcity of lightbulbs was far and away the most demoralizing.

Since the leftist Sandinistas took power in 1979, most of Managua's working poor had always had at least one naked bulb to prove that their dirt-floor cardboard shacks were a step above the abject poverty of their grandparents. But now when that one bulb blew there were no replacements, and they were left to brood in the dark over all their other problems, in a darkened city already deprived of street lights by a government economy move.

Just as the permanently unorganized resentment over everything else wrong here seemed about to jell for once on the lightbulb issue, a cargo ship arrived from the Soviet Union loaded with nothing but lightbulbs. They were smaller and dimmer than the regular bulbs, but they worked fine and everybody relaxed.

The Sandinistas had managed once again to loosen the economic and political noose with which the Reagan administration hopes to strangle the Sandinistas' Marxist revolution.

U.S. policy here is based on the theory that military pressure from the U.S.-backed "contra" rebels will end the Marxist presence, either with an ordinary military victory or by creating so much economic and social disruption that the Sandinistas will be forced by their own people "to cry uncle," as President Reagan put it.

The Sandinistas now go out of their way to let visitors know they are prepared to run the Nicaraguan economy completely into the ground in order to defy Reagan's threat. Lest this seem to be mere rhetoric, they are also willing to demonstrate that they are minutely aware of the precise level of popular resentment, and that they have evolved a Rube Goldberg defense system of controls, force, blind eyes, bluff and jingoism to deal with it.

This approach, they say, will keep their war machine operating, their people eating and their public services more or less in operation until the Yankees either give up and go away, negotiate terms recognizing the Sandinista revolution, or launch a full-scale invasion. There is no alternative, they say.

"Our people understand very well that Ronald Reagan's policy is to strangle us economically until they rise up. But this has only strengthened their will to resist the United States," said Defense Minister Humberto Ortega in an interview. "Suppose we do have to paralyze the country, stop the schools, live under siege conditions. Even then we will not surrender." Economic recovery, he said, is last on the Sandinista priority list, after an end to the fighting and a solution to the political turmoil that the war has stirred up.

The government's severest internal critics believe it, even as they deplore the results. "The Sandinistas will never make any deal with the United States . . . and the contras cannot possibly overthrow them," said Dr. Emilio Alvarez Montalvan, an ophthalmologist and a leader of the largest of three splinters of the Conservative Party. "We hope that they will slowly moderate themselves until they reach a point of tolerance by the United States . . . but we are not optimistic."

Virgilio Godoy, the acerbic head of the Liberal Independent Party, the permanent minority in the rubber-stamp Legislative Assembly, describes Nicaragua's internal situation as "a world of two levels: the visible and formal, where the rules are very clear and admirable; and the invisible world, which here is the real world and where the rules do not operate."

The entire economy, he said, is a prime example. In theory, the government determines wage levels and controls prices, distribution and imports; although there are shortages everyone suffers equally. In practice, companies pay secret "bonuses," which are illegal, in a losing effort to retain good workers; prices are more than doubling every year despite the controls. Many services are exchanged on a barter basis; product distribution is handled chiefly by the black market, and imports are brought in almost completely by individuals smuggling on a small scale while officials turn their backs.

"We call it a semi-official black market because they make almost no effort to enforce the rules," said a diplomatic analyst.

In fact, the Sandinistas bend their own rules so that they, too, can play. There are at least three legal exchange rates for dollars, depending on where one is and what one is buying. Anyone with dollars may shop at the local "diplomatic store" for French wines, American groceries and appliances at prices reasonable by Washington standards but astronomical in local terms

For example, foreigners are required to exchange $60 on arrival at the Managua airport at a rate of 28 cordobas to $1. The 1,500-cordoba taxi ride to town therefore costs about $53. But at the hotel, $1 will bring 630 cordobas, perfectly legally, so that the 1,500-cordoba ride back to the airport costs only $2.38. On the black market, the exchange rate is about 800 to a dollar.

The Sandinistas know that the black market and the barter system are safety valves, supplying needs the government cannot meet. With exports at rock bottom because of the war (the Sandinista view) or because of structural mismanagement (their critics' view), the black market is just about the only source of foreign exchange with which to buy imports -- and every machine, bolt, spare part, battery, drop of fuel and piece of paper in Nicaragua is imported.

The leaders acknowledge that this surreal process has made de facto criminals out of their entire population, but they view it characteristically as temporary, part of the disruption that precedes the revolutionary dawn. "This is not just a problem in Nicaragua but in all of Latin America," President Daniel Ortega said in an interview. "It is a phenomenon of a (world) society in crisis . . . the fault of the capitalist economic system."

While the world crisis works itself through, however, economic news reports in the controlled media are carefully optimistic, and anything else is censored from the sole opposition newspaper, La Prensa. Word of new price controls on melons, a strike attempt at a furniture factory, the chronic gasoline shortage and a virus attack on the crucial cotton crop were all cut from recent editions. The Sandinistas say such stories would spark panic buying, and the controlled press minimizes the impact of the virus and praises the quality of the melons.

In the real world, however, anyone can drop by La Prensa's office and read the censoredstories on the bulletin board, for that is another safety valve: It lends some validity to the Sandinistas' claim that dissent is not stifled.

In fact, dissent is carefully noted. The pervasive Sandinista Defense Committees, the party organization headquarters on every city block and every rural neighborhood, have always kept track of everyone's jobs, health status and private lives, allocating privileges and goodies while monitoring the decibel level of public grumbling and spotting potential resistance leaders. Resentment over economic conditions and the petty tyrannies of committee leaders, however, has risen recently to the point where the committees are now being reorganized "to be more responsive to the community," Interior Minister Tomas Borge said in an interview.

He acknowledged that the committees had become "small centers of personal power" run in large part by former backers of ousted dictator Anastasio Somoza, who rushed to join the new organizations after the revolution "as a logical refuge to avoid punishment and repudiation" by the new leaders. The reorganization, he said, will consist mainly of "eliminating these bad people" from their jobs. The predictable result will be a rise in the committees' efficiency from the Sandinista point of view.

It is a tacit recognition that tensions are mounting, but it is by no means the democratization that the Reagan administration had predicted would follow rising public discontent. As Godoy put it, "People are permitted to complain, but they can't go further than that. People worry that if they do anything, the army will take their son, or their business will be closed or some import will be confiscated . . . . Whenever a small, organized resistance arises, something happens. We cannot get people out of their houses to a rally because we cannot give them a guarantee that nothing will happen afterward."

By all these mechanisms, the Sandinistas have so far avoided making any of the changes the Reagan administration predicted they would have to make as a result of rising pressure from the contras. In fact, administration officials have noted in relation to other countries that Marxist governments are remarkably unresponsive to domestic complaint, so their argument that the Sandinistas, though Marxist, can be forced to change their stripes has been curious from the outset.

In Managua, Sandinista leaders try to give the impression they have been begging the administration for direct peace talks, without any response. The administration in turn insists that Managua must talk with the contras about "national reconciliation," a code word that to the Sandinistas means surrender to a group of U.S. puppets. The puppets cannot win, the Sandinistas say, and they will never cease defending the revolution; therefore, they see nothing ahead but a U.S. invasion.

They are so convincingly adamant about their determination to survive this martyrdom that one almost suspects they would welcome a chance to go back into the hills, to wage once again the guerrilla campaigns that were simple compared with running a government.

"Don't discount the capacity of a Christian nation to suffer and survive persecution from a greater power," Ortega said. "We are seeing here what the capacity of a large country is for destroying a very small place."