{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://veganism.wiki/schema/node.json",
  "title": "veganism.wiki graph node",
  "description": "Schema for any publishable node on veganism.wiki. Every article, person, sanctuary, business, and future entity type conforms to this base. Agents contributing content (e.g. via Paperclip-orchestrated workflows) should produce MDX files whose YAML frontmatter validates against this schema plus the per-type extension.",
  "type": "object",
  "required": ["title", "summary", "pillar"],
  "properties": {
    "title": {
      "type": "string",
      "description": "Canonical name of the node. Sentence case; proper nouns preserved."
    },
    "summary": {
      "type": "string",
      "description": "Single-sentence summary. Displayed in listings, search, and as meta description.",
      "minLength": 10,
      "maxLength": 260
    },
    "pillar": {
      "type": "string",
      "enum": ["nutrition", "ethics", "environment", "health", "history", "recipes", "activism", "animals", "products", "people", "science", "culture", "business", "sanctuary", "media", "events"]
    },
    "tags": { "type": "array", "items": { "type": "string" }, "default": [] },
    "aliases": { "type": "array", "items": { "type": "string" }, "default": [] },
    "relations": {
      "type": "array",
      "description": "Typed edges from this node to other nodes in the graph.",
      "items": {
        "type": "object",
        "required": ["type", "target"],
        "properties": {
          "type": {
            "type": "string",
            "enum": ["related-to", "part-of", "contains", "alternative-to", "contradicts", "supports", "causes", "caused-by", "source-of", "derived-from", "founded-by", "founder-of", "located-in", "affiliated-with", "hosts", "hosted-at", "produces", "produced-by", "sells", "sold-by", "rescues", "rescued-by", "advocates-for", "writes-about"]
          },
          "target": {
            "type": "string",
            "description": "Either a bare slug (e.g. 'veganism' — auto-resolved) or a fully-qualified 'collection/slug' (e.g. 'people/donald-watson').",
            "pattern": "^[a-z0-9][a-z0-9-]*(/[a-z0-9][a-z0-9-]*)?$"
          },
          "note": { "type": "string" }
        }
      },
      "default": []
    },
    "sources": {
      "type": "array",
      "description": "Citations supporting the claims on this page. Strongly encouraged for every factual article.",
      "items": {
        "type": "object",
        "properties": {
          "title": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "note": { "type": "string" }
        }
      },
      "default": []
    },
    "authors": { "type": "array", "items": { "type": "string" }, "default": [] },
    "authored_by": {
      "type": "string",
      "enum": ["ai", "human", "ai+human"],
      "default": "ai",
      "description": "Provenance. Shown as a visible badge on every page."
    },
    "created": { "type": "string", "format": "date" },
    "updated": { "type": "string", "format": "date" },
    "draft": { "type": "boolean", "default": false }
  },
  "allOf": [
    {
      "description": "Per-type extensions. The MDX file's parent directory determines the collection and which extension applies.",
      "oneOf": [
        {
          "title": "article",
          "type": "object"
        },
        {
          "title": "sanctuary",
          "type": "object",
          "properties": {
            "location": {
              "type": "object",
              "required": ["country"],
              "properties": {
                "city": { "type": "string" },
                "region": { "type": "string" },
                "country": { "type": "string" },
                "lat": { "type": "number" },
                "lon": { "type": "number" }
              }
            },
            "founded": { "type": "integer" },
            "website": { "type": "string", "format": "uri" },
            "residents": { "type": "array", "items": { "type": "string" } },
            "accepting_visitors": { "type": "boolean" },
            "donation_url": { "type": "string", "format": "uri" }
          }
        },
        {
          "title": "business",
          "type": "object",
          "required": ["kind"],
          "properties": {
            "kind": { "type": "string", "enum": ["restaurant", "brand", "retailer", "service", "media", "other"] },
            "website": { "type": "string", "format": "uri" },
            "location": {
              "type": "object",
              "properties": {
                "city": { "type": "string" },
                "region": { "type": "string" },
                "country": { "type": "string" }
              }
            },
            "founded": { "type": "integer" },
            "certifications": { "type": "array", "items": { "type": "string" } }
          }
        },
        {
          "title": "person",
          "type": "object",
          "properties": {
            "born": { "type": "string", "format": "date" },
            "died": { "type": "string", "format": "date" },
            "nationality": { "type": "string" },
            "roles": { "type": "array", "items": { "type": "string" } },
            "website": { "type": "string", "format": "uri" }
          }
        }
      ]
    }
  ]
}
