Alexis has a secret. She knows she can tell her dad anything. Then why is she having a private chat with a certain homicide detective named Kate Beckett? We have no idea. Neither does Castle. He presses Beckett for details on his daughter's dilemma, but she's not talking. This drives him crazy. Fortunately, there's nothing like a murder to take your mind off your problems.
When Jack Buckley, a no-nonsense Assistant District Attorney, is tossed off a rooftop, Castle thinks someone he prosecuted went all "Cape Fear" on him in a revenge killing. All we have to say about that is, "Come out, come out wherever you are."
At the D.A.'s office, an intern named Scarlett Price gives Castle a list of Buckley's prosecutions, while the secretary, Nicole Cameron, tells Beckett that her boss had recently gotten into a yelling match with John Knox, a career criminal. Knox tells Beckett and Castle he was at an AA meeting when Buckley was killed. If they don't believe him, they can ask his sponsor - Reverend Miller. It's always nice to have a priest for an alibi.
Their next lead is a guy named Norman Jessup, a recently released con who was semi-stalking Buckley. Jessup witnessed an argument between Buckley and his former brother-in-law, Paul Cho, who says that a man in a ski mask gave him a warning: "Tell Buckley to back off Danton." When we discover Cho has a fondness for call girls, Castle figures Danton must be a pimp. Beckett has Cho call for one of the girls. Surprise, surprise. The woman who shows is none other than Scarlett, the intern from Buckley's office!
Scarlett explains that Buckley was a client. When he found out she was working to pay her way through law school, he gave her an internship in his office. She confirms that Danton is her pimp, but she has no idea who he is. The system is set up to protect the identity of the girls, the clients and, most of all, Danton.
Ryan and Esposito discover the pimp's real name is Dan Tonelli, who tells them Buckley made him a deal during his prosecution. If Tonelli handed over his operation, Buckley would go easy on his sentencing. Castle can't believe it. He says, "Our D.A. was a pimp!"
Castle and Beckett realize that if Buckley was Scarlett's pimp, she must have known what was going on. She tells them that John Knox is the new Danton. She lied because she was afraid he might hurt her. That appears to be a valid concern. Castle finds a beaten Scarlett waiting outside his door. She tells him that Knox killed Buckley. She produces a photo of Reverend Miller with a call girl. Knox blackmailed him for an alibi.
The next morning, Castle proudly shows Beckett the incriminating photo, but his happiness is short-lived when Beckett dresses him down for seeing Scarlett without her. Think she was jealous or just plain mad? We'll go with mad because she had ordered surveillance on Knox but he was able to slip away during the night. Then Castle's phone rings. It's Scarlett. Knox has found her.
A trace of Castle's cell phone leads the team to a dingy hotel room. Gunshots ring out from behind the door. They break in to find Knox dead on the floor and Scarlett, in shock, with a gun in her hand. She explains that it was self-defense and is clearly traumatized.
Castle is worried about Scarlett until he stumbles over a glitch in the timeline. If Beckett had surveillance on Knox last night, there's no way he could have beaten up Scarlett. She must've been in on the takeover from the start, with Knox as an equal partner. But when Buckley's murder investigation uncovered the call girl ring, Scarlett gave them Knox as the mastermind, and then killed him before he could reveal the truth. Castle calls her posing as a customer. And right around the time he reveals who he is, Scarlett is taken into custody.
Alexis finally puts Castle out of his misery by revealing her secret. She's been on the fence about taking a school course abroad. She opts to skip the trip so she can be around to celebrate her dad's birthday. Castle is relieved to hear that his little girl won't be heading overseas in the near future. His joy is short-lived when Alexis mentions that she's considering college at Oxford. You know...the one in England.