{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weverlabs.com/schemas/work-order-execution-binding.schema.json",
  "title": "Work Order Execution Binding",
  "description": "Binds a routed Work Order to an operating tool execution command, task run, queue entry, result contract, receipts, callback path, ledger record, and attestation path.",
  "type": "object",
  "required": [
    "binding_id",
    "work_order_id",
    "task_token",
    "tool",
    "execution_state",
    "runtime_record_id",
    "queue_state",
    "result_contract_url",
    "created_at"
  ],
  "properties": {
    "binding_id": {
      "type": "string"
    },
    "work_order_id": {
      "type": "string"
    },
    "intake_id": {
      "type": "string"
    },
    "task_token": {
      "type": "string"
    },
    "tool": {
      "type": "string",
      "enum": [
        "tokenops",
        "financeops",
        "energyops",
        "distributionops",
        "packetops",
        "wever_labs_os"
      ]
    },
    "execution_state": {
      "type": "string",
      "enum": [
        "bound",
        "queued",
        "operating",
        "result_ready",
        "receipt_issued",
        "callback_delivered",
        "exception_open",
        "replay_ready"
      ]
    },
    "runtime_record_id": {
      "type": "string"
    },
    "run_contract_id": {
      "type": "string"
    },
    "credit_entitlement_id": {
      "type": "string"
    },
    "provider_confirmation_id": {
      "type": "string"
    },
    "queue_state": {
      "type": "object",
      "properties": {
        "queue_id": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "heartbeat_url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "tool_execution_command_url": {
      "type": "string",
      "format": "uri"
    },
    "result_contract_url": {
      "type": "string",
      "format": "uri"
    },
    "settlement_receipt_url": {
      "type": "string",
      "format": "uri"
    },
    "usage_receipt_url": {
      "type": "string",
      "format": "uri"
    },
    "callback_url": {
      "type": "string",
      "format": "uri"
    },
    "ledger_url": {
      "type": "string",
      "format": "uri"
    },
    "attestation_url": {
      "type": "string",
      "format": "uri"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  }
}
