{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codequiry-com/json-schema/codequiry-com-airesults-schema.json",
  "title": "AIResults",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codequiry-com-openapi.yml#/components/schemas/AIResults",
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean"
    },
    "assignment_id": {
      "type": "integer",
      "description": "Echo of the requested check id."
    },
    "assignment_name": {
      "type": "string"
    },
    "message": {
      "type": "string",
      "description": "Present only when the check has no submissions yet; `statistics` and `assignment_status` are omitted in that case."
    },
    "assignment_status": {
      "type": "integer",
      "description": "Numeric status_id."
    },
    "statistics": {
      "type": "object",
      "properties": {
        "total_submissions": {
          "type": "integer"
        },
        "submissions_with_ai_detection": {
          "type": "integer"
        },
        "submissions_with_code_quality": {
          "type": "integer"
        },
        "avg_ai_detection": {
          "type": "number"
        },
        "avg_code_quality": {
          "type": "number"
        },
        "high_ai_risk_count": {
          "type": "integer"
        },
        "medium_ai_risk_count": {
          "type": "integer"
        },
        "low_ai_risk_count": {
          "type": "integer"
        }
      }
    },
    "submissions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "submission_id": {
            "type": "integer"
          },
          "filename": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "status_id": {
            "type": "integer"
          },
          "plagiarism_score": {
            "type": "object",
            "properties": {
              "local": {
                "type": "number"
              },
              "web": {
                "type": "number"
              },
              "total": {
                "type": "number"
              }
            }
          },
          "matches": {
            "type": "object",
            "properties": {
              "local": {
                "type": "integer"
              },
              "web": {
                "type": "integer"
              }
            }
          },
          "ai_detection": {
            "type": [
              "object",
              "null"
            ],
            "description": "AI-generated-code detection for this submission. null until the AI engine has run.",
            "properties": {
              "total_files": {
                "type": "integer"
              },
              "avg_ai_probability": {
                "type": "number"
              },
              "max_ai_probability": {
                "type": "number"
              },
              "min_ai_probability": {
                "type": "number"
              },
              "risk_level": {
                "type": "string",
                "description": "high (>=70), medium (>=45), or low.",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ]
              },
              "files": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "file_path": {
                      "type": "string"
                    },
                    "ai_probability": {
                      "type": "number"
                    },
                    "human_probability": {
                      "type": "number"
                    },
                    "classification": {
                      "type": "string",
                      "description": "Human-readable verdict, e.g. AI-Generated, Likely AI, Human."
                    },
                    "confidence": {
                      "type": "number",
                      "description": "0-1 confidence in the classification."
                    },
                    "summary": {
                      "type": "string"
                    },
                    "detailed_report": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "ai_code_quality": {
            "type": [
              "object",
              "null"
            ],
            "description": "Static code-quality analysis for this submission. null until the AI engine has run.",
            "properties": {
              "total_files": {
                "type": "integer"
              },
              "avg_score": {
                "type": "number"
              },
              "max_score": {
                "type": "number"
              },
              "min_score": {
                "type": "number"
              },
              "files": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "file_path": {
                      "type": "string"
                    },
                    "score": {
                      "type": "number"
                    },
                    "level": {
                      "type": "string",
                      "description": "High, Medium, or Low."
                    },
                    "total_lines": {
                      "type": "integer"
                    },
                    "comment_density": {
                      "type": "number",
                      "description": "Comment lines as a fraction of total lines."
                    },
                    "entropy": {
                      "type": "number",
                      "description": "Token entropy; lower is more repetitive."
                    },
                    "issues": {
                      "type": "array",
                      "description": "Detected code-quality issues. Empty when none were found.",
                      "items": {
                        "type": "string"
                      }
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "file_size": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        }
      }
    }
  }
}