{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://workspai.dev/schemas/analyze-last-run.v1.json",
  "title": "Workspai Analyze Last Run Evidence",
  "type": "object",
  "required": [
    "schemaVersion",
    "generatedAt",
    "workspacePath",
    "workspaceDetected",
    "summary",
    "projects",
    "findings",
    "enterpriseControls"
  ],
  "properties": {
    "schemaVersion": {
      "const": "rapidkit-analyze-v1"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "workspacePath": { "type": "string", "minLength": 1 },
    "workspaceDetected": { "type": "boolean" },
    "profile": { "type": ["string", "null"] },
    "summary": {
      "type": "object",
      "required": [
        "score",
        "verdict",
        "projectCount",
        "runtimeCount",
        "findings"
      ],
      "properties": {
        "statusScope": { "const": "source-structure" },
        "releaseReadiness": { "const": "not-evaluated" },
        "score": { "type": "number" },
        "verdict": {
          "enum": ["ready", "needs-attention", "blocked"]
        },
        "projectCount": { "type": "integer", "minimum": 0 },
        "runtimeCount": { "type": "integer", "minimum": 0 },
        "findings": {
          "type": "object",
          "required": ["fail", "warn", "info"],
          "properties": {
            "fail": { "type": "integer", "minimum": 0 },
            "warn": { "type": "integer", "minimum": 0 },
            "info": { "type": "integer", "minimum": 0 }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    },
    "runtimes": {
      "type": "object",
      "additionalProperties": { "type": "integer", "minimum": 0 }
    },
    "projects": {
      "type": "array",
      "items": { "type": "object", "additionalProperties": true }
    },
    "dependencyGraph": {
      "type": "object",
      "properties": {
        "status": { "enum": ["generated", "empty"] },
        "edges": {
          "type": "array",
          "items": { "type": "object", "additionalProperties": true }
        },
        "topImpactedProjects": {
          "type": "array",
          "items": { "type": "object", "additionalProperties": true }
        }
      },
      "additionalProperties": true
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "severity", "title", "detail", "target", "remediation"],
        "properties": {
          "id": { "type": "string" },
          "severity": { "enum": ["info", "warn", "fail"] },
          "title": { "type": "string" },
          "detail": { "type": "string" },
          "target": { "type": "string" },
          "remediation": { "type": "string" },
          "files": {
            "type": "array",
            "description": "Expected project-relative source paths that close this finding when created or repaired.",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          }
        },
        "additionalProperties": true
      }
    },
    "nextActions": {
      "type": "array",
      "items": { "type": "string" }
    },
    "enterpriseControls": {
      "type": "object",
      "required": ["jsonReady", "ciGateCommand", "releaseGateCommand", "evidencePath"],
      "properties": {
        "jsonReady": { "type": "boolean" },
        "ciGateCommand": { "type": "string" },
        "releaseGateCommand": { "type": "string" },
        "evidencePath": { "type": "string" }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
