{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "setup-preflight.schema.json",
  "title": "Setup Preflight Configuration",
  "description": "Runtime contract for setup-preflight.json. Strict on sceneOptimizer and assetValidator — downstream agents cross-check operationsAvailable against planned operations. A wrong field name means the operation check fails silently.",
  "type": "object",
  "required": [
    "schemaVersion",
    "runtime_route",
    "sceneOptimizer",
    "assetValidator",
    "runtime_context",
    "probed_at"
  ],
  "additionalProperties": true,
  "properties": {
    "schemaVersion": {
      "type": "string"
    },
    "runtime_route": {
      "type": "string",
      "enum": ["kit", "standalone"]
    },
    "kit": {
      "type": "object",
      "description": "Present when runtime_route is 'kit'. Kit application metadata.",
      "additionalProperties": true,
      "properties": {
        "application": { "type": "string" },
        "version": { "type": "string" },
        "path": { "type": "string" },
        "build": { "type": "string" }
      }
    },
    "sceneOptimizer": {
      "type": "object",
      "description": "Scene Optimizer runtime identity. Strict: operationsAvailable is the cross-check contract consumed by EXECUTION.md and so-run-operations.",
      "required": ["extension", "version", "operationsAvailable", "source"],
      "additionalProperties": false,
      "properties": {
        "extension": {
          "type": "string",
          "description": "Extension or package name"
        },
        "version": {
          "type": "string"
        },
        "operationsAvailable": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Sorted list of operation keys registered in the live runtime"
        },
        "source": {
          "type": "string",
          "enum": ["kit-extension", "standalone-package"]
        }
      }
    },
    "assetValidator": {
      "type": "object",
      "description": "Asset Validator runtime identity. Strict: source enum determines validation command patterns.",
      "required": ["package", "version", "source"],
      "additionalProperties": false,
      "properties": {
        "package": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "source": {
          "type": "string",
          "enum": ["kit-extension", "pip", "standalone"]
        }
      }
    },
    "runtime_context": {
      "type": "object",
      "description": "Canonical runtime context block that downstream skills (optimization-report, the runtime-context-header) consume. The probe writes the chosen runtime here and the header prints from it; the source kit/sceneOptimizer/assetValidator fields above are the raw probe data. Inner shape matches the optimization-report schema's runtime_context definition exactly so the block can be copied verbatim into the report.",
      "required": ["kit", "sceneOptimizer", "assetValidator"],
      "properties": {
        "kit": {
          "type": "object",
          "required": ["application", "version", "path"],
          "properties": {
            "application": {
              "type": "string",
              "description": "Friendly name of the Kit application, e.g. 'USD Composer', 'Isaac Sim', 'Kit SDK'."
            },
            "version": {
              "type": "string",
              "description": "Release version, e.g. '110.1.0'."
            },
            "path": {
              "type": "string",
              "description": "Absolute path to the Kit root."
            },
            "build": {
              "type": ["string", "null"],
              "description": "Full build identifier when present (e.g. '110.1.0+main.10181....release'); null when the install path does not encode one."
            }
          }
        },
        "sceneOptimizer": {
          "type": "object",
          "required": ["extension", "version"],
          "properties": {
            "extension": {
              "type": "string",
              "description": "Extension name, typically 'omni.scene.optimizer.core'."
            },
            "version": {
              "type": "string",
              "description": "Extension version, e.g. '110.0.4'."
            }
          }
        },
        "assetValidator": {
          "type": "object",
          "required": ["package", "version", "source"],
          "properties": {
            "package": {
              "type": "string",
              "description": "Package or extension name, e.g. 'omniverse-asset-validator' or 'omni.asset_validator.core'."
            },
            "version": {
              "type": "string",
              "description": "Package version."
            },
            "source": {
              "type": "string",
              "enum": ["kit-extension", "pip", "standalone"],
              "description": "Where Asset Validator was loaded from."
            }
          }
        }
      }
    },
    "probed_at": {
      "type": "string",
      "description": "ISO 8601 timestamp of when the probe ran"
    }
  }
}
