{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/derive-to/json-schema/derive-to-job-schema.json",
  "title": "Job",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/derive-to-openapi.json#/components/schemas/Job",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "chat_context": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "selection": {
          "type": [
            "string",
            "null"
          ]
        },
        "model_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "saving": {
          "type": "boolean"
        }
      },
      "required": [
        "selection",
        "model_id",
        "saving"
      ]
    },
    "agent_id": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "ask",
        "scheduled",
        "graph",
        "node"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "needs_you",
        "succeeded",
        "failed",
        "cancelled",
        "lost"
      ]
    },
    "machine_phase": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "creating",
        "provisioning",
        "starting",
        "ready",
        "launching",
        "running",
        "stopping",
        "parked",
        "deleting",
        "released",
        null
      ],
      "description": "Where the task's cloud machine is. `parked`: stopped with its files, resumable."
    },
    "machine_waiting": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why the machine is waiting to start, in the provider's words (a start limit)."
    },
    "task": {
      "type": "object",
      "properties": {
        "session": {
          "type": "boolean"
        },
        "repo": {
          "type": "string"
        }
      },
      "description": "How the task runs: an interactive session, and the repository it works in."
    },
    "instruction": {
      "type": "string"
    },
    "asked_by": {
      "type": [
        "string",
        "null"
      ]
    },
    "attended": {
      "type": "boolean"
    },
    "parent_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "node_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "trigger_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "origin": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "slack"
              ]
            },
            "requested_by": {
              "type": "string"
            },
            "team_id": {
              "type": "string"
            },
            "channel": {
              "type": "string"
            },
            "thread_ts": {
              "type": "string"
            },
            "message_ts": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "requested_by",
            "team_id",
            "channel",
            "thread_ts",
            "message_ts"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "github"
              ]
            },
            "requested_by": {
              "type": "string"
            },
            "repository": {
              "type": "string"
            },
            "number": {
              "type": [
                "number",
                "null"
              ]
            },
            "delivery_id": {
              "type": "string"
            },
            "comment_id": {
              "type": "number"
            },
            "ack_comment_id": {
              "type": "number"
            }
          },
          "required": [
            "kind",
            "requested_by",
            "repository",
            "number",
            "delivery_id"
          ]
        },
        {
          "nullable": true
        }
      ],
      "description": "Where the task was asked for, when that was outside Derive: a Slack thread or a GitHub event. `requested_by` is that system's handle, for display only."
    },
    "subject": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "artifact"
              ]
            },
            "id": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "id"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "collection"
              ]
            },
            "id": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "id"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "tag"
              ]
            },
            "tag": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "tag"
          ]
        },
        {
          "nullable": true
        }
      ]
    },
    "needs": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "review",
            "decision",
            "escalation",
            "effect"
          ]
        },
        "question_id": {
          "type": "string"
        },
        "target_id": {
          "type": "string"
        },
        "target_version": {
          "type": "number"
        },
        "question": {
          "type": "string"
        },
        "options": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "review_round_id": {
          "type": "string"
        },
        "asked_times": {
          "type": "number"
        },
        "first_asked_at": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "question"
      ]
    },
    "result": {
      "type": "object",
      "properties": {
        "claim_ledger_version": {
          "type": "number",
          "enum": [
            1
          ]
        },
        "attempt_offset": {
          "type": "integer",
          "minimum": 0
        },
        "git": {
          "type": "object",
          "properties": {
            "repo": {
              "type": "string",
              "maxLength": 300
            },
            "branch": {
              "type": [
                "string",
                "null"
              ],
              "maxLength": 300
            },
            "commit": {
              "type": [
                "string",
                "null"
              ],
              "maxLength": 64
            }
          },
          "required": [
            "repo",
            "branch",
            "commit"
          ],
          "description": "Where the latest turn left the task's repository."
        },
        "compute": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "turn": {
                "type": "string"
              },
              "provider": {
                "type": "string",
                "enum": [
                  "ortam",
                  "boat"
                ]
              },
              "sandbox_id": {
                "type": "string"
              },
              "started_at": {
                "type": "string"
              },
              "stopped_at": {
                "type": "string"
              },
              "billable_seconds": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "cost_micro_usd": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              }
            },
            "required": [
              "turn",
              "provider",
              "sandbox_id",
              "started_at",
              "stopped_at",
              "billable_seconds",
              "cost_micro_usd"
            ]
          }
        },
        "runs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "attempt": {
                "type": "integer",
                "minimum": 0
              },
              "provider": {
                "type": "string",
                "maxLength": 80
              },
              "model": {
                "type": "string",
                "maxLength": 200
              },
              "runner_version": {
                "type": "string",
                "maxLength": 80
              },
              "harness_version": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 100
              },
              "skill": {
                "type": "object",
                "properties": {
                  "short_id": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  }
                },
                "required": [
                  "short_id",
                  "version"
                ]
              },
              "input_tokens": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "cached_input_tokens": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "output_tokens": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "duration_ms": {
                "type": "integer",
                "minimum": 0
              },
              "model_cost_micro_usd": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "harness_estimate_micro_usd": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "api_estimate_micro_usd": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "price_version": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "type": "string"
              },
              "actor_id": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "attempt",
              "provider",
              "model",
              "input_tokens",
              "cached_input_tokens",
              "output_tokens",
              "duration_ms",
              "model_cost_micro_usd"
            ]
          },
          "maxItems": 600
        },
        "effects": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "page",
                  "pr",
                  "email",
                  "rows",
                  "other"
                ]
              },
              "label": {
                "type": "string"
              },
              "ref": {
                "type": "string"
              },
              "version": {
                "type": "number"
              },
              "url": {
                "type": "string"
              }
            },
            "required": [
              "kind",
              "label"
            ]
          }
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "ref": {
                "type": "string"
              }
            },
            "required": [
              "label"
            ]
          }
        },
        "failure": {
          "type": "object",
          "properties": {
            "reason": {
              "type": "string"
            },
            "retryable": {
              "type": "boolean"
            }
          },
          "required": [
            "reason",
            "retryable"
          ]
        },
        "summary": {
          "type": "string",
          "maxLength": 2000,
          "description": "One line saying what the run did, kept to 200 characters. Derived from the report when the runner sends none; empty when the run said nothing."
        },
        "superseded_by": {
          "type": "string"
        },
        "route": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "node_id": {
                "type": "string"
              },
              "attempt": {
                "type": "number"
              },
              "selected": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "decision": {
                "type": "string"
              }
            },
            "required": [
              "node_id",
              "attempt"
            ]
          }
        }
      }
    },
    "scheduled_for": {
      "type": [
        "string",
        "null"
      ]
    },
    "started_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "finished_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "lease_until": {
      "type": [
        "string",
        "null"
      ]
    },
    "attempt": {
      "type": "number"
    },
    "cost_micro_usd": {
      "type": [
        "number",
        "null"
      ]
    },
    "report_artifact_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "report_short_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The job's report page, once it has one."
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "chat_context",
    "agent_id",
    "kind",
    "status",
    "task",
    "instruction",
    "asked_by",
    "attended",
    "parent_id",
    "node_id",
    "trigger_id",
    "origin",
    "subject",
    "needs",
    "result",
    "scheduled_for",
    "started_at",
    "finished_at",
    "lease_until",
    "attempt",
    "cost_micro_usd",
    "report_artifact_id",
    "report_short_id",
    "created_at",
    "updated_at"
  ]
}