{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/relations.json",
  "title": "Relation edge document",
  "description": "The document served at /api/v1/relations.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "relations"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every relation edge this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Relation edge",
      "description": "One edge between two documents, in one of two classes named by `via`. `publisher-stated` is a succession the publisher itself states, quoted from a retained artifact. `citation` is one tracked document's retained text carrying a form another is published under, and its quote and its own limit are served at the citations endpoint named on the row. Neither class is a claim that two documents satisfy or cover each other.",
      "properties": {
        "licence_class": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "open",
            "restricted",
            "unknown",
            null
          ],
          "description": "What this archive recorded of the terms the source states. Null where no reading exists for this object. See `rights` on the envelope."
        },
        "text_retained": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether normalised prose of the document is held here for a quotation to be checked against. Held, never served. Null where no reading exists."
        },
        "quote_allowed": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether a quotation from the document appears in this record's own published output. A fact about this record's handling, not a reading of what the publisher permits, and not a grant. Null where no reading exists."
        },
        "snapshot_available": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether a retained snapshot of an observed retrieval is still held here for a digest to be re-checked against. No snapshot is served. Null where no reading exists."
        },
        "rights_of": {
          "type": [
            "string",
            "null"
          ],
          "description": "The tracked entry id the four fields above are the rights OF. Null where the object names no entry."
        },
        "rights_unresolved": {
          "type": [
            "string",
            "null"
          ],
          "description": "Present only where the four fields are null, naming which absence it is: an id this record does not hold, or an object that names no entry."
        },
        "source": {
          "type": "object",
          "description": "The tracked entry this object is about, its state, and where it resolves on this site. `state` is one of `tracked` (this record holds the entry), `not-tracked` (an id is named and this record holds no entry under it) or `no-subject` (the object names no entry, so no lookup applies). `resolves_to` carries an address only where the state is `tracked`; a minted address for an untracked id would 404, and a consumer cannot tell a 404 from a deploy that dropped a file."
        },
        "observed_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day THIS RECORD observed the fact this object carries, at day granularity. It is never a publisher's own date for an event and never a build clock. Null where no such day was read."
        },
        "observed_at_state": {
          "type": "string",
          "enum": [
            "recorded",
            "not-carried",
            "not-an-observation"
          ],
          "description": "Which of the two absences a null `observed_at` is. `not-carried`: this object is a record about something observable and carries no day for when this record read it. `not-an-observation`: this object is not a record of a retrieval at all — a corpus summary, a coverage term — so no day is missing from it. Opposite facts, one blank."
        },
        "observed_at_read_from": {
          "type": [
            "string",
            "null"
          ],
          "description": "The key on the emitting store `observed_at` was read from, so the value can be checked against the store rather than trusted. Null only where the state is `not-an-observation`, which is the one case with no field to name."
        },
        "distance": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "description": "Distance from the source on the filed scale — 0 primary, 1 official notice, 2 official related record, 3 third-party. Defined for signals only. Null on every other object, and a null is NOT zero: zero is the strongest claim the scale makes."
        },
        "distance_label": {
          "type": [
            "string",
            "null"
          ],
          "description": "The scale's own word for `distance`, read from the one home that holds the scale. Null where no distance was read, and null where the record's own label disagrees with the scale — a disagreement is withheld rather than reconciled, because neither side adjudicates the other."
        },
        "distance_state": {
          "type": "string",
          "enum": [
            "recorded",
            "unmeasured",
            "field-absent",
            "out-of-scale",
            "label-disagrees",
            "not-a-signal"
          ],
          "description": "Which reading produced `distance`. `not-a-signal`: this object has no position on the scale. `field-absent`: the record carries no distance key. `unmeasured`: the key is present and null — the entry declared no address to measure from. `out-of-scale`: the record's value is not a member of the scale, so no value is published. `label-disagrees`: the value IS a member and the record's own label is not the scale's word for it, so the value is published and the LABEL is withheld — the two are different withholdings and one sentence covering both said the value was withheld in a case where it is served."
        },
        "via": {
          "type": "string",
          "enum": [
            "publisher-stated",
            "citation"
          ],
          "description": "Which class this edge is. Merging the two would erase the only thing that tells a consumer which claim it is holding."
        },
        "from": {
          "type": [
            "string",
            "null"
          ],
          "description": "The entry whose retained text the edge was read from."
        },
        "to": {
          "type": [
            "string",
            "null"
          ],
          "description": "The entry the edge names, or null where the publisher names a document this record does not track."
        },
        "to_designator": {
          "type": [
            "string",
            "null"
          ],
          "description": "The publisher's own string for the named document, carried whether or not it resolves here."
        },
        "relation": {
          "type": [
            "string",
            "null"
          ],
          "description": "The succession verb the publisher used. Null on a citation edge, which asserts no succession."
        },
        "relation_provenance": {
          "type": [
            "string",
            "null"
          ],
          "description": "Whose act the succession was read from: `publisher_stated` (a sentence in the document's own retained text) or `publisher_listed` (a labelled field on the publisher's own page). There is deliberately no value meaning derived here."
        },
        "evidence_ref": {
          "type": [
            "string",
            "null"
          ],
          "description": "The retained artifact in this repository the quote was read from. It is a repository path and not a served address: no snapshot is served."
        },
        "citation_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "The publisher surface the statement was read at."
        },
        "observed_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day the statement or the citing text was observed here."
        },
        "stated_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "Where the publisher's own words for this edge are published. NO QUOTE SHIPS ON THIS ENDPOINT: a published quote owes a fidelity surface that asserts the span against the bytes it names, and this endpoint has none, so the value is withheld and its address is named instead. For a succession that is the entry's own page; for a citation it is the citations endpoint, which carries the quote and the class's own limit."
        },
        "to_text_retained": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "The NAMED entry's retention position. The unprefixed rights fields are the citing entry's."
        },
        "to_licence_class": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "open",
            "restricted",
            "unknown",
            null
          ],
          "description": "The named entry's terms position."
        },
        "to_quote_allowed": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether a quotation from the named entry appears in this record's own output."
        },
        "to_snapshot_available": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether a retained snapshot of the named entry is still held here."
        },
        "to_rights_of": {
          "type": [
            "string",
            "null"
          ],
          "description": "The entry the `to_`-prefixed fields are the rights of."
        },
        "to_rights_unresolved": {
          "type": [
            "string",
            "null"
          ],
          "description": "Present only where the `to_` fields are null, naming which absence it is."
        }
      },
      "required": [
        "via",
        "from",
        "to",
        "to_designator",
        "relation",
        "stated_at",
        "licence_class",
        "text_retained",
        "quote_allowed",
        "snapshot_available",
        "rights_of",
        "source",
        "observed_at",
        "observed_at_state",
        "observed_at_read_from",
        "distance",
        "distance_label",
        "distance_state"
      ],
      "additionalProperties": true
    }
  }
}
