{
  "$defs": {
    "deferred_segment": {
      "additionalProperties": false,
      "properties": {
        "binding_kind": {"const": "source_current"},
        "byte_length": {"maximum": 900000, "minimum": 1, "type": "integer"},
        "capability": {"pattern": "^cgr1p_[A-Za-z0-9_-]{43}$", "type": "string"},
        "content_sha256": {"pattern": "^[0-9a-f]{64}$", "type": "string"},
        "end_byte": {"maximum": 900000, "minimum": 1, "type": "integer"},
        "kind": {"const": "deferred"},
        "start_byte": {"maximum": 899999, "minimum": 0, "type": "integer"},
        "subject_identity_sha256": {"pattern": "^[0-9a-f]{64}$", "type": "string"}
      },
      "required": ["binding_kind", "byte_length", "capability", "content_sha256", "end_byte", "kind", "start_byte", "subject_identity_sha256"],
      "type": "object"
    },
    "evidence_boundary": {
      "additionalProperties": false,
      "properties": {
        "evidence_class": {"const": "companion_local_receipt_only"},
        "host_request_owned": {"const": false},
        "provider_claim_authority": {"const": false},
        "provider_join_status": {"const": "missing"},
        "runtime_observer_present": {"const": false},
        "schema_version": {"const": "contextguard-receipt-evidence-boundary/v1"},
        "selected_branch": {"const": "S2-UNSUPPORTED"},
        "selected_transport": {"const": "NONE"},
        "stage1_evidence": {"const": false},
        "stage2_evidence": {"const": false}
      },
      "required": ["evidence_class", "host_request_owned", "provider_claim_authority", "provider_join_status", "runtime_observer_present", "schema_version", "selected_branch", "selected_transport", "stage1_evidence", "stage2_evidence"],
      "type": "object"
    },
    "retained_segment": {
      "additionalProperties": false,
      "properties": {
        "end_byte": {"maximum": 900000, "minimum": 1, "type": "integer"},
        "kind": {"const": "retained"},
        "payload_b64u": {"maxLength": 1200000, "pattern": "^[A-Za-z0-9_-]+$", "type": "string"},
        "start_byte": {"maximum": 899999, "minimum": 0, "type": "integer"}
      },
      "required": ["end_byte", "kind", "payload_b64u", "start_byte"],
      "type": "object"
    }
  },
  "$id": "https://context-guard.local/schemas/evidence-pack-v1.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "artifact_kind": {"const": "evidence_pack"},
    "byte_length": {"maximum": 900000, "minimum": 1, "type": "integer"},
    "content_sha256": {"pattern": "^[0-9a-f]{64}$", "type": "string"},
    "evidence_boundary": {"$ref": "#/$defs/evidence_boundary"},
    "router_policy_version": {"const": "contextguard-receipt-router/v1"},
    "schema_version": {"const": "contextguard-receipt-evidence-pack/v1"},
    "segments": {
      "items": {
        "oneOf": [
          {"$ref": "#/$defs/retained_segment"},
          {"$ref": "#/$defs/deferred_segment"}
        ]
      },
      "maxItems": 64,
      "minItems": 1,
      "type": "array"
    }
  },
  "required": ["artifact_kind", "byte_length", "content_sha256", "evidence_boundary", "router_policy_version", "schema_version", "segments"],
  "title": "Context Guard Receipt progressive evidence pack",
  "type": "object"
}
