In other words, Singapore has become a laboratory not only for testing how mass surveillance and big-data analysis might prevent terrorism, but for determining whether technology can be used to engineer a more harmonious society.

Ten years after its founding, the RAHS program has evolved beyond anything Poindexter could have imagined. Across Singapore's national ministries and departments today, armies of civil servants use scenario-based planning and big-data analysis from RAHS for a host of applications beyond fending off bombs and bugs. They use it to plan procurement cycles and budgets, make economic forecasts, inform immigration policy, study housing markets, and develop education plans for Singaporean schoolchildren -- and they are looking to analyze Facebook posts, Twitter messages, and other social media in an attempt to "gauge the nation's mood" about everything from government social programs to the potential for civil unrest.

Because of such uproars, many current and former U.S. officials have come to see Singapore as a model for how they'd build an intelligence apparatus if privacy laws and a long tradition of civil liberties weren't standing in the way. After Poindexter left DARPA in 2003, he became a consultant to RAHS, and many American spooks have traveled to Singapore to study the program firsthand. They are drawn not just to Singapore's embrace of mass surveillance but also to the country's curious mix of democracy and authoritarianism, in which a paternalistic government ensures people's basic needs -- housing, education, security -- in return for almost reverential deference. It is a law-and-order society, and the definition of "order" is all-encompassing.

In late 2003, a group of U.S. lawmakers more sympathetic to Poindexter's ideas arranged for his experiment to be broken into several discrete programs, all of which were given new, classified code names and placed under the supervision of the National Security Agency (NSA). Unbeknownst to almost all Americans at the time, the NSA was running a highly classified program of its own that actually was collecting Americans' phone and Internet communications records and mining them for connections to terrorists. Elements of that program were described in classified documents disclosed in 2013 by former NSA contractor Edward Snowden, sparking the most significant and contentious debate about security and privacy in America in more than four decades.

Back in the United States, however, the TIA program had become the subject of enormous controversy. Just a few weeks after Poindexter met with Ho, journalists reported that the Defense Department was funding experimental research on mining massive amounts of Americans' private data. Some members of Congress and privacy and civil liberties advocates called for TIA to be shut down. It was -- but in name only.

Ho returned home inspired that Singapore could put a TIA-like system to good use. Four months later he got his chance, when an outbreak of severe acute respiratory syndrome (SARS) swept through the country, killing 33, dramatically slowing the economy, and shaking the tiny island nation to its core. Using Poindexter's design, the government soon established the Risk Assessment and Horizon Scanning program (RAHS, pronounced "roz") inside a Defense Ministry agency responsible for preventing terrorist attacks and "nonconventional" strikes, such as those using chemical or biological weapons -- an effort to see how Singapore could avoid or better manage "future shocks." Singaporean officials gave speeches and interviews about how they were deploying big data in the service of national defense -- a pitch that jibed perfectly with the country's technophilic culture.

"I was impressed with the sheer audacity of the concept: that by connecting a vast number of databases, that we could find the proverbial needle in the haystack," Ho later recalled . He wanted to know whether the system, which was not yet deployed in the United States, could be used in Singapore to detect the warning signs of terrorism. It was a matter of some urgency. Just 10 days earlier, terrorists had bombed a nightclub, a bar, and the U.S. consular office on the Indonesian island of Bali, killing 202 people and raising the specter of Islamist terrorism in Southeast Asia.

The two men met in Poindexter's small office in Virginia, and on a whiteboard, Poindexter sketched out for Ho the core concepts of his imagined system, which Poindexter called Total Information Awareness (TIA). It would gather up all manner of electronic records -- emails, phone logs, Internet searches, airline reservations, hotel bookings, credit card transactions, medical reports -- and then, based on predetermined scenarios of possible terrorist plots, look for the digital "signatures" or footprints that would-be attackers might have left in the data space. The idea was to spot the bad guys in the planning stages and to alert law enforcement and intelligence officials to intervene.

In October 2002, Peter Ho, the permanent secretary of defense for the tiny island city-state of Singapore, paid a visit to the offices of the Defense Advanced Research Projects Agency (DARPA), the U.S. Defense Department's R&D outfit best known for developing the M16 rifle, stealth aircraft technology, and the Internet. Ho didn't want to talk about military hardware. Rather, he had made the daylong plane trip to meet with retired Navy Rear Adm. John Poindexter, one of DARPA's then-senior program directors and a former national security advisor to President Ronald Reagan. Ho had heard that Poindexter was running a novel experiment to harness enormous amounts of electronic information and analyze it for patterns of suspicious activity -- mainly potential terrorist attacks.

Singapore was the perfect home for a centrally controlled, complex technological system designed to maintain national order.

In a country run by engineers and technocrats, it's an article of faith among the governing elite, and seemingly among most of the public, that Singapore's 3.8 million citizens and permanent residents -- a mix of ethnic Chinese, Indians, and Malays who live crammed into 716 square kilometers along with another 1.5 million nonresident immigrants and foreign workers -- are perpetually on a knife's edge between harmony and chaos.

"Singapore is a small island," residents are quick to tell visitors, reciting the mantra to explain both their young country's inherent fragility and its obsessive vigilance. Since Singapore gained independence from its union with Malaysia in 1965, the nation has been fixated on the forces aligned against it, from the military superiority of potentially aggressive and much larger neighbors, to its lack of indigenous energy resources, to the country's longtime dependence on Malaysia for fresh water. "Singapore shouldn't exist. It's an invented country," one top-ranking government official told me on a recent visit, trying to capture the existential peril that seems to inform so many of the country's decisions.

But in less than 50 years, Singapore has achieved extraordinary success. Despite the government's quasi-socialistic cradle-to-grave care, the city-state is enthusiastically pro-business, and a 2012 report ranked it as the world's wealthiest country, based on GDP per capita. Singapore's port handles 20 percent of the world's shipping containers and nearly half of the world's crude oil shipments; its airport is the principal air-cargo hub for all of Southeast Asia; and thousands of corporations have placed their Asian regional headquarters there. This economic rise might be unprecedented in the modern era, yet the more Singapore has grown, the more Singaporeans fear loss. The colloquial word kiasu, which stems from a vernacular Chinese word that means "fear of losing," is a shorthand by which natives concisely convey the sense of vulnerability that seems coded into their social DNA (as well as their anxiety about missing out -- on the best schools, the best jobs, the best new consumer products). Singaporeans' boundless ambition is matched only by their extreme aversion to risk.

That is one reason the SARS outbreak flung the door wide open for RAHS. From late February to July of 2003, the virus flamed through the country. It turned out that three women who were hospitalized and treated for pneumonia in Singapore had contracted SARS while traveling in Hong Kong. Although two of the women recovered without infecting anyone, the third patient sparked an outbreak when she passed the virus to 22 people, including a nurse who went on to infect dozens of others. The officials identified a network of three more so-called "superspreaders" -- together, five people caused more than half the country's 238 infections. If Singaporean officials had detected any of these cases sooner, they might have halted the spread of the virus.

Health officials formed a task force two weeks after the virus was first spotted and took extraordinary measures to contain it, but they knew little about how it was spreading. They distributed thermometers to more than 1 million households, along with descriptions of SARS's symptoms. Officials checked for fevers at schools and businesses, and they even used infrared thermal imagers to scan travelers at the airport. The government invoked Singapore's Infectious Diseases Act and ordered in-home quarantines for more than 850 people who showed signs of infection, enforcing the rule with surveillance devices and electronic monitoring equipment. Investigators tracked down all people with whom the victims had been in contact. The government closed all schools at the pre-university level, affecting 600,000 students.

By mid-April, fewer people were visiting the country, and hotel occupancy rates plummeted, along with revenues at shops and restaurants. Taxi drivers reported fewer fares. The unemployment rate ticked up. Officials slashed the country's economic growth forecast for 2003, from a strong 2.5 percent to a possible 0.5 percent. When the full effects of the outbreak were finally measured, the economy had actually contracted 4.2 percent from the same time the previous year. The SARS outbreak reminded Singaporeans that their national prosperity could be imperiled in just a few months by a microscopic invader that might wipe out a significant portion of the densely packed island's population.

Months after the virus abated, Ho and his colleagues ran a simulation using Poindexter's TIA ideas to see whether they could have detected the outbreak. Ho will not reveal what forms of information he and his colleagues used -- by U.S. standards, Singapore's privacy laws are virtually nonexistent, and it's possible that the government collected private communications, financial data, public transportation records, and medical information without any court approval or private consent -- but Ho claims that the experiment was very encouraging. It showed that if Singapore had previously installed a big-data analysis system, it could have spotted the signs of a potential outbreak two months before the virus hit the country's shores. Prior to the SARS outbreak, for example, there were reports of strange, unexplained lung infections in China. Threads of information like that, if woven together, could in theory warn analysts of pending crises.

The RAHS system was operational a year later, and it immediately began "canvassing a range of sources for weak signals of potential future shocks," one senior Singaporean security official involved in the launch later recalled.

The system uses a mixture of proprietary and commercial technology and is based on a "cognitive model" designed to mimic the human thought process -- a key design feature influenced by Poindexter's TIA system. RAHS, itself, doesn't think. It's a tool that helps human beings sift huge stores of data for clues on just about everything. It is designed to analyze information from practically any source -- the input is almost incidental -- and to create models that can be used to forecast potential events. Those scenarios can then be shared across the Singaporean government and be picked up by whatever ministry or department might find them useful. Using a repository of information called an ideas database, RAHS and its teams of analysts create "narratives" about how various threats or strategic opportunities might play out. The point is not so much to predict the future as to envision a number of potential futures that can tell the government what to watch and when to dig further.

The officials running RAHS today are tight-lipped about exactly what data they monitor, though they acknowledge that a significant portion of "articles" in their databases come from publicly available information, including news reports, blog posts, Facebook updates, and Twitter messages. ("These articles have been trawled in by robots or uploaded manually" by analysts, says one program document.) But RAHS doesn't need to rely only on open-source material or even the sorts of intelligence that most governments routinely collect: In Singapore, electronic surveillance of residents and visitors is pervasive and widely accepted.

Surveillance starts in the home, where all Internet traffic in Singapore is filtered, a senior Defense Ministry official told me (commercial and business traffic is not screened, the official said). Traffic is monitored primarily for two sources of prohibited content: porn and racist invective. About 100 websites featuring sexual content are officially blocked. The list is a state secret, but it's generally believed to include Playboy and Hustler magazine's websites and others with sexually laden words in the title. (One Singaporean told me it's easy to find porn -- just look for the web addresses without any obviously sexual words in them.) All other sites, including foreign media, social networks, and blogs, are open to Singaporeans. But post a comment or an article that the law deems racially offensive or inflammatory, and the police may come to your door.

Singaporeans have been charged under the Sedition Act for making racist statements online, but officials are quick to point out that they don't consider this censorship. Hateful speech threatens to tear the nation's multiethnic social fabric and is therefore a national security threat, they say. After the 2012 arrest of two Chinese teenage boys, who police alleged had made racist comments on Facebook and Twitter about ethnic Malays, a senior police official explained to reporters: "The right to free speech does not extend to making remarks that incite racial and religious friction and conflict. The Internet may be a convenient medium to express one's views, but members of the public should bear in mind that they are no less accountable for their actions online."

Singaporean officials stress that citizens are free to criticize the government, and they do. In fact, one of the country's most popular books this year has been a provocative rebuttal to the decades-old official dogma concerning the country's existential peril. Hard Choices: Challenging the Singapore Consensus, by Donald Low and Sudhir Thomas Vadaketh, argues that the ruling People's Action Party, which has held uninterrupted power since 1959, may have invented the notion that Singapore is one step away from ruin in a bid to subdue the masses and cement the government's hold on power.

Commentary that impugns an individual's character or motives, however, is off-limits because, like racial invective, it is seen as a threat to the nation's delicate balance. Journalists, including foreign news organizations, have frequently been charged under the country's strict libel laws. In 2010, the New York Times Co. settled a lawsuit over a column in the International Herald Tribune about "dynastic politics," which implied that Lee Hsien Loong, the prime minister, owed his job to nepotism. Lee's father is Lee Kuan Yew, Singapore's first prime minister, co-founder of the People's Action Party, and the country's patriarch -- revered in Singapore like George Washington might be in the United States if he were still alive. The company paid $114,000, and the Herald Tribune published an apology.

Not only does the government keep a close eye on what its citizens write and say publicly, but it also has the legal authority to monitor all manner of electronic communications, including phone calls, under several domestic security laws aimed at preventing terrorism, prosecuting drug dealing, and blocking the printing of "undesirable" material. According to the civil rights watchdog Privacy International, "the government has wide discretionary powers … to conduct searches without warrants, as is normally required, if it determines that national security, public safety or order, or the public interest are at issue."

The surveillance extends to visitors as well. Mobile-phone SIM cards are an easy way for tourists to make cheap calls and are available at nearly any store -- as ubiquitous as chewing gum in the United States. (Incidentally, the Singaporean government banned commercial sales of gum because chewers were depositing their used wads on subway doors, among other places.) Criminals like disposable SIM cards because they can be hard to trace to an individual user. But to purchase a card in Singapore, a customer has to provide a passport number, which is linked to the card, meaning the phone company -- and, presumably, by extension the government -- has a record of every call made on a supposedly disposable, anonymous device.

Privacy International reported that Singaporeans who want to obtain an Internet account must also show identification -- in the form of the national ID card that every citizen carries -- and Internet service providers "reportedly provide, on a regular basis, information on users to government officials." The Ministry of Home Affairs also has the authority to compel businesses in Singapore to hand over information about threats against their computer networks in order to defend the country's computer systems from malicious software and hackers, a defense official told me. The U.S. Congress has been debating for years now a similar provision that could compel some industries deemed crucial to the U.S. economy or security to hand over threat data, but it has been blocked by the Chamber of Commerce and businesses that see it as costly, heavy-handed government regulation of private security matters.

"In Singapore, people generally feel that if you're not a criminal or an opponent of the government, you don't have anything to worry about."

Perhaps no form of surveillance is as pervasive in Singapore as its network of security cameras, which police have installed in more than 150 "zones" across the country. Even though they adorn the corners of buildings, are fastened to elevator ceilings, and protrude from the walls of hotels, stores, and apartment lobbies, I had little sense of being surrounded by digital hawk eyes while walking around Singapore, any more than while surfing the web I could detect the digital filters of government speech-minders. Most Singaporeans I met hardly cared that they live in a surveillance bubble and were acutely aware that they're not unique in some respects. "Don't you have cameras everywhere in London and New York?" many of the people I talked to asked. (In fact, according to city officials, "London has one of the highest number of CCTV cameras of any city in the world.") Singaporeans presumed that the cameras deterred criminals and accepted that in a densely populated country, there are simply things you shouldn't say. "In Singapore, people generally feel that if you're not a criminal or an opponent of the government, you don't have anything to worry about," one senior government official told me.

This year, the World Justice Project, a U.S.-based advocacy group that studies adherence to the rule of law, ranked Singapore as the world's second-safest country. Prized by Singaporeans, this distinction has earned the country a reputation as one of the most stable places to do business in Asia. Interpol is also building a massive new center in Singapore to police cybercrime. It's only the third major Interpol site outside Lyon, France, and Argentina, and it reflects both the international law enforcement group's desire to crack down on cybercrime and its confidence that Singapore is the best place in Asia to lead that fight.

But it's hard to know whether the low crime rates and adherence to the rule of law are more a result of pervasive surveillance or Singaporeans' unspoken agreement that they mustn't turn on one another, lest the tiny island come apart at the seams. If it's the latter, then the Singapore experiment suggests that governments can install cameras on every block in their cities and mine every piece of online data and all that still wouldn't be enough to dramatically curb crime, prevent terrorism, or halt an epidemic. A national unity of purpose, a sense that we all sink or swim together, has to be instilled in the population. So Singapore is using technology to do that too.

In 2009, Singapore's leaders decided to expand the RAHS system and the use of scenario planning far beyond the realm of national security -- at least as it's commonly understood in the United States. They established the Strategic Futures Network, staffed by deputy secretaries from every ministry, to export the RAHS methods across the entire government. The network looks beyond national security concerns and uses future planning to address all manner of domestic social and economic issues, including identifying "strategic surprise" and so-called "black swan" events that might abruptly upset national stability.

The RAHS team has mounted a study on the public's attitude toward the housing system and what people want out of it. The provision of affordable, equitable housing is a fundamental promise that the government makes to its citizens, and keeping them happy in their neighborhoods has been deemed essential to national harmony. Eighty percent of Singapore's citizens live in public housing -- fashionable, multiroom apartments in high-rise buildings, some of which would sell for around U.S. $1 million on the open market. The government, which also owns about 80 percent of the city's land, sells apartments at interest rates below 3 percent and allows buyers to repay their mortgages out of a forced retirement savings account, to which employers also make a contribution. The effect is that nearly all Singaporean citizens own their own home, and it doesn't take much of a bite out of their income.

Future planning has been applied to a broad variety of policy problems. It has been used to study people's changing attitudes about how kids should be educated and whether it's time to lessen Singapore's historically strong emphasis on test scores for judging student achievement. The Singapore Tourism Board used the methodology to examine trends about who will be visiting the country over the next decade. Officials have tried to forecast whether "alternative foods" derived from experiments and laboratories could reduce Singapore's near-total dependence on food imports.

Singaporeans have even begun studying what officials describe as a pervasive "nostalgia" among many citizens, who are longing for a simpler, slower-paced time before the city-state's breathtaking economic rise, moving from Third World to First World status in a generation and a half. "But there is also an ugly side to nostalgia," the government warns. "It can be about rejecting certain aspects of the present, such as the growth of Singapore into a diverse, global city, and cultivating an insular sense of nationalism. We explore what can be done to channel this urge for nostalgia in a direction that is more forward-looking."

But the future is one of the things that worries Singaporeans. In 2013, the government issued a so-called "population white paper" that described its efforts to grow the country and forecast a 30 percent population increase by 2030, bringing the number of residents to as many as 6.9 million in the already crowded city-state. Immigrants were expected to make up half the total. Singaporeans revolted. Four thousand people attended one rally against the population plan -- one of the largest public protests in the country's history. The white paper revealed a potential double threat: Singaporeans were already turning against the government for growing the country too big and too fast, and now they were turning on their immigrant neighbors, whom they blamed for falling wages and rising home prices.

The protests shook the "nation's mood" at the highest level, and the government was prepared to take drastic measures to quell the unrest, starting with cutting immigrant labor. The National Population and Talent Division -- a kind of immigration-cum-human-resources department -- intends to slow the growth of the workforce to about 1 to 2 percent per year over the rest of the decade, which is a dramatic departure from the more than 3 percent annual growth over the past 30 years. With that, GDP growth is likely to retract to an average of 3 to 4 percent per year. It is impossible to know whether wealthy Singaporeans -- and the country's foreign investors -- will tolerate an economic slowdown. (Or whether a country with an abysmal fertility rate of 1.2 children can even sustain its economy without foreign labor.) But the government has concluded that a slowdown is the right price to pay for keeping a harmonious society. The data tells it so.

Singapore is now undertaking a multiyear initiative to study how people in lower-level service or manufacturing jobs could be replaced by automated systems like computers or robots, or be outsourced. Officials want to understand where the jobs of the future will come from so that they can retrain current workers and adjust education curricula. But turning lower-end jobs into more highly skilled ones -- which native Singaporeans can do -- is a step toward pushing lower-skilled immigrants out of the country.