{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/trajectory/main/json-schema/trajectory-deployment-schema.json",
  "title": "Deployment",
  "description": "Spanner-backed deployment lifecycle row for the platform UI.",
  "x-generated": "2026-10-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trajectory-openapi.json#/components/schemas/Deployment",
  "properties": {
    "deployment_id": {
      "type": "string",
      "title": "Deployment Id",
      "description": "Deployment row id."
    },
    "agent_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agent Id",
      "description": "Owning agent; null for unassigned legacy deployments."
    },
    "production_model_slug": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Production Model Slug",
      "description": "The owning agent production model slug; null until configured."
    },
    "agent_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agent Name",
      "description": "Owning agent display name; null for a deleted agent."
    },
    "test_model_slug": {
      "type": "string",
      "title": "Test Model Slug",
      "description": "Exact test model slug owned by this deployment."
    },
    "model_slug_id": {
      "type": "string",
      "title": "Model Slug Id",
      "description": "ID of this deployment test model slug row."
    },
    "status": {
      "$ref": "#/$defs/DeploymentLifecycleStatus",
      "description": "Deployment lifecycle state."
    },
    "role": {
      "$ref": "#/$defs/DeploymentRole",
      "description": "Whether this is the production or a test deployment."
    },
    "is_active": {
      "type": "boolean",
      "title": "Is Active",
      "description": "True when this deployment currently answers for the slug."
    },
    "checkpoint_id": {
      "type": "string",
      "title": "Checkpoint Id",
      "description": "Trajectory checkpoint selected when the deployment was created."
    },
    "model_endpoint_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Model Endpoint Id",
      "description": "Model Endpoint serving this deployment."
    },
    "base_model_slug": {
      "type": "string",
      "title": "Base Model Slug",
      "description": "Base model of the source checkpoint."
    },
    "checkpoint_step": {
      "type": "integer",
      "title": "Checkpoint Step",
      "description": "Training step of the source checkpoint."
    },
    "created_by": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Created By",
      "description": "Email of the user who requested this deployment."
    },
    "completed_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Completed At",
      "description": "When the deployment first became DEPLOYED; unlike updated_at, later promote/demote transitions never overwrite this."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "When the deployment was requested."
    },
    "updated_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Updated At",
      "description": "Last lifecycle transition; null until the row first moves."
    },
    "failure": {
      "anyOf": [
        {
          "$ref": "#/$defs/AsyncFailure"
        },
        {
          "type": "null"
        }
      ],
      "description": "Structured failure when status is FAILED."
    }
  },
  "type": "object",
  "required": [
    "deployment_id",
    "test_model_slug",
    "model_slug_id",
    "status",
    "role",
    "is_active",
    "checkpoint_id",
    "base_model_slug",
    "checkpoint_step",
    "created_at"
  ],
  "$defs": {
    "AsyncFailure": {
      "properties": {
        "type": {
          "type": "string",
          "title": "Type",
          "description": "Stable category used for exception mapping."
        },
        "code": {
          "type": "string",
          "title": "Code",
          "description": "Stable programmatic reason for the asynchronous failure."
        },
        "message": {
          "type": "string",
          "title": "Message",
          "description": "Human-readable explanation for this failure occurrence."
        },
        "context": {
          "additionalProperties": true,
          "type": "object",
          "title": "Context",
          "description": "Machine-readable values specific to this failure code."
        }
      },
      "type": "object",
      "required": [
        "type",
        "code",
        "message"
      ],
      "title": "AsyncFailure"
    },
    "DeploymentLifecycleStatus": {
      "type": "string",
      "enum": [
        "PENDING",
        "DEPLOYING",
        "DEPLOYED",
        "FAILED",
        "CANCELLING",
        "CANCELLED"
      ],
      "title": "DeploymentLifecycleStatus",
      "description": "Spanner deployment row status."
    },
    "DeploymentRole": {
      "type": "string",
      "enum": [
        "production",
        "test"
      ],
      "title": "DeploymentRole"
    }
  }
}