Order lifecycle safety

Input

{
  "initial": {
    "phase": "new"
  },
  "invariants": [
    {
      "expr": {
        "op": "in",
        "values": [
          "new",
          "paid",
          "shipped",
          "cancelled"
        ],
        "var": "phase"
      },
      "name": "valid_phase"
    }
  ],
  "reachability": [
    {
      "expr": {
        "op": "eq",
        "value": "shipped",
        "var": "phase"
      },
      "name": "settled"
    }
  ],
  "terminal_condition": {
    "op": "in",
    "values": [
      "shipped",
      "cancelled"
    ],
    "var": "phase"
  },
  "transitions": [
    {
      "guard": {
        "op": "eq",
        "value": "new",
        "var": "phase"
      },
      "name": "pay",
      "updates": {
        "phase": {
          "op": "const",
          "value": "paid"
        }
      }
    },
    {
      "guard": {
        "op": "eq",
        "value": "new",
        "var": "phase"
      },
      "name": "cancel",
      "updates": {
        "phase": {
          "op": "const",
          "value": "cancelled"
        }
      }
    },
    {
      "guard": {
        "op": "eq",
        "value": "paid",
        "var": "phase"
      },
      "name": "ship",
      "updates": {
        "phase": {
          "op": "const",
          "value": "shipped"
        }
      }
    },
    {
      "guard": {
        "op": "eq",
        "value": "paid",
        "var": "phase"
      },
      "name": "retry_payment",
      "updates": {
        "phase": {
          "op": "const",
          "value": "paid"
        }
      }
    },
    {
      "guard": {
        "args": [
          {
            "op": "eq",
            "value": "new",
            "var": "phase"
          },
          {
            "op": "eq",
            "value": "shipped",
            "var": "phase"
          }
        ],
        "op": "and"
      },
      "name": "cancel_after_ship",
      "updates": {}
    }
  ],
  "variables": [
    {
      "name": "phase",
      "type": "enum",
      "values": [
        "new",
        "paid",
        "shipped",
        "cancelled"
      ]
    }
  ]
}

Output

Build-time verified. stats.elapsed_ms normalized to 0.

{
  "deadlock": {
    "found": false,
    "trace": null
  },
  "domain_violations": [],
  "exhaustive": true,
  "invariant_violations": [],
  "livelock": {
    "found": false,
    "loop_start": null,
    "trace": null
  },
  "reachability": [
    {
      "goal": "settled",
      "reachable": true,
      "trace": [
        {
          "state": {
            "phase": "new"
          },
          "step": 0,
          "transition": null
        },
        {
          "state": {
            "phase": "paid"
          },
          "step": 1,
          "transition": "pay"
        },
        {
          "state": {
            "phase": "shipped"
          },
          "step": 2,
          "transition": "ship"
        }
      ]
    }
  ],
  "states_explored": 4,
  "stats": {
    "elapsed_ms": 0,
    "timed_out": false
  },
  "status": "verified_safe",
  "transitions_fired": 4,
  "unreachable_transitions": [
    "cancel_after_ship"
  ],
  "verified": true
}

Request

curl --fail-with-body --silent --show-error https://oracles.burgeonads.com/v1/verify/state-machine -H 'Content-Type: application/json' --data-raw '{"variables":[{"name":"phase","type":"enum","values":["new","paid","shipped","cancelled"]}],"initial":{"phase":"new"},"transitions":[{"name":"pay","guard":{"op":"eq","var":"phase","value":"new"},"updates":{"phase":{"op":"const","value":"paid"}}},{"name":"cancel","guard":{"op":"eq","var":"phase","value":"new"},"updates":{"phase":{"op":"const","value":"cancelled"}}},{"name":"ship","guard":{"op":"eq","var":"phase","value":"paid"},"updates":{"phase":{"op":"const","value":"shipped"}}},{"name":"retry_payment","guard":{"op":"eq","var":"phase","value":"paid"},"updates":{"phase":{"op":"const","value":"paid"}}},{"name":"cancel_after_ship","guard":{"op":"and","args":[{"op":"eq","var":"phase","value":"new"},{"op":"eq","var":"phase","value":"shipped"}]},"updates":{}}],"invariants":[{"name":"valid_phase","expr":{"op":"in","var":"phase","values":["new","paid","shipped","cancelled"]}}],"terminal_condition":{"op":"in","var":"phase","values":["shipped","cancelled"]},"reachability":[{"name":"settled","expr":{"op":"eq","var":"phase","value":"shipped"}}]}'