{
  "$defs": {
    "Attestation": {
      "additionalProperties": false,
      "description": "The seller's declarations about the pack.",
      "properties": {
        "explicit_authorship": {
          "title": "Explicit Authorship",
          "type": "boolean"
        },
        "no_customer_data": {
          "title": "No Customer Data",
          "type": "boolean"
        },
        "seller_terms_version": {
          "pattern": "^[a-z0-9][a-z0-9._-]{0,19}$",
          "title": "Seller Terms Version",
          "type": "string"
        }
      },
      "required": [
        "explicit_authorship",
        "no_customer_data",
        "seller_terms_version"
      ],
      "title": "Attestation",
      "type": "object"
    },
    "ExpressionCondition": {
      "additionalProperties": false,
      "description": "One condition of a ``when`` rule over the task context.",
      "properties": {
        "field": {
          "enum": [
            "task_type",
            "category",
            "input_has",
            "language",
            "mode"
          ],
          "title": "Field",
          "type": "string"
        },
        "op": {
          "enum": [
            "eq",
            "in",
            "not_in"
          ],
          "title": "Op",
          "type": "string"
        },
        "values": {
          "items": {
            "type": "string"
          },
          "title": "Values",
          "type": "array"
        }
      },
      "required": [
        "field",
        "op",
        "values"
      ],
      "title": "ExpressionCondition",
      "type": "object"
    },
    "ExpressionRule": {
      "additionalProperties": false,
      "description": "A gene's ``when`` rule: every condition must hold for the gene to apply.",
      "properties": {
        "all": {
          "items": {
            "$ref": "#/$defs/ExpressionCondition"
          },
          "maxItems": 4,
          "minItems": 1,
          "title": "All",
          "type": "array"
        }
      },
      "required": [
        "all"
      ],
      "title": "ExpressionRule",
      "type": "object"
    },
    "PackGene": {
      "additionalProperties": false,
      "description": "One seller-authored gene: plain text plus where it applies.",
      "properties": {
        "key": {
          "pattern": "^[a-z][a-z0-9_]{2,29}$",
          "title": "Key",
          "type": "string"
        },
        "kind": {
          "enum": [
            "style",
            "rule",
            "decision",
            "business",
            "role"
          ],
          "title": "Kind",
          "type": "string"
        },
        "overrides": {
          "default": [],
          "items": {
            "pattern": "^[a-z][a-z0-9_]{2,29}$",
            "type": "string"
          },
          "title": "Overrides",
          "type": "array"
        },
        "placement": {
          "enum": [
            "agent",
            "shared",
            "org"
          ],
          "title": "Placement",
          "type": "string"
        },
        "role_spec": {
          "anyOf": [
            {
              "$ref": "#/$defs/RoleSpec"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "scope": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Scope",
          "type": "array"
        },
        "text": {
          "minLength": 1,
          "title": "Text",
          "type": "string"
        },
        "when": {
          "anyOf": [
            {
              "$ref": "#/$defs/ExpressionRule"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "key",
        "kind",
        "placement",
        "text"
      ],
      "title": "PackGene",
      "type": "object"
    },
    "PackManifest": {
      "additionalProperties": false,
      "description": "Listing-facing facts about the pack.",
      "properties": {
        "attestation": {
          "$ref": "#/$defs/Attestation"
        },
        "language": {
          "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8}){0,3}$",
          "title": "Language",
          "type": "string"
        },
        "target_agents": {
          "items": {
            "$ref": "#/$defs/TargetAgent"
          },
          "maxItems": 10,
          "minItems": 1,
          "title": "Target Agents",
          "type": "array"
        },
        "title": {
          "maxLength": 80,
          "minLength": 3,
          "title": "Title",
          "type": "string"
        }
      },
      "required": [
        "title",
        "language",
        "target_agents",
        "attestation"
      ],
      "title": "PackManifest",
      "type": "object"
    },
    "RoleSpec": {
      "additionalProperties": false,
      "description": "The structured part of a ``role`` gene: who plays which part in the work.",
      "properties": {
        "condition": {
          "default": "",
          "maxLength": 200,
          "title": "Condition",
          "type": "string"
        },
        "label": {
          "maxLength": 40,
          "title": "Label",
          "type": "string"
        },
        "role": {
          "enum": [
            "approver",
            "recipient",
            "reviewer",
            "requester",
            "escalation"
          ],
          "title": "Role",
          "type": "string"
        },
        "task_types": {
          "default": [],
          "items": {
            "type": "string"
          },
          "maxItems": 10,
          "title": "Task Types",
          "type": "array"
        }
      },
      "required": [
        "role",
        "label"
      ],
      "title": "RoleSpec",
      "type": "object"
    },
    "TargetAgent": {
      "additionalProperties": false,
      "description": "An agent the pack is written for, with the task labels it covers.",
      "properties": {
        "agent": {
          "pattern": "^[a-z0-9][a-z0-9_-]{0,63}$",
          "title": "Agent",
          "type": "string"
        },
        "tasks": {
          "items": {
            "maxLength": 60,
            "minLength": 1,
            "type": "string"
          },
          "maxItems": 5,
          "minItems": 1,
          "title": "Tasks",
          "type": "array"
        }
      },
      "required": [
        "agent",
        "tasks"
      ],
      "title": "TargetAgent",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "A genome pack, format version 1.x.",
  "properties": {
    "genes": {
      "items": {
        "$ref": "#/$defs/PackGene"
      },
      "minItems": 1,
      "title": "Genes",
      "type": "array"
    },
    "manifest": {
      "$ref": "#/$defs/PackManifest"
    },
    "pack": {
      "pattern": "^1\\.(0|[1-9][0-9]{0,5})$",
      "title": "Pack",
      "type": "string"
    }
  },
  "required": [
    "pack",
    "manifest",
    "genes"
  ],
  "title": "Genome Pack 1.0",
  "type": "object"
}
