{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://law.arxo.io/schema/fact-set.schema.json",
  "title": "Arxo Fact Protocol fact set 0.1",
  "description": "The facts of one external record produced by a source mapping: pins of the mapping, the model, and the record bytes; the facts in the host FactInput form with typed model terms and provenance; the record as an evidence item; and a trace of the JSON Pointers each fact was read from. facts and evidence pass unchanged into the facts and evidence of a law_ask call or of the Fact Protocol envelope {pin, facts, evidence, query}; the pin, the query, and the case context belong to the caller. The trace stays outside the facts: FactInput provenance is never extended. The contentHash self-pin excludes its own field; no time or host is stored inside, so equal inputs give equal bytes.", "$comment": "SPEC §74; SPEC §208; DECISION-0396; DECISION-0360",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "mapping",
    "model",
    "record",
    "facts",
    "evidence",
    "trace",
    "contentHash"
  ],
  "properties": {
    "schemaVersion": {
      "const": "law.fact-set/0.1"
    },
    "mapping": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "contentHash"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "contentHash": {
          "$ref": "screen-binding.schema.json#/$defs/Digest"
        }
      }
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "version", "semanticHash"],
      "properties": {
        "name": {
          "$ref": "population-binding.schema.json#/$defs/PackageName"
        },
        "version": {
          "$ref": "population-binding.schema.json#/$defs/Version"
        },
        "semanticHash": {
          "$ref": "screen-binding.schema.json#/$defs/Digest"
        }
      }
    },
    "record": {
      "type": "object",
      "additionalProperties": false,
      "required": ["contentHash"],
      "properties": {
        "contentHash": {
          "description": "sha256 of the exact record bytes.",
          "$ref": "screen-binding.schema.json#/$defs/Digest"
        }
      }
    },
    "facts": {
      "description": "In the order of the mapping's fact entries; within an entry, by the scope instance's entity id compared as bytes — independent of array order in the record.",
      "type": "array",
      "items": {
        "$ref": "evaluation-request.schema.json#/$defs/FactInput"
      }
    },
    "evidence": {
      "description": "Empty when the mapping declares no evidence section, otherwise exactly one item: the record.",
      "type": "array",
      "maxItems": 1,
      "items": {
        "$ref": "legal-ir.schema.json#/$defs/EvidenceItem"
      }
    },
    "trace": {
      "description": "One entry per fact, same order: the mapping fact entry and the absolute JSON Pointers of the values it was read from.",
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["entry", "instance", "pointers"],
        "properties": {
          "entry": {
            "description": "Index of the fact entry in the mapping.",
            "type": "integer",
            "minimum": 0
          },
          "instance": {
            "description": "Absolute pointer of the scope instance.",
            "type": "string"
          },
          "pointers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "contentHash": {
      "$ref": "screen-binding.schema.json#/$defs/Digest"
    }
  }
}
