{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Adam91holt/grokbot-sdk/sdk/src/job/job.schema.json",
  "title": "Grok Bot Job",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "job_id",
    "idempotency_key",
    "goal",
    "done_when",
    "seats",
    "on_awaiting_user"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "job_id": { "type": "string", "minLength": 1 },
    "idempotency_key": { "type": "string", "minLength": 1 },
    "goal": { "type": "string", "minLength": 1 },
    "done_when": { "type": "string", "minLength": 1 },
    "seats": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "minLength": 1 }
    },
    "isolation": { "type": "string", "enum": ["clone", "room"], "default": "clone" },
    "mode": { "type": "string", "enum": ["research", "recommend", "implement"], "default": "recommend" },
    "actions_allowed": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "default": [],
      "description": "The only actions a future implement step may do. Empty = no implement, ever. Free strings; reserved forbidden defaults cannot appear here."
    },
    "actions_forbidden": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "default": [
        "message people",
        "publish",
        "spend",
        "delete",
        "force-push",
        "read/write secrets"
      ],
      "description": "Always includes reserved defaults: message people, publish, spend, delete, force-push, read/write secrets."
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name"],
        "properties": {
          "name": { "type": "string", "minLength": 1 },
          "ref": { "type": "string", "minLength": 1 }
        }
      },
      "description": "Named refs only. No secrets inline."
    },
    "side_effect": { "type": "string", "enum": ["read", "mutate"], "default": "read" },
    "on_awaiting_user": { "type": "string", "const": "stop" },
    "deadline": { "type": "string", "minLength": 1 },
    "quiet_hours": {
      "type": "object",
      "additionalProperties": false,
      "required": ["start", "end"],
      "properties": {
        "start": { "type": "string", "minLength": 1 },
        "end": { "type": "string", "minLength": 1 }
      }
    },
    "repo": { "type": "string", "minLength": 1 },
    "base_branch": { "type": "string", "minLength": 1 },
    "branch_name": { "type": "string", "minLength": 1 },
    "test_command": { "type": "string", "minLength": 1 },
    "pr": { "type": "boolean" },
    "implementer": { "type": "string", "minLength": 1 },
    "packet": { "$ref": "#/$defs/packet" }
  },
  "$defs": {
    "packet": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status"],
      "properties": {
        "status": {
          "type": "string",
          "enum": ["queued", "running", "awaiting-user", "done", "failed", "timeout"]
        },
        "recommendation": { "type": "string" },
        "transcript_ref": { "type": "string" },
        "turns": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["speaker", "text"],
            "properties": {
              "speaker": { "type": "string", "minLength": 1 },
              "text": { "type": "string" },
              "kind": { "type": "string" },
              "agentId": { "type": "string" }
            }
          }
        },
        "diffs": { "type": "array", "items": { "type": "string" } },
        "links": { "type": "array", "items": { "type": "string" } },
        "error": { "type": "string" },
        "compat": {
          "type": "object",
          "additionalProperties": false,
          "required": ["status"],
          "properties": {
            "status": { "type": "string" },
            "pinned": { "type": "string" },
            "live": { "type": ["string", "null"] },
            "note": { "type": "string" }
          }
        },
        "apply": {
          "description": "Allowed only when mode is implement and actions_allowed is non-empty. v1 never applies it."
        }
      }
    }
  }
}
