{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getzero.dev/contracts/zero.runtime_setup_lifecycle.v1.schema.json",
  "title": "ZERO Runtime Setup Lifecycle",
  "description": "Current app projection of the claim-to-proof Runtime setup spine derived from RuntimeCapabilityState.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "schema",
    "kind",
    "public",
    "generated_at",
    "deployment_id",
    "mode",
    "status",
    "current_step",
    "current_label",
    "next_action",
    "blocked_reasons",
    "capital_state",
    "authority_state",
    "builder_state",
    "phases",
    "proof_refs"
  ],
  "properties": {
    "schema_version": { "const": "zero.runtime_setup_lifecycle.v1" },
    "schema": { "const": "https://getzero.dev/contracts/zero.runtime_setup_lifecycle.v1.schema.json" },
    "kind": { "const": "runtime_setup_lifecycle" },
    "public": { "const": false },
    "generated_at": { "type": "string", "format": "date-time" },
    "deployment_id": { "type": ["string", "null"] },
    "mode": { "enum": ["paper", "supervised", "live"] },
    "status": { "enum": ["ready", "gated", "blocked", "degraded", "unavailable"] },
    "current_step": {
      "enum": [
        "claim_runtime",
        "observe_first_heartbeat",
        "run_paper_acceptance",
        "approve_agent",
        "approve_builder_fee",
        "grant_short_live_lease",
        "operate_and_prove"
      ]
    },
    "current_label": { "type": "string", "minLength": 1 },
    "next_action": { "type": "string", "minLength": 1 },
    "blocked_reasons": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 }
    },
    "capital_state": {
      "type": "object",
      "additionalProperties": false,
      "required": ["equity_usd", "open_positions", "open_exposure_usd"],
      "properties": {
        "equity_usd": { "type": ["number", "null"] },
        "open_positions": { "type": ["integer", "null"] },
        "open_exposure_usd": { "type": ["number", "null"] }
      }
    },
    "authority_state": {
      "type": "object",
      "additionalProperties": false,
      "required": ["agent_approved", "signer_ready", "lease_state", "schedule_cancel_certified"],
      "properties": {
        "agent_approved": { "type": "boolean" },
        "signer_ready": { "type": "boolean" },
        "lease_state": { "enum": ["active", "expired", "missing"] },
        "schedule_cancel_certified": { "type": "boolean" }
      }
    },
    "builder_state": {
      "type": "object",
      "additionalProperties": false,
      "required": ["configured", "approved", "active", "disabled_reason"],
      "properties": {
        "configured": { "type": "boolean" },
        "approved": { "type": "boolean" },
        "active": { "type": "boolean" },
        "disabled_reason": { "type": ["string", "null"] }
      }
    },
    "phases": {
      "type": "array",
      "minItems": 7,
      "maxItems": 7,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["key", "label", "proof", "complete", "required", "blocked_reason", "next_action", "status"],
        "properties": {
          "key": {
            "enum": [
              "claim_runtime",
              "observe_first_heartbeat",
              "run_paper_acceptance",
              "approve_agent",
              "approve_builder_fee",
              "grant_short_live_lease",
              "operate_and_prove"
            ]
          },
          "label": { "type": "string", "minLength": 1 },
          "proof": { "type": "string", "minLength": 1 },
          "complete": { "type": "boolean" },
          "required": { "type": "boolean" },
          "blocked_reason": { "type": ["string", "null"] },
          "next_action": { "type": ["string", "null"] },
          "status": { "enum": ["complete", "current", "blocked", "optional", "waiting"] }
        }
      }
    },
    "proof_refs": {
      "type": "object",
      "additionalProperties": true
    }
  }
}
