{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Intentrail Mission Anchor Envelope",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "kind",
    "version",
    "mode",
    "scope",
    "status",
    "createdAt",
    "receipt",
    "observer",
    "signature",
    "anchor",
    "transactionHash",
    "blockNumber",
    "claims",
    "note",
    "envelopeDigest"
  ],
  "properties": {
    "kind": { "const": "intentrail.mission-anchor-envelope" },
    "version": { "const": "1.0" },
    "mode": { "enum": ["local", "wallet-observed"] },
    "scope": { "const": "digest-reference-only" },
    "status": { "const": "not-submitted" },
    "createdAt": { "type": "string", "format": "date-time" },
    "receipt": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "version",
        "receiptDigest",
        "manifestDigest",
        "runStatus"
      ],
      "properties": {
        "kind": { "const": "intentrail.mission-run-receipt" },
        "version": { "const": "1.0" },
        "receiptDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "manifestDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "runStatus": { "enum": ["completed", "stopped"] }
      }
    },
    "observer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["address", "chainId"],
      "properties": {
        "address": {
          "oneOf": [
            { "type": "string", "pattern": "^0x[a-f0-9]{40}$" },
            { "type": "null" }
          ]
        },
        "chainId": {
          "oneOf": [
            { "type": "string", "pattern": "^0x[1-9a-f][a-f0-9]*$" },
            { "type": "null" }
          ]
        }
      }
    },
    "signature": { "const": null },
    "anchor": { "const": null },
    "transactionHash": { "const": null },
    "blockNumber": { "const": null },
    "claims": {
      "type": "object",
      "additionalProperties": false,
      "required": ["signed", "broadcast", "confirmed"],
      "properties": {
        "signed": { "const": false },
        "broadcast": { "const": false },
        "confirmed": { "const": false }
      }
    },
    "note": {
      "const": "Prepared locally as an unsigned, unbroadcast digest reference. It is not a signature, transaction, confirmation, ownership record, proof of physical execution, or safety certification."
    },
    "envelopeDigest": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    }
  }
}
