{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.rootblocks.com/schemas/compatibility/consumer-profile.v1.schema.json",
  "title": "RootBlocks Consumer Profile v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "consumerId",
    "consumerName",
    "version",
    "supportedBundleMajors",
    "supportedSchemaFamilies",
    "capabilities",
    "enforcementMode"
  ],
  "properties": {
    "schemaVersion": {
      "const": "rootblocks.consumer-profile/v1"
    },
    "consumerId": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
    },
    "consumerName": {
      "enum": ["rootblocks-console", "darkfactory", "builderx", "rbstd", "agent", "custom"]
    },
    "version": {
      "$ref": "#/$defs/semver"
    },
    "supportedBundleMajors": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "integer",
        "minimum": 0
      },
      "uniqueItems": true
    },
    "supportedSchemaFamilies": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "capabilities": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]{1,127}$"
      },
      "uniqueItems": true
    },
    "enforcementMode": {
      "enum": ["advisory", "enforced"]
    },
    "cacheState": {
      "enum": ["current", "stale-warning", "stale-critical", "invalid", "quarantined", "refreshing"]
    },
    "componentSupport": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "supportsComponentExtensions",
        "requiresBuildPack",
        "supportedPackageKinds",
        "supportedLanguages",
        "supportedSourceModes"
      ],
      "properties": {
        "supportsComponentExtensions": {
          "type": "boolean"
        },
        "requiresBuildPack": {
          "type": "boolean"
        },
        "supportedPackageKinds": {
          "type": "array",
          "items": {
            "enum": [
              "builderx-buildpack",
              "nuget",
              "npm",
              "pypi",
              "maven",
              "gradle",
              "cargo",
              "go-module",
              "composer",
              "gem",
              "docker-oci",
              "custom"
            ]
          },
          "uniqueItems": true
        },
        "supportedLanguages": {
          "type": "array",
          "items": {
            "enum": ["csharp", "typescript", "javascript", "python", "java", "kotlin", "go", "rust", "php", "ruby", "custom"]
          },
          "uniqueItems": true
        },
        "supportedSourceModes": {
          "type": "array",
          "items": {
            "enum": ["builderx-compiler", "agent-generated", "manual-governed", "imported"]
          },
          "uniqueItems": true
        }
      }
    },
    "architectureProfileSupport": {
      "type": "object",
      "additionalProperties": false,
      "required": ["supportsArchitectureProfiles", "supportedProfiles"],
      "properties": {
        "supportsArchitectureProfiles": {
          "type": "boolean"
        },
        "supportedProfiles": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/supportedArchitectureProfile"
          }
        }
      }
    }
  },
  "$defs": {
    "semver": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[A-Za-z0-9.-]+)?(\\+[A-Za-z0-9.-]+)?$"
    },
    "supportedArchitectureProfile": {
      "type": "object",
      "additionalProperties": false,
      "required": ["profileId", "supportedMajors", "supportedLanguages", "supportedRuntimes", "rendererCapabilities"],
      "properties": {
        "profileId": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
        },
        "supportedMajors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "integer",
            "minimum": 0
          },
          "uniqueItems": true
        },
        "supportedLanguages": {
          "type": "array",
          "items": {
            "enum": ["dotnet", "node", "python", "java", "go", "custom"]
          },
          "uniqueItems": true
        },
        "supportedRuntimes": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9.+-]{0,80}$"
          },
          "uniqueItems": true
        },
        "rendererCapabilities": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9.-]{1,127}$"
          },
          "uniqueItems": true
        }
      }
    }
  }
}
