notifyKbcPatchReady method
Reset the rollback boot-counter — call this from the host's first-frame callback (or any "the app survived initial render" signal). Without this call, a bad patch will crash-loop the app until kKbcCrashThreshold quick-crash boots (each within kKbcCrashWindow of the previous), then auto-disable itself.
Typical wiring:
WidgetsBinding.instance.addPostFrameCallback((_) {
Sankofa.instance.deploy?.notifyKbcPatchReady();
});
Idempotent — calling twice in one boot is harmless. Returns the boot count that was reset, mostly useful for telemetry / tests.
Side effect: PROMOTES the currently-active patch to the last_good slot. This is the moment we declare "this patch worked" — every subsequent auto-rollback can restore from this slot instead of dropping the user all the way back to baseline.
Implementation
Future<int> notifyKbcPatchReady() async {
// Cancel the auto-confirm safety-net timer if it's armed — the
// host has explicitly told us the patch is healthy, so we don't
// need the 10s fallback to do it for us.
_autoConfirmTimer?.cancel();
_autoConfirmTimer = null;
final prefs = await SharedPreferences.getInstance();
final priorCrashCount = prefs.getInt(_kbcCrashCountKey) ?? 0;
await _confirmHealthInternal(prefs: prefs);
return priorCrashCount;
}