{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://delegationcontracts.org/schemas/delegation-contract/v0.1/schema.json",
  "title": "DelegationContract",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "task_entry",
    "authority_level",
    "work_package",
    "acceptance_context"
  ],
  "properties": {
    "schema_version": {
      "const": "delegation-contract.v0.1"
    },
    "task_entry": {
      "type": "string",
      "description": "How the delegated work entered the agent workflow."
    },
    "authority_level": {
      "type": "string",
      "enum": ["L0", "L1", "L2", "L3", "L4", "L5"],
      "description": "The highest automation level granted for the delegated work."
    },
    "allowed_actions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "uniqueItems": true
    },
    "work_package": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      },
      "description": "Artifacts the agent must return."
    },
    "acceptance_context": {
      "type": "string",
      "description": "Where the human or governed workflow accepts, rejects, or escalates the result."
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "accessed_at": {
          "type": "string",
          "format": "date"
        }
      }
    },
    "notes": {
      "type": "string"
    }
  }
}
