{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/system-status.schema.json",
  "title": "System status",
  "description": "What GET /v1/system returns and `system-status.mjs --json` prints: CPU load, memory, free disk and what the pipeline itself uses. Numbers only: no path, process argument, user name or host name. A value that could not be measured is null, never 0.",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "generatedAt", "cpu", "memory", "disk", "pipeline", "warnings"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "generatedAt": { "type": "string", "format": "date-time", "x-sensitivity": "none" },
    "cpu": {
      "type": "object",
      "additionalProperties": false,
      "required": ["cores", "usage", "load"],
      "x-sensitivity": "none",
      "properties": {
        "cores": { "type": "integer", "minimum": 0 },
        "usage": {
          "type": ["number", "null"],
          "minimum": 0,
          "maximum": 1,
          "description": "Busy share of all cores over a short sampling window."
        },
        "load": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "items": { "type": "number", "minimum": 0 },
          "description": "Load average over 1, 5 and 15 minutes."
        }
      }
    },
    "memory": {
      "type": "object",
      "additionalProperties": false,
      "required": ["totalMb", "usedMb"],
      "x-sensitivity": "none",
      "properties": {
        "totalMb": { "type": "integer", "minimum": 0 },
        "usedMb": {
          "type": "integer",
          "minimum": 0,
          "description": "Total minus what the OS reports free; on macOS that counts the file cache as used."
        }
      }
    },
    "disk": {
      "type": "object",
      "additionalProperties": false,
      "required": ["home", "logs"],
      "x-sensitivity": "none",
      "properties": {
        "home": { "$ref": "#/$defs/disk" },
        "logs": {
          "oneOf": [{ "$ref": "#/$defs/disk" }],
          "description": "The disk the run logs live on, when it is not the home disk; null when it is the same disk."
        }
      }
    },
    "pipeline": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sessions", "toolkit", "rssMb", "logsMb"],
      "x-sensitivity": "none",
      "properties": {
        "sessions": {
          "type": ["integer", "null"],
          "minimum": 0,
          "description": "Claude Code processes running."
        },
        "toolkit": {
          "type": ["integer", "null"],
          "minimum": 0,
          "description": "multi-agent-mcp server processes running."
        },
        "rssMb": {
          "type": ["integer", "null"],
          "minimum": 0,
          "description": "Their resident memory together."
        },
        "logsMb": {
          "type": ["integer", "null"],
          "minimum": 0,
          "description": "Size of the run log folder; null when it could not be measured in time."
        }
      }
    },
    "warnings": {
      "type": "array",
      "items": { "enum": ["disk-low", "cpu-busy"] },
      "x-sensitivity": "none",
      "description": "disk-low: under 10 percent of the home disk is free. cpu-busy: the 5-minute load is above the core count."
    }
  },
  "$defs": {
    "disk": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["totalMb", "freeMb"],
      "properties": {
        "totalMb": { "type": "integer", "minimum": 0 },
        "freeMb": { "type": "integer", "minimum": 0 }
      }
    }
  }
}
