Incarceron by Catherine Fisher

A vast, sentient prison holds generations of people who have forgotten the outside world; a resourceful young prisoner longs for escape while a privileged ward’s daughter in the seemingly ordered outside begins to uncover unsettling truths about her society. As their lives intersect, they confront the prison’s mysterious intelligence, political deception, and the meaning of freedom, forcing them to challenge the systems that keep people confined.

Purchase from Bookshop.org