{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://medgauge.org/schemas/0.1.0/harness.schema.json",
  "title": "harness",
  "description": "One version of a registered harness (harness registry): runtime, model slots, tools, limits, sandbox, autonomy class and reproduction command.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^hx-[a-z0-9-]+$"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "name_zh": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "agent_cli",
        "api_toolloop",
        "ide_agent",
        "custom"
      ]
    },
    "base_runtime": {
      "type": "object",
      "properties": {
        "product": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "config_hash": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "product",
        "version"
      ],
      "additionalProperties": false
    },
    "model_slots": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "executor",
              "judge",
              "planner",
              "subagent"
            ]
          },
          "compatible_models": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "required": [
          "role",
          "compatible_models"
        ],
        "additionalProperties": false
      }
    },
    "components": {
      "type": "object",
      "properties": {
        "skills": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^(sk|pl|tl|mcp)-[a-z0-9-]+@\\d+\\.\\d+\\.\\d+$"
          }
        },
        "plugins": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^(sk|pl|tl|mcp)-[a-z0-9-]+@\\d+\\.\\d+\\.\\d+$"
          }
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^(sk|pl|tl|mcp)-[a-z0-9-]+@\\d+\\.\\d+\\.\\d+$"
          }
        },
        "mcp_servers": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^(sk|pl|tl|mcp)-[a-z0-9-]+@\\d+\\.\\d+\\.\\d+$"
          }
        }
      },
      "additionalProperties": false
    },
    "system_prompt_hash": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "limits": {
      "type": "object",
      "properties": {
        "max_steps": {
          "type": "integer",
          "minimum": 1
        },
        "max_output_tokens": {
          "type": "integer",
          "minimum": 1
        },
        "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 2
        },
        "timeout_sec": {
          "type": "integer",
          "minimum": 1
        },
        "budget_tokens": {
          "type": "integer",
          "minimum": 1
        },
        "note": {
          "type": "string"
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "sandbox": {
      "type": "object",
      "properties": {
        "container": {
          "type": "boolean"
        },
        "allow_internet": {
          "type": "boolean"
        },
        "filesystem": {
          "type": "string",
          "enum": [
            "readonly_inputs",
            "workspace_write",
            "full"
          ]
        },
        "image_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "container",
        "allow_internet",
        "filesystem"
      ],
      "additionalProperties": false
    },
    "autonomy": {
      "type": "string",
      "description": "Autonomy class: A1 assistant, A2 co-pilot, A3 executes with run records, A4 executes and self-verifies. Distinct from capability levels L0-L5.",
      "enum": [
        "A1",
        "A2",
        "A3",
        "A4"
      ]
    },
    "reproduction": {
      "type": "object",
      "properties": {
        "command": {
          "type": "string",
          "minLength": 1
        },
        "adapter_check": {
          "type": "object",
          "properties": {
            "oracle_pass": {
              "type": "boolean"
            },
            "checked_on": {
              "type": "string",
              "format": "date"
            },
            "benchmark": {
              "type": "string",
              "minLength": 1
            },
            "env_delta": {
              "type": "number",
              "minimum": 0,
              "maximum": 1,
              "description": "Absolute difference in pass^3 for the same harness in two environments (M9). Reported without a pass/fail judgement until a threshold is set (methodology section 8.5)"
            },
            "env_delta_signed": {
              "type": "number",
              "minimum": -1,
              "maximum": 1,
              "description": "Signed difference in pass^3 (second environment minus first)"
            }
          },
          "required": [
            "oracle_pass"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "command"
      ],
      "additionalProperties": false
    },
    "capabilities_targeted": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[ABCDEX]\\.\\d+(\\.\\d+)?$"
      }
    },
    "maintainer": {
      "type": "object",
      "properties": {
        "org": {
          "type": "string",
          "minLength": 1
        },
        "contact": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "org"
      ],
      "additionalProperties": false
    },
    "license": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "proposed",
        "experimental",
        "deprecated",
        "retired",
        "planned"
      ]
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "File path registry/harnesses/<id>/<version>.yaml; immutable once published"
    },
    "interface": {
      "description": "Model interface the harness speaks; a list when it speaks more than one.",
      "oneOf": [
        { "type": "string", "enum": ["messages_api", "chat_completions_compatible", "other"] },
        { "type": "array", "items": { "type": "string", "enum": ["messages_api", "chat_completions_compatible", "other"] }, "minItems": 1, "uniqueItems": true }
      ]
    },
    "notes": {
      "type": "string"
    },
    "tools_exposed_summary": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "id",
    "name",
    "kind",
    "base_runtime",
    "limits",
    "sandbox",
    "autonomy",
    "reproduction",
    "maintainer",
    "license",
    "status",
    "version"
  ]
}
