This logic shouldn't live in `maybe-upgrade`, it should be branched out into a new part of the macro engine that runs after build orders are completed. This would eventually be a whole complicated system, but for now you could just add a simple function to `run-macro-engine` that tries to build an engineering bay if one does not exist *and* is not currently contracted. You'll also need to patch `contracts.clj` to easily answer that second part.