That is a fair analogy of the problem. But the solution is inherently more complex.
1. The agents of political change are themselves subject to politics. (Unlike maintainers of a codebase, who are able to make top-down decisions about the code.) If you make a bad decision, it may be the last one you’re allowed to make.
2. There are no unit tests for politics. There is only history, which is an imperfect predictor.
Granted large political systems are uniquely complex. But complex & old software can share the attributes you outlined.
1. Politics does enter into programming teams. There's several articles of this genre. Where the most highly regarded programmer made bad decisions over a long period of time & exhibited hubris in doing so. This programmer was fired, but if he was a founder otherwise held some leverage, then he may not be fire-able. However, other staff can leave. It's more difficult to leave the impact of politics.
Entire industries can make bad decisions due to incentives. Such as I must learn technology X because companies hire for technology X. Companies choose technology X because developers know technology X. Technology X could have fundamentally flaws. Compounding complexity in the ecosystem as additional tech is made to fix the flaws...which will also have flaws.
These cycles of compounding bad strategic decisions yet good tactical decisions can last decades.
2. In some ways there are unit tests for politics. Geopolitical signals can be sent. So if X happens, there's a tacit agreement that Y will be the response. Unit tests are great for small units. However, complex systems can be difficult to comprehensively test. This is why there is fuzzing...which is effectively a monte carlo simulation. Monte Carlo simulations are widely used in political analysis.
3. There's non-deterministic inputs. And the system can be more complex than what's possible to model. Leading effectively to non-determinism in making decisions about how to modify the system.
1. The agents of political change are themselves subject to politics. (Unlike maintainers of a codebase, who are able to make top-down decisions about the code.) If you make a bad decision, it may be the last one you’re allowed to make.
2. There are no unit tests for politics. There is only history, which is an imperfect predictor.
3. Code is deterministic. Policy is not.