{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mail.hsimc.tech/schemas/parallel-dispatch-plan.schema.json",
  "title": "HSIMC Parallel Mail Dispatch Plan",
  "type": "object",
  "required": [
    "dispatch_id",
    "mail_reality_ref",
    "work_ref",
    "branches",
    "fan_in_policy",
    "state"
  ],
  "properties": {
    "dispatch_id": {
      "type": "string"
    },
    "mail_reality_ref": {
      "type": "string"
    },
    "work_ref": {
      "type": "string"
    },
    "branches": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "branch_id",
          "capability_address_ref",
          "dependencies",
          "resource_locks",
          "authority_state",
          "execution_state"
        ],
        "properties": {
          "branch_id": {
            "type": "string"
          },
          "capability_address_ref": {
            "type": "string"
          },
          "dependencies": {
            "type": "array"
          },
          "resource_locks": {
            "type": "array"
          },
          "authority_state": {
            "enum": [
              "UNRESOLVED",
              "ALLOWED",
              "DENIED",
              "HUMAN_REVIEW_REQUIRED"
            ]
          },
          "capability_state": {
            "type": "string"
          },
          "supervisor_state": {
            "type": "string"
          },
          "execution_state": {
            "enum": [
              "NOT_STARTED",
              "ELIGIBLE_PARALLEL",
              "BLOCKED",
              "RUNNING",
              "EVIDENCE_RETURNED",
              "FAILED",
              "CANCELLED"
            ]
          },
          "evidence_refs": {
            "type": "array"
          }
        }
      }
    },
    "fan_in_policy": {
      "enum": [
        "ALL_REQUIRED",
        "QUORUM",
        "FIRST_VALID_WITH_REVIEW",
        "WORK_POLICY_DEFINED"
      ]
    },
    "idempotency_key": {
      "type": "string"
    },
    "loop_guard_ref": {
      "type": "string"
    },
    "state": {
      "type": "string"
    }
  }
}
