I can reproduce this (but it takes over ten hours to run the autogame from the beginning to the point where it fails)
It's likely that the senate is blocking the treaty cancellation. I see 3 potential reasons for that (3 different bugs?). The code block above the failing one is supposed to cause revolution in case senate of the current government would try to block the action. That's just assumed to success, but it can fail at least if the revolentype prevents a new revolution on the same turn previous one finished. Also, in master the government change is not instantaneous, but will only happen on turn change.
Then there's a chance that in order to go to war, multiple levels of treaties would need to be cancelled. That's known to be buggy, even by FIXME comment in handle_diplomacy_cancel_pact(). It's possible that senate is not supposed to block the action (and thus we didn't revolt) because "has_reason_to_cancel". However, as each step of the pact cancellations is handled separately, the "has_reason_to_cancel" is no longer TRUE when one treaty has already been cancelled, and then senate blocks the second step.
None of those three identified potential causes seem to apply in that autogame.
Hmm yes I have seen this bug with my patches but I can't see any connection with what I have done...
Seem like the root cause is that in sandbox ruleset, United Nations + Manhattan Project gives senate even to Anarchy. AI succesfully entered Anarchy, but still the senate blocks going to war.
Reply To cazfi
Seem like the root cause is that in sandbox ruleset, United Nations + Manhattan Project gives senate even to Anarchy. AI succesfully entered Anarchy, but still the senate blocks going to war.
Likely, it's so not only in sandbox? And we are to fix it within AI code, since it probably should be possible to disable war for revolting nations?
Reply To ihnatus
And we are to fix it within AI code, since it probably should be possible to disable war for revolting nations?
Yea, I have a minor modification in test in that setup where the issue has been reproducible.
There's a couple of "Wanted to cancel treaty but was unable to." messages I've not seen before in S3_1 autogame set run (still in progress) log. Those are from running with the sandbox ruleset.
The codebase on this run was not from any exact git repo revision, but it has a couple of "future" patches in testing.
I'll try to reproduce that.