{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oms.local/schemas/dispatch-result.schema.json",
  "title": "OMS dispatch result receipt",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "dispatch_id", "goal_id", "goal_version", "worker_record_id", "session_id", "ticket_id", "attempt", "lease_token",
    "worktree_id", "worktree_path", "worktree_commit", "status", "summary", "operation_nonce", "reported_at"
  ],
  "properties": {
    "dispatch_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "goal_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "goal_version": { "type": "integer", "minimum": 0 },
    "worker_record_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "session_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "ticket_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "attempt": { "type": "integer", "minimum": 1 },
    "lease_token": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "worktree_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "worktree_path": { "type": "string", "pattern": "^/", "maxLength": 4096 },
    "worktree_commit": { "type": "string", "pattern": "^[a-f0-9]{40}(?:[a-f0-9]{24})?$" },
    "status": { "enum": ["done", "blocked"] },
    "summary": { "type": "string", "minLength": 1, "maxLength": 8192 },
    "operation_nonce": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "reported_at": { "type": "string", "minLength": 20, "maxLength": 24 }
  }
}
