{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "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)."
    },
    "Path": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "description": "Path is a location in the world: labels from a root organizer down, relative to the world."
    },
    "Record": {
      "properties": {
        "entry": {
          "$ref": "#/$defs/EntryRef"
        },
        "profile": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "metadata": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        "publisher": {
          "type": "string"
        },
        "request_id": {
          "type": "string"
        },
        "request_digest": {
          "type": "string"
        },
        "accepted_at": {
          "type": "string"
        }
      },
      "type": "object",
      "required": [
        "entry",
        "profile",
        "hash",
        "metadata",
        "publisher",
        "request_id",
        "request_digest",
        "accepted_at"
      ],
      "description": "Record is one admitted record occurrence: the fact Dawn appended to an individual record's leaf journal under dawn-facts-v2, with the provenance Dawn persists because Journal supplies none."
    },
    "Space": {
      "properties": {
        "root_id": {
          "type": "string"
        },
        "space_id": {
          "type": "string"
        },
        "path": {
          "$ref": "#/$defs/Path"
        }
      },
      "type": "object",
      "required": [
        "root_id",
        "space_id",
        "path"
      ],
      "description": "Space is a space's identity together with its Dawn path: the labels below the world, so a grant by path applies to it."
    },
    "Workspace": {
      "properties": {
        "endpoint": {
          "type": "string"
        },
        "audience": {
          "type": "string"
        },
        "principal": {
          "type": "string"
        },
        "project": {
          "type": "string"
        },
        "worker": {
          "type": "string"
        },
        "path": {
          "$ref": "#/$defs/Path"
        }
      },
      "type": "object",
      "required": [
        "endpoint",
        "audience",
        "principal",
        "project",
        "worker",
        "path"
      ],
      "description": "Workspace is what a prepared directory needs to know: the endpoint, the audience its proofs name, its principal and its path; never a backend."
    }
  },
  "properties": {
    "space": {
      "$ref": "#/$defs/Space"
    },
    "state": {
      "$ref": "#/$defs/Record"
    },
    "grants": {
      "items": {
        "$ref": "#/$defs/Grant"
      },
      "type": "array"
    },
    "workspace": {
      "$ref": "#/$defs/Workspace"
    },
    "replayed": {
      "type": "boolean"
    }
  },
  "type": "object",
  "required": [
    "space",
    "state",
    "grants",
    "workspace",
    "replayed"
  ],
  "title": "ProvisionWorkerResult",
  "description": "ProvisionWorkerResult is the worker's space, its initial state record, the grants and the workspace material."
}
