{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://universalpaper.org/research/schema/0/query-manifest.schema.json",
  "title": "Query manifest (up-research/query-manifest/0)",
  "description": "An optional file beside an agreement that names the questions the agreement will answer. It adds no Term, Event kind or required field, and an agreement without one is exactly as valid. See https://universalpaper.org/research/query-surfaces/. Research is not part of the Universal Paper language. These formats may change or be withdrawn, and no agreement depends on them.",
  "type": "object",
  "required": [
    "format",
    "spec",
    "agreement",
    "questions"
  ],
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": "up-research/query-manifest/0"
    },
    "spec": {
      "type": "string",
      "minLength": 1,
      "description": "The version of the language the agreement is written in."
    },
    "status": {
      "const": "research"
    },
    "simulated": {
      "type": "boolean"
    },
    "note": {
      "type": "string",
      "minLength": 1
    },
    "agreement": {
      "type": "object",
      "required": [
        "chain",
        "fingerprint"
      ],
      "additionalProperties": false,
      "properties": {
        "chain": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$",
          "description": "The ChainId."
        },
        "fingerprint": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$",
          "description": "The content hash of the agreement in force."
        },
        "label": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "source": {
      "type": "object"
    },
    "named_by": {
      "type": "object",
      "required": [
        "role",
        "key"
      ],
      "additionalProperties": false,
      "properties": {
        "role": {
          "type": "string",
          "minLength": 1
        },
        "key": {
          "type": "string",
          "pattern": "^ed25519:[0-9a-f]{64}$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "questions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "asks",
          "call",
          "fixed",
          "open"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
          },
          "asks": {
            "type": "string",
            "minLength": 1,
            "description": "The question in plain words."
          },
          "call": {
            "enum": [
              "validate_bundle",
              "derive_state",
              "check_event",
              "simulate_events",
              "simulate_amendment",
              "simulate_price_conformity",
              "simulate_termination",
              "simulate_eligibility"
            ],
            "description": "An engine call that already exists. A manifest cannot define a new one."
          },
          "fixed": {
            "type": "object",
            "description": "Arguments the manifest pins. Agreements are named by ChainId."
          },
          "open": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true,
            "description": "Arguments the asker supplies, such as the member and the time."
          },
          "reads": {
            "type": "object",
            "description": "For a call that returns a whole state, the part that answers the question."
          }
        }
      },
      "minItems": 1
    },
    "sigs": {
      "type": "array",
      "description": "Signatures, in the form the language already uses. Left out of the fingerprint, as everywhere else."
    }
  }
}
