{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://outcomatic.com/v2/schema.json",
  "title": "Synthetic business outcome record",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "dataset_version",
    "scenario_id",
    "scenario_sha256",
    "process_id",
    "process",
    "domain",
    "split",
    "condition",
    "context",
    "actions",
    "result",
    "evidence",
    "provenance",
    "verification"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^bwo-[a-z0-9_-]+-[0-9]{5}$"
    },
    "dataset_version": {
      "type": "string"
    },
    "scenario_id": {
      "type": "string"
    },
    "scenario_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "process_id": {
      "type": "string"
    },
    "process": {
      "type": "string"
    },
    "domain": {
      "type": "string"
    },
    "split": {
      "enum": [
        "train",
        "validation",
        "evaluation"
      ]
    },
    "condition": {
      "enum": [
        "standard",
        "boundary",
        "missing_evidence",
        "policy_exception",
        "duplicate",
        "external_failure"
      ]
    },
    "context": {
      "type": "object",
      "required": [
        "industry",
        "organization_size",
        "entity",
        "task",
        "scope",
        "initial_state",
        "facts",
        "inputs",
        "policy"
      ],
      "properties": {
        "industry": {
          "type": "string"
        },
        "organization_size": {
          "enum": [
            "small",
            "mid_market",
            "enterprise"
          ]
        },
        "entity": {
          "type": "string"
        },
        "task": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        },
        "initial_state": {
          "type": "object"
        },
        "facts": {
          "type": "object"
        },
        "inputs": {
          "type": "object"
        },
        "policy": {
          "type": "object"
        }
      }
    },
    "episode": {
      "type": "object",
      "required": [
        "workflow",
        "total_steps",
        "steps",
        "unattempted_steps"
      ],
      "properties": {
        "workflow": {
          "type": "string"
        },
        "total_steps": {
          "type": "integer"
        },
        "steps": {
          "type": "array"
        },
        "unattempted_steps": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "actions": {
      "type": "array",
      "minItems": 3,
      "items": {
        "type": "object",
        "required": [
          "sequence",
          "action"
        ],
        "properties": {
          "sequence": {
            "type": "integer",
            "minimum": 1
          },
          "action": {
            "type": "string"
          }
        }
      }
    },
    "result": {
      "type": "object",
      "required": [
        "status",
        "computed_value",
        "final_state"
      ],
      "properties": {
        "status": {
          "enum": [
            "completed",
            "blocked",
            "escalated",
            "duplicate_prevented",
            "failed"
          ]
        },
        "computed_value": {
          "type": [
            "number",
            "array",
            "null"
          ]
        },
        "final_state": {
          "type": "object",
          "required": [
            "status",
            "applied_count"
          ],
          "properties": {
            "status": {
              "type": "string"
            },
            "applied_count": {
              "enum": [
                0,
                1
              ]
            }
          }
        }
      }
    },
    "evidence": {
      "type": "array",
      "minItems": 2,
      "items": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "values"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "values": {
            "type": "object"
          }
        }
      }
    },
    "provenance": {
      "type": "object",
      "required": [
        "kind",
        "generator_version",
        "source_kind",
        "source_urls",
        "contains_customer_data",
        "execution",
        "human_review"
      ],
      "properties": {
        "kind": {
          "const": "synthetic"
        },
        "generator_version": {
          "type": "string"
        },
        "source_kind": {
          "enum": [
            "process_documentation",
            "catalog_taxonomy"
          ]
        },
        "source_urls": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^https://"
          }
        },
        "contains_customer_data": {
          "const": false
        },
        "execution": {
          "const": "deterministic_policy_model"
        },
        "human_review": {
          "enum": [
            "pending_scenario_review",
            "expert_approved_scenario"
          ]
        },
        "scenario_review_id": {
          "type": "string"
        }
      }
    },
    "verification": {
      "type": "object",
      "required": [
        "passed",
        "checks",
        "failures",
        "method",
        "human_verified"
      ],
      "properties": {
        "passed": {
          "const": true
        },
        "checks": {
          "type": "object",
          "minProperties": 9,
          "additionalProperties": {
            "const": true
          }
        },
        "failures": {
          "type": "array",
          "maxItems": 0
        },
        "method": {
          "const": "independent_deterministic_policy_evaluation"
        },
        "human_verified": {
          "const": false
        },
        "scenario_expert_approved": {
          "type": "boolean"
        }
      }
    }
  }
}
