I've gone digging again for where I saw the condition about foundations. I thought I was going mad but eventually found it...
From https://www.homebuilding.co.uk/demolish-and-replace/
"In order to qualify for 0% rated VAT, the entire existing building including the foundations must be replaced. So if you keep, say, the existing substructures, you won’t be able to reclaim the VAT, which adds a whopping 20% onto the construction cost."
I can't find it in HMRC guidance, but I did see this:
https://www.gov.uk/vat-builders/new-homes "any existing buildings on the site have been demolished completely to ground level"
'Ground level' suggests removing the piles. If it was 'ground floor level' I'd read it differently.
But "retaining the ground floor slab" is a well noted exception.
Essentially I'd be losing every wall of the existing building, but technically speaking not going down to ground level.