{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://decantr.ai/schemas/authority-resolution.v2.json",
  "title": "Decantr Authority Resolution v2",
  "type": "object",
  "required": ["schemaVersion", "order", "activeLane", "summary", "conflicts", "stopRule"],
  "properties": {
    "$schema": { "const": "https://decantr.ai/schemas/authority-resolution.v2.json" },
    "schemaVersion": { "const": 2 },
    "generatedAt": { "type": "string", "format": "date-time" },
    "order": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "label", "role", "rank"],
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "production-source",
              "local-law",
              "style-bridge",
              "essence-contract",
              "registry-guidance"
            ]
          },
          "label": { "type": "string" },
          "role": { "type": "string" },
          "rank": { "type": "integer", "minimum": 1 }
        },
        "additionalProperties": false
      }
    },
    "activeLane": {
      "type": "string",
      "enum": [
        "production-source",
        "local-law",
        "style-bridge",
        "essence-contract",
        "registry-guidance"
      ]
    },
    "summary": { "type": "string" },
    "conflicts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "source",
          "category",
          "severity",
          "message",
          "lane",
          "status",
          "recommendedActions"
        ],
        "properties": {
          "id": { "type": "string" },
          "source": { "type": "string" },
          "category": { "type": "string" },
          "severity": { "type": "string", "enum": ["error", "warn", "info"] },
          "message": { "type": "string" },
          "graphAnchor": {
            "$ref": "https://decantr.ai/schemas/verification-report.common.v1.json#/$defs/graphAnchor"
          },
          "lane": {
            "type": "string",
            "enum": [
              "production-source",
              "local-law",
              "style-bridge",
              "essence-contract",
              "registry-guidance"
            ]
          },
          "status": { "type": "string", "enum": ["blocking", "repairable", "advisory"] },
          "recommendedActions": {
            "type": "array",
            "items": { "$ref": "#/$defs/resolutionAction" }
          }
        },
        "additionalProperties": false
      }
    },
    "stopRule": { "type": "string" }
  },
  "additionalProperties": false,
  "$defs": {
    "resolutionAction": {
      "type": "object",
      "required": ["kind", "label", "command", "writes", "rationale"],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "repair_source",
            "accept_observed_source",
            "codify_local_law",
            "update_style_bridge",
            "regenerate_graph",
            "regenerate_context",
            "defer_to_drift_log",
            "mark_advisory"
          ]
        },
        "label": { "type": "string" },
        "command": { "type": ["string", "null"] },
        "writes": { "type": "boolean" },
        "rationale": { "type": "string" }
      },
      "additionalProperties": false
    }
  }
}
