{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/HansBug/pyfcstm/blob/main/docs/source/reference/bmc_results/bmc_cli_v1.schema.json",
  "title": "PyFCSTM BMC CLI result",
  "description": "Stable bmc-cli/v1 envelope emitted by pyfcstm bmc --json.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "input", "property", "result", "witness", "replay", "exit_code"],
  "properties": {
    "schema_version": {"const": "bmc-cli/v1"},
    "input": {"$ref": "#/$defs/input"},
    "property": {"$ref": "#/$defs/property"},
    "result": {"$ref": "#/$defs/result"},
    "witness": {"oneOf": [{"type": "null"}, {"$ref": "#/$defs/witness"}]},
    "replay": {"oneOf": [{"type": "null"}, {"$ref": "#/$defs/replay"}]},
    "exit_code": {"enum": [0, 1, 3, 4]}
  },
  "$defs": {
    "jsonValue": {
      "oneOf": [
        {"type": "null"},
        {"type": "boolean"},
        {"type": "number"},
        {"type": "string"},
        {"type": "array", "items": {"$ref": "#/$defs/jsonValue"}},
        {"type": "object", "additionalProperties": {"$ref": "#/$defs/jsonValue"}}
      ]
    },
    "stringMap": {
      "type": "object",
      "additionalProperties": {"$ref": "#/$defs/jsonValue"}
    },
    "nullableString": {"type": ["string", "null"]},
    "nullableInteger": {"type": ["integer", "null"]},
    "input": {
      "type": "object",
      "additionalProperties": false,
      "required": ["model_path", "query_path"],
      "properties": {
        "model_path": {"type": "string"},
        "query_path": {"type": "string"}
      }
    },
    "property": {
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "polarity", "bound", "case_label", "response_window"],
      "properties": {
        "kind": {"enum": ["reach", "forbid", "invariant", "must_reach", "exists_always", "response", "cover"]},
        "polarity": {"enum": ["witness", "counterexample"]},
        "bound": {"type": "integer", "minimum": 1},
        "case_label": {"$ref": "#/$defs/nullableString"},
        "response_window": {"$ref": "#/$defs/nullableInteger"}
      }
    },
    "result": {
      "type": "object",
      "additionalProperties": false,
      "required": ["node", "kind", "polarity", "status", "property_satisfied", "witness_found", "counterexample_found", "incomplete", "outcome", "reason", "elapsed_ms", "timeout_ms", "has_model", "incomplete_status", "incomplete_reason", "has_incomplete_model", "diagnostics"],
      "properties": {
        "node": {"const": "bmc_solve_result"},
        "kind": {"enum": ["reach", "forbid", "invariant", "must_reach", "exists_always", "response", "cover"]},
        "polarity": {"enum": ["witness", "counterexample"]},
        "status": {"enum": ["sat", "unsat", "unknown", "timeout"]},
        "property_satisfied": {"type": ["boolean", "null"]},
        "witness_found": {"type": "boolean"},
        "counterexample_found": {"type": "boolean"},
        "incomplete": {"type": "boolean"},
        "outcome": {"enum": ["property_satisfied", "property_violated", "witness_found", "no_witness", "incomplete", "timeout", "unknown"]},
        "reason": {"$ref": "#/$defs/nullableString"},
        "elapsed_ms": {"type": "number", "minimum": 0},
        "timeout_ms": {"$ref": "#/$defs/nullableInteger"},
        "has_model": {"type": "boolean"},
        "incomplete_status": {"enum": ["sat", "unsat", "unknown", "timeout", null]},
        "incomplete_reason": {"$ref": "#/$defs/nullableString"},
        "has_incomplete_model": {"type": "boolean"},
        "diagnostics": {"type": "array", "items": {"type": "string"}}
      }
    },
    "event": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "reason", "model_value"],
      "properties": {
        "path": {"type": "string"},
        "reason": {"type": "string"},
        "model_value": {"type": "boolean"}
      }
    },
    "call": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ordinal", "action_name", "stage", "role", "state", "active_leaf", "named_ref", "snapshot"],
      "properties": {
        "ordinal": {"type": "integer", "minimum": 0},
        "action_name": {"type": "string"},
        "stage": {"type": "string"},
        "role": {"type": "string"},
        "state": {"type": "string"},
        "active_leaf": {"type": "string"},
        "named_ref": {"$ref": "#/$defs/nullableString"},
        "snapshot": {"$ref": "#/$defs/stringMap"}
      }
    },
    "witnessFrame": {
      "type": "object",
      "additionalProperties": false,
      "required": ["index", "state_id", "state", "sentinel", "terminated", "vars"],
      "properties": {
        "index": {"type": "integer", "minimum": 0},
        "state_id": {"$ref": "#/$defs/nullableInteger"},
        "state": {"$ref": "#/$defs/nullableString"},
        "sentinel": {"enum": ["init", "terminated", null]},
        "terminated": {"type": "boolean"},
        "vars": {"$ref": "#/$defs/stringMap"}
      }
    },
    "witnessStep": {
      "type": "object",
      "additionalProperties": false,
      "required": ["index", "source_frame", "target_frame", "case_label", "case_kind", "progress", "source_state", "target_state", "delta", "gamma", "input_events", "event_reads", "abstract_calls", "consumed_events", "unconsumed_events"],
      "properties": {
        "index": {"type": "integer", "minimum": 0},
        "source_frame": {"type": "integer", "minimum": 0},
        "target_frame": {"type": "integer", "minimum": 0},
        "case_label": {"type": "string"},
        "case_kind": {"type": "string"},
        "progress": {"type": "string"},
        "source_state": {"$ref": "#/$defs/nullableString"},
        "target_state": {"$ref": "#/$defs/nullableString"},
        "delta": {"type": "boolean"},
        "gamma": {"type": "boolean"},
        "input_events": {"type": "array", "items": {"$ref": "#/$defs/event"}},
        "event_reads": {"type": "array", "items": {"$ref": "#/$defs/event"}},
        "abstract_calls": {"type": "array", "items": {"$ref": "#/$defs/call"}},
        "consumed_events": {"type": "array", "items": {"type": "string"}},
        "unconsumed_events": {"type": "array", "items": {"type": "string"}}
      }
    },
    "witness": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schema_version", "property", "solver", "initial", "frames", "steps", "diagnostics"],
      "properties": {
        "schema_version": {"const": "bmc-witness/v1"},
        "property": {"$ref": "#/$defs/property"},
        "solver": {
          "type": "object",
          "additionalProperties": false,
          "required": ["status", "reason", "incomplete_status"],
          "properties": {
            "status": {"const": "sat"},
            "reason": {"$ref": "#/$defs/nullableString"},
            "incomplete_status": {"enum": ["sat", "unsat", "unknown", "timeout", null]}
          }
        },
        "initial": {
          "type": "object",
          "additionalProperties": false,
          "required": ["mode", "state", "sentinel", "vars"],
          "properties": {
            "mode": {"type": "string"},
            "state": {"$ref": "#/$defs/nullableString"},
            "sentinel": {"enum": ["init", "terminated", null]},
            "vars": {"$ref": "#/$defs/stringMap"}
          }
        },
        "frames": {"type": "array", "items": {"$ref": "#/$defs/witnessFrame"}},
        "steps": {"type": "array", "items": {"$ref": "#/$defs/witnessStep"}},
        "diagnostics": {"type": "array", "items": {"type": "string"}}
      }
    },
    "runtimeFrame": {
      "type": "object",
      "additionalProperties": false,
      "required": ["index", "state", "terminated", "vars"],
      "properties": {
        "index": {"type": "integer", "minimum": 0},
        "state": {"$ref": "#/$defs/nullableString"},
        "terminated": {"type": "boolean"},
        "vars": {"$ref": "#/$defs/stringMap"}
      }
    },
    "runtimeStep": {
      "type": "object",
      "additionalProperties": false,
      "required": ["index", "input_events", "consumed_events", "unconsumed_events", "abstract_calls"],
      "properties": {
        "index": {"type": "integer", "minimum": 0},
        "input_events": {"type": "array", "items": {"type": "string"}},
        "consumed_events": {"type": "array", "items": {"type": "string"}},
        "unconsumed_events": {"type": "array", "items": {"type": "string"}},
        "abstract_calls": {"type": "array", "items": {"$ref": "#/$defs/call"}}
      }
    },
    "mismatch": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "expected", "actual", "message", "tolerance"],
      "properties": {
        "path": {"type": "string"},
        "expected": {"$ref": "#/$defs/jsonValue"},
        "actual": {"$ref": "#/$defs/jsonValue"},
        "message": {"type": "string"},
        "tolerance": {"type": ["number", "null"], "minimum": 0}
      }
    },
    "replay": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ok", "runtime_trace", "mismatches"],
      "properties": {
        "ok": {"type": "boolean"},
        "runtime_trace": {
          "type": "object",
          "additionalProperties": false,
          "required": ["frames", "steps"],
          "properties": {
            "frames": {"type": "array", "items": {"$ref": "#/$defs/runtimeFrame"}},
            "steps": {"type": "array", "items": {"$ref": "#/$defs/runtimeStep"}}
          }
        },
        "mismatches": {"type": "array", "items": {"$ref": "#/$defs/mismatch"}}
      }
    }
  }
}
