{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/amplerun-com/json-schema/amplerun-com-job-schema.json",
  "title": "Job",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amplerun-com-openapi.json#/components/schemas/Job",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "job_id",
    "state",
    "cumulative_charge_micro",
    "funded_through",
    "budget_version"
  ],
  "properties": {
    "job_id": {
      "$ref": "#/$defs/UUID"
    },
    "state": {
      "enum": [
        "RESERVED",
        "STARTING",
        "RUNNING",
        "STOPPING",
        "STOPPED",
        "CLEANING",
        "CLOSED",
        "FAILED",
        "RECONCILING"
      ]
    },
    "cumulative_charge_micro": {
      "$ref": "#/$defs/MicroAmount"
    },
    "funded_through": {
      "$ref": "#/$defs/Rfc3339Utc"
    },
    "budget_version": {
      "$ref": "#/$defs/DecimalString"
    },
    "machine_id": {
      "$ref": "#/$defs/UUID"
    },
    "fence": {
      "$ref": "#/$defs/DecimalString"
    },
    "rate_micro_per_hour": {
      "description": "Additive. The rate agreed at reservation, read from the job's quote snapshot (quotes.machine_rate_micro_per_hour). Evidence only: never recomputed from current offers, never an input to billing or state.",
      "allOf": [
        {
          "$ref": "#/$defs/MicroAmount"
        }
      ]
    },
    "accepted_runtime_ms": {
      "description": "Additive. Control-owned accepted-runtime accumulator; 0 before any accepted receipt.",
      "allOf": [
        {
          "$ref": "#/$defs/DecimalString"
        }
      ]
    },
    "meter_started_at": {
      "description": "Additive. When the meter actually started (verified READY), not when the job was reserved. null means \"not yet measured\" — distinct from zero.",
      "oneOf": [
        {
          "$ref": "#/$defs/Rfc3339Utc"
        },
        {
          "type": "null"
        }
      ]
    },
    "last_meter_receipt_at": {
      "description": "Additive. Observation time (wall_time) of the most recent ACCEPTED meter receipt. null when no receipt has been accepted yet — a RUNNING job with meter_started_at set may still have this null.",
      "oneOf": [
        {
          "$ref": "#/$defs/Rfc3339Utc"
        },
        {
          "type": "null"
        }
      ]
    },
    "stopped_at": {
      "description": "Additive. When the machine confirmed the stop (jobs.stopped_at). Set once the job reaches STOPPED; null before, and null when no stop was confirmed. Display only.",
      "oneOf": [
        {
          "$ref": "#/$defs/Rfc3339Utc"
        },
        {
          "type": "null"
        }
      ]
    },
    "tier": {
      "description": "Additive (D-23). The machine's tier; inference is community inference (don't send sensitive data).",
      "enum": [
        "container",
        "inference"
      ]
    },
    "gpu_model": {
      "description": "Additive. The GPU model the machine's agent reported (its manifest), for naming the deployment (\"Qwen3 8B · RTX 4090\"). Absent when the agent reported none. Display only, never billing input.",
      "type": "string",
      "minLength": 1
    },
    "gpu_count": {
      "description": "Additive. How many of `gpu_model` the machine has, from the same manifest. Absent with gpu_model.",
      "type": "integer",
      "minimum": 1
    },
    "template": {
      "description": "Additive. Present only when the job's quote named a template (quotes.template_id); summary of templates.spec.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "template_id",
        "name",
        "kind"
      ],
      "properties": {
        "template_id": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "enum": [
            "model",
            "classical",
            "custom"
          ]
        }
      }
    }
  },
  "$defs": {
    "DecimalString": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$",
      "description": "Unsigned base-10 integer as string; never a float."
    },
    "MicroAmount": {
      "$ref": "#/$defs/DecimalString",
      "description": "Money in micro-units of the settlement asset as a base-10 integer string (\"5000000\" is 5 USDC). Never a float."
    },
    "Rfc3339Utc": {
      "type": "string",
      "format": "date-time",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?Z$"
    },
    "UUID": {
      "type": "string",
      "format": "uuid",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
    }
  }
}