{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://humanindexed.work/schemas/capability-manifest-v0.1.json",
  "title": "HIWP Capability Manifest v0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["protocolVersion", "manifestId", "issuedAt", "principal", "operatorLayer", "modules", "workContext", "substrates", "claim"],
  "properties": {
    "protocolVersion": {"const": "0.1"},
    "manifestId": {"type": "string", "minLength": 8},
    "issuedAt": {"type": "string", "format": "date-time"},
    "principal": {
      "type": "object", "additionalProperties": false,
      "required": ["subjectId", "naturalPerson", "role", "authority"],
      "properties": {
        "subjectId": {"type": "string"},
        "naturalPerson": {"const": true},
        "role": {"type": "string"},
        "identityAssurance": {"type": "string", "enum": ["self-attested", "verified", "high-assurance"]},
        "authority": {"type": "array", "items": {"type": "string"}, "minItems": 1}
      }
    },
    "operatorLayer": {
      "type": "object", "additionalProperties": false,
      "required": ["version", "integrityHash", "ownershipDomain", "controls", "evaluationSuite"],
      "properties": {
        "version": {"type": "string"},
        "integrityHash": {"type": "string"},
        "ownershipDomain": {"type": "string", "enum": ["operator", "engagement", "joint", "licensed"]},
        "controls": {"type": "array", "items": {"type": "string"}, "minItems": 1},
        "evaluationSuite": {"type": "string"},
        "protectedDetails": {"type": "boolean", "default": true}
      }
    },
    "modules": {
      "type": "array", "minItems": 1,
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["moduleId", "purpose", "autonomy", "risk", "inputs", "outputs", "escalation"],
        "properties": {
          "moduleId": {"type": "string"}, "purpose": {"type": "string"},
          "autonomy": {"type": "string", "enum": ["A0", "A1", "A2", "A3", "A4"]},
          "risk": {"type": "string", "enum": ["R0", "R1", "R2", "R3", "R4"]},
          "inputs": {"type": "array", "items": {"type": "string"}},
          "outputs": {"type": "array", "items": {"type": "string"}},
          "tools": {"type": "array", "items": {"type": "string"}},
          "limitations": {"type": "array", "items": {"type": "string"}},
          "escalation": {"type": "array", "items": {"type": "string"}, "minItems": 1}
        }
      }
    },
    "workContext": {
      "type": "object", "additionalProperties": false,
      "required": ["contextClass", "dataSensitivity", "ownerDomain", "policies"],
      "properties": {
        "contextClass": {"type": "string"}, "dataSensitivity": {"type": "string"},
        "ownerDomain": {"const": "engagement"},
        "policies": {"type": "array", "items": {"type": "string"}},
        "jurisdictions": {"type": "array", "items": {"type": "string"}}
      }
    },
    "substrates": {
      "type": "array", "minItems": 1,
      "items": {"type": "object", "required": ["name", "provider", "dependencyClass"], "properties": {
        "name": {"type": "string"}, "provider": {"type": "string"}, "version": {"type": "string"},
        "dependencyClass": {"type": "string", "enum": ["material", "substitutable", "optional"]}
      }}
    },
    "claim": {
      "type": "object", "additionalProperties": false,
      "required": ["outcome", "acceptanceThreshold", "resourceLimits", "validUntil", "materialChangePolicy"],
      "properties": {
        "outcome": {"type": "string"}, "acceptanceThreshold": {"type": "string"},
        "resourceLimits": {"type": "object"}, "validUntil": {"type": "string", "format": "date-time"},
        "materialChangePolicy": {"type": "array", "items": {"type": "string"}, "minItems": 1}
      }
    },
    "signature": {"type": "object"}
  }
}
