{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://universalpaper.org/research/schema/0/query-trace.schema.json",
  "title": "Query trace (up-research/query-trace/0)",
  "description": "One answer from an engine call: the inputs, the state fingerprint of every agreement read, and the verdict. Two parties who compute the same content hash for a trace hold the same question, inputs, state and verdict. A trace may answer a question named in a manifest, or stand alone. 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",
    "call",
    "inputs",
    "state",
    "verdict"
  ],
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": "up-research/query-trace/0"
    },
    "spec": {
      "type": "string",
      "minLength": 1
    },
    "simulated": {
      "type": "boolean"
    },
    "manifest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$",
      "description": "The fingerprint of the manifest the question came from, when it came from one."
    },
    "question": {
      "type": "string",
      "minLength": 1,
      "description": "The id of the question in that manifest."
    },
    "asks": {
      "type": "string",
      "minLength": 1,
      "description": "The question in plain words, for a trace that does not come from a manifest."
    },
    "reads": {
      "type": "object",
      "description": "For a call that returns a whole state, the part the verdict holds, when no manifest says so."
    },
    "call": {
      "enum": [
        "validate_bundle",
        "derive_state",
        "check_event",
        "simulate_events",
        "simulate_amendment",
        "simulate_price_conformity",
        "simulate_termination",
        "simulate_eligibility"
      ]
    },
    "inputs": {
      "type": "object",
      "required": [
        "at"
      ],
      "properties": {
        "at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "description": "Every argument the call was given, including the time. Chains are named by ChainId, never by position."
    },
    "state": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "chain",
          "fingerprint"
        ],
        "additionalProperties": false,
        "properties": {
          "chain": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          },
          "fingerprint": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$",
            "description": "The state_hash that derive_state returns for the chain."
          }
        }
      },
      "minItems": 1
    },
    "verdict": {
      "type": "object",
      "description": "The values the call returned that the specification determines."
    }
  }
}
