{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "Artifact": {
      "properties": {
        "bytes": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "type": "object",
      "required": [
        "bytes",
        "type"
      ],
      "description": "Artifact is exact retained content with a selected interpretation: the hash of the bytes and the hash of the interpretation descriptor the bytes are read under (order 0002 D4)."
    },
    "Carriage": {
      "properties": {
        "proof": {
          "$ref": "#/$defs/Proof"
        },
        "grants": {
          "items": {
            "$ref": "#/$defs/Grant"
          },
          "type": "array"
        }
      },
      "type": "object",
      "required": [
        "proof",
        "grants"
      ],
      "description": "Carriage is the proof and the grants a request carries."
    },
    "DeclarationAdmission": {
      "properties": {
        "world": {
          "type": "string"
        },
        "root": {
          "type": "string"
        },
        "space": {
          "$ref": "#/$defs/SpaceRef"
        },
        "path": {
          "$ref": "#/$defs/Path"
        },
        "frame": {
          "type": "string"
        },
        "policy": {
          "type": "string"
        },
        "accepted_at": {
          "type": "string"
        },
        "auth": {
          "$ref": "#/$defs/Carriage"
        },
        "request_body": {
          "type": "string",
          "contentEncoding": "base64"
        },
        "signature": {
          "type": "string"
        }
      },
      "type": "object",
      "required": [
        "world",
        "root",
        "space",
        "path",
        "frame",
        "policy",
        "accepted_at",
        "auth",
        "request_body",
        "signature"
      ],
      "description": "DeclarationAdmission records the world, root, exact destination space and its path at admission, the retained frame manifest, Dawn's admission policy, the accepted instant, the worker's request proof and grants, and the root's signature."
    },
    "DeclareRequest": {
      "properties": {
        "operation_id": {
          "type": "string"
        },
        "artifact": {
          "$ref": "#/$defs/Path"
        },
        "subject": {
          "type": "string"
        },
        "statement": true,
        "evidence": {
          "items": {
            "$ref": "#/$defs/EntryRef"
          },
          "type": "array"
        },
        "justifications": {
          "items": {
            "$ref": "#/$defs/Justification"
          },
          "type": "array"
        },
        "relations": {
          "items": {
            "$ref": "#/$defs/Relation"
          },
          "type": "array"
        }
      },
      "type": "object",
      "required": [
        "operation_id",
        "artifact",
        "statement"
      ],
      "description": "DeclareRequest adds one immutable assertion about an artifact's exact content."
    },
    "EntryRef": {
      "properties": {
        "root_id": {
          "type": "string"
        },
        "space_id": {
          "type": "string"
        },
        "position": {
          "type": "integer"
        }
      },
      "type": "object",
      "required": [
        "root_id",
        "space_id",
        "position"
      ],
      "description": "EntryRef is the occurrence identity of one entry: a position in one journal."
    },
    "Grant": {
      "properties": {
        "principal": {
          "type": "string"
        },
        "kind": {
          "type": "string"
        },
        "path": {
          "$ref": "#/$defs/Path"
        },
        "valid_until": {
          "type": "string"
        },
        "issuer": {
          "type": "string"
        },
        "signature": {
          "type": "string",
          "description": "base64 of the 64 Ed25519 signature bytes over the fact"
        }
      },
      "type": "object",
      "required": [
        "principal",
        "kind",
        "path",
        "valid_until",
        "issuer",
        "signature"
      ],
      "description": "Grant is what a principal carries to prove it may act: a kind on a subtree until an instant, issued by another principal (the root or a delegate)."
    },
    "Justification": {
      "properties": {
        "group": {
          "type": "string"
        },
        "premises": {
          "items": {
            "$ref": "#/$defs/EntryRef"
          },
          "type": "array"
        },
        "method": {
          "type": "string"
        }
      },
      "type": "object",
      "required": [
        "group",
        "premises",
        "method"
      ],
      "description": "Justification joins a group of premises that jointly justify a declaration: each premise becomes one justifies fact, and the group id joins them."
    },
    "Path": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "description": "Path is a location in the world: labels from a root organizer down, relative to the world."
    },
    "Proof": {
      "properties": {
        "principal": {
          "type": "string"
        },
        "nonce": {
          "type": "string"
        },
        "timestamp": {
          "type": "string"
        },
        "audience": {
          "type": "string"
        },
        "signature": {
          "type": "string",
          "description": "base64 of the 64 Ed25519 signature bytes"
        }
      },
      "type": "object",
      "required": [
        "principal",
        "nonce",
        "timestamp",
        "audience",
        "signature"
      ],
      "description": "Proof authenticates one request attempt: the principal, a fresh nonce, the instant, the audience the proof is meant for, and the signature over the signing record."
    },
    "Relation": {
      "properties": {
        "kind": {
          "type": "string"
        },
        "target": {
          "$ref": "#/$defs/EntryRef"
        }
      },
      "type": "object",
      "required": [
        "kind",
        "target"
      ],
      "description": "Relation names a declaration's relation to another occurrence: supersedes, challenges or withdraws."
    },
    "SpaceRef": {
      "properties": {
        "root_id": {
          "type": "string"
        },
        "space_id": {
          "type": "string"
        }
      },
      "type": "object",
      "required": [
        "root_id",
        "space_id"
      ],
      "description": "SpaceRef is the exact identity of one space and its journal, as Journal allocated it."
    }
  },
  "properties": {
    "id": {
      "type": "string"
    },
    "request": {
      "$ref": "#/$defs/DeclareRequest"
    },
    "content": {
      "$ref": "#/$defs/Artifact"
    },
    "publisher": {
      "type": "string"
    },
    "admission": {
      "$ref": "#/$defs/DeclarationAdmission"
    }
  },
  "type": "object",
  "required": [
    "id",
    "request",
    "content",
    "publisher",
    "admission"
  ],
  "title": "DeclarationRecord",
  "description": "DeclarationRecord is the retained envelope of one declaration: the worker's assertion and Dawn's authenticated admission, retained in Bytes and named by its digest in the declaration fact."
}
