There was a NASA project to start developing flight software that's smarter in this kind of way, the Remote Agent. It got an award after flying, but if they continued that line of research I haven't heard about it. https://ntrs.nasa.gov/api/citations/20000116204/downloads/20...