{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/native-trigger.schema.json",
  "version": "1.0.0",
  "title": "Multi-Agent Pipeline  -  native component trigger record",
  "description": "The measurements native-trigger.mjs evaluates to decide whether a native (Rust) component is warranted: a pure-CPU operation above thresholdCpuSeconds (T1), batchable into one call (T2), with prebuilt-binary distribution accepted or the work kept inside the MCP toolkit (T3).",
  "type": "object",
  "required": ["thresholdCpuSeconds", "probes", "observed", "distribution"],
  "additionalProperties": false,
  "properties": {
    "thresholdCpuSeconds": {
      "const": 30,
      "description": "Equal to the literal in native-trigger.mjs; the script refuses a record that differs."
    },
    "probes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["id", "argv", "batchable"],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "string", "minLength": 1 },
          "argv": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 },
            "description": "Run from the repo root. A leading node is the running Node binary; $TMP is a temporary directory removed afterwards."
          },
          "batchable": { "type": "boolean" }
        }
      }
    },
    "observed": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["op", "cpuSeconds", "measuredAt"],
        "additionalProperties": false,
        "properties": {
          "op": { "type": "string", "minLength": 1 },
          "cpuSeconds": { "type": "number", "minimum": 0 },
          "wallSeconds": { "type": "number", "minimum": 0 },
          "batchable": { "type": "boolean" },
          "measuredAt": { "type": "string", "format": "date" }
        }
      }
    },
    "distribution": {
      "type": "object",
      "required": ["prebuiltBinaryAccepted", "toolkitOnly"],
      "additionalProperties": false,
      "properties": {
        "prebuiltBinaryAccepted": { "type": "boolean" },
        "toolkitOnly": { "type": "boolean" }
      }
    }
  }
}
