The Doctor (David Tennant), Professor River Song (Alex Kingston), Lux Strackman (Steve Pemberton), and team run from the Vashta Nerada on a planet-sized library. Some team-members have already been killed and their bodies replaced by Vashta Nerada microbes in the spacesuits. When they rest, Lux explains that the library was built by his grandfather for Lux’s Aunt Charlotte, who was stricken with an incurable disease at a young age. He had a giant computer built at the core of the library so her mind could live on there among all the great works. Thousands of patrons are now in the computer core to save them from the Vashta Nerada.
Meanwhile, Donna (Catherine Tate), lives in the simulation of an Earth village, treated by Doctor Moon (Colin Salmon) and married to Lee (Jason Pitt). Time is skipping. She is alerted that it is a stimulation by Miss Evangelista (Talulah Riley) who was killed. In the core, the Doctor learns from the Vashta Nerada that their forests were razed to create all the books in the library, and they claim the library as their own. The Doctor will be allowed to free the people trapped in the core but has only one day. The Doctor wants to hook himself up to the computer terminal, though this will kill him. River Song knocks him out and takes his place. She is living time backwards and if he dies now, she will not be able to meet him in the future.
The patrons stored in the computer rematerialize on the library surface and teleport to safety. Donna emerges from the simulation. She and the Doctor leave behind River’s book and sonic screwdriver. He wonders why his future self will give it to her. He finds her thought pattern in its data recorder. He saves her pattern in the core and she wakes up in a simulation there.
Basically, when the Vashta Nerada arrived, the computer tried to teleport 4022 people out at once and overloaded. Now they are in simulation that uses so much memory that the computer has forgotten what happened. River Song was born in the future and lives backwards to the present. The Doctor doesn’t know her because he will only meet her in his future, though she has lived a life with him. In Donna’s marriage in the simulation, she wears the same wedding dress she wore in The Runaway Bride. The children there, Joshua and Ella, are named for Steven Moffat’s son and his friend. The Doctor says, “Time can be rewritten,” and this is a recurring phrase in future episodes. But it completely contradicts what the First Doctor said. The plot device of people being saved in a teleport bunker is much like the plot of the Star Trek: The Next Generation episode in which Montgomery Scott is saved that way for Picard’s team to find.