{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kaimahi.dev/schemas/agentsuite/v1/build-profile.schema.json",
  "title": "Agent Sandbox Image build profile",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "mediaType", "id", "runtimeBase", "harness", "sourceEpoch"],
  "properties": {
    "schemaVersion": {"const": "1.0.0-draft"},
    "mediaType": {"const": "application/vnd.agentsuite.build.profile.v1+json"},
    "id": {"$ref": "#/$defs/id"},
    "runtimeBase": {"$ref": "#/$defs/images"},
    "harness": {"$ref": "#/$defs/images"},
    "sourceEpoch": {"type": "integer", "minimum": 1}
  },
  "$defs": {
    "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$"},
    "digest": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
    "platform": {
      "type": "object",
      "additionalProperties": false,
      "required": ["os", "architecture"],
      "properties": {
        "os": {"const": "linux"},
        "architecture": {"enum": ["amd64", "arm64"]}
      }
    },
    "descriptor": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mediaType", "digest", "size"],
      "properties": {
        "mediaType": {"const": "application/vnd.oci.image.manifest.v1+json"},
        "digest": {"$ref": "#/$defs/digest"},
        "size": {"type": "integer", "minimum": 1},
        "annotations": {"type": "object", "additionalProperties": {"type": "string"}}
      }
    },
    "images": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["platform", "imageRef", "image"],
        "properties": {
          "platform": {"$ref": "#/$defs/platform"},
          "imageRef": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::[0-9]+)?(?:/[a-z0-9]+(?:[._-][a-z0-9]+)*)+@sha256:[a-f0-9]{64}$"
          },
          "image": {"$ref": "#/$defs/descriptor"}
        }
      }
    }
  }
}
