let rec simplify (t: t) =
match t with
| `Building _
| `Tried_to_start _
| `Started_running _
| `Starting _
| `Still_building _
| `Still_running _
| `Still_running_despite_recoverable_error _
| `Ran_successfully _
| `Successfully_did_nothing _
| `Tried_to_eval_condition _
| `Tried_to_reeval_condition _
| `Active _ -> `In_progress
| `Verified_success _
| `Already_done _ -> `Successful
| `Dependencies_failed _
| `Failed_running _
| `Failed_to_kill _
| `Failed_to_start _
| `Failed_to_eval_condition _
| `Killing _
| `Tried_to_kill _
| `Did_not_ensure_condition _
| `Killed _ -> `Failed
| `Finished s ->
simplify (s.previous_state :> t)
| `Passive _ -> `Activable