{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/launch.schema.json",
  "title": "Launch shape",
  "description": "Shape of launch.json: per host CLI, the argv template and environment that start a run, and where the launch request file goes. Templates use {placeholder} tokens named in `placeholders`. Every field is x-sensitivity none: the file ships with the package and holds templates, never a machine's values.",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "verified", "note", "requestFile", "placeholders", "hosts"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "verified": {
      "type": "boolean",
      "x-sensitivity": "none",
      "description": "false until a live launch trial confirmed the shape on a real host."
    },
    "note": { "type": "string", "x-sensitivity": "none" },
    "requestFile": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "env",
        "directory",
        "directoryDefault",
        "name",
        "fileMode",
        "schema",
        "lifetime"
      ],
      "x-sensitivity": "none",
      "properties": {
        "env": { "const": "MA_LAUNCH_REQUEST" },
        "directory": { "type": "string" },
        "directoryDefault": { "type": "string" },
        "name": { "type": "string" },
        "fileMode": { "type": "string", "pattern": "^0[0-7]{3}$" },
        "schema": { "type": "string" },
        "lifetime": { "type": "string" }
      }
    },
    "placeholders": {
      "type": "object",
      "x-sensitivity": "none",
      "additionalProperties": { "type": "string" }
    },
    "hosts": {
      "type": "object",
      "x-sensitivity": "none",
      "required": ["claude"],
      "additionalProperties": { "$ref": "#/$defs/host" }
    }
  },
  "$defs": {
    "host": {
      "type": "object",
      "additionalProperties": false,
      "required": ["supported", "note"],
      "properties": {
        "supported": { "type": "boolean" },
        "bin": { "type": "string" },
        "cwd": { "type": "string" },
        "note": { "type": "string" },
        "modes": {
          "type": "object",
          "propertyNames": { "enum": ["interactive", "autopilot"] },
          "additionalProperties": { "$ref": "#/$defs/shape" }
        },
        "background": {
          "type": "object",
          "description": "The unattended background launch per request kind: development runs /multi-agent without autopilot, analysis runs /multi-agent:analysis. A question nobody pre-answered parks the run (pendingQuestion) instead of being resolved from a default.",
          "additionalProperties": false,
          "required": ["development", "analysis"],
          "properties": {
            "development": { "$ref": "#/$defs/shape" },
            "analysis": { "$ref": "#/$defs/shape" }
          }
        },
        "resume": {
          "$ref": "#/$defs/shape",
          "description": "The unattended background launch of /multi-agent:resume for a run recorded under the unattended log root."
        }
      },
      "if": { "properties": { "supported": { "const": true } } },
      "then": { "required": ["bin", "cwd", "modes"] }
    },
    "shape": {
      "type": "object",
      "additionalProperties": false,
      "required": ["argv", "env"],
      "properties": {
        "argv": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "env": { "type": "object", "additionalProperties": { "type": "string" } }
      }
    }
  }
}
