{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://srcw-spec.org/spec/0.1/spec.json",
  "title": "Source-Recognized Citation Watermark Entry",
  "description": "Machine-readable entry format for the SRCW protocol, version 0.1.",
  "oneOf": [
    {
      "$ref": "#/$defs/pattern"
    },
    {
      "$ref": "#/$defs/citation_record"
    }
  ],
  "$defs": {
    "spec": {
      "const": "https://srcw-spec.org/spec/0.1/spec.json"
    },
    "selector": {
      "type": "string",
      "description": "A period-separated sequence of sentence groups. Dashes separate one-indexed character positions within a sentence. An empty group skips a sentence.",
      "pattern": "^[1-9][0-9]*(?:-[1-9][0-9]*)*(?:\\.(?:[1-9][0-9]*(?:-[1-9][0-9]*)*)?)*$"
    },
    "register_at": {
      "type": "string",
      "description": "An email address or HTTPS endpoint at which a publisher may register a page.",
      "oneOf": [
        {
          "format": "email"
        },
        {
          "format": "uri",
          "pattern": "^https://"
        }
      ]
    },
    "pattern": {
      "type": "object",
      "required": [
        "spec",
        "pattern",
        "attestation_selector",
        "payload_rule",
        "reuse",
        "register_at"
      ],
      "properties": {
        "spec": {
          "$ref": "#/$defs/spec"
        },
        "pattern": {
          "type": "string",
          "minLength": 1
        },
        "attestation_selector": {
          "$ref": "#/$defs/selector"
        },
        "payload_rule": {
          "const": "sha256-letters"
        },
        "reuse": {
          "const": "public"
        },
        "register_at": {
          "$ref": "#/$defs/register_at"
        }
      },
      "additionalProperties": false
    },
    "referencing_url": {
      "type": "object",
      "required": [
        "url",
        "verified"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "verified": {
          "type": "string",
          "format": "date"
        }
      },
      "additionalProperties": false
    },
    "citation_record": {
      "type": "object",
      "required": [
        "spec",
        "pattern",
        "payload",
        "cites",
        "referencing_urls"
      ],
      "properties": {
        "spec": {
          "$ref": "#/$defs/spec"
        },
        "pattern": {
          "type": "string",
          "minLength": 1
        },
        "payload": {
          "type": "string",
          "pattern": "^[a-z]+$",
          "description": "The lowercase letters derived from the cited document."
        },
        "cites": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://",
          "description": "Canonical URL of the document from which the payload was derived; a fragment identifier may identify a passage."
        },
        "referencing_urls": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/referencing_url"
          }
        }
      },
      "additionalProperties": false
    }
  },
  "examples": [
    {
      "spec": "https://srcw-spec.org/spec/0.1/spec.json",
      "pattern": "exampleA-v1",
      "attestation_selector": "1-4-12.31-5",
      "payload_rule": "sha256-letters",
      "reuse": "public",
      "register_at": "attestation@exampleA.com"
    },
    {
      "spec": "https://srcw-spec.org/spec/0.1/spec.json",
      "pattern": "exampleA-v1",
      "payload": "psahs",
      "cites": "https://exampleA.com/reports/result-17",
      "referencing_urls": [
        {
          "url": "https://exampleB.com/analysis/result-17",
          "verified": "2026-08-21"
        },
        {
          "url": "https://exampleD.com/weekly-roundup",
          "verified": "2026-08-30"
        }
      ]
    }
  ]
}
