{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agtp.cc/json/space-manifest.schema.json",
  "title": "AGTP Space Manifest (2.1)",
  "type": "object",
  "required": ["@context", "type", "issuer", "credentialSubject", "credentialStatus", "proof"],
  "properties": {
    "@context": { "type": "array", "minItems": 2 },
    "id": { "type": "string", "format": "uri" },
    "type": { "type": "array", "contains": { "enum": ["SpaceManifest", "SpaceManifestCredential"] } },
    "issuer": { "type": "string", "pattern": "^did:" },
    "validFrom": { "type": "string", "format": "date-time" },
    "validUntil": { "type": "string", "format": "date-time" },
    "credentialSubject": {
      "type": "object",
      "required": ["id", "version", "manifestHash", "dimensions"],
      "properties": {
        "id": { "type": "string", "pattern": "^did:" },
        "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+" },
        "manifestHash": { "type": "string", "pattern": "^u[A-Za-z0-9_-]+$" },
        "dimensions": { "type": "array", "minItems": 1,
          "items": { "type": "object", "required": ["id", "range", "higherIsBetter"],
            "properties": {
              "id": { "type": "string", "pattern": "^[A-Za-z0-9_.-]+$" },
              "range": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "type": "number" } },
              "higherIsBetter": { "type": "boolean" },
              "unit": { "type": "string" },
              "ref": { "type": "string", "format": "uri" } } } },
        "dimensionRefs": { "type": "array", "items": { "type": "string", "format": "uri" } },
        "aggregation": { "oneOf": [
          { "$ref": "#/$defs/aggregation" },
          { "type": "array", "items": { "$ref": "#/$defs/aggregation" } } ] },
        "persistence_policy": { "type": "object" },
        "status": { "type": "string", "format": "uri" },
        "revocation": { "type": "string", "format": "uri" },
        "capabilities": { "type": "object" },
        "knowledge": { "type": "array", "items": { "type": "object", "required": ["resource", "cid"],
          "properties": { "resource": { "type": "string", "format": "uri" }, "cid": { "type": "string" },
                          "okf_version": { "type": "string" },
                          "role": { "enum": ["dimensions", "policy", "documentation", "corpus"] } } } },
        "discovery": { "type": "object", "properties": {
          "ard": { "type": "string", "pattern": "^urn:air:" },
          "registries": { "type": "array", "items": { "type": "string", "format": "uri" } } } },
        "admission": { "type": "object" }
      },
      "additionalProperties": true
    },
    "credentialStatus": { "type": "object", "required": ["id", "type"] },
    "proof": { "type": "object" }
  },
  "$defs": {
    "aggregation": { "type": "object", "required": ["name"],
      "properties": { "name": { "type": "string" }, "parameters": { "type": "object" },
                      "impl": { "type": "string", "format": "uri" },
                      "dimensions": { "type": "array", "items": { "type": "string" } } } }
  },
  "additionalProperties": true
}
