{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.ontai.dev/v1alpha1/seam-core/InfrastructureRunnerConfig.json",
  "title": "InfrastructureRunnerConfig",
  "description": "Runtime configuration generated by the platform operator for a Conductor agent deployment. Owned by seam-core; platform operator authors RunnerConfig CRs exclusively (INV-009). Conductor agent reads RunnerConfig to discover its phases, steps, and operational parameters. Namespace: ont-system on the target cluster. conductor-schema.md.",
  "x-ont-layer": "seam-core",
  "x-ont-stability": "alpha",
  "x-ont-namespace": "ont-system",
  "x-ont-depends-on": [],
  "type": "object",
  "required": ["spec"],
  "properties": {
    "spec": {
      "type": "object",
      "description": "InfrastructureRunnerConfig specification. Operator-generated at runtime; never human-authored (INV-009).",
      "required": ["clusterRef", "runnerImage"],
      "properties": {
        "clusterRef": {
          "type": "string",
          "description": "Name of the TalosCluster this RunnerConfig is authoritative for."
        },
        "runnerImage": {
          "type": "string",
          "description": "Fully qualified container image reference for the Conductor agent. Format: registry/image:tag. Tag convention: v{talosVersion}-r{revision} stable, dev/dev-rc{N} development. INV-011."
        },
        "phases": {
          "type": "array",
          "description": "Ordered list of operational phases for this cluster's Conductor lifecycle.",
          "items": {
            "type": "object",
            "required": ["name"],
            "properties": {
              "name": {
                "type": "string",
                "description": "Phase name. Must be unique within the RunnerConfig."
              },
              "parameters": {
                "type": "object",
                "description": "Phase-specific parameters passed to capabilities executing within this phase.",
                "additionalProperties": true
              }
            },
            "additionalProperties": false
          }
        },
        "steps": {
          "type": "array",
          "description": "Ordered list of execution steps across all phases.",
          "items": {
            "type": "object",
            "required": ["name", "capability"],
            "properties": {
              "name": {
                "type": "string",
                "description": "Step identifier. Must be unique within the RunnerConfig."
              },
              "capability": {
                "type": "string",
                "description": "Named Conductor capability to invoke for this step (e.g., pack-deploy, talos-upgrade)."
              },
              "parameters": {
                "type": "object",
                "description": "Step-specific parameters forwarded to the capability at runtime.",
                "additionalProperties": true
              },
              "dependsOn": {
                "type": "array",
                "description": "Names of steps that must complete before this step may begin.",
                "items": {
                  "type": "string"
                }
              },
              "haltOnFailure": {
                "type": "boolean",
                "description": "When true, a failure in this step halts the entire RunnerConfig execution. When false, subsequent steps that do not depend on this step may still proceed."
              }
            },
            "additionalProperties": false
          }
        },
        "operationalHistory": {
          "type": "array",
          "description": "Append-only record of completed RunnerConfig executions for this cluster. Written by the Conductor agent.",
          "items": {
            "type": "object",
            "properties": {
              "completedAt": {
                "type": "string",
                "format": "date-time",
                "description": "Timestamp when the execution completed."
              },
              "status": {
                "type": "string",
                "enum": ["Succeeded", "Failed"],
                "description": "Terminal status of the execution."
              },
              "stepCount": {
                "type": "integer",
                "description": "Number of steps executed."
              }
            },
            "additionalProperties": true
          }
        },
        "maintenanceTargetNodes": {
          "type": "array",
          "description": "Node names selected for maintenance operations in the current RunnerConfig generation.",
          "items": {
            "type": "string"
          }
        },
        "operatorLeaderNode": {
          "type": "string",
          "description": "Node name of the elected operator leader for this cluster."
        },
        "selfOperation": {
          "type": "boolean",
          "description": "When true, this RunnerConfig governs an operation on the management cluster itself (e.g., management cluster upgrade)."
        }
      },
      "additionalProperties": false
    },
    "status": {
      "type": "object",
      "description": "Runtime status. Written exclusively by the Conductor agent leader (CR-INV-006).",
      "properties": {
        "capabilities": {
          "type": "array",
          "description": "Self-declared capability manifest emitted by the Conductor agent on startup. Operators must never hardcode capability availability assumptions (CR-INV-005).",
          "items": {
            "type": "object",
            "required": ["name", "version"],
            "properties": {
              "name": {
                "type": "string",
                "description": "Capability name (e.g., pack-deploy, talos-upgrade)."
              },
              "version": {
                "type": "string",
                "description": "Capability version declared by the agent."
              },
              "description": {
                "type": "string",
                "description": "Human-readable description of what this capability does."
              },
              "parameterSchema": {
                "type": "object",
                "description": "Schema describing the parameters accepted by this capability.",
                "additionalProperties": true
              }
            },
            "additionalProperties": false
          }
        },
        "agentVersion": {
          "type": "string",
          "description": "Version string of the Conductor agent binary currently running. Self-reported on startup."
        },
        "agentLeader": {
          "type": "string",
          "description": "Pod name of the current Conductor agent leader. Written by the leader on election win. Cleared on leader departure."
        },
        "phase": {
          "type": "string",
          "enum": ["Completed", "Failed"],
          "description": "Terminal execution phase written by Conductor execute mode. Completed: all steps succeeded. Failed: at least one step failed. Absent while in progress. Platform operators watch this field to detect terminal conditions. conductor-schema.md §17."
        },
        "failedStep": {
          "type": "string",
          "description": "Name of the first step that reached the Failed phase. Present only when phase=Failed. conductor-schema.md §17."
        },
        "stepResults": {
          "type": "array",
          "description": "Results of the most recent step executions in the current RunnerConfig generation.",
          "items": {
            "type": "object",
            "required": ["name", "status"],
            "properties": {
              "name": {
                "type": "string",
                "description": "Step name matching a spec.steps entry."
              },
              "status": {
                "type": "string",
                "enum": ["Succeeded", "Failed", "Skipped"],
                "description": "Terminal status of this step execution."
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "description": "Time this step began execution."
              },
              "completedAt": {
                "type": "string",
                "format": "date-time",
                "description": "Time this step finished execution."
              },
              "message": {
                "type": "string",
                "description": "Additional context about the step outcome."
              }
            },
            "additionalProperties": false
          }
        },
        "conditions": {
          "type": "array",
          "description": "Standard Kubernetes condition list for this RunnerConfig.",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
