{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://civicdataforge.pages.dev/schemas/property-owner-ledger-input-v1.schema.json",
  "title": "CivicDataForge private property owner-ledger input v1",
  "description": "A normalized private owner or authorized-operator record used only for ephemeral composition.",
  "type": "object",
  "additionalProperties": false,
  "required": ["scope", "property_id", "currency", "owner_record_id", "attestation", "facts"],
  "properties": {
    "scope": {"const": "PROPERTY_RECORD"},
    "property_id": {"type": "string", "minLength": 1, "maxLength": 160},
    "currency": {"type": "string", "pattern": "^[A-Z]{3}$"},
    "owner_record_id": {"type": "string", "minLength": 1, "maxLength": 160},
    "source_kind": {"type": "string", "maxLength": 120},
    "period_start": {"type": "string", "format": "date-time"},
    "period_end": {"type": "string", "format": "date-time"},
    "period_basis": {"enum": ["ANNUAL", "TRAILING_TWELVE_MONTHS"]},
    "selected_market_value_path": {"enum": ["facts.market_value", "facts.authorized_market_value"]},
    "expected_cadence": {"type": "string", "maxLength": 80},
    "attestation": {
      "type": "object", "additionalProperties": false, "required": ["authority", "attested_at"],
      "properties": {"authority": {"enum": ["OWNER", "AUTHORIZED_OPERATOR"]}, "attested_at": {"type": "string", "format": "date-time"}}
    },
    "facts": {
      "type": "object", "additionalProperties": false, "minProperties": 1,
      "properties": {
        "acquisition_cost": {"type": "number", "minimum": 0}, "capitalized_closing_costs": {"type": "number", "minimum": 0},
        "capital_improvements": {"type": "number", "minimum": 0}, "depreciation_taken": {"type": "number", "minimum": 0},
        "other_basis_adjustments": {"type": "number", "minimum": 0}, "gross_operating_income": {"type": "number", "minimum": 0},
        "operating_expenses": {"type": "number", "minimum": 0}, "debt_service": {"type": "number", "minimum": 0},
        "cash_invested": {"type": "number", "minimum": 0}, "gross_potential_income": {"type": "number", "minimum": 0},
        "fixed_operating_costs": {"type": "number", "minimum": 0}, "achieved_rent": {"type": "number", "minimum": 0},
        "occupancy_rate": {"type": "number", "minimum": 0, "maximum": 1}, "property_tax_bill": {"type": "number", "minimum": 0},
        "property_tax_year": {"type": "integer", "minimum": 1900, "maximum": 2200}, "insurance_annual": {"type": "number", "minimum": 0},
        "utilities_annual": {"type": "number", "minimum": 0}, "maintenance_annual": {"type": "number", "minimum": 0}
      }
    }
  },
  "allOf": [{
    "if": {"properties": {"facts": {"anyOf": [
      {"required": ["gross_operating_income"]}, {"required": ["operating_expenses"]}, {"required": ["debt_service"]},
      {"required": ["gross_potential_income"]}, {"required": ["fixed_operating_costs"]}, {"required": ["achieved_rent"]},
      {"required": ["insurance_annual"]}, {"required": ["utilities_annual"]}, {"required": ["maintenance_annual"]}
    ]}}},
    "then": {"required": ["period_start", "period_end", "period_basis"]}
  }]
}
