{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/licenseground-com/json-schema/licenseground-com-compliance-risk-result-schema.json",
  "title": "ComplianceRiskResult",
  "description": "Instant machine-actionable hiring decision.",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/licenseground-com-openapi.yml#/components/schemas/ComplianceRiskResult",
  "properties": {
    "can_hire": {
      "type": "boolean",
      "title": "Can Hire",
      "description": "Deterministic decision: True if compliant with all risk criteria."
    },
    "risk_level": {
      "$ref": "#/$defs/RiskLevel",
      "description": "LOW, MEDIUM, HIGH, or CRITICAL."
    },
    "risk_score": {
      "type": "number",
      "maximum": 100.0,
      "minimum": 0.0,
      "title": "Risk Score",
      "description": "Risk index from 0.0 (safest) to 100.0 (maximum risk)."
    },
    "flags": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Flags",
      "description": "Specific risk warning triggers."
    },
    "verification": {
      "$ref": "#/$defs/LicenseVerificationResult",
      "description": "Full underlying verification ground truth."
    }
  },
  "type": "object",
  "required": [
    "can_hire",
    "risk_level",
    "risk_score",
    "verification"
  ],
  "$defs": {
    "DisciplinaryRecord": {
      "properties": {
        "case_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Case Number"
        },
        "action_type": {
          "type": "string",
          "title": "Action Type",
          "description": "E.g., 'Citation', 'Formal Accusation', 'Administrative Fine', 'Suspension Order'"
        },
        "effective_date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Effective Date"
        },
        "description": {
          "type": "string",
          "title": "Description",
          "description": "Summary of board violation or sanctions"
        },
        "penalty_amount": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Penalty Amount"
        },
        "resolved": {
          "type": "boolean",
          "title": "Resolved",
          "default": true
        }
      },
      "type": "object",
      "required": [
        "action_type",
        "description"
      ],
      "title": "DisciplinaryRecord",
      "description": "Detail of any disciplinary citations, suspensions, or formal administrative actions."
    },
    "LicenseStatus": {
      "type": "string",
      "enum": [
        "ACTIVE_CURRENT",
        "INACTIVE",
        "EXPIRED",
        "SUSPENDED",
        "REVOKED",
        "PENDING",
        "DELINQUENT",
        "NOT_FOUND"
      ],
      "title": "LicenseStatus"
    },
    "LicenseVerificationResult": {
      "properties": {
        "verified": {
          "type": "boolean",
          "title": "Verified",
          "description": "True if the entity possesses an authentic, matching registration on the official state registry."
        },
        "canonical_name": {
          "type": "string",
          "title": "Canonical Name",
          "description": "Official legal business name registered with the state licensing board."
        },
        "dba_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Dba Name",
          "description": "Registered Doing-Business-As (DBA) or fictitious business name if applicable."
        },
        "license_number": {
          "type": "string",
          "title": "License Number",
          "description": "Official state license/certificate identifier."
        },
        "state": {
          "$ref": "#/$defs/StateCode",
          "description": "State code (CA, FL, TX)."
        },
        "trade_classification": {
          "type": "string",
          "title": "Trade Classification",
          "description": "State trade classification (e.g., 'C-39 Roofing', 'CCC Certified Roofing Contractor', 'TACLA HVAC')."
        },
        "trade_category": {
          "$ref": "#/$defs/TradeCategory",
          "description": "Normalized trade category.",
          "default": "any"
        },
        "status": {
          "$ref": "#/$defs/LicenseStatus",
          "description": "Current operational license status."
        },
        "is_active": {
          "type": "boolean",
          "title": "Is Active",
          "description": "Helper boolean: True only if status is ACTIVE_CURRENT."
        },
        "disciplinary_actions": {
          "type": "integer",
          "title": "Disciplinary Actions",
          "description": "Total count of historical or pending disciplinary actions/citations.",
          "default": 0
        },
        "disciplinary_records": {
          "items": {
            "$ref": "#/$defs/DisciplinaryRecord"
          },
          "type": "array",
          "title": "Disciplinary Records",
          "description": "Detailed list of formal board actions, if any."
        },
        "issue_date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Issue Date",
          "description": "Date the license was originally issued (YYYY-MM-DD)."
        },
        "expiration_date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expiration Date",
          "description": "Expiration date of the current license cycle (YYYY-MM-DD)."
        },
        "is_expired": {
          "type": "boolean",
          "title": "Is Expired",
          "description": "True if expiration_date is in the past.",
          "default": false
        },
        "workers_comp_exempt": {
          "type": "boolean",
          "title": "Workers Comp Exempt",
          "description": "True if the contractor filed an exemption claiming zero employees.",
          "default": false
        },
        "workers_comp_covered": {
          "type": "boolean",
          "title": "Workers Comp Covered",
          "description": "True if active Workers' Compensation insurance policy is confirmed on file with the state board.",
          "default": false
        },
        "workers_comp_insurer": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Workers Comp Insurer",
          "description": "Name of workers' comp insurance carrier, policy number, or status note."
        },
        "bond_status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Bond Status",
          "description": "Contractor surety bond status (e.g. 'ACTIVE $25,000', 'EXEMPT', 'NOT_REQUIRED')."
        },
        "bond_company": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Bond Company",
          "description": "Surety company underwriting the contractor bond."
        },
        "business_address": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Business Address",
          "description": "Principal place of business on official record."
        },
        "city": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "City"
        },
        "zip_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Zip Code"
        },
        "phone": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Phone"
        },
        "qualifying_agent": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Qualifying Agent",
          "description": "Licensed individual qualifier, master, or primary officer (e.g. Master Electrician or RMO/RME)."
        },
        "grounding_confidence": {
          "type": "number",
          "maximum": 1.0,
          "minimum": 0.0,
          "title": "Grounding Confidence",
          "description": "Confidence score (0.0 to 1.0) indicating exactness of entity name match against registry records."
        },
        "source_registry": {
          "type": "string",
          "title": "Source Registry",
          "description": "Official source registry name (e.g. 'CA Contractors State License Board (CSLB)')."
        },
        "source_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Source Url",
          "description": "Direct URL to official state verification record."
        },
        "cached": {
          "type": "boolean",
          "title": "Cached",
          "description": "True if served from low-latency persistent cache.",
          "default": false
        },
        "source_timestamp": {
          "type": "string",
          "title": "Source Timestamp",
          "description": "ISO 8601 timestamp when data was fetched or grounded."
        }
      },
      "type": "object",
      "required": [
        "verified",
        "canonical_name",
        "license_number",
        "state",
        "trade_classification",
        "status",
        "is_active",
        "grounding_confidence",
        "source_registry"
      ],
      "title": "LicenseVerificationResult",
      "description": "Machine-actionable, deterministic ground-truth verification result."
    },
    "RiskLevel": {
      "type": "string",
      "enum": [
        "LOW",
        "MEDIUM",
        "HIGH",
        "CRITICAL"
      ],
      "title": "RiskLevel"
    },
    "StateCode": {
      "type": "string",
      "enum": [
        "CA",
        "FL",
        "TX",
        "NY",
        "MA",
        "IL",
        "AZ",
        "US"
      ],
      "title": "StateCode"
    },
    "TradeCategory": {
      "type": "string",
      "enum": [
        "roofing",
        "hvac",
        "electrical",
        "plumbing",
        "general_contractor",
        "any"
      ],
      "title": "TradeCategory"
    }
  }
}