{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oms.local/schemas/conductor-dispatch-intent.schema.json",
  "title": "OMS conductor dispatch intent",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "goal_id",
    "goal_version",
    "ticket_id",
    "ticket_version",
    "lease_token",
    "attempt",
    "worker_id",
    "role_id",
    "model_id",
    "provider_mode",
    "worktree_id",
    "worktree_path",
    "capabilities",
    "budget_snapshot",
    "acceptance_criteria",
    "evidence_requirements",
    "task_body",
    "operation_nonce"
  ],
  "properties": {
    "goal_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "goal_version": { "type": "integer", "minimum": 0 },
    "ticket_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "ticket_version": { "type": "integer", "minimum": 0 },
    "lease_token": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "attempt": { "type": "integer", "minimum": 1 },
    "worker_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "role_id": { "type": "string", "pattern": "^oms\\.[a-z0-9.-]{1,63}$" },
    "model_id": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$" },
    "provider_mode": { "enum": ["claude_interactive", "codex_goal"] },
    "worktree_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "worktree_path": { "type": "string", "pattern": "^/", "maxLength": 4096 },
    "capabilities": {
      "type": "array",
      "maxItems": 16,
      "items": { "type": "string", "pattern": "^[a-z][a-z0-9.-]{0,63}$" }
    },
    "budget_snapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": ["profile", "remaining_attempts", "policy_digest"],
      "properties": {
        "profile": { "const": "subscription-only" },
        "remaining_attempts": { "type": "integer", "minimum": 0 },
        "policy_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
      }
    },
    "acceptance_criteria": {
      "type": "array",
      "maxItems": 32,
      "items": { "type": "string", "minLength": 1, "maxLength": 4096 }
    },
    "evidence_requirements": {
      "type": "array",
      "maxItems": 32,
      "items": { "type": "string", "minLength": 1, "maxLength": 4096 }
    },
    "task_body": { "type": "string", "minLength": 1, "maxLength": 32768 },
    "operation_nonce": {
      "type": "string",
      "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"
    }
  }
}
