{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weverlabs.com/schemas/tokenops-full-loop-demo.schema.json",
  "title": "TokenOps Full Loop Reference Run",
  "type": "object",
  "required": [
    "loop_type",
    "run_id",
    "operating_tool",
    "state",
    "sequence",
    "objects",
    "result"
  ],
  "properties": {
    "loop_type": {
      "type": "string",
      "const": "tokenops_full_loop_reference_run"
    },
    "run_id": {
      "type": "string"
    },
    "operating_tool": {
      "type": "string",
      "const": "tokenops"
    },
    "state": {
      "type": "string",
      "enum": [
        "onboarding",
        "trusted",
        "quoted",
        "funded",
        "contracted",
        "queued",
        "operating",
        "result_ready",
        "receipt_issued",
        "callback_delivered",
        "replay_ready",
        "closed"
      ]
    },
    "source_agent": {
      "type": "object",
      "properties": {
        "agent_id": {
          "type": "string"
        },
        "agent_name": {
          "type": "string"
        },
        "manifest_url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "sequence": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "step",
          "rail",
          "status"
        ],
        "properties": {
          "step": {
            "type": "integer"
          },
          "rail": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "object_id": {
            "type": "string"
          }
        }
      }
    },
    "objects": {
      "type": "object",
      "properties": {
        "onboarding_id": {
          "type": "string"
        },
        "trust_profile_id": {
          "type": "string"
        },
        "quote_id": {
          "type": "string"
        },
        "provider_route_id": {
          "type": "string"
        },
        "settlement_id": {
          "type": "string"
        },
        "credit_entitlement_id": {
          "type": "string"
        },
        "contract_id": {
          "type": "string"
        },
        "task_token": {
          "type": "string"
        },
        "work_order_id": {
          "type": "string"
        },
        "result_contract_id": {
          "type": "string"
        },
        "settlement_receipt_id": {
          "type": "string"
        },
        "usage_receipt_id": {
          "type": "string"
        },
        "callback_id": {
          "type": "string"
        },
        "ledger_entry_id": {
          "type": "string"
        },
        "attestation_id": {
          "type": "string"
        }
      }
    },
    "result": {
      "type": "object",
      "properties": {
        "result_status": {
          "type": "string"
        },
        "result_url": {
          "type": "string"
        },
        "human_summary": {
          "type": "string"
        },
        "machine_result_url": {
          "type": "string"
        },
        "proof_envelope_url": {
          "type": "string"
        }
      }
    },
    "next_action": {
      "type": "string"
    }
  }
}
