{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.michaeldariuseastwood.com/schemas/ai-ingestion-manifest.schema.json",
  "title": "AI-ingestion manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "manifestId",
    "dateModified",
    "buildId",
    "canonicalSite",
    "policy",
    "guarantee",
    "licence",
    "sourceDigests",
    "summary",
    "files",
    "topics",
    "quarantine",
    "routes",
    "resources"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "manifestId": {
      "type": "string",
      "minLength": 1
    },
    "dateModified": {
      "type": "string",
      "format": "date"
    },
    "buildId": {
      "type": "string",
      "pattern": "^urn:sha256:[a-f0-9]{64}$"
    },
    "canonicalSite": {
      "type": "string",
      "format": "uri"
    },
    "policy": {
      "type": "string",
      "minLength": 1
    },
    "guarantee": {
      "type": "string",
      "minLength": 1
    },
    "licence": {
      "type": "object",
      "required": [
        "id",
        "name",
        "url",
        "attribution"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "appliesTo": {
          "type": "string",
          "minLength": 1
        },
        "attribution": {
          "type": "string",
          "minLength": 1
        },
        "excluded": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "sourceDigests": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "string",
        "pattern": "^[a-f0-9]{64}$"
      }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "approvedRoutes",
        "resources",
        "topicShards",
        "correctionRecords",
        "quarantinedAssertions"
      ],
      "properties": {
        "approvedRoutes": {
          "type": "integer",
          "minimum": 1
        },
        "resources": {
          "type": "integer",
          "minimum": 1
        },
        "topicShards": {
          "type": "integer",
          "minimum": 1
        },
        "correctionRecords": {
          "type": "integer",
          "minimum": 1
        },
        "quarantinedAssertions": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "hosting": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "provider",
        "publicationBoundary"
      ],
      "properties": {
        "provider": {
          "const": "Netlify"
        },
        "publicationBoundary": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "files": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/file"
      }
    },
    "topics": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/topic"
      }
    },
    "quarantine": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "registerId",
        "appliedEntryIds",
        "correctionEntryIds"
      ],
      "properties": {
        "registerId": {
          "type": "string",
          "minLength": 1
        },
        "appliedEntryIds": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^AQ-[0-9]{3}$"
          }
        },
        "correctionEntryIds": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^AQ-[0-9]{3}$"
          }
        }
      }
    },
    "routes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/route"
      }
    },
    "resources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/resource"
      }
    }
  },
  "$defs": {
    "evidenceDensity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "requiredNamedQuotations",
        "requiredDatedStatistics",
        "requiredInlineCitations"
      ],
      "properties": {
        "requiredNamedQuotations": {
          "type": "integer",
          "minimum": 0
        },
        "requiredDatedStatistics": {
          "type": "integer",
          "minimum": 0
        },
        "requiredInlineCitations": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "file": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path",
        "url",
        "bytes",
        "sha256",
        "topics"
      ],
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "bytes": {
          "type": "integer",
          "minimum": 1
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "topics": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "topic": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "path",
        "url",
        "keywords",
        "resourceIds"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "path": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "keywords": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "resourceIds": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "route": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "route",
        "canonicalUrl",
        "routeClass",
        "schemaType",
        "evidenceDensity",
        "resourceIds"
      ],
      "properties": {
        "route": {
          "type": "string",
          "pattern": "^/"
        },
        "canonicalUrl": {
          "type": "string",
          "format": "uri"
        },
        "routeClass": {
          "type": "string",
          "minLength": 1
        },
        "schemaType": {
          "type": [
            "string",
            "null"
          ]
        },
        "evidenceDensity": {
          "$ref": "#/$defs/evidenceDensity"
        },
        "resourceIds": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "resource": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "resourceId",
        "title",
        "url",
        "route",
        "routeClass",
        "resourceType",
        "datePublished",
        "dateModified",
        "doi",
        "status",
        "relatedResourceIds",
        "source",
        "topics"
      ],
      "properties": {
        "resourceId": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "route": {
          "type": "string",
          "pattern": "^/"
        },
        "routeClass": {
          "type": "string",
          "minLength": 1
        },
        "resourceType": {
          "type": "string",
          "minLength": 1
        },
        "datePublished": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "dateModified": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "doi": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "relatedResourceIds": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "source": {
          "enum": [
            "citation-authority",
            "authority-graph",
            "page-contract"
          ]
        },
        "topics": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "capsule": {
          "type": "string",
          "minLength": 20,
          "maxLength": 400,
          "description": "One or two sentences taken from the page itself, used as the record's answer capsule and fed into the retrieval index. Absent where the page yields no prose that reads as an answer, or where the extracted text carried quarantined wording and was withheld."
        },
        "evidence": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "namedQuotations",
            "datedStatistics",
            "inlineCitations"
          ],
          "description": "Evidence actually measured on the page, not thresholds declared for it.",
          "properties": {
            "namedQuotations": {
              "type": "integer",
              "minimum": 0
            },
            "datedStatistics": {
              "type": "integer",
              "minimum": 0
            },
            "inlineCitations": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      }
    }
  }
}
