{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "scan": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string",
          "const": "internal-link-scan-v1"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Resource identifier returned by the operation."
        },
        "projectId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "domain": {
          "type": "string"
        },
        "homepage": {
          "type": "string"
        },
        "state": {
          "type": "string",
          "enum": [
            "queued",
            "running",
            "paused",
            "cancelled",
            "complete",
            "limit_reached",
            "failed"
          ],
          "description": "Saved lifecycle or evidence state, as enumerated for this record."
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "description": "Recorded explanation; null when no explanation applies."
            },
            {
              "type": "null"
            }
          ],
          "description": "Recorded explanation; null when no explanation applies."
        },
        "createdAt": {
          "type": "string"
        },
        "updatedAt": {
          "type": "string"
        },
        "expiresAt": {
          "type": "string"
        },
        "completedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "revision": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Optimistic concurrency revision; supply it as expectedRevision on the next write."
        },
        "controlRevision": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "discoveredCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "completeCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "unknownCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "pendingCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "admittedCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "edgeCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "excludedReferences": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "exclusions": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "nextEligibleAt": {
          "type": "string"
        },
        "discovery": {
          "type": "object",
          "properties": {
            "state": {
              "type": "string",
              "enum": [
                "pending",
                "complete"
              ],
              "description": "Saved lifecycle or evidence state, as enumerated for this record."
            },
            "coverage": {
              "description": "Dataset scope and completeness, including limits on what these results establish.",
              "type": "object",
              "properties": {
                "completeSiteCensus": {
                  "type": "boolean",
                  "const": false
                },
                "truncated": {
                  "type": "boolean"
                },
                "reasons": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "completeSiteCensus",
                "truncated",
                "reasons"
              ],
              "additionalProperties": false
            },
            "documents": {
              "maxItems": 13,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "requestedUrl": {
                    "type": "string"
                  },
                  "finalUrl": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "checkedAt": {
                    "type": "string"
                  },
                  "sha256": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991,
                        "description": "Resource lifecycle status."
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Resource lifecycle status."
                  },
                  "reason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "description": "Recorded explanation; null when no explanation applies."
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Recorded explanation; null when no explanation applies."
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "robots",
                      "index",
                      "urlset",
                      "unknown"
                    ]
                  }
                },
                "required": [
                  "requestedUrl",
                  "finalUrl",
                  "checkedAt",
                  "sha256",
                  "status",
                  "reason",
                  "kind"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "state"
          ],
          "additionalProperties": false
        },
        "coverage": {
          "type": "object",
          "properties": {
            "inventory": {
              "type": "string",
              "const": "partial"
            },
            "completeSiteCensus": {
              "type": "boolean",
              "const": false
            },
            "representation": {
              "type": "string",
              "const": "raw_html"
            },
            "frontierTruncated": {
              "type": "boolean"
            },
            "renderedVisibility": {
              "type": "boolean",
              "const": false
            },
            "canonicalAliasesMerged": {
              "type": "boolean",
              "const": false
            }
          },
          "required": [
            "inventory",
            "completeSiteCensus",
            "representation",
            "frontierTruncated",
            "renderedVisibility",
            "canonicalAliasesMerged"
          ],
          "additionalProperties": false,
          "description": "Dataset scope and completeness, including limits on what these results establish."
        },
        "usage": {
          "type": "object",
          "properties": {
            "unit": {
              "type": "string",
              "const": "admitted_page"
            },
            "period": {
              "type": "string"
            },
            "limit": {
              "type": "number",
              "const": 300
            },
            "used": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "resetsAt": {
              "type": "string"
            }
          },
          "required": [
            "unit",
            "period",
            "limit",
            "used",
            "resetsAt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "version",
        "id",
        "projectId",
        "domain",
        "homepage",
        "state",
        "reason",
        "createdAt",
        "updatedAt",
        "expiresAt",
        "completedAt",
        "revision",
        "controlRevision",
        "discoveredCount",
        "completeCount",
        "unknownCount",
        "pendingCount",
        "admittedCount",
        "edgeCount",
        "excludedReferences",
        "exclusions",
        "nextEligibleAt",
        "discovery",
        "coverage",
        "usage"
      ],
      "additionalProperties": false
    },
    "limits": {
      "type": "object",
      "properties": {
        "pagesPerRun": {
          "type": "number",
          "const": 300
        },
        "workspacePagesPerDay": {
          "type": "number",
          "const": 300
        },
        "retainedRunsAndSnapshotsPerProject": {
          "type": "number",
          "const": 20
        },
        "retentionDays": {
          "type": "number",
          "const": 30
        },
        "pageBytes": {
          "type": "number",
          "const": 2097152
        },
        "pageTimeoutMs": {
          "type": "number",
          "const": 20000
        },
        "leaseMs": {
          "type": "number",
          "const": 90000
        },
        "maxAttempts": {
          "type": "number",
          "const": 3
        },
        "edgesPerPage": {
          "type": "number",
          "const": 200
        },
        "pageSize": {
          "type": "number",
          "const": 100
        }
      },
      "required": [
        "pagesPerRun",
        "workspacePagesPerDay",
        "retainedRunsAndSnapshotsPerProject",
        "retentionDays",
        "pageBytes",
        "pageTimeoutMs",
        "leaseMs",
        "maxAttempts",
        "edgesPerPage",
        "pageSize"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "scan",
    "limits"
  ],
  "additionalProperties": false
}
