{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dicworkflowkit.local/schemas/project-profile.schema.json",
  "title": "DIC Project Profile",
  "type": "object",
  "required": ["schema", "version", "projectRoot", "designSources", "implementationRoots", "testRoots", "validationCommands"],
  "properties": {
    "schema": { "const": "dic.project-profile.v1" },
    "version": { "type": "string" },
    "projectRoot": { "type": "string" },
    "projectTypes": { "type": "array", "items": { "type": "string" } },
    "adapters": { "type": "array", "items": { "type": "string" } },
    "bddSources": { "type": "array", "items": { "type": "string" } },
    "availableBddSources": { "type": "array", "items": { "type": "string" } },
    "repositoryLayout": {
      "type": "object",
      "properties": {
        "manifests": { "type": "array", "items": { "type": "string" } },
        "moduleRoots": { "type": "array", "items": { "type": "string" } },
        "discovery": { "type": "string" }
      }
    },
    "consistencyScope": {
      "type": "object",
      "properties": {
        "authorityRoots": { "type": "array", "items": { "type": "string" } },
        "relationStrategies": { "type": "array", "items": { "type": "string" } },
        "semanticCrossSpecSearchRequired": { "type": "boolean" }
      }
    },
    "designEntry": {
      "type": "object",
      "required": ["type", "changeId", "lifecycle", "changeRoot", "documents", "deltaSpecs", "baselineSpecs"],
      "properties": {
        "type": { "const": "openspec-change" },
        "changeId": { "type": "string" },
        "lifecycle": { "enum": ["active", "archived"] },
        "changeRoot": { "type": "string" },
        "documents": { "type": "array", "items": { "type": "string" } },
        "deltaSpecs": { "type": "array", "items": { "type": "string" } },
        "baselineSpecs": { "type": "array", "items": { "type": "string" } },
        "designMap": {
          "type": "object",
          "required": ["source", "capabilityId", "architectureDesigns", "moduleDesigns", "adrs", "validationSummary", "validationCommands"],
          "properties": {
            "source": { "type": "string" },
            "capabilityId": { "type": "string" },
            "architectureDesigns": { "type": "array", "items": { "type": "string" } },
            "moduleDesigns": { "type": "array", "items": { "type": "string" } },
            "adrs": { "type": "array", "items": { "type": "string" } },
            "validationSummary": { "type": "string" },
            "validationCommands": { "type": "array", "items": { "$ref": "#/$defs/validationCommand" } }
          }
        }
      }
    },
    "deltaSpecs": { "type": "array", "items": { "type": "string" } },
    "baselineSpecs": { "type": "array", "items": { "type": "string" } },
    "relatedBaselineSpecs": { "type": "array", "items": { "type": "string" } },
    "relatedBaselineReasons": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": { "type": "string" }
      }
    },
    "semanticConsistencyCandidates": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["spec", "score", "sharedSymbols", "reason"],
        "properties": {
          "spec": { "type": "string" },
          "score": { "type": "number", "minimum": 0 },
          "sharedSymbols": {
            "type": "array",
            "items": { "type": "string" },
            "minItems": 2
          },
          "reason": { "const": "shared-normative-symbols" }
        },
        "additionalProperties": false
      }
    },
    "designSources": { "type": "array", "items": { "type": "string" } },
    "implementationRoots": { "type": "array", "items": { "type": "string" } },
    "testRoots": { "type": "array", "items": { "type": "string" } },
    "protectedPaths": { "type": "array", "items": { "type": "string" } },
    "validationCommands": {
      "type": "array",
      "items": { "$ref": "#/$defs/validationCommand" }
    },
    "riskFamilies": { "type": "array", "items": { "type": "string" } },
    "outputContract": { "type": "object" }
  },
  "additionalProperties": true,
  "$defs": {
    "validationCommand": {
      "type": "object",
      "required": ["name", "command", "source"],
      "properties": {
        "name": { "type": "string" },
        "command": { "type": "array", "items": { "type": "string" } },
        "cwd": { "type": "string" },
        "source": { "type": "string" },
        "kind": { "type": "string" }
      }
    }
  }
}
