{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://answerworthy.md/standard/0.1/schema/answerworthy-manifest.schema.json",
  "title": "Normalized Answerworthy Manifest",
  "description": "Normalized parser output for the Answerworthy Manifest Profile 0.1. The source artifact remains Markdown with YAML front matter.",
  "$comment": "SPDX-License-Identifier: Apache-2.0",
  "type": "object",
  "additionalProperties": false,
  "required": ["answerworthy", "entity", "canonical", "last_verified", "kind", "sections"],
  "properties": {
    "answerworthy": { "const": "0.1" },
    "entity": { "type": "string", "minLength": 1, "maxLength": 500 },
    "canonical": { "type": "string", "format": "uri" },
    "manifest": { "type": "string", "format": "uri" },
    "last_verified": { "type": "string", "format": "date" },
    "kind": { "type": "string", "enum": ["organization", "product", "person", "place", "work", "standard", "other"] },
    "aliases": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1, "maxLength": 500 } },
    "sameas": { "type": "array", "uniqueItems": true, "items": { "type": "string", "format": "uri" } },
    "maintainer": { "type": "string", "minLength": 1, "maxLength": 500 },
    "license": { "type": "string", "minLength": 1, "maxLength": 200 },
    "freshness_days": { "type": "integer", "minimum": 1, "maximum": 3650 },
    "content_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "sections": {
      "type": "object",
      "additionalProperties": false,
      "required": ["identity", "answers"],
      "properties": {
        "identity": { "type": "string", "minLength": 1, "maxLength": 10000 },
        "canonical_facts": { "type": "array", "items": { "$ref": "#/$defs/fact" } },
        "answers": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/answer" } },
        "entities": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 4000 } },
        "provenance": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 4000 } },
        "known_corrections": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 4000 } },
        "coverage_limits": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 4000 } },
        "freshness_policy": { "type": "string", "minLength": 1, "maxLength": 8000 }
      }
    }
  },
  "$defs": {
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["url", "class"],
      "properties": {
        "url": { "type": "string", "format": "uri" },
        "class": { "type": "string", "enum": ["owned", "official", "primary_external", "independent_external", "provider_output", "other"] }
      }
    },
    "fact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "statement", "basis", "sources", "verified_at"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]*$" },
        "statement": { "type": "string", "minLength": 1, "maxLength": 4000 },
        "basis": { "type": "string", "enum": ["declared", "observed", "inferred", "externally_corroborated", "manual_adjudication", "unevaluated"] },
        "sources": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/source" } },
        "verified_at": { "type": "string", "format": "date" },
        "scope": { "type": "object", "additionalProperties": { "type": ["string", "number", "boolean", "null"] } }
      }
    },
    "answer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["question", "answer", "source"],
      "properties": {
        "question": { "type": "string", "minLength": 1, "maxLength": 1000 },
        "answer": { "type": "string", "minLength": 1, "maxLength": 4000 },
        "source": { "type": "string", "format": "uri" }
      }
    }
  }
}