{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "description": "Company Recent Job Openings report v2. Every business outcome uses this same shape. Transport/storage/platform failures may prevent output.",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "report_id",
    "request_fingerprint",
    "company_website",
    "lookback_days",
    "checked_at",
    "completed_at",
    "status",
    "signal_status",
    "job_count",
    "jobs",
    "undated_jobs",
    "coverage_complete",
    "coverage_scope",
    "listings_seen",
    "dated_listings",
    "verified_recent_count",
    "excluded_counts",
    "sources",
    "errors",
    "error_code",
    "error_message",
    "retryable",
    "suggested_action",
    "retry_after_seconds",
    "billing_eligible",
    "billing_event",
    "billing_quantity",
    "billing_unit_price_usd",
    "billing_max_charge_usd",
    "pricing_status",
    "paid_usage_confirmed",
    "duration_ms",
    "http_request_count",
    "downloaded_bytes",
    "retry_count",
    "schema_valid",
    "observation_type",
    "request_log"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "description": "Contract version. Pin major version; v2 uses snake_case.",
      "const": "2.0"
    },
    "report_id": {
      "type": "string",
      "description": "Unique content hash for this observation, including checked time."
    },
    "request_fingerprint": {
      "type": "string",
      "description": "Stable normalized-input hash; does not provide cross-run billing idempotency."
    },
    "company_website": {
      "type": [
        "string",
        "null"
      ],
      "description": "Normalized submitted public company website; null for unusable input."
    },
    "lookback_days": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Requested UTC calendar-day lookback. Null if invalid.",
      "minimum": 1,
      "maximum": 365
    },
    "checked_at": {
      "type": "string",
      "description": "UTC timestamp of the source check, not the publication time.",
      "format": "date-time"
    },
    "completed_at": {
      "type": "string",
      "description": "UTC report completion time.",
      "format": "date-time"
    },
    "status": {
      "type": "string",
      "description": "success=complete positive; partial=positive with limits; no_result=complete dated negative; invalid_input=fix caller input; upstream_error=unknown/configuration/budget failure.",
      "enum": [
        "success",
        "partial",
        "no_result",
        "invalid_input",
        "upstream_error"
      ]
    },
    "signal_status": {
      "type": "string",
      "description": "Business interpretation; unknown is never a no-hiring claim.",
      "enum": [
        "verified_recent_openings",
        "no_verified_recent_openings",
        "unknown"
      ]
    },
    "job_count": {
      "type": "integer",
      "minimum": 0,
      "description": "Number of verified recent jobs returned."
    },
    "jobs": {
      "type": "array",
      "description": "Only verified recent jobs; empty for no_result and error outcomes.",
      "items": {
        "type": "object",
        "description": "A checked live listing. Recent jobs always have a verified date; undated_jobs always have null publication fields.",
        "additionalProperties": false,
        "required": [
          "job_key",
          "title",
          "location",
          "published_date",
          "date_meaning",
          "source_url",
          "checked_at",
          "provider",
          "provider_id",
          "evidence_url",
          "evidence_field",
          "raw_published_date",
          "evidence_sha256",
          "current_status_basis"
        ],
        "properties": {
          "job_key": {
            "type": "string",
            "description": "Stable SHA-256 identity from canonical source URL. Use to compare repeat reports; not a newness claim."
          },
          "title": {
            "type": "string",
            "description": "Source-provided job title; never inferred."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source-provided location; null when unavailable. Conflicting source labels are not inferred away."
          },
          "published_date": {
            "type": "string",
            "description": "Verified ISO calendar date or UTC timestamp; required, never null for recent jobs.",
            "anyOf": [
              {
                "format": "date"
              },
              {
                "format": "date-time"
              }
            ]
          },
          "date_meaning": {
            "type": "string",
            "description": "Meaning of the verified source publication field.",
            "enum": [
              "last_published",
              "first_published",
              "date_posted",
              "released"
            ]
          },
          "source_url": {
            "type": "string",
            "description": "Public job URL.",
            "format": "uri"
          },
          "checked_at": {
            "type": "string",
            "description": "UTC timestamp of the source check, not the publication time.",
            "format": "date-time"
          },
          "provider": {
            "type": "string",
            "description": "Source adapter.",
            "enum": [
              "ashby",
              "greenhouse",
              "lever",
              "smartrecruiters",
              "jsonld"
            ]
          },
          "provider_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source identifier converted to string, or null."
          },
          "evidence_url": {
            "type": "string",
            "description": "Exact public API or page inspected for date and current listing evidence.",
            "format": "uri"
          },
          "evidence_field": {
            "type": "string",
            "minLength": 1,
            "description": "Exact date field verified in the source."
          },
          "raw_published_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source date string before normalization; null when absent or of an invalid type."
          },
          "evidence_sha256": {
            "type": "string",
            "description": "SHA-256 of checked source body; audit identifier, not retained content."
          },
          "current_status_basis": {
            "type": "string",
            "description": "Evidence used to establish public listing visibility at checked_at; not a guarantee the position remains unfilled."
          }
        }
      }
    },
    "undated_jobs": {
      "type": "array",
      "description": "Live source listings with unverifiable dates. Never qualify as recent; each published_date is null.",
      "items": {
        "type": "object",
        "description": "A checked live listing. Recent jobs always have a verified date; undated_jobs always have null publication fields.",
        "additionalProperties": false,
        "required": [
          "job_key",
          "title",
          "location",
          "published_date",
          "date_meaning",
          "source_url",
          "checked_at",
          "provider",
          "provider_id",
          "evidence_url",
          "evidence_field",
          "raw_published_date",
          "evidence_sha256",
          "current_status_basis"
        ],
        "properties": {
          "job_key": {
            "type": "string",
            "description": "Stable SHA-256 identity from canonical source URL. Use to compare repeat reports; not a newness claim."
          },
          "title": {
            "type": "string",
            "description": "Source-provided job title; never inferred."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source-provided location; null when unavailable. Conflicting source labels are not inferred away."
          },
          "published_date": {
            "const": null,
            "description": "Null because this listing has no verified publication date."
          },
          "date_meaning": {
            "const": null,
            "description": "Null because this listing has no verified publication date."
          },
          "source_url": {
            "type": "string",
            "description": "Public job URL.",
            "format": "uri"
          },
          "checked_at": {
            "type": "string",
            "description": "UTC timestamp of the source check, not the publication time.",
            "format": "date-time"
          },
          "provider": {
            "type": "string",
            "description": "Source adapter.",
            "enum": [
              "ashby",
              "greenhouse",
              "lever",
              "smartrecruiters",
              "jsonld"
            ]
          },
          "provider_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source identifier converted to string, or null."
          },
          "evidence_url": {
            "type": "string",
            "description": "Exact public API or page inspected for date and current listing evidence.",
            "format": "uri"
          },
          "evidence_field": {
            "const": null,
            "description": "Null because this listing has no verified publication date."
          },
          "raw_published_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source date string before normalization; null when absent or of an invalid type."
          },
          "evidence_sha256": {
            "type": "string",
            "description": "SHA-256 of checked source body; audit identifier, not retained content."
          },
          "current_status_basis": {
            "type": "string",
            "description": "Evidence used to establish public listing visibility at checked_at; not a guarantee the position remains unfilled."
          }
        }
      }
    },
    "coverage_complete": {
      "type": "boolean",
      "description": "All discovered supported ATS listings were checked within limits; does not imply whole-company/web completeness."
    },
    "coverage_scope": {
      "type": "string",
      "description": "Scope of completeness and negative claims."
    },
    "listings_seen": {
      "type": "integer",
      "minimum": 0,
      "description": "Source listing observations before deduplication, including skipped details."
    },
    "dated_listings": {
      "type": "integer",
      "minimum": 0,
      "description": "Listings with parseable dates before window filtering."
    },
    "verified_recent_count": {
      "type": "integer",
      "minimum": 0,
      "description": "Unique verified jobs before output cap."
    },
    "excluded_counts": {
      "type": "object",
      "description": "Counts by exclusion reason; missing key means zero. Listing observations are not unique jobs.",
      "additionalProperties": {
        "type": "integer",
        "minimum": 0
      }
    },
    "sources": {
      "type": "array",
      "description": "Public discovery and evidence chain.",
      "items": {
        "type": "object",
        "description": "Checked source.",
        "additionalProperties": false,
        "required": [
          "url",
          "discovered_from",
          "linked_url",
          "source_type",
          "checked_at",
          "sha256"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Checked public URL.",
            "format": "uri"
          },
          "discovered_from": {
            "type": [
              "string",
              "null"
            ],
            "description": "Page that linked this source; null for submitted root."
          },
          "linked_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Original linked ATS URL, or null."
          },
          "source_type": {
            "type": "string",
            "description": "Source adapter or company_page."
          },
          "checked_at": {
            "type": "string",
            "description": "UTC timestamp of the source check, not the publication time.",
            "format": "date-time"
          },
          "sha256": {
            "type": "string",
            "description": "SHA-256 of the inspected response body."
          }
        }
      }
    },
    "errors": {
      "type": "array",
      "description": "All limits and failures; empty when none.",
      "items": {
        "type": "object",
        "description": "Machine-readable failure or limitation; deterministic codes and actions.",
        "additionalProperties": false,
        "required": [
          "error_code",
          "error_message",
          "source_url",
          "retryable",
          "suggested_action",
          "retry_after_seconds"
        ],
        "properties": {
          "error_code": {
            "type": "string",
            "description": "Stable error classifier."
          },
          "error_message": {
            "type": "string",
            "description": "Fixed explanation for this classifier; not raw upstream exception text."
          },
          "source_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Failed public URL when available; null for input/configuration errors."
          },
          "retryable": {
            "type": "boolean",
            "description": "A later new check might resolve this transient error. Does not authorize a paid retry."
          },
          "suggested_action": {
            "type": "string",
            "description": "Deterministic action.",
            "enum": [
              "fix_input",
              "retry_later",
              "use_supported_source",
              "accept_partial",
              "increase_output_limit",
              "contact_publisher",
              "increase_budget",
              "stop"
            ]
          },
          "retry_after_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Minimum recommended delay; null when not retryable. No automatic new billable runs.",
            "minimum": 0
          }
        }
      }
    },
    "error_code": {
      "type": [
        "string",
        "null"
      ],
      "description": "First actionable error classifier, or null."
    },
    "error_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "First error explanation, or null."
    },
    "retryable": {
      "type": "boolean",
      "description": "True only if an incomplete/unknown outcome has a transient cause."
    },
    "suggested_action": {
      "type": "string",
      "description": "Next caller action.",
      "enum": [
        "use_results",
        "use_scoped_negative",
        "fix_input",
        "retry_later",
        "use_supported_source",
        "accept_partial",
        "increase_output_limit",
        "contact_publisher",
        "increase_budget",
        "stop"
      ]
    },
    "retry_after_seconds": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Delay before caller-authorized retry; null otherwise.",
      "minimum": 0
    },
    "billing_eligible": {
      "type": "boolean",
      "description": "Whether this saved report qualifies for the single report event."
    },
    "billing_event": {
      "type": [
        "string",
        "null"
      ],
      "description": "Single event name when eligible; null otherwise.",
      "enum": [
        null,
        "verified-report"
      ]
    },
    "billing_quantity": {
      "type": "integer",
      "minimum": 0,
      "description": "Zero or one eligible company report, regardless of number of jobs.",
      "enum": [
        0,
        1
      ]
    },
    "billing_unit_price_usd": {
      "type": "number",
      "description": "Proposed price locally; actual configured event price in priced cloud runs.",
      "minimum": 0
    },
    "billing_max_charge_usd": {
      "type": "number",
      "description": "Eligibility × unit price; not proof of payment.",
      "minimum": 0
    },
    "pricing_status": {
      "type": "string",
      "description": "Whether price was confirmed from this run’s platform pricing.",
      "enum": [
        "proposed",
        "runtime_verified"
      ]
    },
    "paid_usage_confirmed": {
      "const": false,
      "description": "Runtime output cannot prove customer revenue. Reconcile payout/paid-plan evidence separately."
    },
    "duration_ms": {
      "type": "integer",
      "minimum": 0,
      "description": "Measured service processing time, excluding platform cold start."
    },
    "http_request_count": {
      "type": "integer",
      "minimum": 0,
      "description": "All outbound requests, including robots and redirects."
    },
    "downloaded_bytes": {
      "type": "integer",
      "minimum": 0,
      "description": "Decompressed source bytes read; not an Apify invoice."
    },
    "retry_count": {
      "type": "integer",
      "minimum": 0,
      "description": "Automatic source retry attempts. Currently zero; transient recovery is caller-controlled."
    },
    "schema_valid": {
      "const": true,
      "description": "True only after output passes bundled JSON Schema validation."
    },
    "observation_type": {
      "type": "string",
      "description": "Origin of this check.",
      "enum": [
        "local_test",
        "platform_run"
      ]
    },
    "request_log": {
      "type": "array",
      "description": "Bounded source request audit; no source body stored.",
      "items": {
        "type": "object",
        "description": "Request observation.",
        "additionalProperties": false,
        "required": [
          "url",
          "checked_at",
          "http_status",
          "bytes",
          "sha256",
          "error_code"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Requested public URL."
          },
          "checked_at": {
            "type": "string",
            "description": "UTC timestamp of the source check, not the publication time.",
            "format": "date-time"
          },
          "http_status": {
            "type": [
              "integer",
              "null"
            ],
            "description": "HTTP status or null if no response."
          },
          "bytes": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Response bytes or null for interrupted body."
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "description": "Body hash or null for incomplete responses."
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Normalized request error or null."
          }
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "enum": [
              "success",
              "partial"
            ]
          }
        }
      },
      "then": {
        "properties": {
          "jobs": {
            "type": "array",
            "minItems": 1
          },
          "signal_status": {
            "const": "verified_recent_openings"
          },
          "billing_eligible": {
            "const": true
          },
          "billing_quantity": {
            "const": 1
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "success"
          }
        }
      },
      "then": {
        "properties": {
          "coverage_complete": {
            "const": true
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "partial"
          }
        }
      },
      "then": {
        "properties": {
          "coverage_complete": {
            "const": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "no_result"
          }
        }
      },
      "then": {
        "properties": {
          "jobs": {
            "type": "array",
            "maxItems": 0
          },
          "undated_jobs": {
            "type": "array",
            "maxItems": 0
          },
          "coverage_complete": {
            "const": true
          },
          "signal_status": {
            "const": "no_verified_recent_openings"
          },
          "billing_eligible": {
            "const": true
          },
          "billing_quantity": {
            "const": 1
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "enum": [
              "invalid_input",
              "upstream_error"
            ]
          }
        }
      },
      "then": {
        "properties": {
          "jobs": {
            "type": "array",
            "maxItems": 0
          },
          "signal_status": {
            "const": "unknown"
          },
          "billing_eligible": {
            "const": false
          },
          "billing_quantity": {
            "const": 0
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "billing_quantity": {
            "const": 0
          }
        }
      },
      "then": {
        "properties": {
          "billing_event": {
            "const": null
          },
          "billing_max_charge_usd": {
            "const": 0
          }
        }
      },
      "else": {
        "properties": {
          "billing_event": {
            "const": "verified-report"
          },
          "billing_unit_price_usd": {
            "const": 0.03
          },
          "billing_max_charge_usd": {
            "const": 0.03
          }
        }
      }
    }
  ]
}
