Set in a distant future, every interstellar spaceship runs on antimatter propulsion which can achieve fractional speed of light travel. There is a doctrine stating that all spaceships with mass exceeding certain amount are required by law to install self-destruct button and concealed explosive charges throughout the entire vessel. The ship's powerful AI ensures everything is in order and eliminates any human error especially at times of crisis, the AI is aware of the self-destruct mechanism and schedules routine check and maintenance for every explosive charges on board. I'm wondering how can we prevent AI from initiating the self destruct and set off the explosive charges that even the crews are not aware of their exact location? Sabotaging the antimatter containment unit as alternative mode of triggering self destruct is prohibited and the AI is required to monitor the condition of all explosive charges and update the captain or who-ever in-charge.
Physical separation of monitoring and detonation circuits.
Assume your AI can take total control of everything it’s connected to. Because if it’s smart enough: it can. Therefore the only way to make sure it can’t detonate the bombs is to make sure it isn’t connected to them.
So give it all the sensor input it needs to monitor the bombs. This can be visual (to check for visible breakdown), chemical (to check for degrading explosives), even electrical (dumb multi-meters etc).
But make the firing circuit a separate dumb circuit. The simpler the better (both for security and dumb human performed maintenance). Unless the AI can manipulate a human into pushing the button or use some self-repair mechanisms to alter the circuit you’re golden.
If the AI can use repair drones etc to manipulate things then I’m sorry. You can’t prevent this. Notably because the AI could just build itself a bomb if it wanted. You could install further AI’s to try prevent such systems being co-opted, but then you end up with full scale cyberwars that your humans can’t control. And if those AI’s can be convinced the suicidal AI is justified then you’re in a worse place than you were before.
To add to Joe Bloggs answer: a separate detonation circuit unconnected to the AI is a must.
As for the workings, you could have human preservation protocols. The self destruct cannot activate unless the signal comes from outside of the ship. The captain will have a portable detonator that won't activate unless it is X amount of distance from the ship. This ensures (ish) the captains survival in case of self destruct. If the ship needs destroying including its crew, the captain at least will need to leave in an escape pod to do so. One for this specific reason could be installed on the bridge. This would prevent both human error (to a degree) and the AI activating it.