{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agent.pricerightdigital.com/automation-health-schema.json",
  "title": "Price Right Digital Automation Health Packet",
  "description": "Preparation-only automation health packet. It documents checks and evidence needs without claiming routing, webhook, CRM, sheet, alert, CMS, or downstream completion.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "health_id",
    "created_at",
    "source_system",
    "source_url",
    "checked_asset",
    "routing_surface",
    "endpoint_checks",
    "field_checks",
    "destination_checks",
    "alert_checks",
    "evidence",
    "risk_assessment",
    "validation",
    "handoff",
    "downstream_status"
  ],
  "properties": {
    "health_id": {
      "type": "string",
      "description": "Unique automation health packet identifier."
    },
    "created_at": {
      "type": "string",
      "description": "ISO timestamp when the packet was created."
    },
    "source_system": {
      "type": "string",
      "description": "System that prepared the packet."
    },
    "source_url": {
      "type": "string",
      "description": "Source URL for the packet."
    },
    "checked_asset": {
      "type": "object",
      "description": "Asset being checked. Naming an asset is not health evidence.",
      "additionalProperties": false,
      "required": [
        "asset_name",
        "asset_type",
        "asset_url",
        "owner_team",
        "expected_goal",
        "expected_cta",
        "expected_destination"
      ],
      "properties": {
        "asset_name": {
          "type": "string",
          "description": "Asset name."
        },
        "asset_type": {
          "type": "string",
          "enum": [
            "landing_page",
            "show_page",
            "contact_form",
            "inventory_form",
            "newsletter_form",
            "review_form",
            "lead_router",
            "apps_script_router",
            "crm_sync",
            "google_sheet",
            "webhook",
            "alerting_flow",
            "internal_reference",
            "unknown"
          ],
          "description": "Type of automation or routing asset."
        },
        "asset_url": {
          "type": "string",
          "description": "Asset URL or reference."
        },
        "owner_team": {
          "type": "string",
          "description": "Owner team."
        },
        "expected_goal": {
          "type": "string",
          "description": "Expected goal of the asset."
        },
        "expected_cta": {
          "type": "string",
          "description": "Expected CTA."
        },
        "expected_destination": {
          "type": "string",
          "description": "Expected destination or system."
        }
      }
    },
    "routing_surface": {
      "type": "object",
      "description": "Routing surface details. These fields do not prove routing works.",
      "additionalProperties": false,
      "required": [
        "form_present",
        "endpoint_url",
        "method",
        "expected_route_key",
        "expected_sheet_or_destination",
        "expected_crm_or_platform",
        "expected_alert_channels",
        "notes"
      ],
      "properties": {
        "form_present": {
          "type": "boolean",
          "description": "Whether a form is expected or observed."
        },
        "endpoint_url": {
          "type": "string",
          "description": "Endpoint URL if known. Do not include secrets."
        },
        "method": {
          "type": "string",
          "description": "Expected HTTP method if known."
        },
        "expected_route_key": {
          "type": "string",
          "description": "Expected route key or hidden field."
        },
        "expected_sheet_or_destination": {
          "type": "string",
          "description": "Expected sheet or destination name without private IDs."
        },
        "expected_crm_or_platform": {
          "type": "string",
          "description": "Expected CRM or platform name."
        },
        "expected_alert_channels": {
          "type": "array",
          "description": "Expected alert channels.",
          "items": {
            "type": "string",
            "description": "One item."
          }
        },
        "notes": {
          "type": "string",
          "description": "Routing notes and limitations."
        }
      }
    },
    "endpoint_checks": {
      "type": "object",
      "description": "Endpoint check results. Do not claim success without direct evidence.",
      "additionalProperties": false,
      "required": [
        "endpoint_known",
        "endpoint_reachable",
        "endpoint_method_verified",
        "endpoint_last_checked_at",
        "endpoint_status",
        "endpoint_notes"
      ],
      "properties": {
        "endpoint_known": {
          "type": "boolean",
          "description": "Whether endpoint is known."
        },
        "endpoint_reachable": {
          "type": "boolean",
          "description": "Whether endpoint reachability was checked and observed."
        },
        "endpoint_method_verified": {
          "type": "boolean",
          "description": "Whether method was verified."
        },
        "endpoint_last_checked_at": {
          "type": "string",
          "description": "Timestamp of endpoint check."
        },
        "endpoint_status": {
          "type": "string",
          "enum": [
            "not_checked",
            "reachable",
            "unreachable",
            "method_mismatch",
            "unknown",
            "failed",
            "blocked"
          ],
          "description": "Endpoint status."
        },
        "endpoint_notes": {
          "type": "string",
          "description": "Endpoint check notes."
        }
      }
    },
    "field_checks": {
      "type": "object",
      "description": "Visible and hidden field checks.",
      "additionalProperties": false,
      "required": [
        "visible_fields_checked",
        "hidden_fields_checked",
        "required_fields_present",
        "route_key_present",
        "utm_fields_present",
        "missing_fields",
        "field_status",
        "notes"
      ],
      "properties": {
        "visible_fields_checked": {
          "type": "boolean",
          "description": "Whether visible fields were checked."
        },
        "hidden_fields_checked": {
          "type": "boolean",
          "description": "Whether hidden fields were checked."
        },
        "required_fields_present": {
          "type": "boolean",
          "description": "Whether required fields were observed."
        },
        "route_key_present": {
          "type": "boolean",
          "description": "Whether route key was observed."
        },
        "utm_fields_present": {
          "type": "boolean",
          "description": "Whether UTM fields were observed."
        },
        "missing_fields": {
          "type": "array",
          "description": "Missing fields.",
          "items": {
            "type": "string",
            "description": "One item."
          }
        },
        "field_status": {
          "type": "string",
          "enum": [
            "not_checked",
            "pass",
            "warn",
            "fail",
            "unverified",
            "blocked"
          ],
          "description": "Field check status."
        },
        "notes": {
          "type": "string",
          "description": "Field check notes."
        }
      }
    },
    "destination_checks": {
      "type": "object",
      "description": "Destination checks. A destination name is not insertion evidence.",
      "additionalProperties": false,
      "required": [
        "destination_named",
        "destination_reachable",
        "destination_type",
        "destination_match_status",
        "destination_notes"
      ],
      "properties": {
        "destination_named": {
          "type": "boolean",
          "description": "Whether destination is named."
        },
        "destination_reachable": {
          "type": "boolean",
          "description": "Whether destination reachability was checked."
        },
        "destination_type": {
          "type": "string",
          "enum": [
            "crm",
            "google_sheet",
            "apps_script",
            "podium",
            "email_platform",
            "cms",
            "webhook",
            "chat",
            "email_alert",
            "unknown",
            "not_applicable"
          ],
          "description": "Destination type."
        },
        "destination_match_status": {
          "type": "string",
          "enum": [
            "not_checked",
            "match_confirmed",
            "mismatch",
            "unverified",
            "blocked",
            "failed"
          ],
          "description": "Destination match status."
        },
        "destination_notes": {
          "type": "string",
          "description": "Destination check notes."
        }
      }
    },
    "alert_checks": {
      "type": "object",
      "description": "Alert behavior checks.",
      "additionalProperties": false,
      "required": [
        "chat_alert_expected",
        "email_alert_expected",
        "sms_alert_expected",
        "webhook_alert_expected",
        "alert_behavior_checked",
        "alert_status",
        "alert_notes"
      ],
      "properties": {
        "chat_alert_expected": {
          "type": "boolean",
          "description": "Whether chat alert is expected."
        },
        "email_alert_expected": {
          "type": "boolean",
          "description": "Whether email alert is expected."
        },
        "sms_alert_expected": {
          "type": "boolean",
          "description": "Whether SMS alert is expected."
        },
        "webhook_alert_expected": {
          "type": "boolean",
          "description": "Whether webhook alert is expected."
        },
        "alert_behavior_checked": {
          "type": "boolean",
          "description": "Whether alert behavior was checked."
        },
        "alert_status": {
          "type": "string",
          "enum": [
            "not_checked",
            "pass",
            "warn",
            "fail",
            "not_configured",
            "unverified",
            "blocked"
          ],
          "description": "Alert status."
        },
        "alert_notes": {
          "type": "string",
          "description": "Alert notes."
        }
      }
    },
    "evidence": {
      "type": "object",
      "description": "Evidence references. Do not include secrets or customer data.",
      "additionalProperties": false,
      "required": [
        "live_submission_evidence",
        "test_submission_evidence",
        "screenshot_or_log_reference",
        "evidence_source_url",
        "evidence_collected_at",
        "evidence_limitations"
      ],
      "properties": {
        "live_submission_evidence": {
          "type": "string",
          "description": "Live submission evidence or not_provided."
        },
        "test_submission_evidence": {
          "type": "string",
          "description": "Test submission evidence or not_provided."
        },
        "screenshot_or_log_reference": {
          "type": "string",
          "description": "Screenshot or log reference."
        },
        "evidence_source_url": {
          "type": "string",
          "description": "Evidence source URL."
        },
        "evidence_collected_at": {
          "type": "string",
          "description": "Evidence collection timestamp."
        },
        "evidence_limitations": {
          "type": "array",
          "description": "Evidence limitations.",
          "items": {
            "type": "string",
            "description": "One item."
          }
        }
      }
    },
    "risk_assessment": {
      "type": "object",
      "description": "Risk assessment from available evidence.",
      "additionalProperties": false,
      "required": [
        "risk_level",
        "suspected_failure_class",
        "customer_impact",
        "workaround_needed",
        "workaround_note"
      ],
      "properties": {
        "risk_level": {
          "type": "string",
          "enum": [
            "low",
            "medium",
            "high",
            "critical",
            "unknown"
          ],
          "description": "Risk level."
        },
        "suspected_failure_class": {
          "type": "string",
          "enum": [
            "none",
            "stale_endpoint",
            "wrong_sheet",
            "missing_hidden_field",
            "alert_missing",
            "webhook_mismatch",
            "crm_destination_unknown",
            "route_key_missing",
            "form_unavailable",
            "page_unavailable",
            "destination_mismatch",
            "evidence_missing",
            "other"
          ],
          "description": "Suspected failure class."
        },
        "customer_impact": {
          "type": "string",
          "description": "Potential customer impact."
        },
        "workaround_needed": {
          "type": "boolean",
          "description": "Whether workaround is needed."
        },
        "workaround_note": {
          "type": "string",
          "description": "Workaround note."
        }
      }
    },
    "validation": {
      "type": "object",
      "description": "Validation state for automation health.",
      "additionalProperties": false,
      "required": [
        "routing_qa_required",
        "hard_contract_required",
        "validation_status",
        "missing_evidence",
        "next_validation_step"
      ],
      "properties": {
        "routing_qa_required": {
          "type": "boolean",
          "description": "Whether routing QA is required."
        },
        "hard_contract_required": {
          "type": "boolean",
          "description": "Whether hard contract is required."
        },
        "validation_status": {
          "type": "string",
          "enum": [
            "draft",
            "planning_only",
            "not_checked",
            "partially_checked",
            "pass",
            "warn",
            "fail",
            "unverified",
            "blocked_missing_evidence",
            "awaiting_downstream_confirmation",
            "downstream_confirmed"
          ],
          "description": "Validation status."
        },
        "missing_evidence": {
          "type": "array",
          "description": "Missing evidence.",
          "items": {
            "type": "string",
            "description": "One item."
          }
        },
        "next_validation_step": {
          "type": "string",
          "description": "Next validation step."
        }
      }
    },
    "handoff": {
      "type": "object",
      "description": "Handoff details. Handoff is not downstream completion.",
      "additionalProperties": false,
      "required": [
        "handoff_name",
        "source_run_id",
        "owner_team",
        "target_system",
        "payload_summary",
        "required_fields",
        "missing_fields",
        "validation_state",
        "next_human_or_system_action",
        "handoff_status"
      ],
      "properties": {
        "handoff_name": {
          "type": "string",
          "description": "Handoff name."
        },
        "source_run_id": {
          "type": "string",
          "description": "Source run ID."
        },
        "owner_team": {
          "type": "string",
          "description": "Owner team."
        },
        "target_system": {
          "type": "string",
          "description": "Target system."
        },
        "payload_summary": {
          "type": "string",
          "description": "Payload summary."
        },
        "required_fields": {
          "type": "array",
          "description": "Required fields.",
          "items": {
            "type": "string",
            "description": "One item."
          }
        },
        "missing_fields": {
          "type": "array",
          "description": "Missing fields.",
          "items": {
            "type": "string",
            "description": "One item."
          }
        },
        "validation_state": {
          "type": "string",
          "description": "Validation state."
        },
        "next_human_or_system_action": {
          "type": "string",
          "description": "Next action."
        },
        "handoff_status": {
          "type": "string",
          "enum": [
            "drafted",
            "ready_for_handoff",
            "handed_off",
            "awaiting_downstream_confirmation",
            "downstream_confirmed",
            "failed_downstream",
            "archived"
          ],
          "description": "Handoff status."
        }
      }
    },
    "downstream_status": {
      "type": "string",
      "enum": [
        "not_sent",
        "handed_off",
        "awaiting_confirmation",
        "confirmed",
        "failed"
      ],
      "description": "Downstream status."
    }
  }
}
