{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://workspai.dev/schemas/workspace-intelligence/workspace-dependency-graph.v1.json",
  "title": "Workspai Workspace Dependency Graph",
  "description": "First-class, versioned dependency graph of inter-project relationships consumed by impact, verify, run --blast-radius, and risk weighting.",
  "type": "object",
  "required": ["schemaVersion", "generatedAt", "nodes", "edges", "stats"],
  "properties": {
    "schemaVersion": {
      "const": "workspace-dependency-graph.v1"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "nodes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "path"],
        "properties": {
          "id": { "type": "string", "minLength": 1 },
          "path": { "type": "string", "minLength": 1 },
          "runtime": { "type": "string" },
          "framework": { "type": "string" },
          "kind": { "type": "string" },
          "operationalProfile": {
            "type": "object",
            "required": ["weight", "score", "verificationPriority", "reasons", "centrality"],
            "properties": {
              "weight": { "enum": ["low", "medium", "high", "critical"] },
              "score": { "type": "integer", "minimum": 0, "maximum": 100 },
              "verificationPriority": { "enum": ["normal", "elevated", "strict"] },
              "reasons": {
                "type": "array",
                "items": { "type": "string" }
              },
              "centrality": {
                "type": "object",
                "required": ["fanIn", "fanOut", "reach", "betweenness", "isHotspot"],
                "properties": {
                  "fanIn": { "type": "integer", "minimum": 0 },
                  "fanOut": { "type": "integer", "minimum": 0 },
                  "reach": { "type": "integer", "minimum": 0 },
                  "betweenness": { "type": "number", "minimum": 0 },
                  "isHotspot": { "type": "boolean" }
                },
                "additionalProperties": true
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      }
    },
    "edges": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["from", "to", "kind", "source", "confidence", "evidence"],
        "properties": {
          "from": { "type": "string", "minLength": 1 },
          "to": { "type": "string", "minLength": 1 },
          "kind": {
            "enum": [
              "code-import",
              "package-dep",
              "event-pub-sub",
              "service-dependsOn",
              "shared-resource"
            ]
          },
          "source": {
            "enum": ["inferred", "contract", "manual"]
          },
          "confidence": {
            "enum": ["high", "medium", "low"]
          },
          "evidence": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["file"],
              "properties": {
                "file": { "type": "string", "minLength": 1 },
                "detail": { "type": "string" }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      }
    },
    "stats": {
      "type": "object",
      "required": [
        "nodeCount",
        "edgeCount",
        "inferredEdges",
        "contractEdges",
        "manualEdges",
        "authoritativeEdges",
        "lowConfidenceEdges",
        "orphanCount",
        "connectedNodeCount",
        "density",
        "edgeCoverageRatio",
        "evidenceCoverageRatio",
        "hotspotCount",
        "hasCycle"
      ],
      "properties": {
        "nodeCount": { "type": "integer", "minimum": 0 },
        "edgeCount": { "type": "integer", "minimum": 0 },
        "inferredEdges": { "type": "integer", "minimum": 0 },
        "contractEdges": { "type": "integer", "minimum": 0 },
        "manualEdges": { "type": "integer", "minimum": 0 },
        "authoritativeEdges": { "type": "integer", "minimum": 0 },
        "lowConfidenceEdges": { "type": "integer", "minimum": 0 },
        "orphanCount": { "type": "integer", "minimum": 0 },
        "connectedNodeCount": { "type": "integer", "minimum": 0 },
        "density": { "type": "number", "minimum": 0 },
        "edgeCoverageRatio": { "type": "number", "minimum": 0, "maximum": 1 },
        "evidenceCoverageRatio": { "type": "number", "minimum": 0, "maximum": 1 },
        "hotspotCount": { "type": "integer", "minimum": 0 },
        "hasCycle": { "type": "boolean" }
      },
      "additionalProperties": true
    },
    "diagnostics": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["code", "severity", "message"],
        "properties": {
          "code": { "type": "string", "minLength": 1 },
          "severity": { "enum": ["info", "warning", "error"] },
          "message": { "type": "string", "minLength": 1 },
          "recommendation": { "type": "string" },
          "nodeIds": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 }
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true
}
