{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://devheallabs.com/dh-adom/source/02-Specification/Schema-Definitions/delegation-contract.schema.json",
  "title": "DH-ADOM Delegation Contract",
  "type": "object",
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "properties": {
    "apiVersion": {
      "const": "dh-adom.devheal.ai/v1alpha1"
    },
    "kind": {
      "const": "DelegationContract"
    },
    "metadata": {
      "type": "object",
      "required": [
        "delegation_id"
      ],
      "properties": {
        "delegation_id": {
          "type": "string"
        }
      }
    },
    "spec": {
      "type": "object",
      "required": [
        "parent_agent",
        "child_agent",
        "purpose",
        "task_id",
        "scope",
        "permissions",
        "autonomy",
        "lifecycle",
        "evidence",
        "acceptance"
      ],
      "properties": {
        "parent_agent": {
          "type": "string"
        },
        "child_agent": {
          "type": "string"
        },
        "purpose": {
          "type": "string"
        },
        "task_id": {
          "type": "string"
        },
        "scope": {
          "type": "object",
          "required": [
            "include",
            "exclude"
          ],
          "properties": {
            "include": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "exclude": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "permissions": {
          "type": "object"
        },
        "autonomy": {
          "type": "object",
          "required": [
            "level",
            "max_steps",
            "max_tool_calls",
            "max_runtime_seconds",
            "max_cost_usd",
            "max_parallel_agents",
            "max_delegation_depth"
          ],
          "properties": {
            "level": {
              "type": "string"
            },
            "max_steps": {
              "type": "integer"
            },
            "max_tool_calls": {
              "type": "integer"
            },
            "max_runtime_seconds": {
              "type": "integer"
            },
            "max_cost_usd": {
              "type": "number"
            },
            "max_parallel_agents": {
              "type": "integer"
            },
            "max_delegation_depth": {
              "type": "integer"
            }
          }
        },
        "lifecycle": {
          "type": "object"
        },
        "evidence": {
          "type": "object"
        },
        "acceptance": {
          "type": "object"
        }
      }
    }
  }
}