{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://qrtrust.local/contracts/reference-network-adoption-stage.schema.json",
  "title": "QR Trust reference network adoption stage gate",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "artifact_type",
    "schema_version",
    "generated_at",
    "stage",
    "stage_name",
    "claim_mode",
    "status",
    "blocking_boundaries",
    "warning_boundaries",
    "boundaries",
    "review_notes"
  ],
  "properties": {
    "artifact_type": {
      "const": "reference_network_adoption_stage_gate"
    },
    "schema_version": {
      "const": "2026-05-21"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "stage": {
      "type": "integer",
      "enum": [0, 1, 2, 3]
    },
    "stage_name": {
      "type": "string",
      "enum": [
        "local_proof",
        "single_operator_pilot",
        "multi_authority_reference",
        "ecosystem_candidate"
      ]
    },
    "claim_mode": {
      "type": "string",
      "enum": ["reference_only", "production_candidate"]
    },
    "status": {
      "type": "string",
      "enum": [
        "ready_for_stage_0_reference",
        "ready_for_stage_1_reference",
        "ready_for_stage_2_reference",
        "ready_for_stage_3_reference",
        "blocked_for_stage_claim",
        "ready_for_production_candidate",
        "blocked_for_production_candidate"
      ]
    },
    "blocking_boundaries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/boundary_id"
      }
    },
    "warning_boundaries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/boundary_id"
      }
    },
    "boundaries": {
      "type": "array",
      "minItems": 14,
      "items": {
        "$ref": "#/$defs/boundary"
      }
    },
    "review_notes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "$defs": {
    "boundary_id": {
      "type": "string",
      "enum": [
        "postgres_source_of_truth",
        "authority_publication",
        "nats_propagation",
        "verifier_cache_read_model",
        "scanner_decision_runtime",
        "scanner_fleet_evidence",
        "cross_surface_qr_evidence",
        "worker_operations_evidence",
        "signing_custody_audit_export",
        "signing_custody",
        "runtime_safety_provider",
        "operator_runbooks",
        "backup_restore",
        "external_governance_audit"
      ]
    },
    "boundary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "layer", "title", "status", "evidence_tier", "evidence"],
      "properties": {
        "id": {
          "$ref": "#/$defs/boundary_id"
        },
        "layer": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "enum": ["pass", "warn", "block"]
        },
        "evidence_tier": {
          "type": "string",
          "enum": ["reference_backed", "operator_backed", "unattached"]
        },
        "evidence": {
          "type": "string",
          "minLength": 1
        },
        "remediation": {
          "type": "string",
          "minLength": 1
        },
        "evidence_refs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/evidence_ref"
          }
        },
        "smoke_scripts": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "evidence_ref": {
      "type": "object",
      "additionalProperties": false,
      "required": ["label", "uri", "owner", "reviewed_at"],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "uri": {
          "type": "string",
          "minLength": 1
        },
        "owner": {
          "type": "string",
          "minLength": 1
        },
        "reviewed_at": {
          "type": "string",
          "minLength": 1,
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      }
    }
  }
}
