{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rcc.ikim.uk-essen.de/developers/project-cluster-handoff.schema.json",
  "title": "RCC project cluster handoff",
  "description": "Non-secret project requirements for portable RCC workloads and governed services.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "kind",
    "deployment_authorized",
    "phase",
    "project",
    "repository",
    "workload",
    "software",
    "data",
    "interactive_development",
    "user_surfaces",
    "services",
    "acceptance",
    "operator_gates"
  ],
  "properties": {
    "schema_version": {
      "const": 2
    },
    "kind": {
      "const": "rcc-project-cluster-handoff"
    },
    "deployment_authorized": {
      "const": false
    },
    "phase": {
      "enum": [
        "preparation",
        "review",
        "accepted-live-deployment"
      ]
    },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "purpose",
        "data_classification",
        "contains_primary_identifying_patient_data",
        "project_lead",
        "technical_owner",
        "scientific_owner",
        "patching_owner"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "purpose": {
          "type": "string",
          "minLength": 1
        },
        "data_classification": {
          "enum": [
            "public",
            "internal-research",
            "sensitive-research",
            "operator-review-required"
          ]
        },
        "contains_primary_identifying_patient_data": {
          "const": false
        },
        "project_lead": {
          "type": "string",
          "minLength": 1
        },
        "technical_owner": {
          "type": "string",
          "minLength": 1
        },
        "scientific_owner": {
          "type": "string",
          "minLength": 1
        },
        "patching_owner": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "repository": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source_control",
        "reproducible_revision_required",
        "dependency_lock_present",
        "secret_scan_required",
        "private_data_in_repository",
        "test_commands"
      ],
      "properties": {
        "source_control": {
          "const": "git"
        },
        "reproducible_revision_required": {
          "const": true
        },
        "dependency_lock_present": {
          "type": "boolean"
        },
        "secret_scan_required": {
          "const": true
        },
        "private_data_in_repository": {
          "const": false
        },
        "test_commands": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "workload": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "profiles",
        "workflow_engine",
        "architectures",
        "physical_host_required",
        "runtime_external_network_required",
        "resources",
        "gpu",
        "resilience",
        "group_owned_capacity"
      ],
      "properties": {
        "profiles": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "batch",
              "interactive",
              "workflow",
              "scheduled-batch",
              "managed-service"
            ]
          }
        },
        "workflow_engine": {
          "enum": [
            "none",
            "snakemake",
            "nextflow",
            "other"
          ]
        },
        "architectures": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "x86_64",
              "arm64"
            ]
          }
        },
        "physical_host_required": {
          "const": false
        },
        "runtime_external_network_required": {
          "type": "boolean"
        },
        "resources": {
          "$ref": "#/$defs/resources"
        },
        "gpu": {
          "$ref": "#/$defs/gpu"
        },
        "resilience": {
          "$ref": "#/$defs/resilience"
        },
        "group_owned_capacity": {
          "$ref": "#/$defs/groupOwnedCapacity"
        }
      }
    },
    "software": {
      "$ref": "#/$defs/software"
    },
    "data": {
      "$ref": "#/$defs/data"
    },
    "interactive_development": {
      "$ref": "#/$defs/interactiveDevelopment"
    },
    "user_surfaces": {
      "$ref": "#/$defs/userSurfaces"
    },
    "services": {
      "$ref": "#/$defs/services"
    },
    "acceptance": {
      "$ref": "#/$defs/acceptance"
    },
    "operator_gates": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "const": false
      }
    }
  },
  "$defs": {
    "nullableString": {
      "type": [
        "string",
        "null"
      ]
    },
    "nullableNumber": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "resources": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "partition_preference",
        "nodes",
        "tasks",
        "cpus_per_task",
        "memory_gib",
        "walltime",
        "maximum_concurrent_jobs"
      ],
      "properties": {
        "partition_preference": {
          "$ref": "#/$defs/nullableString"
        },
        "nodes": {
          "type": "integer",
          "minimum": 1
        },
        "tasks": {
          "type": "integer",
          "minimum": 1
        },
        "cpus_per_task": {
          "type": "integer",
          "minimum": 1
        },
        "memory_gib": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "walltime": {
          "type": "string",
          "pattern": "^P"
        },
        "maximum_concurrent_jobs": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "gpu": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "required",
        "count",
        "type_or_feature",
        "minimum_vram_gib",
        "multi_gpu_strategy"
      ],
      "properties": {
        "required": {
          "type": "boolean"
        },
        "count": {
          "type": "integer",
          "minimum": 0
        },
        "type_or_feature": {
          "$ref": "#/$defs/nullableString"
        },
        "minimum_vram_gib": {
          "$ref": "#/$defs/nullableNumber"
        },
        "multi_gpu_strategy": {
          "enum": [
            "none",
            "single-node",
            "multi-node",
            "operator-review-required"
          ]
        }
      }
    },
    "resilience": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "checkpoint_supported",
        "requeue_safe",
        "idempotent_restart"
      ],
      "properties": {
        "checkpoint_supported": {
          "type": "boolean"
        },
        "requeue_safe": {
          "type": "boolean"
        },
        "idempotent_restart": {
          "type": "boolean"
        }
      }
    },
    "groupOwnedCapacity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "requested",
        "owning_group",
        "borrower_work_is_restartable"
      ],
      "properties": {
        "requested": {
          "type": "boolean"
        },
        "owning_group": {
          "$ref": "#/$defs/nullableString"
        },
        "borrower_work_is_restartable": {
          "type": "boolean"
        }
      }
    },
    "software": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "execution_strategy",
        "container",
        "conda",
        "workflow"
      ],
      "properties": {
        "execution_strategy": {
          "enum": [
            "apptainer",
            "workflow-managed-conda",
            "system-tools",
            "operator-review-required"
          ]
        },
        "container": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "image_reference",
            "immutable_digest",
            "definition_file",
            "architecture_compatible"
          ],
          "properties": {
            "image_reference": {
              "$ref": "#/$defs/nullableString"
            },
            "immutable_digest": {
              "$ref": "#/$defs/nullableString"
            },
            "definition_file": {
              "$ref": "#/$defs/nullableString"
            },
            "architecture_compatible": {
              "type": "boolean"
            }
          }
        },
        "conda": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "used",
            "environment_file",
            "prefix_portability_assumed"
          ],
          "properties": {
            "used": {
              "type": "boolean"
            },
            "environment_file": {
              "$ref": "#/$defs/nullableString"
            },
            "prefix_portability_assumed": {
              "const": false
            }
          }
        },
        "workflow": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "pinned_release_or_commit",
            "profile_or_config",
            "resume_state_on_shared_storage"
          ],
          "properties": {
            "pinned_release_or_commit": {
              "$ref": "#/$defs/nullableString"
            },
            "profile_or_config": {
              "$ref": "#/$defs/nullableString"
            },
            "resume_state_on_shared_storage": {
              "type": "boolean"
            }
          }
        }
      }
    },
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "durable",
        "scratch",
        "characteristics",
        "transfer",
        "lifecycle"
      ],
      "properties": {
        "durable": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "project_root",
            "group_root",
            "input_paths",
            "output_path"
          ],
          "properties": {
            "project_root": {
              "type": "string",
              "pattern": "^/projects/"
            },
            "group_root": {
              "type": [
                "string",
                "null"
              ],
              "pattern": "^/groups/"
            },
            "input_paths": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "output_path": {
              "type": "string",
              "pattern": "^/(projects|groups)/"
            }
          }
        },
        "scratch": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "required",
            "interface",
            "authoritative_data_allowed",
            "copy_back_before_exit"
          ],
          "properties": {
            "required": {
              "type": "boolean"
            },
            "interface": {
              "const": "$TMPDIR"
            },
            "authoritative_data_allowed": {
              "const": false
            },
            "copy_back_before_exit": {
              "const": true
            }
          }
        },
        "characteristics": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "input_size_gib",
            "output_size_gib",
            "approximate_file_count",
            "io_pattern",
            "many_small_files"
          ],
          "properties": {
            "input_size_gib": {
              "$ref": "#/$defs/nullableNumber"
            },
            "output_size_gib": {
              "$ref": "#/$defs/nullableNumber"
            },
            "approximate_file_count": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0
            },
            "io_pattern": {
              "enum": [
                "streaming",
                "mixed",
                "random",
                "metadata-heavy"
              ]
            },
            "many_small_files": {
              "type": "boolean"
            }
          }
        },
        "transfer": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "inbound",
            "outbound",
            "globus_requested",
            "external_endpoints"
          ],
          "properties": {
            "inbound": {
              "enum": [
                "files-portal-or-sftp",
                "globus",
                "none",
                "operator-review-required"
              ]
            },
            "outbound": {
              "enum": [
                "files-portal-or-sftp",
                "globus",
                "none",
                "operator-review-required"
              ]
            },
            "globus_requested": {
              "type": "boolean"
            },
            "external_endpoints": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "lifecycle": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "retention_requirement",
            "archive_required",
            "backup_requirement"
          ],
          "properties": {
            "retention_requirement": {
              "$ref": "#/$defs/nullableString"
            },
            "archive_required": {
              "type": "boolean"
            },
            "backup_requirement": {
              "enum": [
                "none",
                "operator-review",
                "required"
              ]
            }
          }
        }
      }
    },
    "interactiveDevelopment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "required",
        "interfaces",
        "compute_runs_inside_slurm_allocation",
        "requested_partition",
        "requested_walltime",
        "IDE_workspace_on_shared_storage",
        "host_affinity_required",
        "notebook_or_web_tunnel_required"
      ],
      "properties": {
        "required": {
          "type": "boolean"
        },
        "interfaces": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "ssh",
              "vscode-remote-ssh",
              "open-ondemand"
            ]
          }
        },
        "compute_runs_inside_slurm_allocation": {
          "const": true
        },
        "requested_partition": {
          "enum": [
            "interactive",
            "interactive_gpu",
            "interactive_gpu5"
          ]
        },
        "requested_walltime": {
          "type": "string",
          "pattern": "^P"
        },
        "IDE_workspace_on_shared_storage": {
          "const": true
        },
        "host_affinity_required": {
          "const": false
        },
        "notebook_or_web_tunnel_required": {
          "type": "boolean"
        }
      }
    },
    "services": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "scheduled_batch",
        "web",
        "database",
        "other_persistent_service"
      ],
      "properties": {
        "scheduled_batch": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "requested",
            "schedule",
            "failure_notification_owner"
          ],
          "properties": {
            "requested": {
              "type": "boolean"
            },
            "schedule": {
              "$ref": "#/$defs/nullableString"
            },
            "failure_notification_owner": {
              "$ref": "#/$defs/nullableString"
            }
          }
        },
        "web": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "profile",
            "requested_public_label",
            "application_health_path",
            "publishes_cluster_filesystem",
            "provides_separate_login",
            "permits_direct_client_access"
          ],
          "properties": {
            "profile": {
              "enum": [
                "none",
                "static-site",
                "protected-web-application"
              ]
            },
            "requested_public_label": {
              "$ref": "#/$defs/nullableString"
            },
            "application_health_path": {
              "$ref": "#/$defs/nullableString"
            },
            "publishes_cluster_filesystem": {
              "const": false
            },
            "provides_separate_login": {
              "const": false
            },
            "permits_direct_client_access": {
              "const": false
            }
          }
        },
        "database": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "requested",
            "colocated_with_application",
            "publicly_reachable",
            "expected_size_gib",
            "rpo",
            "rto",
            "restore_acceptance_test"
          ],
          "properties": {
            "requested": {
              "type": "boolean"
            },
            "colocated_with_application": {
              "const": true
            },
            "publicly_reachable": {
              "const": false
            },
            "expected_size_gib": {
              "$ref": "#/$defs/nullableNumber"
            },
            "rpo": {
              "$ref": "#/$defs/nullableString"
            },
            "rto": {
              "$ref": "#/$defs/nullableString"
            },
            "restore_acceptance_test": {
              "$ref": "#/$defs/nullableString"
            }
          }
        },
        "other_persistent_service": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "requested",
            "justification",
            "operator_design_required"
          ],
          "properties": {
            "requested": {
              "type": "boolean"
            },
            "justification": {
              "$ref": "#/$defs/nullableString"
            },
            "operator_design_required": {
              "const": true
            }
          }
        }
      }
    },
    "acceptance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "repository_tests",
        "local_smoke_test",
        "slurm_batch_test",
        "interactive_allocation_test",
        "GPU_visibility_and_utilization_test",
        "stage_in_test",
        "stage_out_test",
        "checkpoint_or_resume_test",
        "architecture_test",
        "service_negative_tests",
        "database_restore_test"
      ],
      "properties": {
        "repository_tests": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "local_smoke_test": {
          "$ref": "#/$defs/nullableString"
        },
        "slurm_batch_test": {
          "$ref": "#/$defs/nullableString"
        },
        "interactive_allocation_test": {
          "$ref": "#/$defs/nullableString"
        },
        "GPU_visibility_and_utilization_test": {
          "$ref": "#/$defs/nullableString"
        },
        "stage_in_test": {
          "$ref": "#/$defs/nullableString"
        },
        "stage_out_test": {
          "$ref": "#/$defs/nullableString"
        },
        "checkpoint_or_resume_test": {
          "$ref": "#/$defs/nullableString"
        },
        "architecture_test": {
          "$ref": "#/$defs/nullableString"
        },
        "service_negative_tests": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "database_restore_test": {
          "$ref": "#/$defs/nullableString"
        }
      }
    },
    "userSurfaces": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "clusterdocs_required",
        "rcc_admin_request_required",
        "files_portal_or_sftp_required",
        "open_ondemand_requested",
        "globus_requested",
        "coscine_archive_requested",
        "helpdesk_or_assistant_is_execution_dependency"
      ],
      "properties": {
        "clusterdocs_required": {
          "const": true
        },
        "rcc_admin_request_required": {
          "type": "boolean"
        },
        "files_portal_or_sftp_required": {
          "type": "boolean"
        },
        "open_ondemand_requested": {
          "type": "boolean"
        },
        "globus_requested": {
          "type": "boolean"
        },
        "coscine_archive_requested": {
          "type": "boolean"
        },
        "helpdesk_or_assistant_is_execution_dependency": {
          "const": false
        }
      }
    }
  }
}
