{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://interchange.stellarview.net/schemas/ai_request.schema.json",
  "title": "A request for StellarView's AI: what arrived, the context, and the tasks asked. StellarView picks it up, runs it through Claude Code with the prompt files, and posts a result. Nothing acts on the result without a person.",
  "type": "object",
  "required": [
    "kind",
    "request_id",
    "raised_at",
    "state",
    "tasks",
    "prompts",
    "trigger",
    "context",
    "reply_to"
  ],
  "additionalProperties": false,
  "properties": {
    "kind": {
      "const": "ai_request"
    },
    "request_id": {
      "type": "string",
      "format": "uuid"
    },
    "raised_at": {
      "type": "string",
      "format": "date-time"
    },
    "state": {
      "enum": [
        "open",
        "answered"
      ]
    },
    "tasks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "enum": [
          "summarise",
          "suggest_asset",
          "suggest_work_order"
        ]
      }
    },
    "prompts": {
      "type": "object",
      "description": "For each task, the prompt file under prompts/ai/.",
      "additionalProperties": {
        "type": "string"
      }
    },
    "trigger": {
      "type": "object",
      "required": [
        "event_id",
        "event_type"
      ],
      "properties": {
        "event_id": {
          "type": "string"
        },
        "event_type": {
          "type": "string"
        },
        "jira_key": {
          "type": [
            "string",
            "null"
          ]
        },
        "i3_record": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "context": {
      "type": "object",
      "description": "Everything the prompts may use: the event, the Jira issue as the hub knows it, the candidate assets with their codes and locations, and the open work orders."
    },
    "reply_to": {
      "type": "string",
      "description": "POST the result here."
    }
  }
}
