{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/roark/json-schema/roark-autoimprove-job-detail-schema.json",
  "title": "AutoimproveJobDetail",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/roark-autoimprove-api-openapi.yml#/components/schemas/AutoimproveJobDetail",
  "allOf": [
    {
      "$ref": "#/$defs/AutoimproveJob"
    }
  ],
  "properties": {
    "logEntries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AutoimproveLogEntry"
      },
      "description": "The full worklog, oldest first."
    }
  },
  "required": [
    "logEntries"
  ],
  "$defs": {
    "AutoimproveJob": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "organizationId": {
          "type": "string",
          "format": "uuid"
        },
        "projectId": {
          "type": "string",
          "format": "uuid"
        },
        "agentId": {
          "type": "string",
          "format": "uuid"
        },
        "stagingAgentId": {
          "type": "string",
          "format": "uuid"
        },
        "stagingKind": {
          "type": "string",
          "enum": [
            "DESIGNATED",
            "SHADOW",
            "CHANNEL"
          ]
        },
        "customerIntegrationId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "objectiveMetricDefinitionId": {
          "type": "string",
          "format": "uuid"
        },
        "objectiveLabel": {
          "type": "string"
        },
        "targetValue": {
          "type": "number"
        },
        "baselineValue": {
          "type": [
            "number",
            "null"
          ]
        },
        "currentValue": {
          "type": [
            "number",
            "null"
          ]
        },
        "trigger": {
          "type": "string",
          "enum": [
            "ISSUE",
            "RUN_THRESHOLD_FAILED",
            "USER",
            "DEGRADATION"
          ]
        },
        "issueId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "objectiveId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "validationRunPlanId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "status": {
          "type": "string",
          "enum": [
            "RUNNING",
            "NEEDS_INPUT",
            "PAUSED",
            "AWAITING_PROMOTE",
            "PROMOTED",
            "NO_FIX",
            "CANCELLED",
            "FAILED"
          ]
        },
        "workingMemory": {
          "type": [
            "string",
            "null"
          ]
        },
        "finalReport": {
          "type": [
            "string",
            "null"
          ]
        },
        "maxIterations": {
          "type": "integer"
        },
        "maxSimCalls": {
          "type": "integer"
        },
        "iterationCount": {
          "type": "integer"
        },
        "simCallsUsed": {
          "type": "integer"
        },
        "initiatedByUserId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "concludedAt": {
          "type": [
            "string",
            "null"
          ],
          "description": "When the job reached a terminal status (ISO 8601)."
        },
        "createdAt": {
          "type": "string",
          "description": "When the job was created (ISO 8601)."
        },
        "updatedAt": {
          "type": "string",
          "description": "When the job last changed (ISO 8601)."
        }
      },
      "required": [
        "id",
        "organizationId",
        "projectId",
        "agentId",
        "stagingAgentId",
        "stagingKind",
        "customerIntegrationId",
        "objectiveMetricDefinitionId",
        "objectiveLabel",
        "targetValue",
        "baselineValue",
        "currentValue",
        "trigger",
        "issueId",
        "objectiveId",
        "validationRunPlanId",
        "status",
        "workingMemory",
        "finalReport",
        "maxIterations",
        "maxSimCalls",
        "iterationCount",
        "simCallsUsed",
        "initiatedByUserId",
        "concludedAt",
        "createdAt",
        "updatedAt"
      ],
      "description": "One Autoimprove job: Roark autonomously improving one agent toward one objective metric. Roark only ever changes the staging agent (a shadow clone by default); production changes exactly once, when verified changes are promoted."
    },
    "AutoimproveLogEntry": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "orderIndex": {
          "type": "integer"
        },
        "kind": {
          "type": "string",
          "enum": [
            "STARTED",
            "REASONING",
            "CHANGE",
            "VALIDATION",
            "VERDICT",
            "SLEEP",
            "QUESTION",
            "GUIDANCE",
            "STATUS",
            "SETUP",
            "SUITE"
          ]
        },
        "text": {
          "type": "string"
        },
        "questionOptions": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "configPushId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "simulationRunPlanJobId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "trialCount": {
          "type": [
            "integer",
            "null"
          ]
        },
        "passRateBefore": {
          "type": [
            "number",
            "null"
          ]
        },
        "passRateAfter": {
          "type": [
            "number",
            "null"
          ]
        },
        "createdAt": {
          "type": "string",
          "description": "When the entry was written (ISO 8601)."
        }
      },
      "required": [
        "id",
        "orderIndex",
        "kind",
        "text",
        "questionOptions",
        "configPushId",
        "simulationRunPlanJobId",
        "trialCount",
        "passRateBefore",
        "passRateAfter",
        "createdAt"
      ],
      "description": "One entry in the job's worklog: what Roark did or observed at that step. VALIDATION entries carry the batch's trial count and pass-rate movement; QUESTION entries carry the quick-reply options Roark is waiting on."
    }
  }
}