{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://worldshaper.local/schemas/request-analysis.schema.json",
  "title": "Worldshaper Request Analysis Result",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "submissionId",
    "sourceText",
    "items"
  ],
  "properties": {
    "submissionId": {
      "type": "string",
      "minLength": 1
    },
    "sourceText": {
      "type": "string",
      "minLength": 1
    },
    "routing": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "summary": {
          "type": "string"
        },
        "ambiguity": {
          "type": "string",
          "enum": ["low", "medium", "high"]
        },
        "matchedTerms": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "suggestedTags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "suggestedSystems": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "suggestedModules": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "rationale": {
          "type": "string"
        },
        "possibleDirections": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "kbSections": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        }
      }
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "title",
          "primaryCategory",
          "tags",
          "statusRecommendation",
          "parsedInterpretation",
          "implementationApproach",
          "confidence"
        ],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 120
          },
          "primaryCategory": {
            "type": "string",
            "minLength": 1
          },
          "tags": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "statusRecommendation": {
            "type": "string",
            "enum": [
              "active",
              "needs_review",
              "duplicate",
              "blocked"
            ]
          },
          "parsedInterpretation": {
            "type": "string",
            "minLength": 20
          },
          "implementationApproach": {
            "type": "string",
            "minLength": 20
          },
          "affectedSystems": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "affectedFiles": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "problemType": {
            "type": "string",
            "enum": [
              "feature",
              "bug",
              "workflow",
              "performance",
              "ux",
              "content",
              "unknown"
            ]
          },
          "rawExcerpt": {
            "type": "string"
          },
          "confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "reviewRationale": {
            "type": "string"
          },
          "reviewOptions": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "notes": {
            "type": "string"
          }
        }
      }
    }
  }
}
