Algeria clamps down on jihadis successfully (and won a long bloody war that was at a high level in the 1990s against them):
Algeria can afford to be unpredictable because they have oil and natural gas resources which are well managed (by African standards) and a military which is considered one of the most effective in Africa. Algeria spends 6.2 percent of GDP on defense and that has paid off because Islamic terrorists tend to avoid Algeria because it is a hostile and dangerous place for Islamic terrorists. The government does not send troops outside the country (for peacekeeping or whatever) and concentrates on keeping Algeria safe. That makes the security forces popular within the country and not likely to back a coup. But the military does support the corrupt and often inept government that has opposed foreign investment and free elections for half a century. If that does not change Algeria will, and not for the better.
Oil helps fund this. But with Algeria's government offering no choice but accepting their own autocratic rule or joining jihadis, the government makes sure that the alternative to the autocracy when it finally falters is Islamist government.
Which is bad, too. Which is why I don't dismiss the potential of the 2011 Arab Spring (despite the failure overall) that finally proposed democracy (and that must include rule of law to avoid being tyranny of the majority) as an alternative to the traditional choice given to Arabs of living under autocracy or mullah rule.
And Algeria's strategy also puts them in bed with bad actors despite hostility to Sunni jihadis:
Algeria is considered the most pro-Iran country in North Africa and has always supported the Assad government in Syria.
And low oil prices because of fracking is putting Algeria's strategy of paying for their autocracy under stress.
If the stress is fatal, who takes over?
Is democracy and rule of law really a bad alternative to counting on governments like Algeria's always winning?