Going forward, I would want the goals and outcomes to be defined and approved by all stakeholders, before a single line of code has been written.
In my experience that is almost impossible to acheive. I think only one project I've worked on had defined goals and outcomes before the code was written that did not subsequently change and that was a very short contract making a small addition to an existing system.
"No plan survives contact with the enemy" is as true today as it was in 19th century Prussia.