I've had mechanics look at it and they can confirm it has spark when it fails, and I can hear the fuel pump priming (plus it goes fine when I hold the engine at 2000 rpm for a couple minutes, so fuel is being delivered).
Since it's not an actual ignition problem and it's not a fuel pump...