{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "dd-flow/run-engine-binding@1",
  "title": "Immutable RUN engine binding",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_id", "run_id", "project_root", "bound_at", "source", "reason", "engine", "probe"],
  "properties": {
    "schema_id": {"const": "dd-flow/run-engine-binding@1"},
    "run_id": {"type": "string", "pattern": "^RUN-[0-9]+-[a-z0-9][a-z0-9-]*$"},
    "project_root": {"type": "string", "minLength": 1},
    "bound_at": {"type": "string", "format": "date-time"},
    "source": {"enum": ["run_creation", "legacy_recovery"]},
    "reason": {"type": "string", "minLength": 1},
    "engine": {
      "type": "object",
      "additionalProperties": false,
      "required": ["package_name", "package_version", "engine_version", "integrity_checksum", "snapshot_root"],
      "properties": {
        "package_name": {"type": "string", "minLength": 1},
        "package_version": {"type": "string", "minLength": 1},
        "engine_version": {"type": "string", "minLength": 1},
        "integrity_checksum": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
        "snapshot_root": {"type": "string", "minLength": 1}
      }
    },
    "probe": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "command"],
      "properties": {
        "status": {"enum": ["not_required", "passed"]},
        "command": {"type": ["string", "null"]}
      }
    }
  }
}
