{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sourcefinch-com/json-schema/sourcefinch-com-run-schema.json",
  "title": "Run",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sourcefinch-com-openapi.json#/components/schemas/Run",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "source_id": {
      "type": "string",
      "format": "uuid"
    },
    "source_version": {
      "type": [
        "integer",
        "null"
      ]
    },
    "status": {
      "$ref": "#/$defs/RunStatus"
    },
    "trigger": {
      "$ref": "#/$defs/RunTrigger"
    },
    "attempt": {
      "type": "integer"
    },
    "created_at": {
      "type": "string",
      "description": "ISO-8601 timestamp (UTC)"
    },
    "completed_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO-8601 timestamp (UTC)"
    },
    "error": {
      "type": [
        "string",
        "null"
      ]
    },
    "validation": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {}
    },
    "health": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {}
    },
    "metrics": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {}
    },
    "changes": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {}
    },
    "acquisition_path": {
      "anyOf": [
        {
          "$ref": "#/$defs/AcquisitionPath"
        },
        {
          "type": "null"
        }
      ]
    },
    "usage_rights": {
      "anyOf": [
        {
          "$ref": "#/$defs/UsageRights"
        },
        {
          "type": "null"
        }
      ]
    },
    "failure_class": {
      "anyOf": [
        {
          "$ref": "#/$defs/FailureClass"
        },
        {
          "type": "null"
        }
      ],
      "description": "Why the last attempt failed; transient classes are retried automatically"
    },
    "compliance": {
      "description": "Compliance state at capture: acquisition path, usage rights, terms posture, robots.txt hash and verdict, AI/TDM signals, crawler identity, pay-per-crawl",
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {}
    }
  },
  "required": [
    "id",
    "source_id",
    "source_version",
    "status",
    "trigger",
    "attempt",
    "created_at",
    "completed_at",
    "error",
    "validation",
    "health",
    "metrics",
    "changes",
    "acquisition_path",
    "usage_rights",
    "failure_class",
    "compliance"
  ],
  "additionalProperties": false,
  "$defs": {
    "AcquisitionPath": {
      "type": "string",
      "enum": [
        "official_api",
        "bulk_file",
        "open_data_portal",
        "licensed_feed",
        "publisher_partnership",
        "pay_per_crawl",
        "public_web",
        "customer_authorized",
        "records_request",
        "manual_upload"
      ]
    },
    "FailureClass": {
      "type": "string",
      "enum": [
        "transient_network",
        "origin_5xx",
        "rate_limited",
        "robots_unavailable",
        "robots_disallowed",
        "blocked_challenge",
        "http_4xx",
        "payment_required",
        "redirect_blocked",
        "budget_exceeded",
        "policy_refused",
        "extraction_failed",
        "validation_failed"
      ]
    },
    "RunStatus": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "success",
        "degraded",
        "failed",
        "blocked"
      ]
    },
    "RunTrigger": {
      "type": "string",
      "enum": [
        "manual",
        "schedule",
        "api"
      ]
    },
    "UsageRights": {
      "type": "object",
      "properties": {
        "basis": {
          "type": "string",
          "enum": [
            "catalog",
            "private_recipe"
          ]
        },
        "licence_basis": {
          "type": "string",
          "enum": [
            "public_domain_gov",
            "open_data_licence",
            "site_terms",
            "licensed_feed",
            "customer_supplied",
            "unknown"
          ]
        },
        "licence_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "commercial_use": {
          "type": "string",
          "enum": [
            "allowed",
            "restricted",
            "prohibited",
            "unknown"
          ]
        },
        "redistribution": {
          "type": "string",
          "enum": [
            "allowed",
            "restricted",
            "prohibited",
            "unknown"
          ]
        },
        "attribution_required": {
          "type": "boolean"
        },
        "attribution_text": {
          "type": [
            "string",
            "null"
          ]
        },
        "terms_snapshot_sha256": {
          "type": [
            "string",
            "null"
          ]
        },
        "reviewed_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "ISO-8601 timestamp (UTC)"
        },
        "usage_rights_id": {
          "type": "string",
          "format": "uuid"
        },
        "version": {
          "type": "integer"
        }
      },
      "required": [
        "basis",
        "licence_basis",
        "commercial_use",
        "redistribution",
        "attribution_required"
      ],
      "description": "Usage rights snapshotted at capture (documented provenance and terms posture; not legal advice)",
      "additionalProperties": false
    }
  }
}