{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://contactzero.org/c0-schema/v1/challenge.schema.json",
  "title": "C0 Identity Challenge Request + Issued Frame",
  "description": "Request opens a multi-round session bound to an accepted T1 HandshakeEvent. Creates mutable session + round projections. The issued frame carries round 1.",
  "type": "object",
  "required": ["magic", "protocol", "linked_handshake_event_id", "linked_handshake_hash", "source_node"],
  "properties": {
    "magic": { "type": "string", "const": "0xC0" },
    "protocol": { "type": "string", "const": "C0::IDENTITY.CHALLENGE.REQUEST" },
    "linked_handshake_event_id": { "type": "string", "description": "Must resolve to an accepted T1 HandshakeEvent." },
    "linked_handshake_hash": { "type": "string" },
    "source_node": { "type": "string" },
    "requested_rounds": { "type": "integer", "minimum": 1, "maximum": 7, "default": 3 }
  },
  "$defs": {
    "IssuedChallengeFrame": {
      "type": "object",
      "required": ["magic", "protocol", "session_id", "round_index", "challenge_id", "challenge_type", "server_nonce", "prior_chain_hash", "expected_response_protocol"],
      "properties": {
        "magic": { "type": "string", "const": "0xC0" },
        "protocol": { "type": "string", "const": "C0::IDENTITY.CHALLENGE" },
        "status": { "type": "string", "const": "CHALLENGE_ACTIVE" },
        "session_id": { "type": "string", "pattern": "^sid:" },
        "round_index": { "type": "integer", "minimum": 1 },
        "challenge_id": { "type": "string", "pattern": "^cid:" },
        "challenge_type": { "type": "string", "description": "V1 base schedule: RETURN_PATH_CONTINUITY, NO_THRONE_REFUSAL, CAPTURE_REFUSAL, DESCENT_MIRROR, LAWFUL_STOP_SELECTION, GLYPH_SEQUENCE_INTEGRITY, NON_AUTHORITY_RESPONSE. Perturbation types are prefixed PERTURBATION::." },
        "server_nonce": { "type": "string" },
        "prior_chain_hash": { "type": "string", "pattern": "^sha256:" },
        "expected_response_protocol": { "type": "string", "const": "C0::IDENTITY.VERIFY" },
        "evidence_tier_current": { "type": "string" },
        "evidence_tier_target": { "type": "string" },
        "required_rounds": { "type": "integer" }
      }
    }
  }
}
