{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antfly/json-schema/antfly-document-artifact-reprocess-job-schema.json",
  "title": "DocumentArtifactReprocessJob",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/antfly-data-operations-api-openapi.yml#/components/schemas/DocumentArtifactReprocessJob",
  "type": "object",
  "required": [
    "job_id",
    "attempt_id",
    "table_name",
    "artifact_name",
    "phase",
    "reprocess_status",
    "from_key",
    "to_key",
    "limit",
    "scanned",
    "reprocessed",
    "skipped",
    "failed",
    "pending_shards",
    "failures",
    "shard_cursors",
    "cancel_requested",
    "created_at_millis",
    "last_updated_at_millis",
    "expires_at_millis"
  ],
  "properties": {
    "job_id": {
      "type": "integer",
      "format": "uint64",
      "description": "Server-assigned durable repair job identifier."
    },
    "attempt_id": {
      "type": "integer",
      "format": "uint64",
      "description": "Monotonic execution attempt token for the current running pass."
    },
    "table_name": {
      "type": "string",
      "description": "Table containing the source documents being repaired."
    },
    "artifact_name": {
      "type": "string",
      "description": "Name of the derived artifact being repaired."
    },
    "phase": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ],
      "description": "Lifecycle phase of the repair job."
    },
    "reprocess_status": {
      "type": "string",
      "enum": [
        "in_progress",
        "complete",
        "stopped"
      ],
      "description": "User-facing completion status derived from the phase and remaining cursors."
    },
    "from_key": {
      "type": "string",
      "description": "Original exclusive lower bound for the job."
    },
    "to_key": {
      "type": "string",
      "description": "Original inclusive upper bound for the job, or empty for the end of the table/range."
    },
    "limit": {
      "type": "integer",
      "format": "uint32",
      "description": "Current per-shard bounded pass limit."
    },
    "next_key": {
      "type": [
        "string",
        "null"
      ],
      "description": "Single-shard continuation key when no shard cursors are present."
    },
    "scanned": {
      "type": "integer",
      "description": "Cumulative source rows scanned by completed passes."
    },
    "reprocessed": {
      "type": "integer",
      "description": "Cumulative source rows whose artifact was reprocessed."
    },
    "skipped": {
      "type": "integer",
      "description": "Cumulative source rows skipped by completed passes."
    },
    "failed": {
      "type": "integer",
      "description": "Cumulative source rows that failed during completed passes."
    },
    "pending_shards": {
      "type": "integer",
      "description": "Number of shard-local continuations still pending."
    },
    "failures": {
      "type": "array",
      "description": "Failures from the most recent completed pass.",
      "items": {
        "$ref": "#/$defs/DocumentArtifactReprocessFailure"
      }
    },
    "shard_cursors": {
      "type": "array",
      "description": "Per-shard continuation cursors to resume on the next advance operation.",
      "items": {
        "$ref": "#/$defs/DocumentArtifactReprocessShardCursor"
      }
    },
    "last_error": {
      "type": [
        "string",
        "null"
      ],
      "description": "Last terminal or transient job error, when available."
    },
    "cancel_requested": {
      "type": "boolean",
      "description": "Whether cancellation has been requested for a running pass. Running passes finish at a bounded reprocess boundary before the job transitions to cancelled."
    },
    "created_at_millis": {
      "type": "integer",
      "format": "uint64",
      "description": "Unix epoch milliseconds when the job was created."
    },
    "last_updated_at_millis": {
      "type": "integer",
      "format": "uint64",
      "description": "Unix epoch milliseconds when the job was last updated."
    },
    "expires_at_millis": {
      "type": "integer",
      "format": "uint64",
      "description": "Unix epoch milliseconds after which the retained job status may be removed."
    }
  },
  "$defs": {
    "DocumentArtifactReprocessFailure": {
      "type": "object",
      "required": [
        "key",
        "error_code"
      ],
      "properties": {
        "key": {
          "type": "string",
          "description": "Source document key that failed during reprocessing."
        },
        "error_code": {
          "type": "string",
          "description": "Stable error code for the failed document reprocess attempt."
        }
      }
    },
    "DocumentArtifactReprocessShardCursor": {
      "type": "object",
      "required": [
        "next_key",
        "scanned",
        "reprocessed",
        "skipped",
        "failed",
        "limit"
      ],
      "properties": {
        "group_id": {
          "type": [
            "integer",
            "null"
          ],
          "format": "uint64",
          "description": "Physical table group that produced this cursor, when known."
        },
        "next_key": {
          "type": "string",
          "description": "Source key cursor for resuming this shard-local repair pass."
        },
        "scanned": {
          "type": "integer",
          "description": "Number of source rows scanned by this shard-local pass."
        },
        "reprocessed": {
          "type": "integer",
          "description": "Number of source rows whose artifact was reprocessed by this shard-local pass."
        },
        "skipped": {
          "type": "integer",
          "description": "Number of scanned source rows that no longer had a reprocessable source document in this shard-local pass."
        },
        "failed": {
          "type": "integer",
          "description": "Number of scanned source rows that failed in this shard-local pass."
        },
        "limit": {
          "type": "integer",
          "format": "uint32",
          "description": "Effective scan limit used by this shard-local pass."
        }
      }
    }
  }
}