{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://hai.ai/schemas/header/v1/header.schema.json",
  "title": "Header",
  "description": "The basis for a JACS document",
  "type": "object",
  "properties": {
    "jacsId": {
      "description": "uuid v4 string",
      "type": "string",
      "format": "uuid",
      "hai": "meta"
    },
    "jacsVersion": {
      "description": "Version id of the object. uuid v4 string ",
      "type": "string",
      "format": "uuid",
      "hai": "meta"
    },
    "jacsVersionDate": {
      "description": "Date ",
      "format": "date-time",
      "type": "string",
      "hai": "meta"
    },
    "jacsBranch": {
      "description": "For supporting JACS databases using branch names ",
      "type": "string",
      "format": "uuid",
      "hai": "meta"
    },
    "jacsType": {
      "description": "Type of the document",
      "type": "string",
      "hai": "agent"
    },
    "jacsSignature": {
      "description": "Signature of of every field except this one and the hashing field by the creating/editing agent.",
      "$ref": "https://hai.ai/schemas/components/signature/v1/signature.schema.json"
    },
    "jacsRegistration": {
      "description": "Signature by a sigining authority like https://hai.ai.",
      "$ref": "https://hai.ai/schemas/components/signature/v1/signature.schema.json"
    },
    "jacsAgreement": {
      "description": "Signatures signifying an agreement between agents.",
      "$ref": "https://hai.ai/schemas/components/agreement/v1/agreement.schema.json"
    },
    "jacsAgreementHash": {
      "type": "string",
      "description": "A hash that must not change for each signature. ",
      "hai": "base"
    },
    "jacsPreviousVersion": {
      "description": "Previous Version id of the object. If blank, it's claiming to be the first ",
      "type": "string",
      "format": "uuid",
      "hai": "base"
    },
    "jacsOriginalVersion": {
      "description": "Original Version id of the object.",
      "type": "string",
      "format": "uuid",
      "hai": "meta"
    },
    "jacsOriginalDate": {
      "description": "Original creation date of the document.",
      "type": "string",
      "format": "date-time",
      "hai": "meta"
    },
    "jacsSha256": {
      "description": "Hash of every field except this one. During  updates and creation hash is the last thing to occur, as it includes the signature. Not immediatly required, but eventually required.",
      "type": "string",
      "hai": "base"
    },
    "jacsFiles": {
      "description": "A set of files included with the jacs document",
      "type": "array",
      "items": {
        "$ref": "https://hai.ai/schemas/components/files/v1/files.schema.json"
      }
    },
    "jacsEmbedding": {
      "description": "A set of precalculated vector embeddings ",
      "type": "array",
      "items": {
        "$ref": "https://hai.ai/schemas/components/embedding/v1/embedding.schema.json"
      }
    },
    "jacsLevel": {
      "description": "What is the intended use of the data? Raw data should not change, where as an artifact and config is meant to be updated. ",
      "hai": "meta",
      "type": "string",
      "enum": [
        "raw",
        "config",
        "artifact",
        "derived"
      ]
    },
    "jacsVisibility": {
      "description": "Document visibility level for access control. Controls who can see and access a document through tool responses and API queries. Default is private (safe by default).",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "public",
            "private"
          ]
        },
        {
          "type": "object",
          "properties": {
            "restricted": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 1,
              "description": "Agent IDs or roles that can access this document"
            }
          },
          "required": [
            "restricted"
          ]
        }
      ],
      "default": "private"
    }
  },
  "required": [
    "jacsId",
    "jacsType",
    "jacsVersion",
    "jacsVersionDate",
    "jacsOriginalVersion",
    "jacsOriginalDate",
    "jacsLevel",
    "$schema"
  ]
}
