After fleeing from the Doctor on the Dreamstone Moon, Sam ends up homeless on the colony world of Ha’olam, unable to get a job and home without an identity card, and unable to get an I-card without a job and a home. She survives in a shelter for a month, without the skills to get a job in this century; eventually, however, she learns how to type and is offered an entry-level position with INC. She soon realizes that INC only hires “blanks” such as her for menial clerking positions, and that if she stays with INC she’ll be stuck in a soul-destroying job for at least ten years with no way out. Sam’s roommate Shoshana insists that this really is all there is to life, and when Shoshana has her eye replaced with a computer implant so she’ll be better able to access the planet’s IXNet and get a promotion, Sam walks out on her and her job. She goes back to the shelter with just enough money to tide her over until she can find a better job doing something worthwhile.
The Doctor, meanwhile, is still searching for her, and when he locates her name in the INC employee database he sets off for Ha’olam at once. All his inquiries are blocked by an indifferent receptionist, and he eventually gives up trying to get past her and forges security clearances for himself under the name of Bowman. But he finds the work almost too easy and realizes that the retina-scanning technology has been copied or stolen from Gallifrey. He unleashes chaos upon the company mainframe as a distraction while he investigates, and although he soon discovers that Sam no longer works for INC he does manage to learn that the advanced eye tech comes from the R&D division at Samson Plains. But before he can disconnect from the mainframe, an INC security programme knocks him out.
The Doctor awakens in the Oliver Bainbridge Functional Stabilisation Centre, a private INC prison, accused of corporate espionage and facing a mandatory ten-year sentence. Not all of the prisoners at Bainbridge are corporate spies; some are simply retirees who know too much, or victims of the company health policy who have artificial internal organs which INC doesn’t want falling into the hands of their competitors. All of the prisoners seem resigned to their situation, except the Doctor, who immediately attempts to escape... and fails, as the security guard Rifaat is waiting for him at the exit.
Dr Akalu, the prison’s “morale facilitator”, is fascinated by his new charge, whom he insists upon calling “Mr Bowman”. He remains pleasant and understanding despite the Doctor’s constant escape attempts, and every time the Doctor tries to get away he finds Rifaat waiting, always one step ahead of himn. Akalu advises him to get used to spending the next ten years in prison, but the Doctor refuses to give up. One night he sees an alien in his cell, a centaur-like creature apparently made of blue crystals, which scans him and then disappears. It is never seen again and nobody believes the Doctor when he tells them about it.
Months pass as each escape attempt is thwarted until eventually over a year has gone by. One of the Doctor’s fellow prisoners, a young woman named Ziba, convinces the Doctor to let her escape with him -- but as she tries to climb over the wall she unexpectedly lets go of the rope and falls to her death. The Doctor realizes that every prisoner has been implanted with a false lens in their eyes, and that the warders know every move he makes and can switch him off if he gets too far. Rifaat finally snaps and beats him nearly to death after one escape attempt, but Rifaat is then placed under arrest, charged with assault and sent to a maximum security prison. There’s nothing for the Doctor to fight back against here. Eventually he breaks into Akalu’s office, where he finds the computer terminal active and an AI programme named DOCTOR waiting for him. He finally realizes that DOCTOR has compiled itself into a near-copy of him over the months of gathering information through his eye implant. The more it learns about him, the better it gets at predicting his actions; and whenever he gets too far the implant will simply switch him off. And the Doctor realizes for the first time that he will never be able to escape.
While the Doctor has had idleness thrust upon him, Sam has been busy. A new job at the charitable organisation Livingspace leads her to a desert community founded by former Eurogen workers, who were stranded when their project collapsed due to lack of funding and Eurogen refused to release them from their contracts. Sam works at Eurogen Village for a year, constructing new homes and community buildings and eventually accepting her place in a happy community. But it all falls apart when INC buys out Eurogen’s hold on the land and pays off the Eurogen workers’ contracts. On behalf of those who want to stay, Sam organizes a protest which fails; eventually she is forced to give up and returns to the city with her friends, planning to expose INC’s heartless corporate policies.
After months of organizing protests, Sam’s friends eventually discover that INC owns a controlling share in TCC, the same company which conducted inhuman experiments upon prisoners on Hirath. They manage to expose TCC’s experiments to the public, but INC’s lawyers claim that INC just invested in the company and had no idea what they were really up to. Sam has her friend Rachel hack into the databases of prisons and hospitals across the planet, hoping to find evidence of botched neural edits or other abuses of employee rights. Eventually Rachel downloads the prisoner manifest of the Bainbridge facility -- and Sam finally learns that the Doctor has been trapped there for the last three years...
Sam still isn’t entirely certain what her feelings for the Doctor are, but nevertheless convinces her friends to help break him out. A stray cat which she’s been tending for the last three years leads Sam to the TARDIS, waiting in a back alley of the city of Incopolis, and she comes up with a plan to get it to the Doctor. While her former lover Paul waits in the TARDIS, Sam and the others break into Bainbridge through a flaw in the aqueduct, and locate the Doctor after setting fire to the library as a distraction. The Doctor is nearly catatonic from despair and frustrated boredom, but he manages to pull himself together and use Sam’s cell phone to tell Paul how to pilot the TARDIS to him. DOCTOR realizes what’s happening seconds too late, and the Doctor gets away.
The TARDIS extracts the implant from the Doctor’s eye, and Sam helps him to come to terms with the fact that, after giving up all hope of ever escaping, he finally has. The Doctor decides to go to Samson Plains to investigate the source of the company’s advanced technology, and Sam accompanies him. Meanwhile, Dr Akalu contacts Sam’s former roommate Shoshana in order to create a profile of Sam, and Shoshana is only too happy to help; when Sam walked out on her she inadvertently forgot all about her last month’s rent, and Shoshana nearly ended up on the street herself. Akalu and Shoshana go to Samson Plains to wait for the Doctor, as that’s where DOCTOR had predicted he would end up. DOCTOR itself is becoming more and more like the Doctor as time goes on.
The Doctor and Sam break into Samson Plains and discover that it has been built over the ruins of a crashed alien spaceship. The ship contains artefacts from various different civilisations -- including a mind probe from Gallifrey, which INC scientists are using on level one to power IXNet. DOCTOR leads Akalu and Shoshana to the Doctor and Sam, and Akalu and Shoshana insist that the Doctor’s conspiracy theories are simple paranoia; like any other company, INC is one huge committee which simply isn’t organised enough to run a secret conspiracy as the Doctor has theorised. But the Doctor realizes that this means the real conspirators are elsewhere... and he’s proven right when an organic alien spacecraft arrives, and the crystal centaur aliens he’d encountered before land and begin harvesting the technology from the R&D centre.
The aliens, a group intelligence called the I, capture Shoshana and use her eye implant to access IXNet. The Doctor, Sam and Akalu are also captured, but the Doctor learns that the ship is in fact the chrysalis of a space-dwelling creature, arrested at this stage of its development by the I; it’s willing to help them if they can help it in return. The Doctor escapes while the I, using the stolen eyes of a kidnapped Time Lord named Savar, tamper with the mind probe and manage to turn it up to level two. Every single person connected to IXNet is melded into a new gestalt entity which calls itself the ubernet and begins fighting the invasive I.
The I themselves, as a gestalt entity, are unable to come to a consensus about anything long enough to develop their own original ideas; thus they simply steal technology, plant it like seeds amongst other civilisations and return later to harvest the results. The I head for Bainbridge to begin harvesting the eyes of every prisoner and guard with an implant, but the ubernet manages to communicate through Shoshana and offers to surrender the Doctor if the I agree to leave the ubernet alone. DOCTOR helps Sam to connect to the ubernet and shut it down; she then destroys the mind probe. The Doctor manages to evade the I long enough to upload DOCTOR into the control mechanisms on their ship, and DOCTOR shuts them down, releasing the entity at the heart of the cocoon. The creature finally hatches and flies off into space, and the destruction of their ship breaks the I’s artificial gestalt and reduces each individual I to a mindless drone state.
Shoshana just wants to return to her ordinary life and forget that this happened, while Akalu -- who only wanted to understand other people and help them to get better -- goes into shock after the collapse of the ubernet. The Doctor offers to download DOCTOR into the TARDIS data banks, but the AI gives him the slip and departs into human dataspace to explore the Universe. Sam, who’d used her time in the ubernet to rewrite INC’s company policy manuals, decides that travelling with the Doctor gives her a better chance to right wrongs throughout the galaxy. She’s come to terms with her teenage crush on him and learned that she can survive on her own terms, so she joins him once again. Besides, she’s been dreaming about a dark-haired, rough-around-the-edges Sam who lives an empty life in a bedsit in King’s Cross, and a chance remark of the Doctor’s has led her to suspect that someone has tampered with her life to recreate her as a distracting, ordinary companion for him. If this is the case, they’re in for a shock, for she’s no longer anything of the sort.