{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://trp.ecoclaim.ca/schemas/v3/claim-report.schema.json",
  "title": "TRP ClaimReport",
  "description": "External exchange report with declared perspective, boundary and exclusions. Draft 3.0.0-draft.",
  "allOf": [{ "$ref": "common.schema.json#/$defs/envelope" }],
  "type": "object",
  "required": ["claim_id", "reporting_perspective", "generated_at", "methodology", "scope_boundary", "impact_totals", "quality"],
  "properties": {
    "type": { "const": "trp.claim_report" },
    "claim_id": { "$ref": "common.schema.json#/$defs/identifier" },
    "reporting_perspective": {
      "enum": ["claim_physical_footprint", "contractor_corporate_inventory", "insurer_value_chain_estimate", "property_owner_inventory", "portfolio_operational_metrics", "scenario_comparison"]
    },
    "report_state": { "enum": ["draft", "final"] },
    "generated_at": { "$ref": "common.schema.json#/$defs/timestamp" },
    "period": {
      "type": "object",
      "required": ["start", "end"],
      "properties": {
        "start": { "$ref": "common.schema.json#/$defs/date" },
        "end": { "$ref": "common.schema.json#/$defs/date" }
      }
    },
    "methodology": {
      "type": "object",
      "required": ["id", "version", "factor_dataset_version"],
      "properties": {
        "id": { "type": "string" },
        "version": { "type": "string" },
        "factor_dataset_version": { "type": "string" },
        "calculation_engine": { "type": "string" },
        "calculation_engine_version": { "type": "string" }
      }
    },
    "scope_boundary": {
      "type": "object",
      "required": ["included_domains", "excluded_domains", "allocation_method", "double_counting_review"],
      "properties": {
        "included_domains": { "type": "array", "items": { "type": "string" } },
        "included_lifecycle_modules": { "type": "array", "items": { "type": "string" } },
        "excluded_domains": { "type": "array", "items": { "type": "string" } },
        "allocation_method": { "type": "string" },
        "double_counting_review": { "enum": ["pending", "completed"] }
      }
    },
    "impact_totals": {
      "type": "object",
      "required": ["gross_kg_co2e", "status"],
      "properties": {
        "gross_kg_co2e": { "type": ["number", "null"] },
        "status": { "enum": ["incomplete", "complete"] },
        "missing_domains": { "type": "array", "items": { "type": "string" } }
      }
    },
    "scenarios": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/identifier" } },
    "quality": {
      "type": "object",
      "required": ["completeness", "assurance"],
      "properties": {
        "completeness": { "enum": ["partial", "complete"] },
        "assurance": { "enum": ["not_assured", "internally_reviewed", "independently_verified"] }
      }
    },
    "disclaimer": { "type": "string" }
  }
}
