{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dicworkflowkit.local/schemas/harness-plan.schema.json",
  "title": "齐衡 QIHENG Candidate-Bound Harness Plan",
  "type": "object",
  "required": [
    "schema",
    "planId",
    "generatedAt",
    "profileHash",
    "candidate",
    "gates"
  ],
  "properties": {
    "schema": { "const": "dic.harness-plan.v1" },
    "planId": {
      "type": "string",
      "pattern": "^hplan-[a-f0-9]{16}$"
    },
    "generatedAt": { "type": "string", "format": "date-time" },
    "profileHash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "candidate": { "$ref": "#/$defs/candidate" },
    "gates": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/gate" }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "candidate": {
      "type": "object",
      "required": [
        "id",
        "ref",
        "contentHash",
        "head",
        "clean",
        "trackedDiffHash",
        "untracked"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^candidate-[a-f0-9]{16}$"
        },
        "ref": { "type": "string", "minLength": 1 },
        "contentHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "head": { "type": "string", "minLength": 1 },
        "clean": { "type": "boolean" },
        "trackedDiffHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "untracked": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["path", "contentHash"],
            "properties": {
              "path": { "type": "string", "minLength": 1 },
              "contentHash": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "gate": {
      "type": "object",
      "required": [
        "id",
        "domain",
        "skill",
        "agent",
        "contributors",
        "requiredHandoffs",
        "applicability",
        "defaultDisposition",
        "reason",
        "dependsOn",
        "invalidatedBy",
        "requiredEvidence"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9.-]+$"
        },
        "domain": {
          "enum": [
            "DESIGN",
            "DELIVERY",
            "DEVELOPMENT",
            "TEST",
            "ASSURANCE",
            "ADMISSION"
          ]
        },
        "skill": { "type": "string", "minLength": 1 },
        "agent": { "type": "string" },
        "contributors": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 },
          "uniqueItems": true
        },
        "requiredHandoffs": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 },
          "uniqueItems": true
        },
        "applicability": { "enum": ["REQUIRED", "CONDITIONAL"] },
        "defaultDisposition": { "enum": ["RUN", "ASSESS"] },
        "reason": { "type": "string", "minLength": 1 },
        "dependsOn": {
          "type": "array",
          "items": { "type": "string" },
          "uniqueItems": true
        },
        "invalidatedBy": {
          "type": "array",
          "items": {
            "enum": [
              "DESIGN",
              "POLICY",
              "IMPLEMENTATION",
              "TEST",
              "FIXTURE",
              "PIPELINE",
              "CANDIDATE"
            ]
          },
          "uniqueItems": true
        },
        "requiredEvidence": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string", "minLength": 1 },
          "uniqueItems": true
        }
      },
      "additionalProperties": false
    }
  }
}
