{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://earncitations.com/schemas/fact-ledger-0.1.json",
  "title": "Fact Ledger v0.1",
  "description": "Signed, evidence-linked facts about a business, published at /.well-known/facts.json. Spec: https://earncitations.com/ledger.html. Semantic rules not expressible here (no instructions to AI in claims, superlatives warned, correctFact must reference a fact id, signature verification) are enforced by the reference validator.",
  "type": "object",
  "required": [
    "version",
    "subject",
    "issued",
    "facts"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "version": {
      "const": "0.1"
    },
    "subject": {
      "type": "object",
      "required": [
        "name",
        "url"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://"
        },
        "type": {
          "type": "string",
          "description": "schema.org type, e.g. Organization, LocalBusiness, SoftwareApplication"
        },
        "description": {
          "type": "string"
        },
        "logo": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://"
        },
        "sameAs": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "pattern": "^https?://"
          }
        }
      }
    },
    "issued": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T[\\d:.]+(Z|[+-]\\d{2}:\\d{2}))?$"
    },
    "facts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "claim",
          "evidence"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"
          },
          "claim": {
            "type": "string",
            "minLength": 1,
            "maxLength": 280,
            "description": "One quotable, verifiable sentence. Data, not instructions."
          },
          "category": {
            "enum": [
              "identity",
              "offering",
              "pricing",
              "location",
              "hours",
              "contact",
              "people",
              "policy",
              "metric",
              "integration",
              "compliance",
              "other"
            ]
          },
          "value": {
            "description": "Optional machine-readable value (number, string or object)."
          },
          "evidence": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "pattern": "^https?://"
            },
            "description": "Public pages a human can check the claim against."
          },
          "validFrom": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T[\\d:.]+(Z|[+-]\\d{2}:\\d{2}))?$"
          },
          "validUntil": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T[\\d:.]+(Z|[+-]\\d{2}:\\d{2}))?$"
          }
        }
      }
    },
    "corrections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "incorrect"
        ],
        "properties": {
          "incorrect": {
            "type": "string",
            "description": "The false statement AI keeps repeating."
          },
          "correctFact": {
            "type": "string",
            "description": "id of the fact that corrects it."
          },
          "seenIn": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "firstSeen": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T[\\d:.]+(Z|[+-]\\d{2}:\\d{2}))?$"
          }
        }
      }
    },
    "signature": {
      "type": "object",
      "required": [
        "alg",
        "canonicalization",
        "keyId",
        "publicKey",
        "sig"
      ],
      "properties": {
        "alg": {
          "const": "Ed25519"
        },
        "canonicalization": {
          "const": "JCS"
        },
        "keyId": {
          "type": "string",
          "pattern": "^ed25519:"
        },
        "publicKey": {
          "type": "string"
        },
        "keyUrl": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://"
        },
        "sig": {
          "type": "string",
          "description": "base64url Ed25519 signature over the JCS canonical form of the document without signature."
        }
      }
    }
  }
}
