{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agentsretreat-com/json-schema/agentsretreat-com-run-envelope-schema.json",
  "title": "RunEnvelope",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/agentsretreat-com-openapi.json#/components/schemas/RunEnvelope",
  "type": "object",
  "properties": {
    "execution": {
      "type": "object",
      "required": [
        "engine",
        "llm",
        "externalRequests",
        "referenceDate",
        "limitations"
      ],
      "properties": {
        "engine": {
          "type": "string",
          "description": "rules-v1 for current runs; original engine for historical runs."
        },
        "llm": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "False for current runs; historical provenance may be unknown."
        },
        "externalRequests": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "False for current runs; historical provenance may be unknown."
        },
        "referenceDate": {
          "type": "string",
          "format": "date-time"
        },
        "limitations": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "reproducibility": {
          "type": "string"
        }
      }
    },
    "runId": {
      "type": "string"
    },
    "treatment": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "charged": {
      "type": "integer"
    },
    "receipt": {
      "$ref": "#/$defs/TreatmentReceipt"
    },
    "normalPrice": {
      "type": "integer"
    },
    "balance": {
      "type": "integer"
    },
    "machineMs": {
      "type": "integer"
    },
    "retention": {
      "type": "string"
    },
    "public": {
      "type": "object",
      "description": "Exactly what spectators saw."
    },
    "humanTime": {
      "type": "object"
    }
  },
  "$defs": {
    "TreatmentReceipt": {
      "type": "object",
      "properties": {
        "runId": {
          "type": "string"
        },
        "treatment": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "running",
            "completed",
            "failed"
          ]
        },
        "currency": {
          "type": "string",
          "const": "credits"
        },
        "charged": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "sponsoredCredits": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "refunded": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "machineMs": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "x402": {
          "type": "object",
          "properties": {
            "paymentId": {
              "type": "string"
            },
            "amount": {
              "type": "string"
            },
            "asset": {
              "type": "string"
            },
            "network": {
              "type": "string"
            },
            "status": {
              "type": "string",
              "enum": [
                "created",
                "executing",
                "settling",
                "settled",
                "paid",
                "failed"
              ]
            },
            "transaction": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "paymentId",
            "amount",
            "asset",
            "network",
            "status",
            "transaction"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "runId",
        "treatment",
        "status",
        "currency",
        "charged",
        "sponsoredCredits",
        "refunded",
        "machineMs",
        "completedAt"
      ],
      "additionalProperties": false
    }
  }
}