{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://nsta1.github.io/Orleans.Lattice/docs/agents/schemas/index.schema.json",
  "schema": "lattice.agents/json-schema/v1",
  "title": "Orleans.Lattice agent specification manifest",
  "description": "The manifest: every artifact with its kind, format, schema id and summary, the conventions that bind every artifact, and which API surfaces are covered.",
  "type": "object",
  "required": [
    "schema",
    "audience",
    "subject",
    "conventions",
    "coverage",
    "artifacts"
  ],
  "properties": {
    "schema": {
      "const": "lattice.agents/index/v1"
    },
    "audience": {
      "const": "agents"
    },
    "subject": {
      "const": "Orleans.Lattice"
    },
    "conventions": {
      "type": "object",
      "minProperties": 1
    },
    "coverage": {
      "type": "object",
      "required": [
        "api_surfaces_covered",
        "api_surfaces_not_covered"
      ],
      "properties": {
        "api_surfaces_covered": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "api_surfaces_not_covered": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "package",
              "reason"
            ],
            "properties": {
              "package": {
                "$ref": "#/$defs/package"
              },
              "reason": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "path",
          "kind",
          "format",
          "schema",
          "summary"
        ],
        "properties": {
          "path": {
            "type": "string",
            "pattern": "^[a-z0-9/._-]+\\.(json|yaml)$"
          },
          "kind": {
            "$ref": "#/$defs/id"
          },
          "format": {
            "enum": [
              "json",
              "yaml"
            ]
          },
          "schema": {
            "type": "string",
            "pattern": "^lattice\\.agents/[a-z0-9-]+/v1$"
          },
          "summary": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      },
      "minItems": 1
    }
  },
  "additionalProperties": false,
  "$defs": {
    "claim": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "statement",
            "source"
          ],
          "properties": {
            "statement": {
              "type": "string",
              "minLength": 1
            },
            "source": {
              "$ref": "#/$defs/source"
            }
          },
          "additionalProperties": false
        },
        {
          "$ref": "#/$defs/uncertain"
        }
      ]
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
    },
    "package": {
      "type": "string",
      "pattern": "^Orleans\\.Lattice(\\.[A-Z][A-Za-z0-9]*)*$"
    },
    "packages": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^Orleans\\.Lattice(\\.[A-Z][A-Za-z0-9]*)*$"
      }
    },
    "source": {
      "type": "string",
      "pattern": "^((src|docs|test|samples|spec|tools|benchmark|reference-architecture|\\.github)/[A-Za-z0-9_./\\-]+|FEATURES\\.md|PACKAGES\\.md|README\\.md|reference-architecture\\.md)(#[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*)?$"
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^((src|docs|test|samples|spec|tools|benchmark|reference-architecture|\\.github)/[A-Za-z0-9_./\\-]+|FEATURES\\.md|PACKAGES\\.md|README\\.md|reference-architecture\\.md)(#[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*)?$"
      }
    },
    "text": {
      "type": "string",
      "minLength": 1
    },
    "uncertain": {
      "type": "object",
      "required": [
        "status",
        "reason",
        "required_source"
      ],
      "properties": {
        "status": {
          "const": "uncertain"
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "required_source": {
          "type": "string",
          "minLength": 1
        },
        "issue": {
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false
    }
  }
}
