{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antfly/json-schema/antfly-document-artifact-manifest-schema.json",
  "title": "DocumentArtifactManifest",
  "description": "Inspection view for a derived document artifact produced from a source\ntable row. The typed fields form the stable summary contract. The\nembedded manifest/state JSON fields are optional raw detail intended\nfor admin/debug inspection so producers can evolve their internal unit\nschema without changing this route contract.\n",
  "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/DocumentArtifactManifest",
  "type": "object",
  "required": [
    "document_id",
    "artifact_name",
    "artifact_id",
    "manifest_version",
    "generation",
    "source_url",
    "source_fingerprint",
    "content_type",
    "route_type",
    "unit_count",
    "chunk_count",
    "child_ranges",
    "child_range_count",
    "merge_status",
    "merge_from_generation",
    "merge_to_generation",
    "merge_operation_granularity",
    "merge_operation_count"
  ],
  "properties": {
    "document_id": {
      "type": "string",
      "description": "Stable identity of the source document."
    },
    "artifact_name": {
      "type": "string",
      "description": "Name of the derived artifact."
    },
    "artifact_id": {
      "type": "string",
      "description": "Stable identity of this artifact under the document."
    },
    "manifest_version": {
      "type": "integer",
      "format": "uint64",
      "description": "Version of the opaque manifest payload schema."
    },
    "generation": {
      "type": "integer",
      "format": "uint64",
      "description": "Monotonic generation for the current artifact state."
    },
    "source_url": {
      "type": "string",
      "description": "Source URL or source identifier used to derive this artifact."
    },
    "source_fingerprint": {
      "type": "string",
      "description": "Fingerprint of the source bytes and extractor configuration."
    },
    "content_type": {
      "type": "string",
      "description": "Effective source content type selected during extraction."
    },
    "route_type": {
      "type": "string",
      "description": "Producer route selected for the source content."
    },
    "unsupported_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Reason extraction was skipped, when the source type is unsupported."
    },
    "unit_count": {
      "type": "integer",
      "description": "Number of extracted document units."
    },
    "chunk_count": {
      "type": "integer",
      "description": "Number of indexable chunks derived from the units."
    },
    "ocr_attempted_count": {
      "type": "integer",
      "description": "Number of pages for which OCR was attempted."
    },
    "ocr_selected_count": {
      "type": "integer",
      "description": "Number of pages where OCR text was selected over embedded text."
    },
    "ocr_retained_embedded_count": {
      "type": "integer",
      "description": "Number of attempted pages where embedded text remained preferable."
    },
    "ocr_failed_count": {
      "type": "integer",
      "description": "Number of pages whose OCR rendering or recognition failed."
    },
    "ocr_failed_page_numbers": {
      "type": "array",
      "description": "Up to 32 one-based page numbers where OCR failed.",
      "items": {
        "type": "integer",
        "format": "uint32"
      }
    },
    "ocr_failed_pages_truncated": {
      "type": "boolean",
      "description": "Whether additional failed page numbers were omitted from the summary."
    },
    "child_ranges": {
      "type": "array",
      "description": "Parsed child range descriptors for this artifact generation.",
      "items": {
        "$ref": "#/$defs/DocumentArtifactChildRange"
      }
    },
    "child_range_count": {
      "type": "integer",
      "description": "Number of storage child ranges used by this artifact."
    },
    "merge_status": {
      "type": "string",
      "description": "Current materialization or merge status."
    },
    "merge_from_generation": {
      "type": "integer",
      "format": "uint64",
      "description": "Previous artifact generation used by the current merge plan."
    },
    "merge_to_generation": {
      "type": "integer",
      "format": "uint64",
      "description": "Target artifact generation produced by the current merge plan."
    },
    "merge_operation_granularity": {
      "type": "string",
      "description": "Granularity used when computing merge-plan operations."
    },
    "merge_operation_count": {
      "type": "integer",
      "description": "Number of merge operations recorded for this artifact."
    },
    "last_error_code": {
      "type": [
        "string",
        "null"
      ],
      "description": "Last extraction or materialization error code, when the current artifact generation failed."
    },
    "last_error_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "Human-readable last extraction or materialization error summary, when available."
    },
    "manifest_json": {
      "type": "string",
      "description": "Opaque JSON manifest for the artifact units and provenance. Present only for raw detail responses."
    },
    "state_json": {
      "type": [
        "string",
        "null"
      ],
      "description": "Optional opaque JSON state for incremental processing. Present only for raw detail responses."
    }
  },
  "$defs": {
    "DocumentArtifactChildRange": {
      "type": "object",
      "description": "Parsed child-range descriptor from a derived document artifact manifest.",
      "required": [
        "range_id",
        "range_kind",
        "artifact_name",
        "split_boundary",
        "placement",
        "start_key",
        "end_key_exclusive",
        "last_key",
        "child_count"
      ],
      "properties": {
        "range_id": {
          "type": "string",
          "description": "Stable range identifier within the artifact manifest generation."
        },
        "range_kind": {
          "type": "string",
          "description": "Kind of children covered by this range, such as unit or chunk."
        },
        "artifact_name": {
          "type": "string",
          "description": "Artifact namespace covered by this range."
        },
        "split_boundary": {
          "type": "string",
          "description": "Logical boundary used for splitting this range."
        },
        "placement": {
          "type": "string",
          "description": "Current placement summary for the range."
        },
        "owner_group_id": {
          "type": [
            "integer",
            "null"
          ],
          "format": "uint64",
          "description": "Owner group for this child artifact range, when assigned."
        },
        "placement_generation": {
          "type": [
            "integer",
            "null"
          ],
          "format": "uint64",
          "description": "Placement generation for range ownership metadata."
        },
        "route_status": {
          "type": [
            "string",
            "null"
          ],
          "description": "Current routing status for child writes in this range."
        },
        "split_eligible": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether this range may split at its configured split boundary."
        },
        "start_key": {
          "type": "string",
          "description": "Inclusive first internal child key covered by this range."
        },
        "end_key_exclusive": {
          "type": "string",
          "description": "Exclusive end internal child key, or empty for the final range."
        },
        "last_key": {
          "type": "string",
          "description": "Inclusive last internal child key covered by this range."
        },
        "child_count": {
          "type": "integer",
          "description": "Number of child records covered by this range."
        },
        "text_bytes": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Approximate extracted text bytes covered by this range when available."
        }
      }
    }
  }
}