{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/candidates.json",
  "title": "Revision candidate document",
  "description": "The document served at /api/v1/candidates.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "candidates"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every revision candidate this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Revision candidate",
      "description": "One difference detected between two observations of a tracked entry, with the verdict the nightly placed it in, the result of each limb of the triple, the evidence the record names as lacking, the witness fields and the entry's rights. Nothing is placed by the endpoint.",
      "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."
        },
        "candidate_id": {
          "type": "string",
          "description": "The candidate, named by its entry and the day of its later observation."
        },
        "instrument_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "The tracked entry the candidate was detected on."
        },
        "url": {
          "type": "string",
          "description": "The candidate's page on this site."
        },
        "before_observed": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day of the earlier observation of the pair."
        },
        "after_observed": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day of the later observation of the pair."
        },
        "digest_before": {
          "type": [
            "string",
            "null"
          ],
          "description": "The digest of the earlier observation's normalised text."
        },
        "digest_after": {
          "type": [
            "string",
            "null"
          ],
          "description": "The digest of the later observation's normalised text."
        },
        "verdict": {
          "type": "object",
          "description": "As the verdict file holds it: `placed` (false where the file holds no row, with every other field null), `state`, `basis`, `rule_version`, `class`, `cause`, `detail`, `needs`, `findings` (each limb that did not pass, with its state, class and detail), `model_read`, `model_read_receipt`, `reproducible` (false where a model read is recorded as not reproducible), `witness_address` (where a witness confirmation wrote one), `statements` (a publisher-stated confirmation's notes, each its `source`, `basis`, `instrument_id`, `field`, `surface`, `surface_name`, `store`, `day`, `day_rule` and `text_sha256`, never its text; null where the row holds none), `window` (the closed window `from` and `to` the notes were placed in, or null), `triple` (what the triple placed, kept beside a publisher-stated confirmation, or null), and `read_from`."
        },
        "limbs_read": {
          "type": "boolean",
          "description": "False where the triple projection holds no row for the candidate."
        },
        "limbs": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object"
          },
          "description": "Each limb in the projection's order, with `limb`, `verdict`, `why` and `flags` (every flag the limb states about itself, under its own name, as stored). Null where `limbs_read` is false."
        },
        "limbs_not_in_projection": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          },
          "description": "Limb names some candidate carries and this one does not. Null where `limbs_read` is false."
        },
        "missing_evidence": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object"
          },
          "description": "One entry per field naming an absence of evidence, with `limb`, `field`, `value`, `why` and `read_from`; the fields read are listed in the envelope's `missing_evidence_rule`. Empty where they name no lack; null where `limbs_read` is false."
        },
        "witness": {
          "type": "object",
          "description": "`witness`, `witness_address` and `offered_as_witness_change` as the projection holds them, and `confirmation_subject`, the verdict's `subject`. Each null where its file holds no row; `witness` and `offered_as_witness_change` are also null where the stored value is not a boolean."
        },
        "confirm_gate": {
          "type": "object",
          "description": "The screen's verdict and the confirm gate's reading as `state/rescreen.json` holds them and the candidate page renders them: `read` (false where the file holds no row, with every other field null), `verdict`, `rule`, `outcome`, `eliminated_by`, `elements` (each with its `key` and `state`; what was measured and what would settle it are rendered on the candidate page) and `read_from`."
        }
      },
      "required": [
        "candidate_id",
        "instrument_id",
        "url",
        "before_observed",
        "after_observed",
        "digest_before",
        "digest_after",
        "verdict",
        "limbs_read",
        "limbs",
        "limbs_not_in_projection",
        "missing_evidence",
        "witness",
        "confirm_gate",
        "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
    }
  }
}
