First we assume that our program needs to solve a well defined mathematical problem. Then we realise that that has nothing to do with any relevant programming problem.
This sounds similar to the process used for some parts of Cardano. Duncan Coutts talked about this in this video:
What you program it's top down. So every level of the stack effects everything below. Interestingly things below can also hotpatch things above as needed by developers. Simply ship the patch upstream or monkey patch it yourself and publish the github repo with your patch.