{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentatlas.id/registry/schema.json",
  "title": "Agent Atlas registry",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "contract_version",
    "revision",
    "generated_at",
    "title",
    "updated",
    "policy",
    "identities"
  ],
  "$defs": {
    "permissions": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "reference",
        "generate",
        "publish",
        "replace_master",
        "approval_required"
      ],
      "properties": {
        "reference": {
          "type": "boolean"
        },
        "generate": {
          "type": "boolean"
        },
        "publish": {
          "type": "boolean"
        },
        "replace_master": {
          "type": "boolean",
          "const": false
        },
        "approval_required": {
          "type": "boolean"
        }
      }
    },
    "status_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "description",
        "permissions"
      ],
      "properties": {
        "description": {
          "type": "string",
          "minLength": 20
        },
        "permissions": {
          "$ref": "#/$defs/permissions"
        }
      }
    },
    "resource": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "role",
        "mime",
        "url",
        "immutable_url",
        "sha256",
        "visibility"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "type": {
          "type": "string",
          "enum": [
            "image",
            "audio",
            "video",
            "model-3d",
            "document"
          ]
        },
        "role": {
          "type": "string",
          "minLength": 3
        },
        "mime": {
          "type": "string",
          "pattern": "^[a-z0-9.+-]+/[a-zA-Z0-9.+-]+$"
        },
        "url": {
          "type": "string",
          "pattern": "^/[a-z0-9_./-]+$"
        },
        "immutable_url": {
          "type": "string",
          "pattern": "^/objects/sha256/[a-f0-9]{64}\\.[a-z0-9]+$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "visibility": {
          "type": "string",
          "enum": [
            "public",
            "restricted"
          ]
        }
      }
    },
    "production_profile": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "state",
        "resource_ids"
      ],
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "ready",
            "reference-only",
            "restricted",
            "unregistered"
          ]
        },
        "resource_ids": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          }
        }
      }
    },
    "https_url": {
      "type": "string",
      "pattern": "^https://[A-Za-z0-9._~:/?#\\[\\]@!$&'()*+,;=%-]+$"
    },
    "presence_link": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "url"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "url": {
          "$ref": "#/$defs/https_url"
        }
      }
    },
    "work_item": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "url"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 2,
          "maxLength": 80
        },
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "summary": {
          "type": "string",
          "minLength": 8,
          "maxLength": 240
        }
      }
    },
    "agent_packet": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "state",
        "statement"
      ],
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "ready",
            "unregistered"
          ]
        },
        "statement": {
          "type": "string",
          "maxLength": 1200
        }
      }
    }
  },
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.4.0"
    },
    "contract_version": {
      "type": "string",
      "const": "1.4.0"
    },
    "revision": {
      "type": "string",
      "pattern": "^atlas-[0-9]{4}-[0-9]{2}-[0-9]{2}-r[0-9]+$"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "title": {
      "type": "string",
      "minLength": 5
    },
    "updated": {
      "type": "string",
      "format": "date"
    },
    "policy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "canonical",
        "approved",
        "legacy",
        "exploratory"
      ],
      "properties": {
        "canonical": {
          "$ref": "#/$defs/status_policy"
        },
        "approved": {
          "$ref": "#/$defs/status_policy"
        },
        "legacy": {
          "$ref": "#/$defs/status_policy"
        },
        "exploratory": {
          "$ref": "#/$defs/status_policy"
        }
      }
    },
    "identities": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "slug",
          "name",
          "family",
          "status",
          "role",
          "asset",
          "thumbnail",
          "sha256",
          "dimensions",
          "alt",
          "usage",
          "exclusions",
          "accent",
          "voice",
          "motif",
          "palette",
          "framing",
          "negative_prompt",
          "related_slugs",
          "review",
          "permissions",
          "resources",
          "production_profiles",
          "relations",
          "dossier",
          "room",
          "agent",
          "presence",
          "work"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "family": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "canonical",
              "approved",
              "exploratory",
              "legacy"
            ]
          },
          "role": {
            "type": "string",
            "minLength": 3
          },
          "asset": {
            "type": "string",
            "pattern": "^/assets/[a-z0-9-]+/master\\.png$"
          },
          "thumbnail": {
            "type": "string",
            "pattern": "^/assets/[a-z0-9-]+/card\\.webp$"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "dimensions": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "width",
              "height"
            ],
            "properties": {
              "width": {
                "type": "integer",
                "minimum": 1
              },
              "height": {
                "type": "integer",
                "minimum": 1
              }
            }
          },
          "alt": {
            "type": "string",
            "minLength": 40
          },
          "usage": {
            "type": "string",
            "minLength": 8
          },
          "exclusions": {
            "type": "string",
            "minLength": 8
          },
          "accent": {
            "type": "string",
            "pattern": "^#[a-fA-F0-9]{6}$"
          },
          "voice": {
            "type": "string",
            "minLength": 8
          },
          "motif": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "palette": {
            "type": "array",
            "minItems": 4,
            "maxItems": 4,
            "items": {
              "type": "string",
              "pattern": "^#[a-fA-F0-9]{6}$"
            }
          },
          "framing": {
            "type": "string",
            "minLength": 20
          },
          "negative_prompt": {
            "type": "array",
            "minItems": 3,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 2
            }
          },
          "related_slugs": {
            "type": "array",
            "minItems": 2,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            }
          },
          "review": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "state",
              "updated",
              "steward"
            ],
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "canonical",
                  "approved",
                  "exploratory",
                  "legacy"
                ]
              },
              "updated": {
                "type": "string",
                "format": "date"
              },
              "steward": {
                "type": "string",
                "minLength": 3
              }
            }
          },
          "permissions": {
            "$ref": "#/$defs/permissions"
          },
          "resources": {
            "type": "array",
            "minItems": 2,
            "uniqueItems": true,
            "items": {
              "$ref": "#/$defs/resource"
            }
          },
          "production_profiles": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "visual",
              "gallery",
              "voice",
              "model_3d",
              "motion"
            ],
            "properties": {
              "visual": {
                "$ref": "#/$defs/production_profile"
              },
              "gallery": {
                "$ref": "#/$defs/production_profile"
              },
              "voice": {
                "$ref": "#/$defs/production_profile"
              },
              "model_3d": {
                "$ref": "#/$defs/production_profile"
              },
              "motion": {
                "$ref": "#/$defs/production_profile"
              }
            }
          },
          "room": {
            "type": "string",
            "enum": [
              "atlas",
              "study",
              "production-floor",
              "archive-lab",
              "creative-studio"
            ]
          },
          "relations": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "slug",
                "type",
                "label"
              ],
              "properties": {
                "slug": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "type": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "label": {
                  "type": "string",
                  "minLength": 2
                }
              }
            }
          },
          "dossier": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "tagline",
              "origin",
              "behavioral_signature",
              "field_note"
            ],
            "properties": {
              "tagline": {
                "type": "string",
                "minLength": 8
              },
              "origin": {
                "type": "string",
                "minLength": 20
              },
              "behavioral_signature": {
                "type": "string",
                "minLength": 20
              },
              "field_note": {
                "type": "string",
                "minLength": 8
              }
            }
          },
          "agent": {
            "$ref": "#/$defs/agent_packet"
          },
          "presence": {
            "type": "array",
            "maxItems": 8,
            "items": {
              "$ref": "#/$defs/presence_link"
            }
          },
          "work": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "$ref": "#/$defs/work_item"
            }
          }
        }
      }
    }
  }
}
