{
  "$id": "https://git-span.com/schemas/cli/v1/history.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "HistoryDocument",
  "description": "Root document of `history --format json`.",
  "type": "object",
  "properties": {
    "commits": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/HistoryCommitDoc"
      }
    },
    "current": {
      "anyOf": [
        {
          "$ref": "#/$defs/CurrentDoc"
        },
        {
          "type": "null"
        }
      ]
    },
    "schema_version": {
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "scoped": {
      "description": "Present (as `true`) only when the timeline is a `--limit`-scoped\nwindow, matching the hand-built era's insert-if-true emission.\n`Option`-shaped so the schema marks the key optional — schemars\ncannot see `skip_serializing_if` and would otherwise require it.",
      "type": [
        "boolean",
        "null"
      ]
    },
    "span": {
      "type": "string"
    }
  },
  "additionalProperties": false,
  "required": [
    "commits",
    "schema_version",
    "span"
  ],
  "$defs": {
    "CommitAnchorDoc": {
      "description": "One timeline anchor: exactly one of `content`/`diff` is present —\n`content` replaces `diff` on a first-add whose snapshot text was\nextractable. Modeled as a one-of so the schema states the exclusion;\nthe current-anchor shape below deliberately does not share it.",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "content": {
              "type": "string"
            },
            "path": {
              "type": "string"
            },
            "rebound": {
              "anyOf": [
                {
                  "$ref": "#/$defs/ReboundDoc"
                },
                {
                  "type": "null"
                }
              ]
            },
            "unavailable": {
              "anyOf": [
                {
                  "$ref": "#/$defs/UnavailableDoc"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "content",
            "path"
          ]
        },
        {
          "type": "object",
          "properties": {
            "diff": {
              "type": "string"
            },
            "path": {
              "type": "string"
            },
            "rebound": {
              "anyOf": [
                {
                  "$ref": "#/$defs/ReboundDoc"
                },
                {
                  "type": "null"
                }
              ]
            },
            "unavailable": {
              "anyOf": [
                {
                  "$ref": "#/$defs/UnavailableDoc"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "diff",
            "path"
          ]
        }
      ]
    },
    "CurrentAnchorDoc": {
      "description": "The current-drift anchor shape: `diff` always present, `content` optional\n— the commit-anchor one-of deliberately does not leak here.",
      "type": "object",
      "properties": {
        "content": {
          "type": [
            "string",
            "null"
          ]
        },
        "diff": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "proposed": {
          "type": [
            "string",
            "null"
          ]
        },
        "recorded": {
          "anyOf": [
            {
              "$ref": "#/$defs/RecordedDoc"
            },
            {
              "type": "null"
            }
          ]
        },
        "sources": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/SourceDoc"
          }
        },
        "unavailable": {
          "anyOf": [
            {
              "$ref": "#/$defs/UnavailableDoc"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "diff",
        "path"
      ]
    },
    "CurrentDoc": {
      "type": "object",
      "properties": {
        "anchors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CurrentAnchorDoc"
          }
        },
        "span_diff": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "anchors"
      ]
    },
    "HistoryCommitDoc": {
      "type": "object",
      "properties": {
        "anchors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CommitAnchorDoc"
          }
        },
        "date": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "span_diff": {
          "type": [
            "string",
            "null"
          ]
        },
        "summary": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "anchors",
        "date",
        "hash",
        "summary"
      ]
    },
    "ReboundDoc": {
      "description": "The structured form discriminator of a `rebound anchor` block — its\npresence *is* \"this is the rebound block\", so a consumer never has to\nparse the patch string to tell the two blocks at one address apart.",
      "type": "object",
      "properties": {
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "from",
        "to"
      ]
    },
    "RecordedDoc": {
      "description": "The `recorded` marker: present exactly when no snapshot in the render's\nsnapshot set hashes to the declaration's recorded token.",
      "type": "string",
      "enum": [
        "unrecoverable"
      ]
    },
    "SourceDoc": {
      "description": "The three layer strings, as published on `drift` findings' `source` and\n`history`'s `sources` array — the vocabulary lives on [`DriftSource`]\nitself, so both surfaces republish it by construction rather than by a\nsecond copy of the match that would drift from it.",
      "type": "string",
      "enum": [
        "HEAD",
        "INDEX",
        "WORKTREE"
      ]
    },
    "UnavailableDoc": {
      "description": "The `unavailable` vocabulary: a status to style, never source to render\n— no placeholder prose is ever emitted as content or as diff body text.",
      "type": "string",
      "enum": [
        "absent",
        "range-past-eof",
        "binary",
        "filter-failed",
        "submodule"
      ]
    }
  }
}
