{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getzero.dev/contracts/zero.vibe_deploy.proof_chain.v1.schema.json",
  "title": "ZERO Vibe Deploy Proof Chain v1",
  "description": "Ordered proof contract for establishing Runtime ownership, liveness, paper capability, Hyperliquid authority, main-wallet Builder Code authority before live lease, short live-lease execution authority, and no-secret Builder fill reconciliation.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema_version",
    "schema",
    "kind",
    "public",
    "status",
    "canonical_order",
    "trust_states",
    "steps",
    "enforcement"
  ],
  "properties": {
    "schema_version": {
      "const": "zero.vibe_deploy.proof_chain.v1"
    },
    "schema": {
      "const": "https://getzero.dev/contracts/zero.vibe_deploy.proof_chain.v1.schema.json"
    },
    "kind": {
      "const": "vibe_deploy_proof_chain"
    },
    "public": {
      "const": true
    },
    "status": {
      "enum": ["ready", "degraded"]
    },
    "canonical_order": {
      "type": "array",
      "prefixItems": [
        { "const": "claim_runtime" },
        { "const": "observe_first_heartbeat" },
        { "const": "run_paper_acceptance" },
        { "const": "record_paper_acceptance" },
        { "const": "approve_agent" },
        { "const": "approve_builder_fee" },
        { "const": "grant_short_live_lease" },
        { "const": "builder_fill_reconciliation" }
      ],
      "minItems": 8,
      "maxItems": 8
    },
    "trust_states": {
      "type": "object",
      "required": ["paper_capable", "authority_ready", "execution_authorized", "revenue_authority", "revenue_reconciled"],
      "properties": {
        "paper_capable": {
          "$ref": "#/$defs/trust_state"
        },
        "authority_ready": {
          "$ref": "#/$defs/trust_state"
        },
        "execution_authorized": {
          "$ref": "#/$defs/trust_state"
        },
        "revenue_authority": {
          "$ref": "#/$defs/trust_state"
        },
        "revenue_reconciled": {
          "$ref": "#/$defs/trust_state"
        }
      }
    },
    "steps": {
      "type": "array",
      "minItems": 8,
      "items": {
        "type": "object",
        "required": ["key", "proof", "surface", "actor", "auth", "receipt_source", "stored_evidence", "secret_policy"],
        "properties": {
          "key": {
            "enum": [
              "claim_runtime",
              "observe_first_heartbeat",
              "run_paper_acceptance",
              "record_paper_acceptance",
              "approve_agent",
              "approve_builder_fee",
              "grant_short_live_lease",
              "builder_fill_reconciliation"
            ]
          },
          "proof": {
            "type": "string",
            "minLength": 8
          },
          "surface": {
            "type": "string",
            "minLength": 3
          },
          "actor": {
            "enum": ["runtime", "operator"]
          },
          "auth": {
            "type": "string",
            "minLength": 8
          },
          "receipt_source": {
            "type": "string",
            "minLength": 8
          },
          "stored_evidence": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 3
            }
          },
          "secret_policy": {
            "type": "string",
            "minLength": 20
          }
        }
      }
    },
    "enforcement": {
      "type": "object",
      "required": [
        "paper_capable_requires",
        "authority_ready_requires",
        "execution_authorized_requires",
        "revenue_authority_requires",
        "revenue_reconciliation_requires",
        "builder_fee_main_wallet_only",
        "builder_fee_required_before_live_lease",
        "builder_fill_reconciliation_required_after_live_fills",
        "no_promotion_without_distinct_receipts",
        "no_app_checkbox_substitution",
        "no_fabricated_backfill"
      ],
      "properties": {
        "paper_capable_requires": {
          "$ref": "#/$defs/step_array"
        },
        "authority_ready_requires": {
          "$ref": "#/$defs/step_array"
        },
        "execution_authorized_requires": {
          "$ref": "#/$defs/step_array"
        },
        "revenue_authority_requires": {
          "$ref": "#/$defs/step_array"
        },
        "revenue_reconciliation_requires": {
          "$ref": "#/$defs/step_array"
        },
        "builder_fee_main_wallet_only": {
          "const": true
        },
        "builder_fee_required_before_live_lease": {
          "const": true
        },
        "builder_fill_reconciliation_required_after_live_fills": {
          "const": true
        },
        "no_promotion_without_distinct_receipts": {
          "const": true
        },
        "no_app_checkbox_substitution": {
          "const": true
        },
        "no_fabricated_backfill": {
          "const": true
        }
      }
    }
  },
  "$defs": {
    "step_array": {
      "type": "array",
      "minItems": 1,
      "items": {
        "enum": [
          "claim_runtime",
          "observe_first_heartbeat",
          "run_paper_acceptance",
          "record_paper_acceptance",
          "approve_agent",
          "approve_builder_fee",
          "grant_short_live_lease",
          "builder_fill_reconciliation"
        ]
      }
    },
    "trust_state": {
      "type": "object",
      "required": ["requires", "proves"],
      "properties": {
        "requires": {
          "$ref": "#/$defs/step_array"
        },
        "proves": {
          "type": "string",
          "minLength": 20
        }
      }
    }
  }
}
