{
  "openapi": "3.1.0",
  "info": {
    "title": "Orch8.io API",
    "description": "Durable task sequencing engine — REST API.\n\nAll versioned endpoints are available under the `/api/v1` prefix (canonical) and also at the bare path for backward compatibility. Bare-path responses carry Deprecation, Sunset, and successor-version +            Link headers. Health and metrics endpoints remain at the root +            (`/health/*`, `/metrics`).",
    "license": {
      "name": "BUSL-1.1"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/api/v1",
      "description": "Versioned API (canonical)"
    },
    {
      "url": "/",
      "description": "Unversioned (deprecated, backward-compat)"
    }
  ],
  "paths": {
    "/alerts/rules": {
      "get": {
        "tags": [
          "alerts"
        ],
        "operationId": "list_rules",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alert rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AlertRule"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "alerts"
        ],
        "operationId": "create_rule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AlertRuleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Rule created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlertRule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid rule (e.g. literal secret instead of credentials:// reference)"
          }
        }
      }
    },
    "/alerts/rules/{id}": {
      "get": {
        "tags": [
          "alerts"
        ],
        "operationId": "get_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rule with evaluator state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlertRuleView"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "put": {
        "tags": [
          "alerts"
        ],
        "operationId": "update_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AlertRuleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Rule replaced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlertRule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid rule"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "delete": {
        "tags": [
          "alerts"
        ],
        "operationId": "delete_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/approvals/act/{token}": {
      "get": {
        "tags": [
          "approvals"
        ],
        "operationId": "confirm_page",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "Approval magic-link token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation page (no state change)",
            "content": {
              "text/html": {}
            }
          },
          "410": {
            "description": "Unknown, used, or expired link",
            "content": {
              "text/html": {}
            }
          }
        }
      },
      "post": {
        "tags": [
          "approvals"
        ],
        "operationId": "act",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "Approval magic-link token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Optional `comment` (form field or JSON `{\"comment\"}`)",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Decision recorded"
          },
          "409": {
            "description": "Workflow already finished"
          },
          "410": {
            "description": "Unknown, used, or expired link"
          }
        }
      }
    },
    "/approvals/slack/interactions": {
      "post": {
        "tags": [
          "approvals"
        ],
        "operationId": "slack_interaction",
        "requestBody": {
          "description": "Slack interactivity payload",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Interaction processed (Slack requires 200)"
          },
          "401": {
            "description": "Bad Slack signature, stale timestamp, or unknown token"
          }
        }
      }
    },
    "/artifacts/{key}": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_artifact_bytes",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "Artifact object key (`<instance_id>/<artifact_id>`); the route is the wildcard `/artifacts/{*key}`, so the key keeps its slashes",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "content_type",
            "in": "query",
            "description": "Override response Content-Type",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Raw artifact bytes"
          },
          "404": {
            "description": "Artifact not found"
          }
        }
      }
    },
    "/budgets": {
      "get": {
        "tags": [
          "budgets"
        ],
        "operationId": "list_budgets",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Budgets with current-period spend and state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BudgetStatus"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "budgets"
        ],
        "operationId": "create_budget",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BudgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantBudget"
                }
              }
            }
          },
          "400": {
            "description": "Invalid budget"
          },
          "403": {
            "description": "Requires the root/admin API key"
          }
        }
      }
    },
    "/budgets/alerts": {
      "get": {
        "tags": [
          "budgets"
        ],
        "operationId": "list_alerts",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max alerts (default 100, max 1000)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`budget.threshold_crossed` records, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BudgetAlert"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/budgets/{id}": {
      "put": {
        "tags": [
          "budgets"
        ],
        "operationId": "update_budget",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Budget id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BudgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantBudget"
                }
              }
            }
          },
          "403": {
            "description": "Requires the root/admin API key"
          },
          "404": {}
        }
      },
      "delete": {
        "tags": [
          "budgets"
        ],
        "operationId": "delete_budget",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Budget id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {},
          "403": {},
          "404": {}
        }
      }
    },
    "/changes": {
      "get": {
        "tags": [
          "changes"
        ],
        "operationId": "list_changes",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Required without X-Tenant-Id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Exclusive opaque cursor from next_cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, capped at 500",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ascending tenant state changes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangePage"
                }
              }
            }
          },
          "400": {
            "description": "Missing tenant or malformed cursor"
          }
        }
      }
    },
    "/changes/stream": {
      "get": {
        "tags": [
          "changes"
        ],
        "operationId": "stream_changes",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Required without X-Tenant-Id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Overrides Last-Event-ID when supplied",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum changes fetched per poll",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resumable tenant change stream (SSE)"
          },
          "400": {
            "description": "Missing tenant or malformed cursor"
          },
          "429": {
            "description": "Concurrent stream limit reached"
          }
        }
      }
    },
    "/circuit-breakers": {
      "get": {
        "tags": [
          "crate::circuit_breakers"
        ],
        "operationId": "list_all_breakers",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CircuitBreakerState"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/cluster/nodes": {
      "get": {
        "tags": [
          "crate::cluster"
        ],
        "operationId": "list_nodes",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClusterNode"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/cluster/nodes/{id}/drain": {
      "post": {
        "tags": [
          "crate::cluster"
        ],
        "operationId": "drain_node",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Node ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Drain signal sent"
          }
        }
      }
    },
    "/continuity/attention": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "create_attention_task",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/attention/{id}/assign": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "assign_attention_task",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/attention/{id}/decide": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "decide_attention_task",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/capsules/import": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "import_capsule",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/commercial/validate": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "validate_commercial_plan",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialContinuityPlan"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Deployment violates a mandatory commercial invariant"
          }
        }
      }
    },
    "/continuity/compensations/{id}": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "get_compensation_run",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/compensations/{id}/claim": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "claim_compensation_step",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/compensations/{id}/steps/{effect_id}/complete": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "complete_compensation_step",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/compensations/{id}/steps/{effect_id}/fail": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "fail_compensation_step",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/compensations/{id}/steps/{effect_id}/verify": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "verify_compensation_step",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/conformance/badge": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "render_badge",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConformanceCertificate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Server-verified SVG badge",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Certificate is invalid, expired, or tampered"
          }
        }
      }
    },
    "/continuity/conformance/certificates": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "certify",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CertificationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConformanceCertificate"
                }
              }
            }
          },
          "400": {
            "description": "Results or certificate window do not qualify"
          },
          "503": {
            "description": "Signing is not configured"
          }
        }
      }
    },
    "/continuity/delegations/claim": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "claim_delegation",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/delegations/{id}": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "get_delegation",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/disclosure/minimize": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "minimize_disclosure",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/effects/{id}/resolve": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "resolve_effect",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/evaluations/gate": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "evaluate_gate",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/evaluations/stored-gate": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "evaluate_stored_gate",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "create_execution",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "get_execution",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/budget-reservations": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_execution_budget_reservations",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      },
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "reserve_execution_budget",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/budget-reservations/{reservation_id}/reconcile": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "reconcile_execution_budget",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/budget-reservations/{reservation_id}/release": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "release_execution_budget",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/checkpoints": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_continuity_checkpoints",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/checkpoints/{checkpoint_id}": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "get_continuity_checkpoint",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/compensations": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "create_compensation_run",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/compensations/preview": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "preview_compensation",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/effects": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_effects",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/evaluations": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_evaluations",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      },
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "append_evaluation",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/handoff-preview": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "handoff_preview",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/invariants/evaluate": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "evaluate_invariants",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/invariants/results": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_invariant_results",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/locations": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_locations",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/placement": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "choose_placement",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/provenance": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_provenance",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      },
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "record_provenance_boundary",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/provenance/verify": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "verify_provenance",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/test-fixture": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "extract_test_fixture",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/executions/{id}/what-if": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_what_if_runs",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      },
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "run_what_if",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/fault-lab/run": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "run_fault_lab",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/federation/sign": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "sign_federation",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/federation/verify": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "verify_federation",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/gateways/validate": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "validate_gateway",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GatewayManifest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompiledPlacementPolicy"
                }
              }
            }
          },
          "400": {
            "description": "Gateway manifest is unsafe or invalid"
          }
        }
      }
    },
    "/continuity/grants": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "issue_continuation_grant",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/grants/consume": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "consume_continuation_grant",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "create_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "get_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/accept": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "accept_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/accept-external": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "accept_external_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/attach-device-capsule": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "attach_device_capsule",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/export": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "export_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/reject": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "reject_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/resume": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "resume_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/resume-external": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "resume_external_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/handoffs/{id}/revoke": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "revoke_handoff",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/invariants": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_invariants",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      },
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "create_invariant",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/migrations/plan": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "plan_live_migration",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/migrations/{id}": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "get_live_migration",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/migrations/{id}/apply": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "apply_live_migration",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/migrations/{id}/rollback": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "rollback_live_migration",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/offers/validate": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "validate_offer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortableWorkOffer"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Offer violates the protocol contract"
          }
        }
      }
    },
    "/continuity/optimizations/recommend": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "recommend_optimizations",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/optimizations/{id}/accept": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "accept_optimization",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/policies/compile": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "compile_policy",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompilePolicyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompiledPlacementPolicy"
                }
              }
            }
          },
          "400": {
            "description": "Policy is invalid or contains unknown keys"
          }
        }
      }
    },
    "/continuity/profiles": {
      "get": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "list_profiles",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProfileContract"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/continuity/profiles/{profile}/offers": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "create_profile_offer",
        "parameters": [
          {
            "name": "profile",
            "in": "path",
            "description": "Snake-case trust-boundary profile name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProfileOfferRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortableWorkOffer"
                }
              }
            }
          },
          "400": {
            "description": "Unknown profile or invalid offer"
          }
        }
      }
    },
    "/continuity/protocol": {
      "get": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "protocol_description",
        "responses": {
          "200": {
            "description": "Versioned handoff protocol and invariants",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProtocolDescription"
                }
              }
            }
          }
        }
      }
    },
    "/continuity/providers/choose": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "choose_provider",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/receipts/verify": {
      "post": {
        "tags": [
          "continuity-product"
        ],
        "operationId": "verify_receipt",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecutionReceipt"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Receipt is incomplete or its digest does not match"
          }
        }
      }
    },
    "/continuity/residency/evaluate": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "evaluate_residency",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/scenarios/generate": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "generate_scenarios",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/scenarios/reproduce": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "reproduce_incident",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/streams": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "create_stream",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/streams/{id}/frames": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_stream_frames",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      },
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "append_stream_frame",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/streams/{id}/retract": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "retract_stream_frames",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/continuity/streams/{id}/windows": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_stream_windows",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/cron": {
      "get": {
        "tags": [
          "cron"
        ],
        "operationId": "list_cron",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of cron schedules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CronSchedule"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "cron"
        ],
        "operationId": "create_cron",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCronRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Cron schedule created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Invalid cron expression"
          }
        }
      }
    },
    "/cron/{id}": {
      "get": {
        "tags": [
          "cron"
        ],
        "operationId": "get_cron",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Cron schedule ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cron schedule found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CronSchedule"
                }
              }
            }
          },
          "404": {
            "description": "Cron schedule not found"
          }
        }
      },
      "put": {
        "tags": [
          "cron"
        ],
        "operationId": "update_cron",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Cron schedule ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCronRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Cron schedule updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CronSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid cron expression"
          },
          "404": {
            "description": "Cron schedule not found"
          }
        }
      },
      "delete": {
        "tags": [
          "cron"
        ],
        "operationId": "delete_cron",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Cron schedule ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Cron schedule deleted"
          }
        }
      }
    },
    "/cron/{id}/next-fires": {
      "get": {
        "tags": [
          "cron"
        ],
        "operationId": "next_fires",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Cron schedule ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "n",
            "in": "query",
            "description": "How many upcoming fires to preview (default 5, max 50)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Upcoming fire instants (UTC, DST-correct)",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "404": {
            "description": "Cron schedule not found"
          }
        }
      }
    },
    "/debug/template": {
      "post": {
        "tags": [
          "debug"
        ],
        "operationId": "debug_template_endpoint",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DebugTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Resolved template value with provenance trace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DebugTemplateResponse"
                }
              }
            }
          }
        }
      }
    },
    "/embed/approvals": {
      "get": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_list_approvals",
        "responses": {
          "200": {
            "description": "Pending approvals of the sub-tenant's runs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbedApprovalList"
                }
              }
            }
          },
          "403": {
            "description": "Token lacks approvals:resolve"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      }
    },
    "/embed/approvals/{id}": {
      "post": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_resolve_approval",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Approval id from GET /embed/approvals",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResolveApprovalRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Decision recorded",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Choice is not offered by the approval"
          },
          "404": {
            "description": "Unknown or foreign approval"
          },
          "409": {
            "description": "Already resolved, or the run already finished"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      }
    },
    "/embed/runs": {
      "get": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_list_runs",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Page size (default 20, max 100).",
            "required": false,
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Opaque cursor from a previous page.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The sub-tenant's runs, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbedRunList"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid embed token"
          },
          "403": {
            "description": "Token lacks runs:read"
          },
          "404": {
            "description": "Embedding is disabled"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      },
      "post": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_start_run",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartRunRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Run started for the token's sub-tenant",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Token lacks runs:start or the sequence"
          },
          "404": {
            "description": "Unknown/invisible sequence, or embedding disabled"
          },
          "429": {
            "description": "Tenant pool or sub-tenant cap reached (`sub_tenant_quota_exceeded`)"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      }
    },
    "/embed/runs/{id}": {
      "get": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_get_run",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Run (instance) id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Run timeline; outputs only for opted-in steps",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbedRunDetail"
                }
              }
            }
          },
          "404": {
            "description": "Unknown, foreign, or embedding disabled"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      }
    },
    "/embed/sequences": {
      "get": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_list_sequences",
        "responses": {
          "200": {
            "description": "Latest version of every sequence visible to the sub-tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbedSequenceList"
                }
              }
            }
          },
          "403": {
            "description": "Token lacks sequences:read / builder:edit / runs:start"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      }
    },
    "/embed/sequences/{name}": {
      "get": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_get_sequence",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "description": "Sequence name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Namespace (default `default`).",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Summary + `definition`. Owned sequences and gallery templates carry the full definition; other tenant-level sequences an allow-list projection (block types, ids, handler names, nesting; `redacted: true`)",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "404": {
            "description": "Unknown or not visible"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      },
      "put": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_put_sequence",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "description": "Sequence name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Namespace (default `default`).",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "description": "Sequence document (blocks, input_schema, embed, …); identity fields are server-assigned",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "New version created, owned by the token's sub-tenant",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Token lacks builder:edit or the sequence"
          },
          "409": {
            "description": "The name belongs to the tenant or another sub-tenant"
          },
          "413": {
            "description": "Body exceeds 1 MiB"
          },
          "422": {
            "description": "Rejected by the embed sandbox: a handler outside the allowlist (`[embed] sandbox_handlers`), a `credentials://` reference, or a `sub_sequence` target the sub-tenant does not own"
          },
          "429": {
            "description": "Per-sequence version cap or per-sub-tenant sequence cap reached (`sub_tenant_quota_exceeded`)"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      }
    },
    "/embed/theme": {
      "get": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_get_theme",
        "responses": {
          "200": {
            "description": "Tenant embed theme (embed token or tenant API key)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThemeResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid embed token"
          },
          "404": {
            "description": "Embedding is disabled"
          }
        },
        "security": [
          {
            "embed_token": []
          }
        ]
      },
      "put": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_put_theme",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbedTheme"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Stored; `hide_badge` reports the effective (license-gated) value",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThemeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid theme"
          },
          "404": {
            "description": "Embedding is disabled"
          }
        }
      }
    },
    "/embed/tokens": {
      "post": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_issue_token",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IssueTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Scoped embed token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssueTokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid sub-tenant, scopes, sequences or TTL"
          },
          "404": {
            "description": "Embedding is disabled (no token secret)"
          }
        }
      }
    },
    "/embed/tokens/{jti}/revoke": {
      "post": {
        "tags": [
          "embed"
        ],
        "operationId": "embed_revoke_token",
        "parameters": [
          {
            "name": "jti",
            "in": "path",
            "description": "Token id (`token_id` from the mint response)",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Token revoked; it is refused within a few seconds"
          },
          "403": {
            "description": "Operator capability required"
          },
          "404": {
            "description": "Embedding is disabled"
          }
        }
      }
    },
    "/events": {
      "get": {
        "tags": [
          "events"
        ],
        "operationId": "list_events",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "pending | consumed | expired",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max rows (default 100, max 1000)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Rows to skip",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "paged",
            "in": "query",
            "description": "Return items, offset and has_more metadata instead of an array",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events, newest first (payloads redacted)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventListResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "events"
        ],
        "operationId": "ingest_event",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IngestEventRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Duplicate producer id — already ingested",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngestOutcome"
                }
              }
            }
          },
          "201": {
            "description": "Event ingested (and possibly matched)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngestOutcome"
                }
              }
            }
          },
          "400": {
            "description": "Missing fields"
          }
        }
      }
    },
    "/events/batch": {
      "post": {
        "tags": [
          "events"
        ],
        "operationId": "ingest_event_batch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchIngestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Outbox batch accepted; individual duplicates are reported",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchIngestResponse"
                }
              }
            }
          },
          "400": {
            "description": "Empty, oversized, or invalid batch"
          }
        }
      }
    },
    "/events/{id}": {
      "get": {
        "tags": [
          "events"
        ],
        "operationId": "get_event",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Event (payload redacted)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/federation/calls/{call_id}": {
      "get": {
        "tags": [
          "federation"
        ],
        "operationId": "get_call",
        "parameters": [
          {
            "name": "call_id",
            "in": "path",
            "description": "Outbound call id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (ignored when the caller is bound to a tenant by its key/header).",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FederationCall"
                }
              }
            }
          },
          "404": {}
        }
      }
    },
    "/federation/identity": {
      "get": {
        "tags": [
          "federation"
        ],
        "operationId": "get_identity",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FederationIdentity"
                }
              }
            }
          },
          "503": {
            "description": "No engine encryption key configured"
          }
        }
      }
    },
    "/federation/inbound": {
      "post": {
        "tags": [
          "federation"
        ],
        "operationId": "inbound",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignedFederationMessage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Signed response envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignedFederationMessage"
                }
              }
            }
          },
          "401": {
            "description": "Envelope outside its validity window (clock skew)"
          },
          "403": {
            "description": "Unknown/revoked/expired peer, bad signature, or policy denial"
          },
          "404": {
            "description": "Allowed sequence is not deployed"
          },
          "503": {
            "description": "Federation disabled (no engine encryption key)"
          }
        },
        "security": [
          {}
        ]
      }
    },
    "/federation/peers": {
      "get": {
        "tags": [
          "federation"
        ],
        "operationId": "list_peers",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (ignored when the caller is bound to a tenant by its key/header).",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FederationPeerRecord"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "federation"
        ],
        "operationId": "create_peer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PeerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FederationPeerRecord"
                }
              }
            }
          },
          "400": {
            "description": "Invalid peer (identity/key mismatch, non-HTTPS endpoint, wildcard disclosure for an organization peer)"
          },
          "403": {
            "description": "Requires the root/admin API key"
          },
          "409": {
            "description": "Peer already registered"
          }
        }
      }
    },
    "/federation/peers/{peer_id}": {
      "get": {
        "tags": [
          "federation"
        ],
        "operationId": "get_peer",
        "parameters": [
          {
            "name": "peer_id",
            "in": "path",
            "description": "Peer federation id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (ignored when the caller is bound to a tenant by its key/header).",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FederationPeerRecord"
                }
              }
            }
          },
          "404": {}
        }
      },
      "put": {
        "tags": [
          "federation"
        ],
        "operationId": "update_peer",
        "parameters": [
          {
            "name": "peer_id",
            "in": "path",
            "description": "Peer federation id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PeerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FederationPeerRecord"
                }
              }
            }
          },
          "403": {
            "description": "Requires the root/admin API key"
          },
          "404": {}
        }
      },
      "delete": {
        "tags": [
          "federation"
        ],
        "operationId": "delete_peer",
        "parameters": [
          {
            "name": "peer_id",
            "in": "path",
            "description": "Peer federation id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (ignored when the caller is bound to a tenant by its key/header).",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "204": {},
          "403": {
            "description": "Requires the root/admin API key"
          },
          "404": {}
        }
      }
    },
    "/handlers": {
      "get": {
        "tags": [
          "workers"
        ],
        "operationId": "list_handlers",
        "responses": {
          "200": {
            "description": "Handler catalog",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HandlerCatalog"
                }
              }
            }
          }
        }
      }
    },
    "/health/live": {
      "get": {
        "tags": [
          "health"
        ],
        "summary": "Liveness probe: returns 200 while the process is running, unless an engine\nruns here and its tick loop has not completed an iteration within\n`engine.liveness_stale_secs` — then 503, so the orchestrator restarts a\nwedged scheduler instead of keeping it forever (I-H11).",
        "operationId": "liveness",
        "responses": {
          "200": {
            "description": "Process is alive"
          },
          "503": {
            "description": "Engine tick loop is wedged"
          }
        }
      }
    },
    "/health/ready": {
      "get": {
        "tags": [
          "health"
        ],
        "summary": "Readiness probe: returns 200 only if the database is reachable AND the\nengine tick loop is still running and ticking. A dead or wedged scheduler\nwith a live DB must not report ready — otherwise the LB keeps routing to a\nserver that accepts work but never executes it.",
        "operationId": "readiness",
        "responses": {
          "200": {
            "description": "Database reachable and engine running"
          },
          "503": {
            "description": "Database unreachable or engine stopped or stalled"
          }
        }
      }
    },
    "/info": {
      "get": {
        "tags": [
          "health"
        ],
        "summary": "Deployment info for UI chrome: engine version plus the optional\noperator-set environment label/color (`ORCH8_ENV_LABEL`,\n`ORCH8_ENV_COLOR`). Read straight from the environment — this is\ncosmetic metadata, not engine configuration, so it does not flow\nthrough `EngineConfig`.",
        "operationId": "info",
        "responses": {
          "200": {
            "description": "Engine version and environment label"
          }
        }
      }
    },
    "/instances": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "list_instances",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Filter by namespace",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sequence_id",
            "in": "query",
            "description": "Filter by sequence",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "state",
            "in": "query",
            "description": "Comma-separated states",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sub_tenant",
            "in": "query",
            "description": "Filter by sub-tenant (X-Orch8-Sub-Tenant overrides)",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Pagination offset",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Pagination limit (max 1000)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of instances",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskInstance"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "create_instance",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInstanceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Deduplicated (idempotency key match)",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "201": {
            "description": "Instance created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/instances/batch": {
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "create_instances_batch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchCreateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Batch created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountResponse"
                }
              }
            }
          },
          "400": {
            "description": "Empty batch"
          }
        }
      }
    },
    "/instances/batch-action": {
      "post": {
        "tags": [
          "instances"
        ],
        "summary": "Apply one control action to every instance matching a filter. Capped,\naudited, and dry-run-able. Tenant-scoped — a tenant can only act on its own\ninstances.",
        "operationId": "batch_action",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchActionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Batch action result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchActionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing tenant or invalid action params"
          }
        }
      }
    },
    "/instances/bulk/reschedule": {
      "patch": {
        "tags": [
          "instances"
        ],
        "operationId": "bulk_reschedule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkRescheduleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Bulk reschedule result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountResponse"
                }
              }
            }
          }
        }
      }
    },
    "/instances/bulk/state": {
      "patch": {
        "tags": [
          "instances"
        ],
        "operationId": "bulk_update_state",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpdateStateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Bulk state update result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountResponse"
                }
              }
            }
          }
        }
      }
    },
    "/instances/dlq": {
      "get": {
        "tags": [
          "instances"
        ],
        "summary": "DLQ: list failed instances.",
        "operationId": "list_dlq",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Filter by namespace",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Pagination offset",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Pagination limit",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Failed instances (DLQ)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskInstance"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/instances/dlq/groups": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "list_groups",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sequence_id",
            "in": "query",
            "description": "Filter by sequence",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Failed instances grouped by root-cause fingerprint,\n        ordered by affected count then recency",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DlqGroup"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/instances/dlq/groups/{fingerprint}/retry": {
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "retry_group",
        "parameters": [
          {
            "name": "fingerprint",
            "in": "path",
            "description": "Group fingerprint hash",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DlqGroupRetryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Retry outcome",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DlqGroupRetryResponse"
                }
              }
            }
          },
          "404": {
            "description": "No failed instances match this fingerprint"
          },
          "409": {
            "description": "Bulk retry not unlocked: no verified sample and no force"
          }
        }
      }
    },
    "/instances/{id}": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_instance",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Instance found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskInstance"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/artifacts": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "list_instance_artifacts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Artifact metadata for the instance",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/audit": {
      "get": {
        "tags": [
          "crate::instances"
        ],
        "operationId": "list_audit_log",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AuditLogEntry"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/blocks/{block_id}/resolved-input": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "inspect_instance_block",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "block_id",
            "in": "path",
            "description": "Step block id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "at_block",
            "in": "query",
            "description": "Historical boundary block",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resolution trace for the block against the instance snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolutionTrace"
                }
              }
            }
          },
          "404": {
            "description": "Instance, sequence, or block not found"
          }
        }
      }
    },
    "/instances/{id}/checkpoints": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "list_checkpoints",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of checkpoints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Checkpoint"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "save_checkpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveCheckpointRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Checkpoint saved",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/checkpoints/latest": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_latest_checkpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Latest checkpoint",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Checkpoint"
                }
              }
            }
          },
          "404": {
            "description": "No checkpoint found"
          }
        }
      }
    },
    "/instances/{id}/checkpoints/prune": {
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "prune_checkpoints",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PruneCheckpointsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Pruned checkpoints",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountResponse"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/children": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_instance_children",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Parent instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Child instances spawned by this instance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskInstance"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Parent instance not found"
          }
        }
      }
    },
    "/instances/{id}/compare/{other}": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "compare_runs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Left instance",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "other",
            "in": "path",
            "description": "Right instance",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Path and output comparison (no payloads)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunComparison"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/context": {
      "patch": {
        "tags": [
          "instances"
        ],
        "operationId": "update_context",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateContextRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Context updated"
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/context/data": {
      "patch": {
        "tags": [
          "instances"
        ],
        "operationId": "patch_context_data",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchContextDataRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Data patch applied without replacing other context sections"
          },
          "400": {
            "description": "Existing data is not an object"
          },
          "404": {
            "description": "Instance not found"
          },
          "409": {
            "description": "Concurrent context updates; retry the request"
          },
          "413": {
            "description": "Merged context exceeds its size limit"
          }
        }
      }
    },
    "/instances/{id}/diagnosis": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_diagnosis",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ranked diagnosis of why the instance is not progressing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceDiagnosisReport"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/effects": {
      "get": {
        "tags": [
          "continuity"
        ],
        "operationId": "list_instance_effects",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/instances/{id}/explain": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_explanation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "llm",
            "in": "query",
            "description": "Attach an LLM-written narrative. Evidence is redacted with the platform RedactionPolicy before it is sent; the structured fields stay template-based. Provider/model/key come from ORCH8_EXPLAIN_LLM_PROVIDER / _MODEL / _API_KEY.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Plain-language explanation with likely cause, evidence, and suggested fix",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceExplanation"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/fork": {
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "fork_instance",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Source instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ForkRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Fork created and scheduled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Unknown block or invalid context patch"
          },
          "404": {
            "description": "Instance or sequence not found"
          }
        }
      }
    },
    "/instances/{id}/fork-preview": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "fork_preview",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from_block_id",
            "in": "query",
            "description": "Fork point",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What a fork from this block would do — nothing is mutated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForkPreview"
                }
              }
            }
          },
          "400": {
            "description": "Block is not a top-level block of the sequence"
          },
          "404": {
            "description": "Instance or block not found"
          }
        }
      }
    },
    "/instances/{id}/inject-blocks": {
      "post": {
        "tags": [
          "crate::instances"
        ],
        "operationId": "inject_blocks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InjectBlocksRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Blocks injected"
          }
        }
      }
    },
    "/instances/{id}/logs": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_instance_logs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Step logs (oldest first)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StepLog"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/outputs": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_outputs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Block outputs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BlockOutput"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/receipts/export": {
      "get": {
        "tags": [
          "receipts"
        ],
        "summary": "Export the effect-receipt ledger of one instance as a signed JSONL bundle.",
        "operationId": "export_instance_receipts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signed JSONL bundle: header, one line per effect receipt, signature trailer. At-most-once dispatch evidence, not an exactly-once claim.",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          },
          "503": {
            "description": "Signing key not configured"
          }
        }
      }
    },
    "/instances/{id}/remediations": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "preview_remediations",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "State-bound remediation previews",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RemediationPreview"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/remediations/apply": {
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "apply_remediation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyRemediationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Post-action remediation evidence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RemediationApplyEvidence"
                }
              }
            }
          },
          "400": {
            "description": "Stale, manual, or unacknowledged remediation"
          },
          "404": {
            "description": "Instance or preview not found"
          }
        }
      }
    },
    "/instances/{id}/resume-from/{block_id}": {
      "post": {
        "tags": [
          "instances"
        ],
        "summary": "DLQ surgery: re-run an instance from an arbitrary block.",
        "description": "Wipes the target block's outputs and the outputs of every block at or\nafter it in the sequence's top-level `blocks` array (including blocks\nnested inside wiped composites), optionally shallow-merges a context\npatch into `context.data`, and re-schedules the instance immediately.\nEarlier blocks keep their outputs: on the flat all-step execution path\nthe completed-blocks check skips them, so side-effectful handlers do not\nrun twice. On the tree path the execution tree is rebuilt from scratch —\nthe exact same semantics as `POST /instances/{id}/retry`, which also\ndeletes the tree while preserving real outputs.\n\nLinear assumption: \"after\" is defined by position in the top-level\n`blocks` array, which is the order both execution paths (flat fast path\nand tree evaluator) run top-level blocks in. The target must itself be a\ntop-level block — resuming from a block nested inside a composite is not\nsupported.",
        "operationId": "resume_from_block",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "block_id",
            "in": "path",
            "description": "Top-level block to resume from",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ResumeFromRequest"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Instance re-scheduled from the given block",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Unknown block, or instance is in a state that cannot be resumed"
          },
          "404": {
            "description": "Instance or sequence not found"
          }
        }
      }
    },
    "/instances/{id}/retry": {
      "post": {
        "tags": [
          "instances"
        ],
        "summary": "Retry a failed instance: reset to scheduled with immediate fire time.",
        "operationId": "retry_instance",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Instance retried",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Instance is not in failed state"
          },
          "404": {
            "description": "Instance not found"
          },
          "409": {
            "description": "Instance state changed concurrently"
          }
        }
      }
    },
    "/instances/{id}/share": {
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "create_share",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateShareRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Share created; token returned once",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateShareResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid expiry or field allowlist"
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/share/{share_id}": {
      "delete": {
        "tags": [
          "instances"
        ],
        "operationId": "revoke_share",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "share_id",
            "in": "path",
            "description": "Share ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Share revoked"
          },
          "404": {
            "description": "Unknown, foreign, or already-revoked share"
          }
        }
      }
    },
    "/instances/{id}/shares": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "list_shares",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Shares for the instance (tokens are never returned)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProgressShare"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/signals": {
      "post": {
        "tags": [
          "instances"
        ],
        "operationId": "send_signal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendSignalRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Signal enqueued",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Instance is in terminal state"
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/state": {
      "patch": {
        "tags": [
          "instances"
        ],
        "operationId": "update_state",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateStateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "State updated"
          },
          "400": {
            "description": "Invalid state transition"
          },
          "404": {
            "description": "Instance not found"
          },
          "409": {
            "description": "Instance state changed concurrently"
          }
        }
      }
    },
    "/instances/{id}/stream": {
      "get": {
        "tags": [
          "instances"
        ],
        "summary": "SSE stream for instance progress.",
        "operationId": "stream_instance",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "poll_ms",
            "in": "query",
            "description": "Poll interval in ms (min 100ms)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Server-Sent Events stream of instance state/output changes plus live llm_delta events from streaming llm_call steps",
            "content": {
              "text/event-stream": {}
            }
          },
          "404": {
            "description": "Instance not found"
          },
          "429": {
            "description": "Per-tenant concurrent stream limit reached"
          },
          "503": {
            "description": "Too many concurrent streams"
          }
        }
      }
    },
    "/instances/{id}/timeline": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_timeline",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Pagination offset over executed-block entries",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size (default 200, max 1000)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "include_outputs",
            "in": "query",
            "description": "Include output payloads and current context (default true)",
            "required": true,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Execution timeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimelineResponse"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/tree": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_execution_tree",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Execution tree",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExecutionNode"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/instances/{id}/workbench": {
      "get": {
        "tags": [
          "instances"
        ],
        "operationId": "get_workbench",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max timeline events (default 500)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Joined, redacted execution view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecutionWorkbenchView"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found"
          }
        }
      }
    },
    "/jobs": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "List jobs, newest first, with keyset pagination.",
        "operationId": "list_jobs",
        "parameters": [
          {
            "name": "handler",
            "in": "query",
            "description": "Only jobs for this handler",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "scheduled | running | completed | failed | cancelled | dead_lettered",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size (default 50, max 500)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Opaque `next_cursor` from the previous page",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant filter (admin callers without X-Tenant-Id only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Namespace filter",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of jobs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid status or cursor"
          }
        }
      },
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Enqueue a background job.",
        "operationId": "enqueue_job",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnqueueJobRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Idempotent replay: existing job returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "201": {
            "description": "Job enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "413": {
            "description": "Payload exceeds the context size limit"
          }
        }
      }
    },
    "/jobs/{id}": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "Fetch one job.",
        "operationId": "get_job",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Job id (= instance id)",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "description": "Job not found"
          }
        }
      },
      "delete": {
        "tags": [
          "jobs"
        ],
        "summary": "Cancel a job. The cancel is a durable signal the engine applies promptly\n(202) -- saga compensations and `on_cancel` hooks run as part of it, so the\nreturned job may still show its pre-cancel status. Cancelling a job that\nalready finished is a 409.",
        "operationId": "cancel_job",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Job id (= instance id)",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Cancellation requested",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "description": "Job not found"
          },
          "409": {
            "description": "Job already finished"
          }
        }
      }
    },
    "/license": {
      "get": {
        "tags": [
          "license"
        ],
        "operationId": "get_license",
        "responses": {
          "200": {
            "description": "Offline-verified license status (soft enforcement only)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LicenseInfo"
                }
              }
            }
          }
        }
      }
    },
    "/llm-cache": {
      "delete": {
        "tags": [
          "usage"
        ],
        "operationId": "purge_llm_cache",
        "parameters": [
          {
            "name": "tenant",
            "in": "query",
            "description": "Tenant (admin/unscoped callers only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Entries removed: {\"deleted\": n}",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "No tenant resolvable"
          }
        }
      }
    },
    "/migrations/import": {
      "post": {
        "tags": [
          "migrations"
        ],
        "summary": "Import a migration batch.",
        "operationId": "import",
        "requestBody": {
          "description": "MigrationImportRequest: { migration_id, source_engine_id, sequences: [SequenceDefinition], instances: [{ instance, execution_tree, block_outputs, effect_receipts, pending_signals, continuity }] } (at most 100 instances and 500 sequences)",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "MigrationImportResponse: per-instance status (`imported` | `already_present`), owned epoch, and the target runtime id",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Invalid batch (limits, unknown sequence, inconsistent ids)"
          },
          "403": {
            "description": "Batch contains another tenant's records"
          },
          "409": {
            "description": "An instance id exists but was not created by this migration"
          }
        }
      }
    },
    "/placement/policies": {
      "get": {
        "tags": [
          "placement"
        ],
        "operationId": "get_policies",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (root key only; defaults to the X-Tenant-Id principal)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tenant's placement policies",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlacementPolicies"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "placement"
        ],
        "operationId": "put_policies",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (root key only; defaults to the X-Tenant-Id principal)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlacementPolicies"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Policies replaced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlacementPolicies"
                }
              }
            }
          },
          "400": {
            "description": "Invalid policies"
          }
        }
      }
    },
    "/pools": {
      "get": {
        "tags": [
          "pools"
        ],
        "operationId": "list_pools",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ResourcePool"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "pools"
        ],
        "operationId": "create_pool",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePoolRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourcePool"
                }
              }
            }
          }
        }
      }
    },
    "/pools/{id}": {
      "get": {
        "tags": [
          "pools"
        ],
        "operationId": "get_pool",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourcePool"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "pools"
        ],
        "operationId": "delete_pool",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {}
        }
      }
    },
    "/pools/{pool_id}/resources": {
      "get": {
        "tags": [
          "pools"
        ],
        "operationId": "list_resources",
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PoolResource"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "pools"
        ],
        "operationId": "add_resource",
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddResourceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolResource"
                }
              }
            }
          }
        }
      }
    },
    "/pools/{pool_id}/resources/{resource_id}": {
      "put": {
        "tags": [
          "pools"
        ],
        "operationId": "update_resource",
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "resource_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateResourceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolResource"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "pools"
        ],
        "operationId": "delete_resource",
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "resource_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {}
        }
      }
    },
    "/prompts": {
      "get": {
        "tags": [
          "prompts"
        ],
        "operationId": "list_prompts",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PromptSummary"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "prompts"
        ],
        "operationId": "push_prompt",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PushPromptRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Identical to the latest version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushPromptResponse"
                }
              }
            }
          },
          "201": {
            "description": "New version created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushPromptResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid prompt"
          }
        }
      }
    },
    "/prompts/{name}": {
      "get": {
        "tags": [
          "prompts"
        ],
        "operationId": "get_prompt",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "description": "Prompt name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptDetail"
                }
              }
            }
          },
          "404": {}
        }
      }
    },
    "/prompts/{name}/labels/{label}": {
      "put": {
        "tags": [
          "prompts"
        ],
        "operationId": "set_prompt_label",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "description": "Prompt name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "label",
            "in": "path",
            "description": "Label, e.g. production",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetLabelRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptLabel"
                }
              }
            }
          },
          "400": {},
          "404": {}
        }
      },
      "delete": {
        "tags": [
          "prompts"
        ],
        "operationId": "delete_prompt_label",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "description": "Prompt name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "label",
            "in": "path",
            "description": "Label",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {},
          "404": {}
        }
      }
    },
    "/prompts/{name}/resolve": {
      "get": {
        "tags": [
          "prompts"
        ],
        "operationId": "resolve_prompt",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "description": "Prompt name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "label",
            "in": "query",
            "description": "Resolve through this label (its stable version)",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "query",
            "description": "Exact version",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptTemplate"
                }
              }
            }
          },
          "404": {}
        }
      }
    },
    "/prompts/{name}/versions/{version}": {
      "get": {
        "tags": [
          "prompts"
        ],
        "operationId": "get_prompt_version",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "description": "Prompt name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "description": "Version number",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptTemplate"
                }
              }
            }
          },
          "404": {}
        }
      }
    },
    "/public/progress/embed.js": {
      "get": {
        "tags": [
          "public"
        ],
        "operationId": "embed_loader",
        "responses": {
          "200": {
            "description": "Embed loader script",
            "content": {
              "application/javascript": {}
            }
          }
        }
      }
    },
    "/public/progress/{token}": {
      "get": {
        "tags": [
          "public"
        ],
        "operationId": "public_progress",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "Share token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Redacted progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicProgress"
                }
              }
            }
          },
          "404": {
            "description": "Unknown, expired, or revoked link"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/public/progress/{token}/embed": {
      "get": {
        "tags": [
          "public"
        ],
        "operationId": "embed_page",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "Share token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Self-contained progress-bar page",
            "content": {
              "text/html": {}
            }
          },
          "404": {
            "description": "Unknown, expired, or revoked link"
          }
        }
      }
    },
    "/queues/dispatch": {
      "get": {
        "tags": [
          "routing"
        ],
        "operationId": "list_dispatch",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dispatch configs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QueueDispatchConfig"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "routing"
        ],
        "operationId": "set_dispatch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetDispatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Dispatch config set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueueDispatchConfig"
                }
              }
            }
          },
          "400": {
            "description": "push mode requires push_url"
          }
        }
      }
    },
    "/queues/dispatch/{tenant_id}/{queue_name}": {
      "delete": {
        "tags": [
          "routing"
        ],
        "operationId": "delete_dispatch",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "description": "Tenant id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "queue_name",
            "in": "path",
            "description": "Queue name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    },
    "/rate-budgets": {
      "get": {
        "tags": [
          "placement"
        ],
        "operationId": "list_budgets",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (root key only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tenant's rate budgets",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateBudgetList"
                }
              }
            }
          }
        }
      }
    },
    "/rate-budgets/{key}": {
      "put": {
        "tags": [
          "placement"
        ],
        "operationId": "put_budget",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "Budget key, e.g. `stripe-api`",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (root key only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RateBudgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Budget created (full) or reshaped",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateBudget"
                }
              }
            }
          },
          "400": {
            "description": "Invalid key or bucket parameters"
          }
        }
      },
      "delete": {
        "tags": [
          "placement"
        ],
        "operationId": "delete_budget",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "Budget key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (root key only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/receipts/export": {
      "get": {
        "tags": [
          "receipts"
        ],
        "summary": "Export every effect receipt created in `[from, to)` for a tenant.",
        "operationId": "export_window_receipts",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Window start (RFC 3339, inclusive)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Window end (RFC 3339, exclusive)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant (unscoped callers only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signed JSONL bundle for the window. `scope.truncated=true` when more than 10000 instances were touched in the window.",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid window or missing tenant"
          },
          "503": {
            "description": "Signing key not configured"
          }
        }
      }
    },
    "/receipts/signing-key": {
      "get": {
        "tags": [
          "receipts"
        ],
        "summary": "The public half of the key that signs receipt bundles.",
        "operationId": "signing_key",
        "responses": {
          "200": {
            "description": "Engine receipt-signing public key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SigningKeyResponse"
                }
              }
            }
          },
          "503": {
            "description": "Signing key not configured"
          }
        }
      }
    },
    "/releases": {
      "get": {
        "tags": [
          "releases"
        ],
        "operationId": "list_releases",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max rows (default 100)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Releases, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowRelease"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "create_release",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateReleaseRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Release created (draft)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowRelease"
                }
              }
            }
          },
          "400": {
            "description": "Baseline/candidate mismatch"
          },
          "404": {
            "description": "Sequence not found"
          }
        }
      }
    },
    "/releases/{id}": {
      "get": {
        "tags": [
          "releases"
        ],
        "operationId": "get_release",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Release",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowRelease"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/releases/{id}/canary": {
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "start_canary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CanaryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Canary started/resumed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowRelease"
                }
              }
            }
          },
          "409": {
            "description": "Release is not ready/paused"
          }
        }
      }
    },
    "/releases/{id}/decisions": {
      "get": {
        "tags": [
          "releases"
        ],
        "operationId": "list_decisions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Immutable audit trail, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ReleaseDecision"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/releases/{id}/diff": {
      "get": {
        "tags": [
          "releases"
        ],
        "operationId": "diff_release",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Semantic diff of this release",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SemanticDiff"
                }
              }
            }
          }
        }
      }
    },
    "/releases/{id}/evaluate": {
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "evaluate_release",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Gate evaluation; a failing gate during canary rolls the release back automatically (idempotent)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EvaluationReport"
                }
              }
            }
          }
        }
      }
    },
    "/releases/{id}/pause": {
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "pause_release",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paused (traffic returns to baseline)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowRelease"
                }
              }
            }
          }
        }
      }
    },
    "/releases/{id}/promote": {
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "promote_release",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PromoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Promoted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowRelease"
                }
              }
            }
          },
          "409": {
            "description": "Gates not passing (pass force=true to override)"
          }
        }
      }
    },
    "/releases/{id}/rollback": {
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "rollback_release",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rolled back — all new traffic returns to the baseline. Idempotent: rolling back an already rolled-back release is a no-op.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowRelease"
                }
              }
            }
          }
        }
      }
    },
    "/releases/{id}/target": {
      "put": {
        "tags": [
          "releases"
        ],
        "operationId": "set_release_target",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "Sub-tenant rollout target, or null to return to per-instance cohorts",
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ReleaseTarget"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Target replaced (audited)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowRelease"
                }
              }
            }
          },
          "400": {
            "description": "Invalid target"
          },
          "409": {
            "description": "Release is promoted or rolled back"
          }
        }
      }
    },
    "/releases/{id}/validate": {
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "validate_release",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Release id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Validation report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationReport"
                }
              }
            }
          },
          "409": {
            "description": "Release is not in draft"
          }
        }
      }
    },
    "/routing-rules": {
      "get": {
        "tags": [
          "routing"
        ],
        "operationId": "list_rules",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "handler_name",
            "in": "query",
            "description": "Filter by handler",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Routing rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QueueRoutingRule"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "routing"
        ],
        "operationId": "create_rule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRoutingRuleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Rule created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueueRoutingRule"
                }
              }
            }
          },
          "400": {
            "description": "Missing/empty fields"
          }
        }
      }
    },
    "/routing-rules/{id}": {
      "get": {
        "tags": [
          "routing"
        ],
        "operationId": "get_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueueRoutingRule"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "delete": {
        "tags": [
          "routing"
        ],
        "operationId": "delete_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/runtimes": {
      "get": {
        "tags": [
          "continuity"
        ],
        "description": "List the tenant's live runtime advertisements (`RuntimeCapabilities`). A device-session (`dst_`) caller receives only the runtimes it could delegate to now — other than itself, not draining, not expired, at least `registered` trust, advertising `orch8.delegation` — reduced to `runtime_id`, `kind`, `handlers`, `observed_at` and `expires_at`, with `trust` reported as `registered` and every other fact omitted.",
        "operationId": "list_runtimes",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/runtimes/browser-sessions": {
      "post": {
        "tags": [
          "workers"
        ],
        "summary": "Mint a browser-session token. Operator/Admin only — called by the\ncustomer's app backend, never by the browser itself.",
        "operationId": "create_browser_session",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBrowserSessionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Scoped browser-session token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateBrowserSessionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid handlers, queues, or ttl"
          },
          "403": {
            "description": "Caller is not an operator"
          }
        }
      }
    },
    "/runtimes/device-sessions": {
      "post": {
        "tags": [
          "workers"
        ],
        "summary": "Mint a device-session token. Operator/Admin only — called by the\ncustomer's app backend, never by the phone itself.",
        "operationId": "create_device_session",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDeviceSessionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Scoped device-session token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDeviceSessionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid device_id, handlers, or ttl"
          },
          "403": {
            "description": "Caller is not an operator"
          },
          "409": {
            "description": "The device is registered to another tenant"
          }
        }
      }
    },
    "/runtimes/register": {
      "post": {
        "tags": [
          "continuity"
        ],
        "operationId": "register_runtime",
        "responses": {
          "default": {
            "description": "Continuity API response"
          }
        }
      }
    },
    "/sequences": {
      "get": {
        "tags": [
          "sequences"
        ],
        "operationId": "list_sequences",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Optional tenant filter",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Optional namespace filter",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max rows (default 200, max 1000)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Pagination offset",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "All sequences (filtered/paginated)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SequenceDefinition"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "sequences"
        ],
        "operationId": "create_sequence",
        "requestBody": {
          "description": "Sequence definition as JSON, or as YAML with `Content-Type: application/yaml`",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SequenceDefinition"
              }
            },
            "application/yaml": {
              "schema": {
                "$ref": "#/components/schemas/SequenceDefinition"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Sequence created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "409": {
            "description": "Sequence already exists"
          }
        }
      }
    },
    "/sequences/by-name": {
      "get": {
        "tags": [
          "sequences"
        ],
        "operationId": "get_sequence_by_name",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Namespace",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Sequence name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "query",
            "description": "Optional version",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sequence found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceDefinition"
                }
              }
            }
          },
          "404": {
            "description": "Sequence not found"
          }
        }
      }
    },
    "/sequences/dataflow": {
      "post": {
        "tags": [
          "sequences"
        ],
        "operationId": "compile_draft",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SequenceDefinition"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Typed dataflow report and deterministic bindings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataflowResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid sequence or generation bounds exceeded"
          }
        }
      }
    },
    "/sequences/inspect-template": {
      "post": {
        "tags": [
          "sequences"
        ],
        "operationId": "inspect_draft",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InspectTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Resolution trace for the block's params",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolutionTrace"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "404": {
            "description": "Sequence or block not found"
          }
        }
      }
    },
    "/sequences/migrate-instance": {
      "post": {
        "tags": [
          "sequences"
        ],
        "operationId": "migrate_instance",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MigrateInstanceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Instance migrated to new sequence version"
          },
          "400": {
            "description": "Instance in terminal state"
          },
          "404": {
            "description": "Instance or sequence not found"
          },
          "409": {
            "description": "Target sequence is structurally incompatible with the instance's execution state"
          }
        }
      }
    },
    "/sequences/preflight": {
      "post": {
        "tags": [
          "sequences"
        ],
        "operationId": "preflight_draft",
        "requestBody": {
          "description": "Draft definition as JSON, or as YAML with `Content-Type: application/yaml`",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SequenceDefinition"
              }
            },
            "application/yaml": {
              "schema": {
                "$ref": "#/components/schemas/SequenceDefinition"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Preflight report for the draft definition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreflightReport"
                }
              }
            }
          },
          "400": {
            "description": "Body is not a sequence definition"
          }
        }
      }
    },
    "/sequences/releases/diff": {
      "post": {
        "tags": [
          "releases"
        ],
        "operationId": "diff_sequences",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiffRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Semantic diff report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SemanticDiff"
                }
              }
            }
          },
          "404": {
            "description": "Sequence not found"
          }
        }
      }
    },
    "/sequences/versions": {
      "get": {
        "tags": [
          "sequences"
        ],
        "operationId": "list_sequence_versions",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "namespace",
            "in": "query",
            "description": "Namespace",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Sequence name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "All versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SequenceDefinition"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{id}": {
      "get": {
        "tags": [
          "sequences"
        ],
        "operationId": "get_sequence",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sequence ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sequence found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceDefinition"
                }
              }
            }
          },
          "404": {
            "description": "Sequence not found"
          }
        }
      }
    },
    "/sequences/{id}/dataflow": {
      "get": {
        "tags": [
          "sequences"
        ],
        "operationId": "compile_stored",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sequence id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Typed dataflow report and deterministic bindings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataflowResponse"
                }
              }
            }
          },
          "404": {
            "description": "Sequence not found"
          }
        }
      }
    },
    "/sequences/{id}/deprecate": {
      "post": {
        "tags": [
          "sequences"
        ],
        "operationId": "deprecate_sequence",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sequence ID to deprecate",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sequence deprecated"
          }
        }
      }
    },
    "/sequences/{id}/preflight": {
      "get": {
        "tags": [
          "sequences"
        ],
        "operationId": "preflight_stored",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sequence id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Preflight report for the stored sequence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreflightReport"
                }
              }
            }
          },
          "404": {
            "description": "Sequence not found"
          }
        }
      }
    },
    "/sessions": {
      "post": {
        "tags": [
          "crate::sessions"
        ],
        "operationId": "create_session",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSessionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/by-key/{tenant_id}/{key}": {
      "get": {
        "tags": [
          "crate::sessions"
        ],
        "operationId": "get_session_by_key",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "key",
            "in": "path",
            "description": "Session key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}": {
      "get": {
        "tags": [
          "crate::sessions"
        ],
        "operationId": "get_session",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Session ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/data": {
      "patch": {
        "tags": [
          "crate::sessions"
        ],
        "operationId": "update_session_data",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Session ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSessionDataRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Session data updated"
          }
        }
      }
    },
    "/sessions/{id}/instances": {
      "get": {
        "tags": [
          "crate::sessions"
        ],
        "operationId": "list_session_instances",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Session ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskInstance"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/state": {
      "patch": {
        "tags": [
          "crate::sessions"
        ],
        "operationId": "update_session_state",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Session ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSessionStateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Session state updated"
          }
        }
      }
    },
    "/sub-tenants/{sub}/limits": {
      "get": {
        "tags": [
          "sub-tenants"
        ],
        "operationId": "get_sub_tenant_limits",
        "parameters": [
          {
            "name": "sub",
            "in": "path",
            "description": "Sub-tenant id ([A-Za-z0-9._:-]{1,128})",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Caps (null = uncapped; unset sub-tenants are uncapped)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubTenantLimitsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid sub-tenant id or no tenant"
          }
        }
      },
      "put": {
        "tags": [
          "sub-tenants"
        ],
        "operationId": "put_sub_tenant_limits",
        "parameters": [
          {
            "name": "sub",
            "in": "path",
            "description": "Sub-tenant id ([A-Za-z0-9._:-]{1,128})",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubTenantLimits"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Caps replaced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubTenantLimitsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid sub-tenant id, body or no tenant"
          }
        }
      }
    },
    "/sub-tenants/{sub}/resume": {
      "post": {
        "tags": [
          "sub-tenants"
        ],
        "operationId": "resume_sub_tenant",
        "parameters": [
          {
            "name": "sub",
            "in": "path",
            "description": "Sub-tenant id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Embed tokens of the sub-tenant are accepted again"
          },
          "403": {
            "description": "Operator capability required"
          }
        }
      }
    },
    "/sub-tenants/{sub}/suspend": {
      "post": {
        "tags": [
          "sub-tenants"
        ],
        "operationId": "suspend_sub_tenant",
        "parameters": [
          {
            "name": "sub",
            "in": "path",
            "description": "Sub-tenant id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Every embed token of the sub-tenant is refused (401) within a few seconds"
          },
          "403": {
            "description": "Operator capability required"
          }
        }
      }
    },
    "/tenants/{tenant_id}/circuit-breakers": {
      "get": {
        "tags": [
          "crate::circuit_breakers"
        ],
        "operationId": "list_breakers_for_tenant",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "description": "Tenant id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CircuitBreakerState"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/tenants/{tenant_id}/circuit-breakers/{handler}": {
      "get": {
        "tags": [
          "crate::circuit_breakers"
        ],
        "operationId": "get_breaker",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "description": "Tenant id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "handler",
            "in": "path",
            "description": "Handler name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CircuitBreakerState"
                }
              }
            }
          },
          "404": {
            "description": "Handler not found"
          }
        }
      }
    },
    "/tenants/{tenant_id}/circuit-breakers/{handler}/reset": {
      "post": {
        "tags": [
          "crate::circuit_breakers"
        ],
        "operationId": "reset_breaker",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "description": "Tenant id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "handler",
            "in": "path",
            "description": "Handler name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Circuit breaker reset"
          }
        }
      }
    },
    "/triggers": {
      "get": {
        "tags": [
          "triggers"
        ],
        "operationId": "list_triggers",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Triggers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TriggerDef"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "triggers"
        ],
        "operationId": "create_trigger",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTriggerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Trigger created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TriggerDef"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    },
    "/triggers/{slug}": {
      "get": {
        "tags": [
          "triggers"
        ],
        "operationId": "get_trigger",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "description": "Trigger slug",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Trigger. For activepieces_poll triggers the response additionally carries a `poll_state` field (cursor, last_error, consecutive_failures, last_poll_at).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TriggerDef"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "delete": {
        "tags": [
          "triggers"
        ],
        "operationId": "delete_trigger",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "description": "Trigger slug",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/triggers/{slug}/fire": {
      "post": {
        "tags": [
          "triggers"
        ],
        "summary": "Fire a trigger: create a new instance from the trigger's sequence.",
        "description": "The request body becomes the initial `context.data` for the instance.",
        "operationId": "fire_trigger",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "description": "Trigger slug",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Instance created"
          },
          "400": {
            "description": "Trigger disabled or bad secret"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/triggers/{slug}/target": {
      "patch": {
        "tags": [
          "triggers"
        ],
        "operationId": "retarget_trigger",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "description": "Trigger slug",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RetargetTriggerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Trigger target updated; credentials and settings preserved"
          },
          "404": {
            "description": "Trigger or sequence not found"
          },
          "409": {
            "description": "Trigger changed concurrently or sequence name/version is ambiguous"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "tags": [
          "usage"
        ],
        "operationId": "get_usage",
        "parameters": [
          {
            "name": "tenant",
            "in": "query",
            "description": "Tenant (admin/unscoped callers only)",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start",
            "in": "query",
            "description": "Window start (RFC 3339)",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "end",
            "in": "query",
            "description": "Window end (RFC 3339)",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Usage aggregated by (kind, model) with estimated USD costs, cache savings and current budget status",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "No tenant resolvable"
          }
        }
      }
    },
    "/usage/sub-tenants": {
      "get": {
        "tags": [
          "sub-tenants"
        ],
        "operationId": "get_sub_tenant_usage",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Window start (RFC 3339, inclusive). Defaults to the start of the\ncurrent UTC month.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Window end (RFC 3339, exclusive). Defaults to now.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Per-sub-tenant activity in [from, to)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubTenantUsageResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid window or no tenant"
          }
        }
      }
    },
    "/webhooks/deliveries": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "operationId": "list_deliveries",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "description": "Filter by endpoint URL",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "event_type",
            "in": "query",
            "description": "Filter by event type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "delivered",
            "in": "query",
            "description": "true = delivered, false = failed",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "error_class",
            "in": "query",
            "description": "Final-attempt error class",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max rows (default 100, max 1000)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery summaries, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookDeliverySummary"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/deliveries/{delivery_id}": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "operationId": "get_delivery",
        "parameters": [
          {
            "name": "delivery_id",
            "in": "path",
            "description": "Delivery (attempt group) id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Attempt timeline for one delivery",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookDeliveryAttempt"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No attempts recorded for this delivery"
          }
        }
      }
    },
    "/webhooks/outbox": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "operationId": "list_outbox",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Max rows (default 100, max 1000)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Parked webhook deliveries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookOutboxEntry"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/outbox/{id}": {
      "delete": {
        "tags": [
          "webhooks"
        ],
        "operationId": "discard_outbox",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Parked delivery id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Discarded"
          }
        }
      }
    },
    "/webhooks/outbox/{id}/redeliver": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "operationId": "redeliver_outbox",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Parked delivery id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Redelivered (row removed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RedeliverResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such parked delivery"
          },
          "409": {
            "description": "Delivery is pending or already claimed by the scheduler"
          },
          "502": {
            "description": "Redelivery failed (row kept)"
          }
        }
      }
    },
    "/webhooks/outbox/{id}/redeliver-preview": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "operationId": "redeliver_preview",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Parked delivery id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What a redelivery would send (no side effect)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RedeliverPreview"
                }
              }
            }
          },
          "404": {
            "description": "No such parked delivery"
          }
        }
      }
    },
    "/webhooks/{slug}": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Accept an inbound webhook POST and create a new instance from its body.",
        "description": "Rejects with 404 if:\n- The slug doesn't exist.\n- The trigger is disabled.\n- The trigger is not of type `webhook` (events and nats are internal only).\n\nRejects with 401 if:\n- The trigger has no secret, or the request signature is missing/invalid.",
        "operationId": "public_webhook",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "description": "Webhook slug (the trigger slug)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Webhook accepted; instance created and queued for execution"
          },
          "401": {
            "description": "Missing or invalid webhook signature"
          },
          "404": {
            "description": "Unknown slug, disabled trigger, or non-webhook trigger type"
          }
        }
      }
    },
    "/workers": {
      "get": {
        "tags": [
          "workers"
        ],
        "operationId": "list_workers",
        "parameters": [
          {
            "name": "alive_within_secs",
            "in": "query",
            "description": "Liveness window in seconds (default 60)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "include_stale",
            "in": "query",
            "description": "Include workers not seen within the window",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Worker fleet with liveness",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkerInfo"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/workers/commands": {
      "post": {
        "tags": [
          "workers"
        ],
        "summary": "Queue a control command for a worker. The worker picks it up via\n`GET /workers/{worker_id}/commands` and acks it after acting.",
        "description": "This is an operator/admin endpoint: only callers with an admin context may\nenqueue commands to the worker fleet.",
        "operationId": "enqueue_command",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnqueueCommandRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Command queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerCommand"
                }
              }
            }
          },
          "403": {
            "description": "Admin context required"
          }
        }
      }
    },
    "/workers/commands/{id}": {
      "delete": {
        "tags": [
          "workers"
        ],
        "summary": "Acknowledge (delete) a delivered command.",
        "operationId": "ack_command",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Command id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "/workers/tasks": {
      "get": {
        "tags": [
          "workers"
        ],
        "operationId": "list_tasks",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "description": "Comma-separated worker task states",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "handler_name",
            "in": "query",
            "description": "Filter by handler name",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "worker_id",
            "in": "query",
            "description": "Filter by claiming worker id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "queue_name",
            "in": "query",
            "description": "Filter by queue name",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max rows to return (≤ 1000)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Skip N rows",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Worker tasks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkerTask"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/workers/tasks/poll": {
      "post": {
        "tags": [
          "workers"
        ],
        "operationId": "poll_tasks",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PollRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Claimed worker tasks and lease hints",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PollTasksResponse"
                }
              }
            }
          }
        }
      }
    },
    "/workers/tasks/poll/queue": {
      "post": {
        "tags": [
          "workers"
        ],
        "operationId": "poll_tasks_from_queue",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueuePollRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Claimed worker tasks from queue and lease hints",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PollTasksResponse"
                }
              }
            }
          }
        }
      }
    },
    "/workers/tasks/stats": {
      "get": {
        "tags": [
          "workers"
        ],
        "operationId": "task_stats",
        "parameters": [
          {
            "name": "window_secs",
            "in": "query",
            "description": "When set (1..=604800), `completed`/`failed` rows are counted only if finished within the last N seconds, so `by_handler` failure rates reflect a recent window; `pending`/`claimed` are live gauges and always counted. Omit for lifetime counts (default).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Aggregate worker task stats",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerTaskStats"
                }
              }
            }
          }
        }
      }
    },
    "/workers/tasks/{id}/artifacts/{upload_id}": {
      "post": {
        "tags": [
          "workers"
        ],
        "summary": "Upload a task-owned file before completion. The client chooses `upload_id`,\nso a phone can safely retry after suspension or a network transition.",
        "operationId": "upload_task_artifact",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Worker task ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "upload_id",
            "in": "path",
            "description": "Stable client idempotency key",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "worker_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "claim_epoch",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "name": "file_name",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sha256",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Artifact stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerArtifactReceipt"
                }
              }
            }
          },
          "409": {
            "description": "Lease changed or upload ID reused with other bytes"
          }
        }
      }
    },
    "/workers/tasks/{id}/attempts": {
      "get": {
        "tags": [
          "workers"
        ],
        "operationId": "list_task_attempts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkerTaskAttemptEvent"
                  }
                }
              }
            }
          },
          "404": {}
        }
      }
    },
    "/workers/tasks/{id}/complete": {
      "post": {
        "tags": [
          "workers"
        ],
        "operationId": "complete_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Worker task ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompleteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Task completed"
          },
          "404": {
            "description": "Worker task not found"
          }
        }
      }
    },
    "/workers/tasks/{id}/fail": {
      "post": {
        "tags": [
          "workers"
        ],
        "operationId": "fail_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Worker task ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Task failed"
          },
          "404": {
            "description": "Worker task not found"
          }
        }
      }
    },
    "/workers/tasks/{id}/heartbeat": {
      "post": {
        "tags": [
          "workers"
        ],
        "operationId": "heartbeat_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Worker task ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HeartbeatRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Heartbeat/checkpoint updated; response contains checkpoint_seq"
          },
          "404": {
            "description": "Worker task is not currently owned by this worker"
          },
          "409": {
            "description": "Worker lost ownership or checkpoint sequence is stale"
          }
        }
      }
    },
    "/workers/tasks/{id}/release": {
      "post": {
        "tags": [
          "workers"
        ],
        "summary": "Voluntarily give a claimed task back (tab closing, app backgrounding).\nSafe to call from `fetch(url, {keepalive: true})` during `pagehide`.",
        "operationId": "release_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Worker task ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReleaseRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Task released"
          },
          "404": {
            "description": "Worker task not found"
          },
          "409": {
            "description": "Caller no longer holds this lease (or ownership changed)"
          }
        }
      }
    },
    "/workers/version-pins": {
      "get": {
        "tags": [
          "workers"
        ],
        "summary": "List worker version pins, optionally filtered by tenant.",
        "operationId": "list_version_pins",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "Filter by tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pins",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkerVersionPin"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "workers"
        ],
        "summary": "Create-or-update a minimum-worker-version pin for a `(tenant, handler)`.",
        "operationId": "set_version_pin",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetVersionPinRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Pin set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerVersionPin"
                }
              }
            }
          }
        }
      }
    },
    "/workers/version-pins/{tenant_id}/{handler_name}": {
      "delete": {
        "tags": [
          "workers"
        ],
        "summary": "Delete a worker version pin.",
        "operationId": "delete_version_pin",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "description": "Tenant id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "handler_name",
            "in": "path",
            "description": "Handler name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    },
    "/workers/{worker_id}/commands": {
      "get": {
        "tags": [
          "workers"
        ],
        "summary": "List a worker's pending control commands (the worker control channel).",
        "operationId": "list_commands",
        "parameters": [
          {
            "name": "worker_id",
            "in": "path",
            "description": "Worker id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pending commands",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkerCommand"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ABSplitDef": {
        "type": "object",
        "description": "A/B split: deterministically route each instance to one of several\nweighted variants. The chosen variant is persisted in the block output\nso re-executions always follow the same path.",
        "required": [
          "id",
          "variants"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "variants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ABVariant"
            },
            "description": "Weighted variants. Weights are relative (e.g. 70 + 30 = 100%)."
          }
        }
      },
      "ABVariant": {
        "type": "object",
        "description": "One arm of an A/B split.",
        "required": [
          "name",
          "weight",
          "blocks"
        ],
        "properties": {
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            },
            "description": "Blocks to execute when this variant is chosen."
          },
          "name": {
            "type": "string",
            "description": "Human-readable label (e.g. \"control\", `\"variant_a\"`)."
          },
          "weight": {
            "type": "integer",
            "format": "int32",
            "description": "Relative weight. Higher = more traffic.",
            "minimum": 0
          }
        }
      },
      "AddResourceRequest": {
        "type": "object",
        "required": [
          "resource_key",
          "name"
        ],
        "properties": {
          "daily_cap": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "name": {
            "type": "string"
          },
          "resource_key": {
            "type": "string"
          },
          "warmup_days": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "warmup_start": {
            "type": [
              "string",
              "null"
            ]
          },
          "warmup_start_cap": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "weight": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "Affinity": {
        "type": "string",
        "description": "Sticky-affinity mode.",
        "enum": [
          "instance",
          "none"
        ]
      },
      "AlertCondition": {
        "oneOf": [
          {
            "type": "object",
            "description": "Failed (dead-lettered) instances in the tenant. Fires when the total\nreaches `threshold`, or when at least `growth` new failures land\nwithin `window_secs`. At least one of the two must be set.",
            "required": [
              "kind"
            ],
            "properties": {
              "growth": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int64",
                "minimum": 0
              },
              "kind": {
                "type": "string",
                "enum": [
                  "dlq_growth"
                ]
              },
              "threshold": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int64",
                "minimum": 0
              },
              "window_secs": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "description": "Any circuit breaker (or the named handler's) for the tenant is open.",
            "required": [
              "kind"
            ],
            "properties": {
              "handler": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "kind": {
                "type": "string",
                "enum": [
                  "circuit_breaker_opened"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Instances paused by budget enforcement (`paused_reason =\nbudget_exceeded`) reach `min_instances` (default 1).",
            "required": [
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "budget_breach"
                ]
              },
              "min_instances": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "description": "No worker for `handler` (optionally on `queue`) has polled within\n`seen_within_secs`.",
            "required": [
              "handler",
              "kind"
            ],
            "properties": {
              "handler": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "worker_pool_empty"
                ]
              },
              "queue": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "seen_within_secs": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              }
            }
          }
        ],
        "description": "What the evaluator watches."
      },
      "AlertDestination": {
        "oneOf": [
          {
            "type": "object",
            "description": "Slack incoming webhook; `url_ref` is `credentials://id[/field]`.",
            "required": [
              "url_ref",
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "slack"
                ]
              },
              "url_ref": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "description": "`PagerDuty` Events API v2. `routing_key_ref` is a credential reference.\nFiring sends `trigger`, recovery sends `resolve` with the same\n`dedup_key`.",
            "required": [
              "routing_key_ref",
              "type"
            ],
            "properties": {
              "routing_key_ref": {
                "type": "string"
              },
              "severity": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "pagerduty"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Generic JSON webhook, HMAC-signed (`X-Orch8-Signature`) with the\nsecret behind `secret_ref`.",
            "required": [
              "url",
              "secret_ref",
              "type"
            ],
            "properties": {
              "secret_ref": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "webhook"
                ]
              },
              "url": {
                "type": "string"
              }
            }
          }
        ],
        "description": "Where a transition is delivered."
      },
      "AlertRule": {
        "type": "object",
        "description": "A tenant-scoped alert rule.",
        "required": [
          "id",
          "tenant_id",
          "name",
          "condition",
          "destination",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "condition": {
            "$ref": "#/components/schemas/AlertCondition"
          },
          "cooldown_secs": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "destination": {
            "$ref": "#/components/schemas/AlertDestination"
          },
          "enabled": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AlertRuleRequest": {
        "type": "object",
        "required": [
          "name",
          "condition",
          "destination"
        ],
        "properties": {
          "condition": {
            "$ref": "#/components/schemas/AlertCondition"
          },
          "cooldown_secs": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "destination": {
            "$ref": "#/components/schemas/AlertDestination"
          },
          "enabled": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string",
            "description": "Tenant (defaults to the `X-Tenant-Id` header)."
          }
        }
      },
      "AlertRuleState": {
        "type": "object",
        "description": "Evaluator bookkeeping for one rule, updated with a version CAS so that\nexactly one engine node emits each transition.",
        "required": [
          "rule_id",
          "firing",
          "version"
        ],
        "properties": {
          "firing": {
            "type": "boolean"
          },
          "last_evaluated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_fired_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_resolved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_value": {
            "type": "number",
            "format": "double",
            "description": "Last observed metric value (DLQ count, open breakers, …)."
          },
          "rule_id": {
            "type": "string",
            "format": "uuid"
          },
          "samples": {
            "type": "array",
            "items": {
              "type": "array",
              "items": false,
              "prefixItems": [
                {
                  "type": "integer",
                  "format": "int64"
                },
                {
                  "type": "number",
                  "format": "double"
                }
              ]
            },
            "description": "Rolling samples `(unix_secs, value)` for rate conditions."
          },
          "version": {
            "type": "integer",
            "format": "int64",
            "description": "Monotonic CAS version (0 = never stored)."
          }
        }
      },
      "AlertRuleView": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AlertRule"
          },
          {
            "type": "object",
            "properties": {
              "state": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/AlertRuleState",
                    "description": "Evaluator state (absent until first evaluation)."
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        ]
      },
      "ApiCapability": {
        "type": "string",
        "description": "Coarse principal capabilities enforced before tenant API routing.",
        "enum": [
          "operator",
          "worker",
          "device",
          "publisher",
          "approver",
          "auditor",
          "browser_worker",
          "device_node"
        ]
      },
      "ApplyRemediationRequest": {
        "type": "object",
        "required": [
          "preview_id"
        ],
        "properties": {
          "acknowledge_side_effect_risk": {
            "type": "boolean",
            "description": "Required for recipes which may repeat an external side effect."
          },
          "preview_id": {
            "type": "string"
          }
        }
      },
      "ArtifactRef": {
        "type": "object",
        "description": "A durable reference to stored bytes. Travels in step outputs / context as\n`{ \"artifact\": { ... } }` — never the bytes themselves.",
        "required": [
          "id",
          "instance_id",
          "key",
          "content_type",
          "size",
          "uri"
        ],
        "properties": {
          "content_type": {
            "type": "string",
            "description": "MIME type captured at store time (e.g. `image/png`, `text/html`)."
          },
          "id": {
            "type": "string",
            "description": "Opaque artifact id (unique within the instance)."
          },
          "instance_id": {
            "type": "string",
            "description": "Owning instance — artifacts are instance-scoped (object keys are\nprefixed with it, so an instance's blobs can be enumerated via\n`list_artifacts` and removed via `delete_artifact`). Note: unlike DB\nrows, object-store blobs are not yet swept automatically on instance\ndeletion — that cleanup is a follow-up."
          },
          "key": {
            "type": "string",
            "description": "Backend object key (e.g. `\"<instance_id>/<id>\"`)."
          },
          "size": {
            "type": "integer",
            "format": "int64",
            "description": "Size in bytes.",
            "minimum": 0
          },
          "uri": {
            "type": "string",
            "description": "Logical URI: `artifact://<key>`."
          }
        }
      },
      "AuditEntry": {
        "type": "object",
        "required": [
          "timestamp",
          "event",
          "details"
        ],
        "properties": {
          "details": {},
          "event": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AuditLogEntry": {
        "type": "object",
        "description": "An immutable audit log entry recording a state transition or lifecycle event.",
        "required": [
          "id",
          "instance_id",
          "tenant_id",
          "event_type",
          "created_at"
        ],
        "properties": {
          "block_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Block ID related to this event, if any."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "details": {
            "description": "Additional event data (e.g., error message, signal payload)."
          },
          "event_type": {
            "type": "string",
            "description": "Event type (e.g. `state_transition`, `signal_received`, `step_completed`, `step_failed`)."
          },
          "from_state": {
            "type": [
              "string",
              "null"
            ],
            "description": "Previous state (for transitions)."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "to_state": {
            "type": [
              "string",
              "null"
            ],
            "description": "New state (for transitions)."
          }
        }
      },
      "AutoDecideDef": {
        "type": "object",
        "description": "`wait_for_input.auto_decide`: let a calibrated decision model answer a\nhuman gate when it is confident enough.",
        "properties": {
          "api_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "API key (literal or `credentials://` reference). When omitted the\noperator's `TYPESAFE_API_KEY` is used — only for the default endpoint."
          },
          "base_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Endpoint override; requires an explicit `api_key`."
          },
          "instructions": {
            "type": [
              "string",
              "null"
            ],
            "description": "Question put to the model; defaults to the gate's `prompt`."
          },
          "interpret_replies": {
            "type": "boolean",
            "description": "Map a free-text human reply (`{\"text\": \"sure, go ahead\"}`) onto one of\nthe gate's choices instead of rejecting it as an invalid value."
          },
          "model": {
            "type": [
              "string",
              "null"
            ],
            "description": "Model id; defaults to `jev-latest`."
          },
          "threshold": {
            "type": "number",
            "format": "double",
            "description": "Minimum model confidence in `[0, 1]` to accept without a human."
          }
        }
      },
      "BatchAction": {
        "type": "string",
        "description": "The operation a batch action applies to every matched instance.",
        "enum": [
          "retry",
          "pause",
          "resume",
          "cancel",
          "signal"
        ]
      },
      "BatchActionRequest": {
        "type": "object",
        "required": [
          "filter",
          "action"
        ],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/BatchAction"
          },
          "dry_run": {
            "type": "boolean",
            "description": "When true, count matching instances and apply nothing."
          },
          "filter": {
            "$ref": "#/components/schemas/BulkFilter"
          },
          "limit": {
            "type": "integer",
            "format": "int32",
            "description": "Hard cap on how many instances are acted on. Default 1000, max 10000.",
            "minimum": 0
          },
          "payload": {
            "description": "Payload for the `signal` action."
          },
          "signal_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Custom signal name for the `signal` action (no `custom:` prefix). Ignored\nfor the other actions."
          }
        }
      },
      "BatchActionResponse": {
        "type": "object",
        "required": [
          "matched",
          "applied",
          "skipped",
          "failed",
          "dry_run"
        ],
        "properties": {
          "applied": {
            "type": "integer",
            "format": "int64",
            "description": "Instances the action was successfully applied to.",
            "minimum": 0
          },
          "dry_run": {
            "type": "boolean"
          },
          "failed": {
            "type": "integer",
            "format": "int64",
            "description": "Instances where applying the action errored.",
            "minimum": 0
          },
          "matched": {
            "type": "integer",
            "format": "int64",
            "description": "Instances matched by the filter (capped by `limit`).",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "format": "int64",
            "description": "Instances the action did not apply to (e.g. retry of a non-Failed\ninstance, or a signal to a terminal instance).",
            "minimum": 0
          }
        }
      },
      "BatchCreateRequest": {
        "type": "object",
        "required": [
          "instances"
        ],
        "properties": {
          "instances": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateInstanceRequest"
            }
          }
        }
      },
      "BatchIngestRequest": {
        "type": "object",
        "required": [
          "events"
        ],
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IngestEventRequest"
            },
            "description": "Events read from a transactional outbox. Retries are safe because each\nitem carries its producer idempotency identity."
          }
        }
      },
      "BatchIngestResponse": {
        "type": "object",
        "required": [
          "outcomes"
        ],
        "properties": {
          "outcomes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IngestOutcome"
            }
          }
        }
      },
      "BlockDefinition": {
        "oneOf": [
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/StepDef"
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "step"
                    ]
                  }
                }
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/ParallelDef"
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "parallel"
                    ]
                  }
                }
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/RaceDef"
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "race"
                    ]
                  }
                }
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/LoopDef"
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "loop"
                    ]
                  }
                }
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/ForEachDef"
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "for_each"
                    ]
                  }
                }
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/RouterDef"
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "router"
                    ]
                  }
                }
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/TryCatchDef"
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "try_catch"
                    ]
                  }
                }
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/SubSequenceDef",
                "description": "Invoke another sequence as a sub-workflow."
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "sub_sequence"
                    ]
                  }
                }
              }
            ],
            "description": "Invoke another sequence as a sub-workflow."
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/ABSplitDef",
                "description": "A/B split: route traffic to one of several variants by weight."
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "ab_split"
                    ]
                  }
                }
              }
            ],
            "description": "A/B split: route traffic to one of several variants by weight."
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/CancellationScopeDef",
                "description": "Cancellation scope: child blocks cannot be cancelled by external cancel signals.\nProvides subtree-level non-cancellability (Temporal-style structured concurrency)."
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "cancellation_scope"
                    ]
                  }
                }
              }
            ],
            "description": "Cancellation scope: child blocks cannot be cancelled by external cancel signals.\nProvides subtree-level non-cancellability (Temporal-style structured concurrency)."
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/SagaDef",
                "description": "Saga: sequential steps with compensating actions, rolled back in\nreverse order if any step's action fails."
              },
              {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "saga"
                    ]
                  }
                }
              }
            ],
            "description": "Saga: sequential steps with compensating actions, rolled back in\nreverse order if any step's action fails."
          }
        ],
        "description": "A block is either a leaf (step) or a composite (parallel, race, etc.).\n\nThis recursive enum IS the workflow DSL.\nEach variant wraps its definition in `Box<T>` so the enum carries a pointer\nplus its variant tag. `StepDef` is large, with many `Option<...>` fields, and\nwithout boxing every `BlockDefinition` — even `SubSequence`, which is small\n— paid the full size. `Box<T>` is transparent to both `serde` (the default\nimpl delegates to the inner type so wire format is unchanged) and `utoipa`\n(which forwards `ToSchema` through `Box<T>`), so this is an internal\nrepresentation change only."
      },
      "BlockId": {
        "type": "string"
      },
      "BlockOutput": {
        "type": "object",
        "required": [
          "id",
          "instance_id",
          "block_id",
          "output",
          "output_size",
          "attempt",
          "created_at"
        ],
        "properties": {
          "attempt": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "block_id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "output": {},
          "output_ref": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reference key if output was externalized (exceeded size threshold)."
          },
          "output_size": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "BlockOutputSummary": {
        "type": "object",
        "description": "Summary of one recorded output — the payload itself stays behind the\nlazy detail endpoint (`/instances/{id}/outputs`).",
        "required": [
          "block_id",
          "attempt",
          "output_size",
          "status",
          "recorded_at"
        ],
        "properties": {
          "attempt": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "block_id": {
            "type": "string"
          },
          "output_size": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "description": "`ok` | `error` | `retry`."
          }
        }
      },
      "BlockType": {
        "type": "string",
        "enum": [
          "step",
          "parallel",
          "race",
          "loop",
          "for_each",
          "router",
          "try_catch",
          "sub_sequence",
          "ab_split",
          "cancellation_scope",
          "saga"
        ]
      },
      "BreakerState": {
        "type": "string",
        "enum": [
          "closed",
          "open",
          "half_open"
        ]
      },
      "Budget": {
        "type": "object",
        "description": "Optional per-instance resource budget enforced by the scheduler.\n\nWhen any configured limit is exceeded (recorded LLM token usage or\nexecuted step count), the scheduler pauses the instance with\n`metadata.paused_reason = \"budget_exceeded\"` instead of letting it keep\nspending. Resume via the normal `Paused -> Scheduled` transition.\n\nv1 semantics: the budget is checked when the scheduler claims the\ninstance, *before* executing work for that tick. A resumed instance\ntherefore gets one more tick of work before the check fires again; if the\nbudget is still exceeded it pauses again on the next claim. A single\ntick's work may also overshoot the limit slightly (the check is\npre-flight, not mid-step).",
        "properties": {
          "max_attention_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum human-attention units reserved by the execution."
          },
          "max_bytes_transferred": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum bytes transferred across runtime boundaries."
          },
          "max_cost_microunits": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum monetary spend in millionths of the configured currency unit."
          },
          "max_energy_millijoules": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum estimated energy consumption in millijoules."
          },
          "max_external_calls": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum number of calls crossing an external-effect boundary."
          },
          "max_input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Max total LLM input (prompt) tokens recorded for this instance."
          },
          "max_output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Max total LLM output (completion) tokens recorded for this instance."
          },
          "max_steps": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Max executed steps (`context.runtime.total_steps_executed`)."
          },
          "max_total_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Max combined (input + output) LLM tokens recorded for this instance."
          },
          "max_wall_time_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum elapsed execution time in milliseconds."
          }
        }
      },
      "BudgetAlert": {
        "type": "object",
        "description": "Durable record that a budget crossed a soft threshold. Exactly one row per\n`(budget_id, period_start, threshold_percent)`.",
        "required": [
          "id",
          "event",
          "tenant_id",
          "budget_id",
          "period",
          "period_start",
          "threshold_percent",
          "spend_usd",
          "limit_usd",
          "blocking",
          "created_at"
        ],
        "properties": {
          "blocking": {
            "type": "boolean",
            "description": "Whether this threshold makes new dispatches fail (100% + hard cap)."
          },
          "budget_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "event": {
            "type": "string",
            "description": "Always [`BUDGET_THRESHOLD_EVENT`]."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "limit_usd": {
            "type": "number",
            "format": "double"
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "period": {
            "$ref": "#/components/schemas/BudgetPeriod"
          },
          "period_start": {
            "type": "string",
            "format": "date-time"
          },
          "spend_usd": {
            "type": "number",
            "format": "double"
          },
          "tenant_id": {
            "type": "string"
          },
          "threshold_percent": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "BudgetPeriod": {
        "type": "string",
        "description": "Budget accounting period (UTC calendar boundaries).",
        "enum": [
          "daily",
          "monthly"
        ]
      },
      "BudgetRequest": {
        "type": "object",
        "description": "Create/replace body. `limit_usd` is the per-period estimated spend cap.",
        "required": [
          "tenant_id",
          "period",
          "limit_usd"
        ],
        "properties": {
          "hard_cap": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Fail new `llm_call` dispatches closed at 100%. Default `true`."
          },
          "limit_usd": {
            "type": "number",
            "format": "double"
          },
          "model": {
            "type": [
              "string",
              "null"
            ],
            "description": "Model prefix filter (e.g. `gpt-5`, `claude-opus`); omit for all models."
          },
          "period": {
            "$ref": "#/components/schemas/BudgetPeriod"
          },
          "tenant_id": {
            "type": "string"
          },
          "thresholds": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Soft alert thresholds in percent. Default `[50, 80, 100]`."
          }
        }
      },
      "BudgetState": {
        "type": "string",
        "description": "Budget health derived from spend vs. limit.",
        "enum": [
          "ok",
          "warning",
          "exceeded"
        ]
      },
      "BudgetStatus": {
        "type": "object",
        "description": "Current-period status of one budget.",
        "required": [
          "budget",
          "period_start",
          "period_end",
          "spend_usd",
          "percent_used",
          "state",
          "blocking",
          "unpriced_events"
        ],
        "properties": {
          "blocking": {
            "type": "boolean",
            "description": "True when a hard-capped budget is exhausted: new dispatches fail."
          },
          "budget": {
            "$ref": "#/components/schemas/TenantBudget"
          },
          "percent_used": {
            "type": "number",
            "format": "double"
          },
          "period_end": {
            "type": "string",
            "format": "date-time"
          },
          "period_start": {
            "type": "string",
            "format": "date-time"
          },
          "spend_usd": {
            "type": "number",
            "format": "double"
          },
          "state": {
            "$ref": "#/components/schemas/BudgetState"
          },
          "unpriced_events": {
            "type": "integer",
            "format": "int64",
            "description": "Usage from models without a known price is not counted."
          }
        }
      },
      "BulkFilter": {
        "type": "object",
        "properties": {
          "metadata": {
            "type": [
              "object",
              "null"
            ],
            "description": "Top-level `metadata` equality filters (key → value), combined with AND.\nServed by the same indexed path as `GET /instances?metadata.k=v`.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "namespace": {
            "type": [
              "string",
              "null"
            ]
          },
          "sequence_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "states": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/InstanceState"
            }
          },
          "tenant_id": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "BulkRescheduleRequest": {
        "type": "object",
        "required": [
          "filter",
          "offset_secs"
        ],
        "properties": {
          "filter": {
            "$ref": "#/components/schemas/BulkFilter"
          },
          "offset_secs": {
            "type": "integer",
            "format": "int64",
            "description": "Shift `next_fire_at` by this many seconds (positive = later, negative = earlier)."
          }
        }
      },
      "BulkUpdateStateRequest": {
        "type": "object",
        "required": [
          "filter",
          "state"
        ],
        "properties": {
          "filter": {
            "$ref": "#/components/schemas/BulkFilter"
          },
          "state": {
            "$ref": "#/components/schemas/InstanceState"
          }
        }
      },
      "CanaryRequest": {
        "type": "object",
        "required": [
          "percent"
        ],
        "properties": {
          "percent": {
            "type": "integer",
            "format": "int32",
            "description": "Percentage of new instances routed to the candidate (1–100).",
            "minimum": 0
          }
        }
      },
      "CancellationScopeDef": {
        "type": "object",
        "description": "Cancellation scope: wraps child blocks in a non-cancellable boundary.\n\nWhen a cancel signal is received, blocks inside a `CancellationScope`\ncontinue executing until completion. The cancel takes effect only after\nall scoped blocks finish.",
        "required": [
          "id",
          "blocks"
        ],
        "properties": {
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            },
            "description": "Child blocks protected from cancellation."
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          }
        }
      },
      "CapsuleRequirements": {
        "type": "object",
        "description": "Requirements that must be satisfied before accepting a capsule.",
        "properties": {
          "classification": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DataClassification",
                "description": "Data classification the `policy` is evaluated for (default `internal`)."
              },
              {
                "type": "null"
              }
            ]
          },
          "credentials": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "hardware": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "labels": {
            "type": "object",
            "description": "Placement: every label must be advertised with exactly this value.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "minimum_trust": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuntimeTrustLevel"
              },
              {
                "type": "null"
              }
            ]
          },
          "plugins": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "policy": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LocalityPolicy",
                "description": "Locality/residency policy evaluated at dispatch (recorded as a\nplacement decision) and re-evaluated against every claimant."
              },
              {
                "type": "null"
              }
            ]
          },
          "prefer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PlacementPreference",
                "description": "Soft preference (sticky affinity / preferred labels) with a bounded\nwait. Never widens eligibility; see\n[`crate::placement::PlacementPreference`]."
              },
              {
                "type": "null"
              }
            ]
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requires_human_ui": {
            "type": "boolean"
          },
          "requires_network": {
            "type": "boolean"
          },
          "residency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Placement: data-residency zone; only runtimes advertising the label\n`residency=<zone>` may claim. Never relaxed."
          },
          "runtime_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuntimeId",
                "description": "Placement: only this runtime may claim. The task then acts as that\nnode's durable mailbox: it stays `pending` until the node polls."
              },
              {
                "type": "null"
              }
            ]
          },
          "runtime_kinds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RuntimeKind"
            },
            "description": "Placement: only runtimes of these kinds may claim. Empty = any kind.\nA list that excludes `server` forces remote dispatch even when the\nserver has the handler registered in-process."
          }
        }
      },
      "CertificationRequest": {
        "type": "object",
        "required": [
          "subject",
          "results",
          "issued_at",
          "expires_at"
        ],
        "properties": {
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConformanceCheckResult"
            }
          },
          "subject": {
            "type": "string"
          }
        }
      },
      "ChangeCursor": {
        "type": "object",
        "description": "Exclusive position in the tenant audit feed. Ordering is total even when\nmultiple changes share a timestamp because UUID is the tie-breaker.",
        "required": [
          "created_at",
          "id"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "ChangePage": {
        "type": "object",
        "required": [
          "changes",
          "has_more"
        ],
        "properties": {
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AuditLogEntry"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Checkpoint": {
        "type": "object",
        "description": "A checkpoint captures execution state at a point in time for efficient recovery.",
        "required": [
          "id",
          "instance_id",
          "checkpoint_data",
          "created_at"
        ],
        "properties": {
          "checkpoint_data": {
            "description": "Snapshot of execution state: completed block IDs, context, etc."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          }
        }
      },
      "CircuitBreakerState": {
        "type": "object",
        "description": "Circuit breaker state for a (tenant, handler) pair.\n\nBreakers are scoped per-tenant so a noisy customer cannot trip the circuit\nfor an unrelated tenant sharing the same handler name.",
        "required": [
          "tenant_id",
          "handler",
          "state",
          "failure_count",
          "failure_threshold",
          "cooldown_secs"
        ],
        "properties": {
          "cooldown_secs": {
            "type": "integer",
            "format": "int64",
            "description": "Cooldown period in seconds before transitioning from Open to `HalfOpen`.",
            "minimum": 0
          },
          "failure_count": {
            "type": "integer",
            "format": "int32",
            "description": "Consecutive failure count.",
            "minimum": 0
          },
          "failure_threshold": {
            "type": "integer",
            "format": "int32",
            "description": "Threshold of failures before opening the circuit.",
            "minimum": 0
          },
          "handler": {
            "type": "string",
            "description": "Handler name this breaker protects."
          },
          "opened_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the circuit was last opened (to compute cooldown expiry)."
          },
          "state": {
            "$ref": "#/components/schemas/BreakerState"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId",
            "description": "Owning tenant — breakers are isolated per-tenant."
          }
        }
      },
      "ClaimedWorkerTask": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WorkerTask"
          },
          {
            "type": "object",
            "properties": {
              "runtime_kinds": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RuntimeKind"
                },
                "description": "`$runtime.runtime_kinds`: kinds allowed to claim (empty = any)."
              },
              "target_runtime_id": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/RuntimeId",
                    "description": "`$runtime.runtime_id`: the only node allowed to claim (mailbox)."
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        ],
        "description": "A claimed task as delivered to a runtime node: the task (with its\n`effect_id`, `continuity_epoch`, and effective `lease_secs`) plus its\nplacement echoed at the top level for debugging."
      },
      "ClusterNode": {
        "type": "object",
        "description": "Represents a running engine node in a multi-node cluster.",
        "required": [
          "id",
          "name",
          "status",
          "registered_at",
          "last_heartbeat_at",
          "drain"
        ],
        "properties": {
          "capabilities_withdrawn": {
            "type": "boolean",
            "description": "New placement/claim capability was withdrawn before shutdown."
          },
          "drain": {
            "type": "boolean",
            "description": "If true, the node should stop accepting new work and drain."
          },
          "drain_started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "First durable transition into draining."
          },
          "execution_handoff_evidence": {
            "type": [
              "string",
              "null"
            ],
            "description": "Durable evidence written only after the local scheduler has drained."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique node ID (generated at startup)."
          },
          "last_heartbeat_at": {
            "type": "string",
            "format": "date-time",
            "description": "Last heartbeat timestamp."
          },
          "name": {
            "type": "string",
            "description": "Human-readable node name (e.g. hostname or pod name)."
          },
          "registered_at": {
            "type": "string",
            "format": "date-time",
            "description": "When this node first registered."
          },
          "status": {
            "$ref": "#/components/schemas/NodeStatus",
            "description": "Node status."
          },
          "stopped_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Graceful or stale stop time."
          }
        }
      },
      "CommercialContinuityPlan": {
        "type": "object",
        "description": "Enforceable plan for hosted relay, Conformance Cloud, and OEM deployments.",
        "required": [
          "deployment",
          "tenant_isolation",
          "signed_receipts",
          "conformance_required",
          "evidence_retention_days",
          "allowed_protocol_majors"
        ],
        "properties": {
          "allowed_protocol_majors": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          "conformance_required": {
            "type": "boolean"
          },
          "deployment": {
            "$ref": "#/components/schemas/RelayDeployment"
          },
          "evidence_retention_days": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "oem_product_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "signed_receipts": {
            "type": "boolean"
          },
          "tenant_isolation": {
            "type": "boolean"
          },
          "usage_meter": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CompensationVerificationPolicy": {
        "type": "string",
        "enum": [
          "handler_result",
          "provider_receipt",
          "manual"
        ]
      },
      "CompilePolicyRequest": {
        "type": "object",
        "required": [
          "source"
        ],
        "properties": {
          "source": {
            "type": "string"
          }
        }
      },
      "CompiledPlacementPolicy": {
        "type": "object",
        "description": "Human-editable placement policy compiled into the durable core vocabulary.",
        "required": [
          "source",
          "requirements",
          "policy",
          "classification",
          "source_sha256"
        ],
        "properties": {
          "classification": {
            "$ref": "#/components/schemas/DataClassification"
          },
          "policy": {
            "$ref": "#/components/schemas/LocalityPolicy"
          },
          "requirements": {
            "$ref": "#/components/schemas/CapsuleRequirements"
          },
          "source": {
            "type": "string"
          },
          "source_sha256": {
            "type": "string"
          }
        }
      },
      "CompleteRequest": {
        "type": "object",
        "required": [
          "worker_id",
          "claim_epoch",
          "output"
        ],
        "properties": {
          "claim_epoch": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "logs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepLogEntry"
            },
            "description": "Optional log lines the worker captured while running this task."
          },
          "output": {},
          "traceparent": {
            "type": [
              "string",
              "null"
            ],
            "description": "W3C `traceparent` of the worker's span (alternatively sent as the\n`traceparent` HTTP header) so the completion joins the dispatch trace."
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "Confidence": {
        "type": "string",
        "description": "How confident the producer of a finding is in its diagnosis.\n\nDiagnosis surfaces must never claim certainty while multiple\nexplanations remain possible — pick the honest level.",
        "enum": [
          "low",
          "medium",
          "high",
          "certain"
        ]
      },
      "ConformanceCertificate": {
        "type": "object",
        "required": [
          "protocol",
          "subject",
          "score",
          "results_sha256",
          "issued_at",
          "expires_at",
          "issuer"
        ],
        "properties": {
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          },
          "issuer": {
            "type": "string"
          },
          "protocol": {
            "$ref": "#/components/schemas/ProtocolVersion"
          },
          "results_sha256": {
            "type": "string"
          },
          "score": {
            "$ref": "#/components/schemas/ContinuityScore"
          },
          "signature": {
            "type": [
              "string",
              "null"
            ]
          },
          "subject": {
            "type": "string"
          }
        }
      },
      "ConformanceCheck": {
        "type": "string",
        "enum": [
          "protocol_compatibility",
          "atomic_ownership",
          "stale_owner_rejected",
          "duplicate_effect_fenced",
          "offline_resume",
          "policy_enforced",
          "receipt_verifiable",
          "tenant_isolation"
        ]
      },
      "ConformanceCheckResult": {
        "type": "object",
        "required": [
          "check",
          "passed",
          "evidence_sha256",
          "duration_ms"
        ],
        "properties": {
          "check": {
            "$ref": "#/components/schemas/ConformanceCheck"
          },
          "duration_ms": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "evidence_sha256": {
            "type": "string"
          },
          "finding": {
            "type": [
              "string",
              "null"
            ]
          },
          "passed": {
            "type": "boolean"
          }
        }
      },
      "ContextAccess": {
        "type": "object",
        "description": "Controls which context sections a step handler can see.\nWhen set, only the listed sections are passed to the handler.\n\n`data` supports field-level granularity via [`FieldAccess`]; other sections\nare all-or-nothing because they are small by design (`config`, `runtime`)\nor append-only streams (`audit`).",
        "properties": {
          "audit": {
            "type": "boolean",
            "description": "Allow reading `context.audit`."
          },
          "config": {
            "type": "boolean",
            "description": "Allow reading `context.config`."
          },
          "data": {
            "description": "Controls read access to `context.data`. Accepts legacy `true`/`false`,\nthe keywords `\"all\"`/`\"none\"`, or an explicit `{\"fields\": [..]}` list."
          },
          "runtime": {
            "type": "boolean",
            "description": "Allow reading `context.runtime`."
          }
        }
      },
      "ContinuityId": {
        "type": "string",
        "format": "uuid"
      },
      "ContinuityScore": {
        "type": "object",
        "required": [
          "score_millipoints",
          "passed",
          "total",
          "mandatory_failures"
        ],
        "properties": {
          "mandatory_failures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConformanceCheck"
            }
          },
          "passed": {
            "type": "integer",
            "minimum": 0
          },
          "score_millipoints": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "total": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "CountResponse": {
        "type": "object",
        "required": [
          "count"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "CreateBrowserSessionRequest": {
        "type": "object",
        "required": [
          "handlers"
        ],
        "properties": {
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Handler allowlist: polls for any other handler are refused."
          },
          "queues": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Named queues the tab may poll with `/workers/tasks/poll/queue`."
          },
          "runtime_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Runtime identity to bind (a fresh one is minted when absent)."
          },
          "ttl_secs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Token lifetime in seconds (default 900, max 3600).",
            "minimum": 0
          }
        }
      },
      "CreateBrowserSessionResponse": {
        "type": "object",
        "required": [
          "token",
          "runtime_id",
          "expires_at",
          "handlers"
        ],
        "properties": {
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "queues": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "runtime_id": {
            "type": "string"
          },
          "token": {
            "type": "string"
          }
        }
      },
      "CreateCredentialRequest": {
        "type": "object",
        "required": [
          "id",
          "name",
          "value"
        ],
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/CredentialKind"
          },
          "name": {
            "type": "string"
          },
          "refresh_token": {
            "type": [
              "string",
              "null"
            ]
          },
          "refresh_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "tenant_id": {
            "type": "string"
          },
          "value": {
            "type": "string",
            "description": "Raw secret value (typically JSON) — will be stored and redacted on read."
          }
        }
      },
      "CreateCronRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "namespace",
          "sequence_id",
          "cron_expr"
        ],
        "properties": {
          "cron_expr": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "metadata": {},
          "namespace": {
            "$ref": "#/components/schemas/Namespace"
          },
          "overlap_policy": {
            "$ref": "#/components/schemas/OverlapPolicy",
            "description": "Behavior when a fire is due while a previous run is still active:\n`allow` (default), `skip`, `buffer_one`, `cancel_previous`."
          },
          "sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "timezone": {
            "type": "string"
          }
        }
      },
      "CreateDeviceSessionRequest": {
        "type": "object",
        "required": [
          "device_id",
          "runtime_id"
        ],
        "properties": {
          "device_id": {
            "type": "string",
            "description": "The mobile device (`MobileEngineConfig.device_id`) the token acts for."
          },
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Handlers the phone may poll and advertise. Empty = the phone only\ndelegates (it never claims tasks)."
          },
          "runtime_id": {
            "type": "string",
            "description": "The phone's persisted runtime id (`MobileEngine.node_runtime_id()`):\nits `worker_id` for leases and the owner of executions it hosts."
          },
          "ttl_secs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Token lifetime in seconds (default 3600, max 86400).",
            "minimum": 0
          }
        }
      },
      "CreateDeviceSessionResponse": {
        "type": "object",
        "required": [
          "token",
          "device_id",
          "runtime_id",
          "expires_at",
          "handlers"
        ],
        "properties": {
          "device_id": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "runtime_id": {
            "type": "string"
          },
          "token": {
            "type": "string"
          }
        }
      },
      "CreateInstanceRequest": {
        "type": "object",
        "required": [
          "sequence_id",
          "tenant_id",
          "namespace"
        ],
        "properties": {
          "budget": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Budget",
                "description": "Optional resource budget (token/step caps) enforced by the scheduler.\nWhen any configured limit is exceeded the instance is paused with\n`metadata.paused_reason = \"budget_exceeded\"`. Default: no budget."
              },
              {
                "type": "null"
              }
            ]
          },
          "concurrency_key": {
            "type": [
              "string",
              "null"
            ]
          },
          "context": {
            "$ref": "#/components/schemas/ExecutionContext"
          },
          "dry_run": {
            "type": "boolean",
            "description": "Run this instance in dry-run mode: side-effecting steps (HTTP/LLM/MCP\ncalls, agent loops, event/signal emission, memory writes, block\ninjection, external plugins) skip their real effect and return a stub;\ncontrol flow and templating run normally. Any sequence can be run dry.\nDefault false."
          },
          "dry_run_auto_approve": {
            "type": "boolean",
            "description": "When dry-run is on, auto-approve `human_review` gates with the default\nchoice so the simulation flows past them instead of pausing. Ignored\nunless `dry_run` is true. Default false."
          },
          "idempotency_key": {
            "type": [
              "string",
              "null"
            ]
          },
          "max_concurrency": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "metadata": {},
          "namespace": {
            "$ref": "#/components/schemas/Namespace"
          },
          "next_fire_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "priority": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Priority",
                "description": "Explicit priority. When omitted, the lane decides: `priority_lane`,\nthen the sequence's `placement.priority_lane`, then the tenant plan's\n`default_priority_lane`, else `normal`."
              },
              {
                "type": "null"
              }
            ]
          },
          "priority_lane": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PriorityLane",
                "description": "Priority lane (`premium` → high, `standard` → normal, `batch` → low).\nIgnored when `priority` is set."
              },
              {
                "type": "null"
              }
            ]
          },
          "sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "sub_tenant": {
            "type": [
              "string",
              "null"
            ],
            "description": "End customer inside the tenant. The `X-Orch8-Sub-Tenant` header is\nauthoritative; a body value must match it."
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "timezone": {
            "type": "string"
          }
        }
      },
      "CreatePoolRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "name"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "strategy": {
            "$ref": "#/components/schemas/RotationStrategy"
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "CreateReleaseRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "baseline_sequence_id",
          "candidate_sequence_id"
        ],
        "properties": {
          "baseline_sequence_id": {
            "type": "string",
            "format": "uuid"
          },
          "candidate_sequence_id": {
            "type": "string",
            "format": "uuid"
          },
          "gates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReleaseGate"
            }
          },
          "in_flight_policy": {
            "$ref": "#/components/schemas/InFlightPolicy"
          },
          "target": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReleaseTarget",
                "description": "Optional sub-tenant staged rollout: sub-tenant scoped instances are\nrouted by sub-tenant instead of per-instance cohorts; unscoped\ninstances stay on the baseline until promotion. Unknown fields in\nthe target are rejected (the persisted type itself is lenient)."
              },
              {
                "type": "null"
              }
            ]
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "CreateRoutingRuleRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "handler_name",
          "queue_override"
        ],
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "handler_name": {
            "type": "string"
          },
          "match_queue": {
            "type": [
              "string",
              "null"
            ]
          },
          "priority": {
            "type": "integer",
            "format": "int32"
          },
          "queue_override": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "CreateSessionRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "session_key"
        ],
        "properties": {
          "data": {},
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "session_key": {
            "type": "string"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          }
        }
      },
      "CreateShareRequest": {
        "type": "object",
        "properties": {
          "allowed_fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Top-level `context.data` keys to expose publicly. Default: none."
          },
          "expires_in_secs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Lifetime in seconds (60..=7776000). Default 7 days."
          }
        }
      },
      "CreateShareResponse": {
        "type": "object",
        "required": [
          "id",
          "token",
          "url",
          "embed_url",
          "embed_snippet",
          "expires_at",
          "allowed_fields"
        ],
        "properties": {
          "allowed_fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "embed_snippet": {
            "type": "string",
            "description": "Paste-in `<script>` snippet."
          },
          "embed_url": {
            "type": "string",
            "description": "Embeddable HTML page URL."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "token": {
            "type": "string",
            "description": "The bearer token. Returned only once; store it securely."
          },
          "url": {
            "type": "string",
            "description": "Public JSON URL (absolute when the server has `api.public_url`)."
          }
        }
      },
      "CreateTriggerRequest": {
        "type": "object",
        "required": [
          "slug",
          "sequence_name",
          "tenant_id"
        ],
        "properties": {
          "config": {},
          "namespace": {
            "type": "string"
          },
          "secret": {
            "type": [
              "string",
              "null"
            ]
          },
          "sequence_name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "trigger_type": {
            "$ref": "#/components/schemas/TriggerType"
          },
          "version": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32"
          }
        }
      },
      "CredentialKind": {
        "type": "string",
        "description": "The kind of secret held in a credential.",
        "enum": [
          "api_key",
          "oauth2",
          "basic"
        ]
      },
      "CredentialResponse": {
        "type": "object",
        "description": "API response for credentials — secret material is completely stripped.\n\nCredential values never leave the server; they are only resolved\ninternally by step handlers (LLM, HTTP, etc.) via `credentials://<id>`.",
        "required": [
          "id",
          "name",
          "enabled",
          "has_refresh_token",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether this credential can be resolved by step handlers."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "has_refresh_token": {
            "type": "boolean",
            "description": "Whether a refresh token is configured (true/false, never the value)."
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/CredentialKind"
          },
          "name": {
            "type": "string"
          },
          "refresh_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "tenant_id": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CronSchedule": {
        "type": "object",
        "description": "A cron schedule that periodically creates instances of a sequence.",
        "required": [
          "id",
          "tenant_id",
          "namespace",
          "sequence_id",
          "cron_expr",
          "timezone",
          "enabled",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "cron_expr": {
            "type": "string",
            "description": "Standard cron expression (e.g. \"0 9 * * MON-FRI\")."
          },
          "enabled": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "last_skipped_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the `skip` overlap policy last skipped an occurrence."
          },
          "last_triggered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "metadata": {
            "description": "Extra metadata to inject into created instances."
          },
          "namespace": {
            "$ref": "#/components/schemas/Namespace"
          },
          "next_fire_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "overlap_policy": {
            "$ref": "#/components/schemas/OverlapPolicy",
            "description": "Behavior when a fire is due while a previous run is still active."
          },
          "sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "skipped_fires": {
            "type": "integer",
            "format": "int64",
            "description": "Occurrences skipped by the `skip` overlap policy."
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "timezone": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DataClassification": {
        "type": "string",
        "enum": [
          "public",
          "internal",
          "confidential",
          "restricted"
        ]
      },
      "DataflowFinding": {
        "type": "object",
        "required": [
          "code",
          "severity",
          "consumer",
          "reference",
          "summary"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "consumer": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "severity": {
            "$ref": "#/components/schemas/DataflowSeverity"
          },
          "summary": {
            "type": "string"
          }
        }
      },
      "DataflowReport": {
        "type": "object",
        "required": [
          "findings",
          "references_checked"
        ],
        "properties": {
          "findings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataflowFinding"
            }
          },
          "references_checked": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "DataflowResponse": {
        "type": "object",
        "required": [
          "report",
          "generated"
        ],
        "properties": {
          "generated": {
            "$ref": "#/components/schemas/GeneratedDataflowTypes"
          },
          "report": {
            "$ref": "#/components/schemas/DataflowReport"
          }
        }
      },
      "DataflowSeverity": {
        "type": "string",
        "enum": [
          "warning",
          "error"
        ]
      },
      "DebugTemplateRequest": {
        "type": "object",
        "description": "Request body for the lightweight template debugger.",
        "required": [
          "template"
        ],
        "properties": {
          "context_config": {
            "description": "`context.config` fixture."
          },
          "context_data": {
            "description": "`context.data` fixture."
          },
          "outputs": {
            "description": "Prior block outputs fixture: `{block_id: output}`."
          },
          "template": {
            "type": "string",
            "description": "Raw template string to resolve (e.g. `\"{{ context.data.name | upper }}\"`)."
          }
        }
      },
      "DebugTemplateResponse": {
        "type": "object",
        "description": "Response from the template debugger.",
        "required": [
          "entries"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResolutionEntry"
            },
            "description": "Per-expression provenance trace."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Top-level error when the template string is malformed or resolution\nfails entirely."
          },
          "result": {
            "description": "The resolved value after template evaluation, redacted.\n`None` when the entire resolution failed."
          },
          "result_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "JSON type of the resolved value (`string`, `number`, ...)."
          }
        }
      },
      "DelaySpec": {
        "type": "object",
        "required": [
          "duration"
        ],
        "properties": {
          "business_days_only": {
            "type": "boolean"
          },
          "duration": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "fire_at_local": {
            "type": [
              "string",
              "null"
            ],
            "description": "Fire at a specific local wall-clock time (ISO 8601 `NaiveDateTime`,\ne.g. `\"2026-03-08T02:30:00\"`). When set, `duration` is ignored and\nthe engine converts this local time to UTC using the step-level\n`timezone` (or the instance timezone as fallback). DST transitions\nare handled by rolling forward to the next valid local time."
          },
          "holidays": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Holiday dates (YYYY-MM-DD) to skip when `business_days_only` is true.\nMerged with `context.config.holidays` at runtime for tenant-level calendars."
          },
          "jitter": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "timezone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Timezone for `fire_at_local` (IANA, e.g. `\"America/New_York\"`).\nFalls back to the instance's timezone if omitted."
          }
        }
      },
      "DeliveryErrorClass": {
        "type": "string",
        "description": "Normalized failure class for a delivery attempt. Metrics are emitted\nby class (bounded cardinality), never by endpoint.",
        "enum": [
          "dns",
          "connect",
          "tls",
          "timeout",
          "redirect_rejected",
          "http_status",
          "signature_configuration",
          "response_too_large",
          "internal_policy",
          "serialization",
          "aborted",
          "other"
        ]
      },
      "Diagnosis": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Finding",
            "description": "The explanation itself: code, summary, evidence, remediations,\nconfidence."
          },
          {
            "type": "object",
            "required": [
              "category",
              "health"
            ],
            "properties": {
              "category": {
                "$ref": "#/components/schemas/DiagnosisCategory"
              },
              "health": {
                "$ref": "#/components/schemas/DiagnosisHealth"
              }
            }
          }
        ],
        "description": "One ranked explanation."
      },
      "DiagnosisCategory": {
        "type": "string",
        "description": "How strongly the evidence points at this explanation. Used as the\nprimary ranking key.",
        "enum": [
          "direct_evidence",
          "probable_cause",
          "health_warning"
        ]
      },
      "DiagnosisHealth": {
        "type": "string",
        "description": "Whether the observed situation is normal, degraded, or self-contradictory.",
        "enum": [
          "expected",
          "degraded",
          "inconsistent"
        ]
      },
      "DiffEntry": {
        "type": "object",
        "description": "One semantic difference between two sequence versions.",
        "required": [
          "category",
          "severity",
          "summary"
        ],
        "properties": {
          "block_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": "string",
            "description": "Stable category code, `snake_case` (`block_added`,\n`handler_changed`, `input_schema_narrowed`, ...)."
          },
          "severity": {
            "$ref": "#/components/schemas/DiffSeverity"
          },
          "summary": {
            "type": "string"
          }
        }
      },
      "DiffRequest": {
        "type": "object",
        "required": [
          "baseline_sequence_id",
          "candidate_sequence_id"
        ],
        "properties": {
          "baseline_sequence_id": {
            "type": "string",
            "format": "uuid"
          },
          "candidate_sequence_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "DiffSeverity": {
        "type": "string",
        "description": "How much a semantic-diff change matters, ordered.",
        "enum": [
          "informational",
          "behavioral",
          "side_effect_risk",
          "incompatible"
        ]
      },
      "DispatchMode": {
        "type": "string",
        "description": "How tasks on a queue reach workers.",
        "enum": [
          "poll",
          "push"
        ]
      },
      "DlqGroup": {
        "type": "object",
        "description": "One root-cause group of failed instances.",
        "required": [
          "fingerprint",
          "components",
          "error_class",
          "error_code",
          "sample_message",
          "count",
          "first_occurrence",
          "last_occurrence",
          "sequences",
          "blocks",
          "handlers",
          "sample_instance_ids"
        ],
        "properties": {
          "blocks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Affected block ids (bounded)."
          },
          "components": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The fingerprint's components — the grouping is explainable, never\na black box."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Failed instances in this group.",
            "minimum": 0
          },
          "error_class": {
            "$ref": "#/components/schemas/ErrorClass"
          },
          "error_code": {
            "type": "string",
            "description": "Stable error code shared by the group (`HTTP_STATUS`, `TIMEOUT`,\n`unknown`, ...)."
          },
          "fingerprint": {
            "type": "string",
            "description": "Stable fingerprint hash (group key)."
          },
          "first_occurrence": {
            "type": "string",
            "format": "date-time"
          },
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Affected handlers (bounded)."
          },
          "last_occurrence": {
            "type": "string",
            "format": "date-time"
          },
          "sample_instance_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Up to ten newest instance ids for drill-down / sample retry."
          },
          "sample_message": {
            "type": "string",
            "description": "One representative (redacted) message."
          },
          "sequences": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Affected sequence names (bounded)."
          }
        }
      },
      "DlqGroupRetryRequest": {
        "type": "object",
        "description": "Request body for group retry.",
        "required": [
          "mode"
        ],
        "properties": {
          "force": {
            "type": "boolean",
            "description": "Bulk only: explicit override when no successful sample exists."
          },
          "limit": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Bulk only: cap on instances retried in this call (default 100,\nmax 500).",
            "minimum": 0
          },
          "mode": {
            "$ref": "#/components/schemas/DlqRetryMode"
          },
          "sample_verified_instance_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Bulk only: an instance from this group whose *sample retry*\nsucceeded (now `completed`). Verified server-side."
          }
        }
      },
      "DlqGroupRetryResponse": {
        "type": "object",
        "description": "Response for group retry.",
        "required": [
          "fingerprint",
          "mode",
          "retried",
          "skipped"
        ],
        "properties": {
          "fingerprint": {
            "type": "string"
          },
          "mode": {
            "$ref": "#/components/schemas/DlqRetryMode"
          },
          "retried": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Instances transitioned back to `scheduled`."
          },
          "skipped": {
            "type": "integer",
            "format": "int64",
            "description": "Instances skipped (no longer failed / no longer in the group).",
            "minimum": 0
          }
        }
      },
      "DlqRetryMode": {
        "type": "string",
        "enum": [
          "sample",
          "bulk"
        ]
      },
      "EffectId": {
        "type": "string",
        "format": "uuid"
      },
      "EffectKind": {
        "type": "string",
        "description": "Classification of a potentially externally visible operation.",
        "enum": [
          "http",
          "worker",
          "webhook",
          "message",
          "storage",
          "model",
          "human_decision",
          "custom"
        ]
      },
      "EffectReceipt": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "continuity_id",
          "epoch",
          "instance_id",
          "block_id",
          "kind",
          "state",
          "destination_fingerprint",
          "request_sha256",
          "attempt",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "attempt": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "block_id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "continuity_id": {
            "$ref": "#/components/schemas/ContinuityId"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "destination_fingerprint": {
            "type": "string"
          },
          "epoch": {
            "$ref": "#/components/schemas/ExecutionEpoch"
          },
          "id": {
            "$ref": "#/components/schemas/EffectId"
          },
          "idempotency_key": {
            "type": [
              "string",
              "null"
            ]
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "kind": {
            "$ref": "#/components/schemas/EffectKind"
          },
          "provider_receipt_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "request_sha256": {
            "type": "string"
          },
          "state": {
            "$ref": "#/components/schemas/EffectState"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EffectState": {
        "type": "string",
        "description": "Evidence state for an external effect; this never claims exactly-once.",
        "enum": [
          "planned",
          "prepared",
          "dispatched",
          "committed",
          "unknown",
          "verified",
          "compensated",
          "abandoned"
        ]
      },
      "EmbedApproval": {
        "type": "object",
        "required": [
          "id",
          "instance_id",
          "step_id",
          "prompt",
          "choices",
          "created_at"
        ],
        "properties": {
          "choices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HumanChoice"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "prompt": {
            "type": "string"
          },
          "step_id": {
            "type": "string"
          }
        }
      },
      "EmbedApprovalList": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmbedApproval"
            }
          }
        }
      },
      "EmbedHandler": {
        "type": "object",
        "description": "A handler the embedded builder may place in a step.",
        "required": [
          "name"
        ],
        "properties": {
          "default_params": {},
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "label": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          }
        }
      },
      "EmbedRunDetail": {
        "type": "object",
        "required": [
          "id",
          "sequence",
          "state",
          "created_at",
          "updated_at",
          "steps"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "sequence": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmbedStep"
            }
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EmbedRunList": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmbedRunSummary"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "EmbedRunSummary": {
        "type": "object",
        "required": [
          "id",
          "sequence",
          "state",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "current_step": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "sequence": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EmbedScope": {
        "type": "string",
        "description": "What an embed token may do.",
        "enum": [
          "runs:read",
          "runs:start",
          "approvals:resolve",
          "sequences:read",
          "builder:edit"
        ]
      },
      "EmbedSequenceList": {
        "type": "object",
        "required": [
          "items",
          "handlers"
        ],
        "properties": {
          "handlers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmbedHandler"
            },
            "description": "Handlers available to the builder (empty without `builder:edit`)."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmbedSequenceSummary"
            }
          }
        }
      },
      "EmbedSequenceSummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "namespace",
          "version",
          "owned",
          "gallery"
        ],
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display description (`embed.description`)."
          },
          "gallery": {
            "type": "boolean",
            "description": "Read-only gallery template (copy it to customise)."
          },
          "id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "input_schema": {
            "description": "JSON Schema of the run input (`context.data`), if the sequence has one."
          },
          "name": {
            "type": "string"
          },
          "namespace": {
            "type": "string"
          },
          "owned": {
            "type": "boolean",
            "description": "Whether the token's sub-tenant owns (and may edit) the sequence."
          },
          "template": {
            "description": "Opaque gallery template descriptor (`embed.template`)."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display title (`embed.title`)."
          },
          "version": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "EmbedStep": {
        "type": "object",
        "required": [
          "id",
          "name",
          "state"
        ],
        "properties": {
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "output": {
            "description": "Present only for steps listed in the sequence's\n`embed.visible_outputs`."
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "state": {
            "type": "string"
          }
        }
      },
      "EmbedTheme": {
        "type": "object",
        "description": "Tenant-wide embed theme served to embed-kit components.\n\nPersisted, so unknown fields are tolerated on read (binary rollback);\nthe API decodes request bodies with [`crate::strict`] instead.",
        "properties": {
          "css_vars": {
            "type": "object",
            "description": "CSS custom properties (`--orch8-*`), name → value.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "hide_badge": {
            "type": "boolean",
            "description": "Requested badge removal. Only honoured with a `white_label` license."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "EnqueueCommandRequest": {
        "type": "object",
        "required": [
          "worker_id",
          "command"
        ],
        "properties": {
          "command": {
            "$ref": "#/components/schemas/WorkerCommandKind",
            "description": "`drain`, `reload`, `ping`, or `place`."
          },
          "payload": {},
          "tenant_id": {
            "type": "string",
            "description": "Tenant owning the target worker. Tenant-scoped (per-tenant key) worker\nstreams only receive commands of their own tenant; leave empty to\naddress workers connected with the root key."
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "EnqueueJobRequest": {
        "type": "object",
        "description": "Body of `POST /jobs`.",
        "required": [
          "handler"
        ],
        "properties": {
          "delay_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Run no earlier than `now + delay_ms`. Mutually exclusive with `run_at`.",
            "minimum": 0
          },
          "handler": {
            "type": "string",
            "description": "Handler name. Built-in handlers run in-process; any other name is\ndispatched to external workers (pull via `/workers/tasks/poll` or push\nvia a queue dispatch config)."
          },
          "idempotency_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Tenant-scoped idempotency key. Re-posting the same key returns the\nexisting job with HTTP 200 instead of creating a duplicate."
          },
          "metadata": {
            "description": "Free-form caller metadata (JSON object) stored on the instance."
          },
          "namespace": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional namespace. Default `default`."
          },
          "payload": {
            "description": "JSON object passed to the handler as its `params` (and stored as the\ninstance's `context.data`)."
          },
          "priority": {
            "type": [
              "string",
              "null"
            ],
            "description": "Priority level name: `low`, `normal` (default), `high`, `critical`\n(case-insensitive)."
          },
          "queue": {
            "type": [
              "string",
              "null"
            ],
            "description": "Named worker queue. Omitted = default queue."
          },
          "retry": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/JobRetry"
              },
              {
                "type": "null"
              }
            ]
          },
          "run_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Run no earlier than this instant. Mutually exclusive with `delay_ms`."
          },
          "tenant_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional tenant (the `X-Tenant-Id` header is authoritative when set)."
          }
        },
        "additionalProperties": false
      },
      "ErrorClass": {
        "type": "string",
        "description": "Broad, stable classification of where a failure originates. Used to\nseparate \"fix your workflow\" from \"fix your infrastructure\" without\nreading messages.",
        "enum": [
          "application",
          "configuration",
          "worker",
          "credential",
          "policy",
          "external_dependency",
          "timeout",
          "cancelled",
          "internal"
        ]
      },
      "EscalationDef": {
        "type": "object",
        "description": "Action to take when an SLA deadline is breached.",
        "required": [
          "handler"
        ],
        "properties": {
          "handler": {
            "type": "string",
            "description": "Handler name to invoke on breach (e.g. `\"notify_slack\"`, `\"send_alert\"`)."
          },
          "params": {
            "description": "Parameters passed to the escalation handler."
          }
        }
      },
      "EvaluationReport": {
        "type": "object",
        "required": [
          "baseline",
          "candidate",
          "gates",
          "auto_rolled_back",
          "release_state"
        ],
        "properties": {
          "auto_rolled_back": {
            "type": "boolean",
            "description": "Applied automatically when a gate fails during canary."
          },
          "baseline": {
            "$ref": "#/components/schemas/VariantStats"
          },
          "candidate": {
            "$ref": "#/components/schemas/VariantStats"
          },
          "gates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GateEvaluation"
            }
          },
          "release_state": {
            "$ref": "#/components/schemas/ReleaseState"
          }
        }
      },
      "EventEnvelope": {
        "type": "object",
        "description": "One ingested event. Canonical identity is\n`(tenant_id, event_name, producer_event_id)` — re-sending the same\nproducer id is a safe no-op.",
        "required": [
          "id",
          "tenant_id",
          "event_name",
          "producer_event_id",
          "correlation_key",
          "status",
          "received_at"
        ],
        "properties": {
          "consumed_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The instance whose wait consumed this event."
          },
          "correlation_key": {
            "type": "string",
            "description": "Tenant-scoped business correlation key (order id, customer id...)."
          },
          "event_name": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "payload": {},
          "producer_event_id": {
            "type": "string",
            "description": "The producer's idempotency identity for this event."
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "$ref": "#/components/schemas/EventStatus"
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "EventListResponse": {
        "oneOf": [
          {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventEnvelope"
            }
          },
          {
            "type": "object",
            "required": [
              "items",
              "offset",
              "has_more"
            ],
            "properties": {
              "has_more": {
                "type": "boolean"
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/EventEnvelope"
                }
              },
              "offset": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          }
        ]
      },
      "EventStatus": {
        "type": "string",
        "description": "Inbox lifecycle of an event.",
        "enum": [
          "pending",
          "consumed",
          "expired"
        ]
      },
      "EventWait": {
        "type": "object",
        "description": "A registered `wait_for_event` block instance.",
        "required": [
          "id",
          "tenant_id",
          "instance_id",
          "block_id",
          "event_names",
          "correlation_key",
          "join_mode",
          "status",
          "created_at"
        ],
        "properties": {
          "block_id": {
            "type": "string"
          },
          "correlation_key": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "event_names": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Event names this wait listens for."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "join_mode": {
            "$ref": "#/components/schemas/JoinMode"
          },
          "matched_event_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Envelope ids consumed by this wait so far."
          },
          "matched_names": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Names of events matched so far (deduplicated)."
          },
          "status": {
            "$ref": "#/components/schemas/WaitStatus"
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "Evidence": {
        "type": "object",
        "description": "One piece of evidence backing a finding: a fact, where it was observed,\nand when.",
        "required": [
          "label",
          "summary"
        ],
        "properties": {
          "data": {
            "description": "Optional structured payload (already redacted by the producer)."
          },
          "label": {
            "type": "string",
            "description": "Short machine-friendly label, e.g. `next_fire_at`, `worker_last_seen`."
          },
          "observed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When this fact was observed (not when the finding was assembled)."
          },
          "summary": {
            "type": "string",
            "description": "Human-readable statement of the fact."
          }
        }
      },
      "ExecutionContext": {
        "type": "object",
        "description": "Multi-section execution context with different permission semantics.",
        "properties": {
          "audit": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AuditEntry"
            },
            "description": "Append-only audit trail."
          },
          "config": {
            "description": "Read-only after initialization."
          },
          "data": {
            "description": "Read/write by step handlers."
          },
          "runtime": {
            "$ref": "#/components/schemas/RuntimeContext",
            "description": "Engine-managed runtime state. Read-only to step handlers."
          }
        }
      },
      "ExecutionEpoch": {
        "type": "integer",
        "format": "int64",
        "description": "Monotonic ownership generation for one portable execution.",
        "minimum": 0
      },
      "ExecutionLocationReceipt": {
        "type": "object",
        "required": [
          "runtime_id",
          "kind",
          "trust",
          "entered_at"
        ],
        "properties": {
          "entered_at": {
            "type": "string",
            "format": "date-time"
          },
          "exited_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "kind": {
            "$ref": "#/components/schemas/RuntimeKind"
          },
          "region": {
            "type": [
              "string",
              "null"
            ]
          },
          "runtime_id": {
            "$ref": "#/components/schemas/RuntimeId"
          },
          "trust": {
            "$ref": "#/components/schemas/RuntimeTrustLevel"
          }
        }
      },
      "ExecutionNode": {
        "type": "object",
        "required": [
          "id",
          "instance_id",
          "block_id",
          "block_type",
          "state"
        ],
        "properties": {
          "block_id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "block_type": {
            "$ref": "#/components/schemas/BlockType"
          },
          "branch_index": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32"
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "id": {
            "$ref": "#/components/schemas/ExecutionNodeId"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "parent_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ExecutionNodeId"
              },
              {
                "type": "null"
              }
            ]
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "state": {
            "$ref": "#/components/schemas/NodeState"
          }
        }
      },
      "ExecutionNodeId": {
        "type": "string",
        "format": "uuid"
      },
      "ExecutionReceipt": {
        "type": "object",
        "description": "Portable, hash-verifiable bill of execution.",
        "required": [
          "protocol",
          "receipt_id",
          "tenant_id",
          "continuity_id",
          "instance_id",
          "final_epoch",
          "sequence_sha256",
          "model_ids",
          "tool_ids",
          "locations",
          "effects",
          "policy_outcome",
          "consent_receipt_ids",
          "created_at",
          "digest_sha256"
        ],
        "properties": {
          "consent_receipt_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "continuity_id": {
            "$ref": "#/components/schemas/ContinuityId"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "digest_sha256": {
            "type": "string"
          },
          "effects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EffectReceipt"
            }
          },
          "final_epoch": {
            "$ref": "#/components/schemas/ExecutionEpoch"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "locations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExecutionLocationReceipt"
            }
          },
          "model_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "policy_outcome": {
            "$ref": "#/components/schemas/PolicyOutcome"
          },
          "previous_receipt_sha256": {
            "type": [
              "string",
              "null"
            ]
          },
          "protocol": {
            "$ref": "#/components/schemas/ProtocolVersion"
          },
          "receipt_id": {
            "type": "string",
            "format": "uuid"
          },
          "sequence_sha256": {
            "type": "string"
          },
          "signature": {
            "type": [
              "string",
              "null"
            ]
          },
          "signing_key_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "tool_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ExecutionWorkbenchView": {
        "type": "object",
        "required": [
          "instance_id",
          "sequence_id",
          "sequence_name",
          "sequence_version",
          "state",
          "context_data",
          "nodes",
          "events",
          "outputs",
          "events_truncated",
          "share_path"
        ],
        "properties": {
          "context_data": {
            "description": "Redacted context data."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkbenchEvent"
            },
            "description": "Unified, stably-ordered event timeline (bounded by `limit`)."
          },
          "events_truncated": {
            "type": "boolean",
            "description": "True when `events` was truncated at the requested limit."
          },
          "instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "nodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExecutionNode"
            },
            "description": "Definition tree nodes with their execution state."
          },
          "outputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockOutputSummary"
            }
          },
          "sequence_id": {
            "type": "string",
            "format": "uuid"
          },
          "sequence_name": {
            "type": "string"
          },
          "sequence_version": {
            "type": "integer",
            "format": "int32"
          },
          "share_path": {
            "type": "string",
            "description": "Shareable deep-link path (ids only, never payloads)."
          },
          "state": {
            "type": "string"
          }
        }
      },
      "ExplanationMode": {
        "type": "string",
        "description": "How the explanation text was produced.",
        "enum": [
          "template",
          "llm"
        ]
      },
      "FailRequest": {
        "type": "object",
        "required": [
          "worker_id",
          "claim_epoch",
          "message"
        ],
        "properties": {
          "claim_epoch": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "logs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepLogEntry"
            },
            "description": "Optional log lines the worker captured while running this task."
          },
          "message": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "FailureEnvelope": {
        "type": "object",
        "description": "Structured description of one failure, preserved alongside the\nhuman-readable message.",
        "required": [
          "error_code",
          "error_class",
          "message",
          "retryable",
          "occurred_at"
        ],
        "properties": {
          "block_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Block that failed, when the failure is block-scoped."
          },
          "details": {
            "description": "Producer-supplied structured details (already redacted)."
          },
          "error_class": {
            "$ref": "#/components/schemas/ErrorClass"
          },
          "error_code": {
            "type": "string",
            "description": "Stable machine code, `SCREAMING_SNAKE_CASE`, e.g. `HANDLER_TIMEOUT`,\n`HTTP_STATUS`, `NO_COMPATIBLE_WORKER`. Codes are producer-defined\nbut must be stable across releases."
          },
          "external_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Normalized external status (HTTP status, DB SQLSTATE class, exit\ncode), when the failure came from an external dependency."
          },
          "handler": {
            "type": [
              "string",
              "null"
            ],
            "description": "Handler that failed, when applicable."
          },
          "message": {
            "type": "string",
            "description": "The human-readable message. Kept verbatim; never used as the\nprimary machine interface."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "resource": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ResourceRef",
                "description": "The credential / queue / worker / plugin / breaker involved, when\napplicable. This is an identifier, never a secret."
              },
              {
                "type": "null"
              }
            ]
          },
          "retryable": {
            "type": "boolean",
            "description": "Whether the engine considered this retryable at the time."
          }
        }
      },
      "FailureFingerprint": {
        "type": "object",
        "description": "A stable, explainable root-cause fingerprint for grouping DLQ entries.",
        "required": [
          "hash",
          "components"
        ],
        "properties": {
          "components": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The components that went into the hash, in order — kept so the\ngrouping is explainable, never a black box."
          },
          "hash": {
            "type": "string",
            "description": "Hex-encoded 64-bit FNV-1a hash of the normalized components."
          }
        }
      },
      "FederationCall": {
        "type": "object",
        "description": "Durable record of one outbound call. `version` is the CAS token.",
        "required": [
          "call_id",
          "tenant_id",
          "instance_id",
          "block_id",
          "peer_id",
          "sequence",
          "input",
          "state",
          "next_poll_at",
          "created_at",
          "updated_at",
          "version"
        ],
        "properties": {
          "attempts": {
            "type": "integer",
            "format": "int32",
            "description": "Consecutive transport failures (drives backoff).",
            "minimum": 0
          },
          "block_id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "call_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "input": {
            "description": "Minimized input: only the peer's `disclosed_fields`."
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "next_poll_at": {
            "type": "string",
            "format": "date-time"
          },
          "notified": {
            "type": "boolean",
            "description": "Local instance was told about the terminal state (resume signal sent)."
          },
          "peer_id": {
            "$ref": "#/components/schemas/FederationPeerId"
          },
          "remote_instance_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "result": {},
          "sequence": {
            "type": "string"
          },
          "sequence_version": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32"
          },
          "state": {
            "$ref": "#/components/schemas/FederationCallState"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "withheld_sha256": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "SHA-256 of each withheld top-level field (evidence, never the value)."
          }
        }
      },
      "FederationCallState": {
        "type": "string",
        "description": "Lifecycle of an outbound federated call.",
        "enum": [
          "pending",
          "running",
          "completed",
          "failed",
          "cancelled"
        ]
      },
      "FederationEnvelope": {
        "type": "object",
        "required": [
          "id",
          "peer_id",
          "tenant_id",
          "continuity_id",
          "epoch",
          "destination_runtime_id",
          "payload_sha256",
          "issued_at",
          "expires_at",
          "signature"
        ],
        "properties": {
          "continuity_id": {
            "$ref": "#/components/schemas/ContinuityId"
          },
          "destination_runtime_id": {
            "$ref": "#/components/schemas/RuntimeId"
          },
          "epoch": {
            "$ref": "#/components/schemas/ExecutionEpoch"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "$ref": "#/components/schemas/FederationMessageId"
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload_sha256": {
            "type": "string"
          },
          "peer_id": {
            "$ref": "#/components/schemas/FederationPeerId"
          },
          "signature": {
            "type": "string"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          }
        }
      },
      "FederationIdentity": {
        "type": "object",
        "description": "Public identity other engines register us under.",
        "required": [
          "peer_id",
          "public_key",
          "trust_root_sha256"
        ],
        "properties": {
          "peer_id": {
            "$ref": "#/components/schemas/FederationPeerId"
          },
          "public_key": {
            "type": "string"
          },
          "trust_root_sha256": {
            "type": "string"
          }
        }
      },
      "FederationMessageId": {
        "type": "string",
        "format": "uuid"
      },
      "FederationPeerId": {
        "type": "string",
        "format": "uuid"
      },
      "FederationPeerRecord": {
        "type": "object",
        "description": "One entry of the per-tenant federation trust registry.",
        "required": [
          "tenant_id",
          "peer_id",
          "name",
          "endpoint",
          "public_key",
          "remote_tenant_id",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "endpoint": {
            "type": "string",
            "description": "HTTPS base URL of the peer's gateway (no trailing path)."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "inbound": {
            "$ref": "#/components/schemas/PeerInboundPolicy"
          },
          "name": {
            "type": "string"
          },
          "outbound": {
            "$ref": "#/components/schemas/PeerOutboundPolicy"
          },
          "peer_id": {
            "$ref": "#/components/schemas/FederationPeerId",
            "description": "The peer's federation identity (derived from its public key; see\n[`peer_id_from_public_key`])."
          },
          "public_key": {
            "type": "string",
            "description": "Base64 raw 32-byte ed25519 verifying key of the peer."
          },
          "relationship": {
            "$ref": "#/components/schemas/PeerRelationship"
          },
          "remote_tenant_id": {
            "$ref": "#/components/schemas/TenantId",
            "description": "Tenant at the peer that this relationship is bound to: our calls\ntarget it, and its calls must come from it."
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId",
            "description": "Local tenant that owns this trust relationship."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Finding": {
        "type": "object",
        "description": "One read-only diagnostic statement with its evidence and suggested\nremediations.",
        "required": [
          "code",
          "severity",
          "summary",
          "confidence",
          "observed_at"
        ],
        "properties": {
          "affected_resource": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ResourceRef"
              },
              {
                "type": "null"
              }
            ]
          },
          "code": {
            "type": "string",
            "description": "Stable machine code, `SCREAMING_SNAKE_CASE`, e.g. `NO_COMPATIBLE_WORKER`."
          },
          "confidence": {
            "$ref": "#/components/schemas/Confidence"
          },
          "docs_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Documentation link for `error_code`\n(`https://orch8.io/docs/errors#ORCH8-P001`)."
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stable public error code from [`crate::error_catalog`], e.g.\n`ORCH8-P001`. Filled automatically for catalogued keys."
          },
          "evidence": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Evidence"
            }
          },
          "observed_at": {
            "type": "string",
            "format": "date-time"
          },
          "remediation": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Remediation"
            }
          },
          "severity": {
            "$ref": "#/components/schemas/FindingSeverity"
          },
          "summary": {
            "type": "string",
            "description": "One-sentence human-readable statement."
          }
        }
      },
      "FindingSeverity": {
        "type": "string",
        "description": "How severe a finding is for the operator.",
        "enum": [
          "info",
          "warning",
          "error",
          "critical"
        ]
      },
      "ForEachDef": {
        "type": "object",
        "required": [
          "id",
          "collection",
          "body"
        ],
        "properties": {
          "body": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          },
          "collection": {
            "type": "string"
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "item_var": {
            "type": "string"
          },
          "max_iterations": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "retain_iterations": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Keep only the most recent N iterations' body-step outputs; older outputs\nare compacted at each iteration boundary. `None` retains everything.",
            "minimum": 0
          }
        }
      },
      "ForkPreview": {
        "type": "object",
        "required": [
          "instance_id",
          "from_block_id",
          "copied_blocks",
          "re_executed_blocks",
          "side_effect_blocks",
          "sandbox_default"
        ],
        "properties": {
          "copied_blocks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blocks whose recorded outputs would be copied into the fork."
          },
          "from_block_id": {
            "type": "string"
          },
          "instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "re_executed_blocks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blocks that would execute again in the fork."
          },
          "sandbox_default": {
            "type": "boolean",
            "description": "Forks start in dry-run (sandbox) mode unless explicitly overridden."
          },
          "side_effect_blocks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Re-executed blocks with external side effects — the UI must\nrequire explicit confirmation for these."
          }
        }
      },
      "ForkRequest": {
        "type": "object",
        "description": "Body for `POST /instances/{id}/fork`. `from_block_id` must be a top-level\nblock of the source's sequence; `context` (optional) is shallow-merged\ninto the fork's `context.data` with the same per-key semantics as\nresume-from; `dry_run` defaults to **true** so a forked production\nworkflow does not re-fire side effects unless explicitly asked to.\n`signals` are enqueued on the fork before it becomes claimable.",
        "required": [
          "from_block_id"
        ],
        "properties": {
          "context": {},
          "dry_run": {
            "type": "boolean"
          },
          "from_block_id": {
            "type": "string"
          },
          "signals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InjectedSignal"
            }
          }
        }
      },
      "ForkResponse": {
        "type": "object",
        "required": [
          "id",
          "forked_from",
          "state",
          "copied_blocks",
          "rerun_blocks",
          "dry_run"
        ],
        "properties": {
          "copied_blocks": {
            "type": "integer",
            "description": "Number of pre-fork top-level blocks whose outputs were copied (the\nfork will NOT re-execute these).",
            "minimum": 0
          },
          "dry_run": {
            "type": "boolean",
            "description": "Whether the fork runs in dry-run mode."
          },
          "forked_from": {
            "$ref": "#/components/schemas/InstanceId",
            "description": "ID of the source instance."
          },
          "id": {
            "$ref": "#/components/schemas/InstanceId",
            "description": "ID of the newly created fork."
          },
          "rerun_blocks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pre-fork top-level blocks whose outputs could not be copied (never\nexecuted, artifact-backed, or mid-flight sentinel) — these WILL\n(re-)execute on the fork, in addition to everything from\n`from_block_id` onward."
          },
          "state": {
            "type": "string",
            "description": "Always `scheduled` — the fork fires immediately."
          }
        }
      },
      "GateEvaluation": {
        "type": "object",
        "description": "Outcome of evaluating one gate.",
        "required": [
          "gate",
          "verdict"
        ],
        "properties": {
          "baseline_rate": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Observed baseline rate, or `None` when it has no observations.\nA populated rate does not imply that `min_sample` has been reached."
          },
          "candidate_rate": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Observed candidate rate, or `None` when it has no observations."
          },
          "gate": {
            "$ref": "#/components/schemas/ReleaseGate"
          },
          "verdict": {
            "$ref": "#/components/schemas/GateVerdict"
          }
        }
      },
      "GateMetric": {
        "type": "string",
        "description": "Gate metrics evaluated over canary observations.",
        "enum": [
          "error_rate",
          "cancel_rate"
        ]
      },
      "GateVerdict": {
        "type": "string",
        "enum": [
          "inconclusive",
          "pass",
          "fail"
        ]
      },
      "GatewayAdapter": {
        "type": "string",
        "enum": [
          "generic_http",
          "mcp",
          "local_process",
          "mobile_worker"
        ]
      },
      "GatewayManifest": {
        "type": "object",
        "description": "Drop-in wrapper/gateway manifest used by `orch8 wrap`, MCP, and local workers.",
        "required": [
          "protocol",
          "name",
          "adapter",
          "entrypoint",
          "handler",
          "policy_source",
          "environment_allowlist",
          "secret_references",
          "receipt_required"
        ],
        "properties": {
          "adapter": {
            "$ref": "#/components/schemas/GatewayAdapter"
          },
          "arguments": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "entrypoint": {
            "type": "string"
          },
          "environment_allowlist": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "handler": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "policy_source": {
            "type": "string"
          },
          "protocol": {
            "$ref": "#/components/schemas/ProtocolVersion"
          },
          "receipt_required": {
            "type": "boolean"
          },
          "secret_references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "GeneratedDataflowTypes": {
        "type": "object",
        "description": "Deterministic language bindings and their canonical source schema.",
        "required": [
          "generator_version",
          "sequence_sha256",
          "schema",
          "typescript",
          "python"
        ],
        "properties": {
          "generator_version": {
            "type": "string"
          },
          "kotlin": {
            "type": "string"
          },
          "python": {
            "type": "string"
          },
          "schema": {},
          "sequence_sha256": {
            "type": "string"
          },
          "swift": {
            "type": "string"
          },
          "typescript": {
            "type": "string"
          }
        }
      },
      "HandlerCatalog": {
        "type": "object",
        "description": "Catalog of every handler name the engine can serve.",
        "required": [
          "builtin",
          "external"
        ],
        "properties": {
          "builtin": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Handlers executed in-process by the engine."
          },
          "external": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Handler names served by external workers (from the worker registry)."
          }
        }
      },
      "HeartbeatRequest": {
        "type": "object",
        "required": [
          "worker_id",
          "claim_epoch"
        ],
        "properties": {
          "checkpoint": {},
          "checkpoint_seq": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "claim_epoch": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "HumanChoice": {
        "type": "object",
        "description": "One option presented to the human reviewer in advanced mode.",
        "required": [
          "label",
          "value"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "Display text shown in the UI."
          },
          "value": {
            "type": "string",
            "description": "Stable identifier stored in context and used for router matching."
          }
        }
      },
      "HumanInputDef": {
        "type": "object",
        "description": "Configuration for human-in-the-loop steps.",
        "properties": {
          "allow_comment": {
            "type": "boolean",
            "description": "When true, the reviewer can attach a free-text comment to their decision."
          },
          "auto_decide": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AutoDecideDef",
                "description": "Confidence-gated automation: ask the Jev decision model to answer the\ngate first. At or above `threshold` confidence the gate is accepted\nwithout a human (the decision, confidence and probabilities are kept\non the gate's output as evidence); below it — or when the model is\nunavailable — the step parks for a human exactly as without this\nsetting.\nBoxed: most gates don't set it, and `HumanInputDef` rides inside\nevery `StepDef` (and so inside large async state machines)."
              },
              {
                "type": "null"
              }
            ]
          },
          "choices": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/HumanChoice"
            },
            "description": "Choices the human can pick from. If `None`, the engine applies the\ndefault yes/no preset."
          },
          "escalation_handler": {
            "type": [
              "string",
              "null"
            ],
            "description": "If set and timeout expires, send a signal to this escalation target\ninstead of failing the step."
          },
          "prompt": {
            "type": "string",
            "description": "Prompt or instructions for the human reviewer."
          },
          "store_as": {
            "type": [
              "string",
              "null"
            ],
            "description": "Context-variable name under which the picked value is stored\n(`context.data[store_as]`). If `None`, the block id is used."
          },
          "timeout": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Timeout in milliseconds before the step fails or escalates.\nIf omitted, waits indefinitely.",
            "minimum": 0
          }
        }
      },
      "InFlightPolicy": {
        "type": "string",
        "description": "How in-flight instances are treated when a release promotes.",
        "enum": [
          "pin",
          "operator_decision"
        ]
      },
      "IngestEventRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "event_name",
          "producer_event_id",
          "correlation_key"
        ],
        "properties": {
          "correlation_key": {
            "type": "string"
          },
          "event_name": {
            "type": "string"
          },
          "payload": {},
          "producer_event_id": {
            "type": "string",
            "description": "Producer idempotency identity — re-sending the same id is a safe\nno-op."
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "IngestOutcome": {
        "type": "object",
        "description": "Outcome of ingesting one event.",
        "required": [
          "event_id",
          "duplicate"
        ],
        "properties": {
          "duplicate": {
            "type": "boolean",
            "description": "True when the producer identity was already known. Matching can resume\nif the original event is still pending after an earlier attempt."
          },
          "event_id": {
            "type": "string",
            "format": "uuid",
            "description": "ID of the submitted envelope. A duplicate may have a different\ntransport ID from the canonical event stored in the inbox."
          },
          "matched_wait": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The wait (if any) this event was matched into."
          },
          "satisfied": {
            "type": "boolean",
            "description": "True when the match satisfied the wait's join and resumed the\nwaiting instance."
          }
        }
      },
      "InjectBlocksRequest": {
        "type": "object",
        "required": [
          "blocks"
        ],
        "properties": {
          "blocks": {
            "description": "Blocks must be a valid JSON array of `BlockDefinition` objects."
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Position to inject at (0-indexed). If omitted, blocks are appended.",
            "minimum": 0
          }
        }
      },
      "InjectedSignal": {
        "type": "object",
        "description": "A signal enqueued atomically with a resume-from or fork, so it is already\npending when the instance becomes claimable. Closes the race window of the\nseparate \"reset, then signal\" two-call pattern.",
        "required": [
          "signal_type"
        ],
        "properties": {
          "payload": {},
          "signal_type": {
            "$ref": "#/components/schemas/SignalType"
          }
        }
      },
      "InspectTemplateRequest": {
        "type": "object",
        "description": "Request body for draft inspection: a definition (or stored sequence\nid), the block to inspect, and the context/outputs fixture to resolve\nagainst.",
        "required": [
          "block_id"
        ],
        "properties": {
          "block_id": {
            "type": "string",
            "description": "The step block whose params to inspect."
          },
          "context_config": {
            "description": "`context.config` fixture."
          },
          "context_data": {
            "description": "`context.data` fixture."
          },
          "outputs": {
            "description": "Prior block outputs fixture: `{block_id: output}`."
          },
          "sequence": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SequenceDefinition",
                "description": "Draft sequence definition. Exactly one of `sequence` /\n`sequence_id` must be set."
              },
              {
                "type": "null"
              }
            ]
          },
          "sequence_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Stored sequence id."
          }
        }
      },
      "InstanceDiagnosisReport": {
        "type": "object",
        "description": "The full report for one instance.",
        "required": [
          "instance_id",
          "state",
          "diagnoses",
          "generated_at"
        ],
        "properties": {
          "diagnoses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Diagnosis"
            },
            "description": "Ranked: direct evidence first, then probable causes, then health\nwarnings; higher confidence first within a category."
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "state": {
            "type": "string",
            "description": "Instance state at diagnosis time (engine state name)."
          }
        }
      },
      "InstanceExplanation": {
        "type": "object",
        "description": "A plain-language explanation of an instance's current situation.",
        "required": [
          "instance_id",
          "state",
          "headline",
          "likely_cause",
          "suggested_fix",
          "code",
          "confidence",
          "mode",
          "generated_at"
        ],
        "properties": {
          "alternatives": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Other plausible explanations, ranked, as `CODE: summary` lines."
          },
          "code": {
            "type": "string",
            "description": "Machine key of the primary diagnosis or failure (e.g. `NO_COMPATIBLE_WORKER`, `HTTP_STATUS`)."
          },
          "commands": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Commands the operator can run verbatim. Describing a command never\nruns it."
          },
          "confidence": {
            "$ref": "#/components/schemas/Confidence"
          },
          "docs_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stable public code when catalogued (`ORCH8-P001`)."
          },
          "evidence": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Facts backing the explanation (already redacted by their producers)."
          },
          "failure": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/FailureEnvelope",
                "description": "Structured failure envelope for failed instances."
              },
              {
                "type": "null"
              }
            ]
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "headline": {
            "type": "string",
            "description": "One sentence: what is going on."
          },
          "instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "likely_cause": {
            "type": "string",
            "description": "The most likely cause, in plain language."
          },
          "llm_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why an LLM narrative was requested but not produced (the template\nexplanation is still complete)."
          },
          "mode": {
            "$ref": "#/components/schemas/ExplanationMode"
          },
          "narrative": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LlmNarrative"
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "type": "string",
            "description": "Engine state name at explanation time."
          },
          "suggested_fix": {
            "type": "string",
            "description": "What to do about it."
          }
        }
      },
      "InstanceId": {
        "type": "string",
        "format": "uuid",
        "description": "Newtype wrappers prevent mixing up UUIDs at compile time.\nZero cost at runtime (transparent newtypes)."
      },
      "InstanceState": {
        "type": "string",
        "description": "Instance states form a strict state machine.\nTransitions are validated at runtime via `can_transition_to`.",
        "enum": [
          "scheduled",
          "running",
          "waiting",
          "paused",
          "completed",
          "failed",
          "cancelled"
        ]
      },
      "InterceptorAction": {
        "type": "object",
        "description": "An interceptor action that fires at a lifecycle point.",
        "required": [
          "handler"
        ],
        "properties": {
          "handler": {
            "type": "string",
            "description": "Handler name to invoke (must be registered or dispatched to external worker)."
          },
          "params": {
            "description": "Static params passed to the handler."
          }
        }
      },
      "InterceptorDef": {
        "type": "object",
        "description": "Defines lifecycle hooks attached to a sequence.\nInterceptors are evaluated at defined points in the instance lifecycle.",
        "properties": {
          "after_step": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InterceptorAction",
                "description": "Called after each step completes (success or failure)."
              },
              {
                "type": "null"
              }
            ]
          },
          "before_step": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InterceptorAction",
                "description": "Called before each step executes. Can modify context or skip the step."
              },
              {
                "type": "null"
              }
            ]
          },
          "on_complete": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InterceptorAction",
                "description": "Called when the instance completes."
              },
              {
                "type": "null"
              }
            ]
          },
          "on_failure": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InterceptorAction",
                "description": "Called when the instance fails."
              },
              {
                "type": "null"
              }
            ]
          },
          "on_signal": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InterceptorAction",
                "description": "Called when a signal is received."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "IssueTokenRequest": {
        "type": "object",
        "required": [
          "sub_tenant",
          "scopes"
        ],
        "properties": {
          "scopes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmbedScope"
            }
          },
          "sequences": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Tenant-level sequences the token may see and run, beyond the\nsub-tenant's own sequences and the read-only gallery: `\"name\"`\n(namespace `default`), `\"namespace/name\"`, or `\"*\"` for every\ntenant-level sequence. null/empty = no tenant-level access."
          },
          "sub_tenant": {
            "type": "string"
          },
          "ttl_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Lifetime (default 900, max 3600)."
          }
        },
        "additionalProperties": false
      },
      "IssueTokenResponse": {
        "type": "object",
        "required": [
          "token",
          "token_id",
          "expires_at"
        ],
        "properties": {
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "token": {
            "type": "string"
          },
          "token_id": {
            "type": "string",
            "format": "uuid",
            "description": "The token's `jti`; pass it to `POST /embed/tokens/{jti}/revoke`."
          }
        }
      },
      "Job": {
        "type": "object",
        "description": "Job representation returned by every `/jobs` endpoint.",
        "required": [
          "id",
          "instance_id",
          "handler",
          "status",
          "created_at",
          "run_at"
        ],
        "properties": {
          "attempts": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Executions started so far (0 before the first run).",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last error message when failed / dead-lettered (or while retrying)."
          },
          "handler": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Job id (identical to `instance_id`)."
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "description": "Backing instance id — usable with every `/instances/{id}` endpoint."
          },
          "output": {
            "description": "Handler output once completed."
          },
          "queue": {
            "type": [
              "string",
              "null"
            ]
          },
          "run_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the job is (or was first) due to run."
          },
          "status": {
            "$ref": "#/components/schemas/JobStatus"
          }
        }
      },
      "JobPage": {
        "type": "object",
        "description": "`GET /jobs` response page (keyset-paginated, newest first).",
        "required": [
          "items",
          "has_more"
        ],
        "properties": {
          "has_more": {
            "type": "boolean"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Job"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Opaque cursor for the next (older) page; absent on the last page."
          }
        }
      },
      "JobRetry": {
        "type": "object",
        "description": "Retry policy for a job.\n\n`max_attempts` counts **total** executions including the first one\n(BullMQ/Sidekiq semantics): `1` means \"never retry\", `3` means \"run at\nmost three times\". Backoff is exponential (x2) starting at\n`initial_backoff_ms`, capped at `max_backoff_ms` (default 60 000).",
        "required": [
          "max_attempts",
          "initial_backoff_ms"
        ],
        "properties": {
          "initial_backoff_ms": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "max_attempts": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "max_backoff_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "JobStatus": {
        "type": "string",
        "description": "Externally visible job status, derived from the instance state.",
        "enum": [
          "scheduled",
          "running",
          "completed",
          "failed",
          "cancelled",
          "dead_lettered"
        ]
      },
      "JoinMode": {
        "oneOf": [
          {
            "type": "object",
            "description": "Resume on the first matching event.",
            "required": [
              "mode"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "any"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Resume once every named event has arrived (in any order).",
            "required": [
              "mode"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "all"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Resume once `count` matching events arrived.",
            "required": [
              "count",
              "mode"
            ],
            "properties": {
              "count": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "mode": {
                "type": "string",
                "enum": [
                  "count"
                ]
              }
            }
          }
        ],
        "description": "Join policies for multi-event waits."
      },
      "LicenseInfo": {
        "type": "object",
        "description": "`GET /license` body.",
        "required": [
          "status",
          "features"
        ],
        "properties": {
          "edition": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "licensee": {
            "type": [
              "string",
              "null"
            ]
          },
          "max_sub_tenants": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "status": {
            "$ref": "#/components/schemas/LicenseStatus"
          }
        }
      },
      "LicenseStatus": {
        "type": "string",
        "enum": [
          "licensed",
          "unlicensed",
          "expired",
          "invalid"
        ]
      },
      "LlmNarrative": {
        "type": "object",
        "description": "Optional LLM narrative. The prompt contained only redacted evidence.",
        "required": [
          "provider",
          "model",
          "text"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        }
      },
      "LocalityPolicy": {
        "type": "object",
        "required": [
          "version"
        ],
        "properties": {
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LocalityRule"
            }
          },
          "version": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "LocalityRule": {
        "type": "object",
        "required": [
          "classification"
        ],
        "properties": {
          "allowed_connectivity": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RuntimeConnectivity"
            }
          },
          "allowed_regions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allowed_runtime_ids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RuntimeId"
            },
            "description": "An empty list means any runtime. A non-empty list supports policies such\nas \"PII stays on this device\" without embedding executable code."
          },
          "allowed_runtime_kinds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RuntimeKind"
            }
          },
          "classification": {
            "$ref": "#/components/schemas/DataClassification"
          },
          "maximum_cost_microunits": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "maximum_latency_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "minimum_battery_percent": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "minimum_trust": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuntimeTrustLevel"
              },
              {
                "type": "null"
              }
            ]
          },
          "require_hardware": {
            "type": [
              "string",
              "null"
            ]
          },
          "require_offline": {
            "type": [
              "boolean",
              "null"
            ]
          }
        }
      },
      "LoopDef": {
        "type": "object",
        "required": [
          "id",
          "condition",
          "body"
        ],
        "properties": {
          "body": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          },
          "break_on": {
            "type": [
              "string",
              "null"
            ]
          },
          "condition": {
            "type": "string"
          },
          "continue_on_error": {
            "type": "boolean"
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "max_iterations": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "poll_interval": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Seconds to wait between loop-condition polls.",
            "minimum": 0
          },
          "retain_iterations": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Keep only the most recent N iterations' body-step outputs; older outputs\nare compacted (deleted) at each iteration boundary to bound storage\ngrowth on long-running loops. `None` retains everything (default).",
            "minimum": 0
          }
        }
      },
      "MigrateInstanceRequest": {
        "type": "object",
        "description": "Hot migration: rebind a running instance to a different sequence version.\nThe instance will pick up the new version's block definitions on its next tick.\nOnly non-terminal instances can be migrated.",
        "required": [
          "instance_id",
          "target_sequence_id"
        ],
        "properties": {
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "description": "The instance to migrate."
          },
          "target_sequence_id": {
            "type": "string",
            "format": "uuid",
            "description": "The new sequence version to bind the instance to."
          }
        }
      },
      "Namespace": {
        "type": "string"
      },
      "NodeState": {
        "type": "string",
        "enum": [
          "pending",
          "running",
          "waiting",
          "completed",
          "failed",
          "cancelled",
          "skipped"
        ]
      },
      "NodeStatus": {
        "type": "string",
        "description": "Status of a cluster node.",
        "enum": [
          "active",
          "draining",
          "stopped"
        ]
      },
      "OverlapPolicy": {
        "type": "string",
        "description": "What to do when a schedule fires while a previous run it created is\nstill active (scheduled / running / waiting / paused).",
        "enum": [
          "allow",
          "skip",
          "buffer_one",
          "cancel_previous"
        ]
      },
      "ParallelDef": {
        "type": "object",
        "required": [
          "id",
          "branches"
        ],
        "properties": {
          "branches": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/BlockDefinition"
              }
            }
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          }
        }
      },
      "PatchContextDataRequest": {
        "type": "object",
        "required": [
          "patch"
        ],
        "properties": {
          "patch": {
            "type": "object",
            "description": "Shallow merge into context.data; omitted keys and all other sections remain unchanged.",
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            }
          },
          "remove_keys": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Remove these data keys before applying the patch; other sections remain intact."
          }
        },
        "additionalProperties": false
      },
      "PeerInboundPolicy": {
        "type": "object",
        "description": "What the peer may do here.",
        "properties": {
          "handlers": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "When set, an inbound start is refused unless every step handler of\nthe target sequence is in this list."
          },
          "returned_outputs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Block ids whose outputs are returned to the peer on completion. No\nother instance data (context, errors, logs) ever leaves."
          },
          "sequences": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Local sequence names the peer may start in this tenant."
          }
        }
      },
      "PeerOutboundPolicy": {
        "type": "object",
        "description": "What this engine may send to the peer.",
        "properties": {
          "disclosed_fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Top-level input fields allowed to leave. Everything else is withheld\n(only its SHA-256 is kept locally as evidence)."
          },
          "sequences": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Remote sequence names this tenant may start at the peer."
          }
        }
      },
      "PeerRelationship": {
        "type": "string",
        "description": "Trust relationship with a peer.",
        "enum": [
          "organization",
          "cluster"
        ]
      },
      "PeerRequest": {
        "type": "object",
        "description": "Create/replace body for a trust-registry entry.",
        "required": [
          "peer_id",
          "name",
          "endpoint",
          "public_key",
          "remote_tenant_id"
        ],
        "properties": {
          "endpoint": {
            "type": "string",
            "description": "HTTPS base URL of the peer's gateway."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "inbound": {
            "$ref": "#/components/schemas/PeerInboundPolicy"
          },
          "name": {
            "type": "string"
          },
          "outbound": {
            "$ref": "#/components/schemas/PeerOutboundPolicy"
          },
          "peer_id": {
            "$ref": "#/components/schemas/FederationPeerId",
            "description": "Peer federation identity from the peer's `GET /federation/identity`.\nMust match `public_key`."
          },
          "public_key": {
            "type": "string",
            "description": "Base64 raw 32-byte ed25519 public key of the peer."
          },
          "relationship": {
            "$ref": "#/components/schemas/PeerRelationship"
          },
          "remote_tenant_id": {
            "type": "string",
            "description": "Tenant at the peer this relationship binds to."
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "tenant_id": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Placement": {
        "type": "object",
        "description": "Step- or sequence-level `placement`.",
        "properties": {
          "affinity": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Affinity",
                "description": "`instance`: prefer the runtime that ran the previous worker step."
              },
              {
                "type": "null"
              }
            ]
          },
          "affinity_wait_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Bounded wait for `affinity` before any eligible runtime may claim.\nDefault 15000, maximum 600000.",
            "minimum": 0
          },
          "labels": {
            "type": "object",
            "description": "Every label must be advertised with exactly this value.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "priority_lane": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PriorityLane",
                "description": "Priority lane. Sequence-level (sets the instance priority at\ncreation); rejected on steps because priority is per instance."
              },
              {
                "type": "null"
              }
            ]
          },
          "region": {
            "type": [
              "string",
              "null"
            ],
            "description": "Only runtimes advertising this region may claim the step."
          },
          "residency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Data-residency zone: only runtimes advertising the label\n`residency=<zone>` may claim. Never relaxed; the step waits\n(`placement_unsatisfied`) instead."
          }
        }
      },
      "PlacementPolicies": {
        "type": "object",
        "description": "`GET|PUT /api/v1/placement/policies` body.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlacementPolicy"
            }
          }
        }
      },
      "PlacementPolicy": {
        "type": "object",
        "description": "One tenant placement policy.",
        "required": [
          "name"
        ],
        "properties": {
          "match": {
            "$ref": "#/components/schemas/PolicyMatch"
          },
          "name": {
            "type": "string"
          },
          "prefer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PolicyPreference"
              },
              {
                "type": "null"
              }
            ]
          },
          "require": {
            "$ref": "#/components/schemas/PolicyRequirement"
          }
        }
      },
      "PlacementPreference": {
        "type": "object",
        "description": "Soft preference window compiled into [`CapsuleRequirements::prefer`].\nUntil `until_ms` (unix epoch milliseconds) only a preferred claimant may\ntake the task; afterwards any claimant satisfying the hard requirements\nmay. A preference never widens eligibility.",
        "required": [
          "until_ms"
        ],
        "properties": {
          "labels": {
            "type": "object",
            "description": "Preferred labels (from tenant policies).",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "until_ms": {
            "type": "integer",
            "format": "int64"
          },
          "worker_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sticky affinity: the worker id (== runtime id for capability polls)\nthat ran the instance's previous worker step."
          }
        }
      },
      "PolicyMatch": {
        "type": "object",
        "description": "Selector of a tenant placement policy. Every present field must match;\nan empty selector matches every worker-dispatched step of the tenant.",
        "properties": {
          "handler": {
            "type": [
              "string",
              "null"
            ],
            "description": "Step handler name."
          },
          "sequence": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sequence name."
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "Instance tag: an entry of the instance's `metadata.tags` array."
          }
        }
      },
      "PolicyOutcome": {
        "type": "string",
        "enum": [
          "allow",
          "deny",
          "unknown"
        ]
      },
      "PolicyPreference": {
        "type": "object",
        "description": "Soft preference a matching policy adds: runtimes with these labels get\nthe task first for a bounded wait, then any eligible runtime may claim.",
        "properties": {
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          }
        }
      },
      "PolicyRequirement": {
        "type": "object",
        "description": "Hard constraints a matching policy adds.",
        "properties": {
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "region": {
            "type": [
              "string",
              "null"
            ]
          },
          "residency": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PollRequest": {
        "type": "object",
        "required": [
          "handler_name",
          "worker_id"
        ],
        "properties": {
          "capabilities": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuntimeCapabilities",
                "description": "Short-lived, fail-closed capability advertisement used for atomic\nhardware, region, browser/mobile UI, network, and trust matching."
              },
              {
                "type": "null"
              }
            ]
          },
          "handler_name": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "version": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional worker build/deploy version, recorded on the worker registry."
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "PollTasksResponse": {
        "type": "object",
        "required": [
          "tasks",
          "lease_secs",
          "heartbeat_interval_secs",
          "poll_after_ms"
        ],
        "properties": {
          "heartbeat_interval_secs": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "lease_secs": {
            "type": "integer",
            "format": "int64",
            "description": "Server-wide default lease; each task's own `lease_secs` wins.",
            "minimum": 0
          },
          "poll_after_ms": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClaimedWorkerTask"
            }
          }
        }
      },
      "PoolResource": {
        "type": "object",
        "description": "A single resource within a pool.",
        "required": [
          "id",
          "pool_id",
          "resource_key",
          "name",
          "created_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "daily_cap": {
            "type": "integer",
            "format": "int32",
            "description": "Maximum assignments per day (0 = unlimited).",
            "minimum": 0
          },
          "daily_usage": {
            "type": "integer",
            "format": "int32",
            "description": "Current daily usage count.",
            "minimum": 0
          },
          "daily_usage_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Date of the current daily usage counter."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether this resource is active and available for assignment."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "Display name for the resource."
          },
          "pool_id": {
            "type": "string",
            "format": "uuid"
          },
          "resource_key": {
            "$ref": "#/components/schemas/ResourceKey"
          },
          "warmup_days": {
            "type": "integer",
            "format": "int32",
            "description": "Number of days for the warmup ramp (0 = no warmup).",
            "minimum": 0
          },
          "warmup_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Date when this resource was added to the pool."
          },
          "warmup_start_cap": {
            "type": "integer",
            "format": "int32",
            "description": "Starting daily cap during warmup (ramps linearly to `daily_cap`).",
            "minimum": 0
          },
          "weight": {
            "type": "integer",
            "format": "int32",
            "description": "Weight for weighted rotation (higher = more assignments). Default 1.",
            "minimum": 0
          }
        }
      },
      "PortableWorkOffer": {
        "type": "object",
        "description": "Framework-neutral unit of work offered to capability-aware runtimes.",
        "required": [
          "id",
          "protocol",
          "tenant_id",
          "continuity_id",
          "expected_epoch",
          "handler",
          "input",
          "input_schema",
          "requirements",
          "classification",
          "idempotency_key",
          "receipt_required",
          "expires_at"
        ],
        "properties": {
          "classification": {
            "$ref": "#/components/schemas/DataClassification"
          },
          "continuity_id": {
            "$ref": "#/components/schemas/ContinuityId"
          },
          "expected_epoch": {
            "$ref": "#/components/schemas/ExecutionEpoch"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "handler": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "idempotency_key": {
            "type": "string"
          },
          "input": {},
          "input_schema": {},
          "policy": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LocalityPolicy"
              },
              {
                "type": "null"
              }
            ]
          },
          "protocol": {
            "$ref": "#/components/schemas/ProtocolVersion"
          },
          "receipt_required": {
            "type": "boolean"
          },
          "requirements": {
            "$ref": "#/components/schemas/CapsuleRequirements"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          }
        }
      },
      "PreflightCheck": {
        "type": "object",
        "description": "One named readiness check with its findings.",
        "required": [
          "id",
          "status",
          "summary"
        ],
        "properties": {
          "findings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Finding"
            },
            "description": "Detailed findings (empty for a clean pass)."
          },
          "id": {
            "type": "string",
            "description": "Stable check identifier, `snake_case`: `definition_valid`,\n`handlers_have_workers`, `credentials_present`, ..."
          },
          "status": {
            "$ref": "#/components/schemas/PreflightStatus"
          },
          "summary": {
            "type": "string",
            "description": "Human-readable one-liner of the result."
          }
        }
      },
      "PreflightReport": {
        "type": "object",
        "description": "The combined preflight report for one sequence.",
        "required": [
          "sequence_name",
          "sequence_version",
          "overall",
          "checks",
          "generated_at"
        ],
        "properties": {
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PreflightCheck"
            }
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "overall": {
            "$ref": "#/components/schemas/PreflightStatus",
            "description": "Worst status across all checks."
          },
          "sequence_name": {
            "type": "string"
          },
          "sequence_version": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "PreflightStatus": {
        "type": "string",
        "description": "Outcome of a single preflight check.\n\nOrdering is by increasing severity for aggregation: `Pass < Warning <\nUnknown < Fail`. `Unknown` outranks `Warning` because unproven\nreadiness is riskier than a known cosmetic issue.",
        "enum": [
          "pass",
          "warning",
          "unknown",
          "fail"
        ]
      },
      "Priority": {
        "type": "string",
        "enum": [
          "Low",
          "Normal",
          "High",
          "Critical"
        ]
      },
      "PriorityLane": {
        "type": "string",
        "description": "Plan/tenant priority lane. Lanes map onto the engine's existing instance\n[`Priority`], which drives claim order and cooperative preemption.",
        "enum": [
          "premium",
          "standard",
          "batch"
        ]
      },
      "ProfileContract": {
        "type": "object",
        "required": [
          "profile",
          "handler",
          "policy_source",
          "required_evidence",
          "forbidden_payload_classes",
          "requires_signed_receipt"
        ],
        "properties": {
          "forbidden_payload_classes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "handler": {
            "type": "string"
          },
          "policy_source": {
            "type": "string"
          },
          "profile": {
            "$ref": "#/components/schemas/TrustBoundaryProfile"
          },
          "required_evidence": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requires_signed_receipt": {
            "type": "boolean"
          }
        }
      },
      "ProfileOfferRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "continuity_id",
          "expected_epoch",
          "input",
          "idempotency_key"
        ],
        "properties": {
          "continuity_id": {
            "$ref": "#/components/schemas/ContinuityId"
          },
          "expected_epoch": {
            "$ref": "#/components/schemas/ExecutionEpoch"
          },
          "idempotency_key": {
            "type": "string"
          },
          "input": {},
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          }
        }
      },
      "ProgressShare": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "instance_id",
          "created_at",
          "expires_at"
        ],
        "properties": {
          "allowed_fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Top-level `context.data` keys the public view may include."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          }
        }
      },
      "PromoteRequest": {
        "type": "object",
        "properties": {
          "force": {
            "type": "boolean",
            "description": "Promote even when gates are inconclusive or failing."
          }
        }
      },
      "PromptCanary": {
        "type": "object",
        "description": "Canary split of a label between its stable version and a candidate.",
        "required": [
          "version",
          "percent"
        ],
        "properties": {
          "percent": {
            "type": "integer",
            "format": "int32",
            "description": "0–100. Selection is a deterministic hash of `(instance, block, name)`,\nthe same scheme `ab_split` uses, so one execution always sees one side.",
            "minimum": 0
          },
          "version": {
            "type": "integer",
            "format": "int32",
            "description": "Candidate version receiving `percent` of executions."
          }
        }
      },
      "PromptDetail": {
        "type": "object",
        "required": [
          "name",
          "versions",
          "labels"
        ],
        "properties": {
          "labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromptLabel"
            }
          },
          "name": {
            "type": "string"
          },
          "versions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromptTemplate"
            },
            "description": "Newest first."
          }
        }
      },
      "PromptLabel": {
        "type": "object",
        "description": "A movable alias (`production`, `canary`, …) onto an immutable version.",
        "required": [
          "tenant_id",
          "name",
          "label",
          "version",
          "updated_at"
        ],
        "properties": {
          "canary": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PromptCanary"
              },
              {
                "type": "null"
              }
            ]
          },
          "label": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "type": "integer",
            "format": "int32",
            "description": "Stable version the label points at."
          }
        }
      },
      "PromptMessage": {
        "type": "object",
        "description": "One templated chat message of a prompt version.",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "content": {
            "type": "string",
            "description": "Message text; `{{ variable }}` placeholders are rendered at dispatch."
          },
          "role": {
            "type": "string",
            "description": "Chat role (`system`, `user`, `assistant`)."
          }
        }
      },
      "PromptResolution": {
        "type": "object",
        "description": "Which version a step resolved, recorded in the step output and pinned per\n`(instance, block)` so retries and replays reuse the same version.",
        "required": [
          "name",
          "version",
          "variant",
          "content_hash"
        ],
        "properties": {
          "content_hash": {
            "type": "string"
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Label the version was resolved through, if any."
          },
          "name": {
            "type": "string"
          },
          "variant": {
            "type": "string",
            "description": "`stable` or `canary` when resolved through a label; `pinned` when an\nexplicit version was requested; `latest` otherwise."
          },
          "version": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "PromptSummary": {
        "type": "object",
        "description": "One prompt in the registry listing.",
        "required": [
          "name",
          "latest_version",
          "versions",
          "labels",
          "updated_at"
        ],
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromptLabel"
            }
          },
          "latest_version": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "versions": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "PromptTemplate": {
        "type": "object",
        "description": "An immutable, tenant-scoped prompt version.",
        "required": [
          "tenant_id",
          "name",
          "version",
          "content_hash",
          "created_at"
        ],
        "properties": {
          "content_hash": {
            "type": "string",
            "description": "SHA-256 over the canonical template content (not name/version), used\nto make `push` idempotent and to prove which content a step ran."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromptMessage"
            },
            "description": "Templated messages, sent before any `messages` the step itself adds."
          },
          "model_params": {
            "type": "object",
            "description": "Default model params (`provider`, `model`, `temperature`,\n`max_tokens`, …). Step params override them key by key."
          },
          "name": {
            "type": "string"
          },
          "response_schema": {
            "type": [
              "object",
              "null"
            ],
            "description": "Optional JSON Schema the response must satisfy (see `llm_call`\n`response_schema`). A step-level `response_schema` wins."
          },
          "system": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional system prompt (templated)."
          },
          "tenant_id": {
            "type": "string"
          },
          "variables": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Variable names referenced by the template (derived at push time)."
          },
          "version": {
            "type": "integer",
            "format": "int32",
            "description": "Monotonic per `(tenant_id, name)`, starting at 1. Never reused."
          }
        }
      },
      "ProtocolDescription": {
        "type": "object",
        "required": [
          "name",
          "version",
          "transports",
          "invariants"
        ],
        "properties": {
          "invariants": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "name": {
            "type": "string"
          },
          "transports": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "version": {
            "$ref": "#/components/schemas/ProtocolVersion"
          }
        }
      },
      "ProtocolVersion": {
        "type": "object",
        "required": [
          "major",
          "minor"
        ],
        "properties": {
          "major": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "minor": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "PruneCheckpointsRequest": {
        "type": "object",
        "required": [
          "keep"
        ],
        "properties": {
          "keep": {
            "type": "integer",
            "format": "int32",
            "description": "Number of most recent checkpoints to keep.",
            "minimum": 0
          }
        }
      },
      "PublicProgress": {
        "type": "object",
        "required": [
          "status",
          "completed",
          "total",
          "percent",
          "steps",
          "created_at",
          "updated_at",
          "link_expires_at"
        ],
        "properties": {
          "completed": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": [
              "object",
              "null"
            ],
            "description": "Only the share's allowlisted `context.data` keys; absent otherwise."
          },
          "link_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "percent": {
            "type": "integer",
            "format": "int32",
            "description": "0..=100.",
            "minimum": 0
          },
          "status": {
            "type": "string",
            "description": "Instance status: `scheduled` | `running` | `waiting` | `paused` | `completed` | `failed` | `cancelled`."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicStep"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicStep": {
        "type": "object",
        "required": [
          "label",
          "status"
        ],
        "properties": {
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "label": {
            "type": "string"
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "description": "`pending` | `running` | `waiting` | `completed` | `failed` | `skipped` | `cancelled`"
          }
        }
      },
      "PushPromptRequest": {
        "type": "object",
        "description": "Push body: the content of a new prompt version.",
        "required": [
          "name"
        ],
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optionally point this label at the pushed version in the same call."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromptMessage"
            }
          },
          "model_params": {
            "type": [
              "object",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "response_schema": {
            "type": [
              "object",
              "null"
            ]
          },
          "system": {
            "type": [
              "string",
              "null"
            ]
          },
          "tenant_id": {
            "type": "string",
            "description": "Tenant (ignored/must match when the caller is tenant-scoped)."
          }
        }
      },
      "PushPromptResponse": {
        "type": "object",
        "required": [
          "prompt",
          "created"
        ],
        "properties": {
          "created": {
            "type": "boolean",
            "description": "False when the content equals the latest version (returned as-is)."
          },
          "label": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PromptLabel"
              },
              {
                "type": "null"
              }
            ]
          },
          "prompt": {
            "$ref": "#/components/schemas/PromptTemplate"
          }
        }
      },
      "QueueDispatchConfig": {
        "type": "object",
        "required": [
          "tenant_id",
          "queue_name",
          "mode",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "mode": {
            "$ref": "#/components/schemas/DispatchMode"
          },
          "push_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Target URL for `push` mode (required when `mode = push`)."
          },
          "queue_name": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "QueuePollRequest": {
        "type": "object",
        "required": [
          "queue_name",
          "handler_name",
          "worker_id"
        ],
        "properties": {
          "capabilities": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuntimeCapabilities"
              },
              {
                "type": "null"
              }
            ]
          },
          "handler_name": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "queue_name": {
            "type": "string"
          },
          "version": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional worker build/deploy version, recorded on the worker registry."
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "QueueRoutingRule": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "handler_name",
          "queue_override",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "enabled": {
            "type": "boolean"
          },
          "handler_name": {
            "type": "string",
            "description": "The handler name this rule applies to."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "match_queue": {
            "type": [
              "string",
              "null"
            ],
            "description": "When set, the rule only applies if the task's currently-declared queue\nequals this value (queue remap). `None` matches any current queue."
          },
          "priority": {
            "type": "integer",
            "format": "int32",
            "description": "Higher priority rules are evaluated first; the first match wins."
          },
          "queue_override": {
            "type": "string",
            "description": "The queue the matching task is routed to instead."
          },
          "tenant_id": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RaceDef": {
        "type": "object",
        "required": [
          "id",
          "branches"
        ],
        "properties": {
          "branches": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/BlockDefinition"
              }
            }
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "semantics": {
            "$ref": "#/components/schemas/RaceSemantics"
          }
        }
      },
      "RaceSemantics": {
        "type": "string",
        "enum": [
          "first_to_resolve",
          "first_to_succeed"
        ]
      },
      "RateBudget": {
        "type": "object",
        "description": "A durable token bucket per `(tenant, key)`. Steps declaring\n`\"rate_budget\": \"<key>\"` take one token before dispatch; with no token\nthe instance is deferred (never failed) until one refills.",
        "required": [
          "tenant_id",
          "key",
          "capacity",
          "refill_per_sec",
          "tokens",
          "updated_at"
        ],
        "properties": {
          "capacity": {
            "type": "integer",
            "format": "int32",
            "description": "Bucket size (maximum burst).",
            "minimum": 0
          },
          "key": {
            "type": "string"
          },
          "refill_per_sec": {
            "type": "number",
            "format": "double",
            "description": "Tokens added per second."
          },
          "tenant_id": {
            "type": "string"
          },
          "tokens": {
            "type": "number",
            "format": "double",
            "description": "Tokens currently available (as of `updated_at`)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RateBudgetList": {
        "type": "object",
        "description": "`GET /rate-budgets` response.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RateBudget"
            }
          }
        }
      },
      "RateBudgetRequest": {
        "type": "object",
        "description": "`PUT /rate-budgets/{key}` body.",
        "required": [
          "capacity",
          "refill_per_sec"
        ],
        "properties": {
          "capacity": {
            "type": "integer",
            "format": "int32",
            "description": "Bucket size: the maximum burst.",
            "minimum": 0
          },
          "refill_per_sec": {
            "type": "number",
            "format": "double",
            "description": "Tokens refilled per second (e.g. `25` for 25 req/s, `0.5` for 30/min)."
          }
        }
      },
      "RedeliverPreview": {
        "type": "object",
        "description": "What a redelivery *would* send, without sending it. Secrets never\nappear: the signature is described, not exposed.",
        "required": [
          "url",
          "event_type",
          "payload_bytes",
          "will_be_signed",
          "previous_attempts"
        ],
        "properties": {
          "event_type": {
            "type": "string"
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "The last error seen before parking."
          },
          "payload_bytes": {
            "type": "integer",
            "description": "Serialized payload size in bytes.",
            "minimum": 0
          },
          "previous_attempts": {
            "type": "integer",
            "format": "int32",
            "description": "How many attempts were made before parking."
          },
          "previous_delivery_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Attempt history of the pass that parked this entry, if linked."
          },
          "url": {
            "type": "string"
          },
          "will_be_signed": {
            "type": "boolean",
            "description": "Whether the request will carry `X-Orch8-Timestamp` /\n`X-Orch8-Signature` HMAC headers."
          }
        }
      },
      "RedeliverResponse": {
        "type": "object",
        "required": [
          "redelivered"
        ],
        "properties": {
          "delivery_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The new attempt group recorded for this redelivery pass — inspect\nit via `GET /webhooks/deliveries/{delivery_id}`."
          },
          "redelivered": {
            "type": "boolean",
            "description": "Whether the redelivery succeeded (and the outbox row was removed)."
          }
        }
      },
      "RelayDeployment": {
        "type": "string",
        "enum": [
          "hosted",
          "private_cloud",
          "oem_embedded"
        ]
      },
      "ReleaseDecision": {
        "type": "object",
        "description": "Immutable audit record of one state transition (or attempted one).",
        "required": [
          "id",
          "release_id",
          "from_state",
          "to_state",
          "actor",
          "reason",
          "decided_at"
        ],
        "properties": {
          "actor": {
            "type": "string",
            "description": "Who/what decided: `operator`, `gate:error_rate`, `validation`."
          },
          "decided_at": {
            "type": "string",
            "format": "date-time"
          },
          "from_state": {
            "$ref": "#/components/schemas/ReleaseState"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": "string",
            "description": "Human-readable justification."
          },
          "release_id": {
            "type": "string",
            "format": "uuid"
          },
          "to_state": {
            "$ref": "#/components/schemas/ReleaseState"
          }
        }
      },
      "ReleaseGate": {
        "type": "object",
        "description": "One release gate: the candidate may regress at most\n`max_regression` (absolute difference, e.g. `0.05` = five\npercentage points) versus the baseline, evaluated only once both\nvariants have at least `min_sample` terminal observations.",
        "required": [
          "metric",
          "max_regression",
          "min_sample"
        ],
        "properties": {
          "max_regression": {
            "type": "number",
            "format": "double",
            "description": "Maximum allowed absolute regression of the candidate vs. the\nbaseline (candidate − baseline)."
          },
          "metric": {
            "$ref": "#/components/schemas/GateMetric"
          },
          "min_sample": {
            "type": "integer",
            "format": "int32",
            "description": "Minimum terminal instances per variant before the gate is\nconclusive.",
            "minimum": 0
          }
        }
      },
      "ReleaseRequest": {
        "type": "object",
        "required": [
          "worker_id",
          "claim_epoch"
        ],
        "properties": {
          "claim_epoch": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "started": {
            "type": "boolean",
            "description": "Whether the handler already started. `false`: the task goes straight\nback to `pending` and its effect receipt is untouched. `true`: treated\nlike a lease expiry after start (a side-effecting step's receipt\nbecomes `unknown` and the step's retry policy decides)."
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "ReleaseState": {
        "type": "string",
        "description": "Release lifecycle states.",
        "enum": [
          "draft",
          "validating",
          "ready",
          "canary",
          "promoted",
          "paused",
          "rolled_back",
          "failed"
        ]
      },
      "ReleaseTarget": {
        "type": "object",
        "description": "Sub-tenant staged-rollout target of a release.\n\nPersisted, so unknown fields are tolerated on read (binary rollback);\nthe API decodes request bodies with [`crate::strict`] instead.",
        "properties": {
          "percentage": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Percentage (0–100) of the remaining sub-tenants that receive the\ncandidate, bucketed by a stable hash of the sub-tenant id.",
            "minimum": 0
          },
          "sub_tenants": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Sub-tenants that always receive the candidate."
          }
        }
      },
      "Remediation": {
        "type": "object",
        "description": "A suggested, separately authorized action. Describing a remediation\nnever performs it.",
        "required": [
          "summary"
        ],
        "properties": {
          "action": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RemediationAction",
                "description": "Machine-applicable classification of the action, when the producer\nknows it. Consumers must use this typed field instead of parsing\n`command` strings; `None` means the action is manual."
              },
              {
                "type": "null"
              }
            ]
          },
          "command": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional CLI command the operator can run verbatim."
          },
          "link": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional API route or dashboard path for the action."
          },
          "side_effect_risk": {
            "type": "boolean",
            "description": "True when performing this action may repeat external side effects\n(re-running a block, redelivering a webhook). UIs must require\nexplicit confirmation for these."
          },
          "summary": {
            "type": "string",
            "description": "Human-readable description of the action."
          }
        }
      },
      "RemediationAction": {
        "type": "string",
        "description": "Machine-applicable subset of a human remediation suggestion.",
        "enum": [
          "resume_instance",
          "retry_instance",
          "manual"
        ]
      },
      "RemediationApplyEvidence": {
        "type": "object",
        "required": [
          "preview_id",
          "action",
          "before_state",
          "after_state",
          "applied_at"
        ],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/RemediationAction"
          },
          "after_state": {
            "type": "string"
          },
          "applied_at": {
            "type": "string",
            "format": "date-time"
          },
          "before_state": {
            "type": "string"
          },
          "preview_id": {
            "type": "string"
          }
        }
      },
      "RemediationPreview": {
        "type": "object",
        "description": "Stable preview generated from the current diagnosis and instance state.",
        "required": [
          "preview_id",
          "finding_code",
          "remediation_index",
          "action",
          "summary",
          "side_effect_risk",
          "expected_state"
        ],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/RemediationAction"
          },
          "command": {
            "type": [
              "string",
              "null"
            ]
          },
          "expected_state": {
            "type": "string"
          },
          "finding_code": {
            "type": "string"
          },
          "preview_id": {
            "type": "string"
          },
          "remediation_index": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "side_effect_risk": {
            "type": "boolean"
          },
          "summary": {
            "type": "string"
          }
        }
      },
      "ResolutionEntry": {
        "type": "object",
        "description": "One template expression's resolution provenance.",
        "required": [
          "param_path",
          "expression",
          "status"
        ],
        "properties": {
          "coerced_to_string": {
            "type": "boolean",
            "description": "True when a non-string value was coerced into a string because the\nexpression sits inside a larger interpolated string."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "The evaluation error, when `status == error`."
          },
          "expression": {
            "type": "string",
            "description": "The original template expression (inner text of `{{ ... }}`)."
          },
          "fallback_used": {
            "type": "boolean",
            "description": "True when the value came from a fallback segment, not the first."
          },
          "param_path": {
            "type": "string",
            "description": "Dotted location of the parameter inside the block's `params`\n(e.g. `body.email`, `headers.0.value`)."
          },
          "result_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "JSON type of the resolved value (`string`, `number`, ...)."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "The fallback-chain segment that supplied the value (a source path\nlike `context.data.email`, or `literal` for a quoted default)."
          },
          "status": {
            "$ref": "#/components/schemas/ResolutionStatus"
          },
          "value": {
            "description": "The resolved value, redacted. Absent for `missing` / `error`."
          }
        }
      },
      "ResolutionStatus": {
        "type": "string",
        "description": "Outcome of resolving one template expression.",
        "enum": [
          "ok",
          "null",
          "missing",
          "redacted",
          "error"
        ]
      },
      "ResolutionTrace": {
        "type": "object",
        "description": "The full trace for one block's parameters.",
        "required": [
          "block_id",
          "entries"
        ],
        "properties": {
          "block_id": {
            "type": "string"
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResolutionEntry"
            },
            "description": "One entry per template expression found in the params."
          },
          "resolved_params": {
            "description": "The block's params with every template resolved, redacted. `None`\nwhen whole-params resolution failed (see `entries` for the error)."
          }
        }
      },
      "ResolveApprovalRequest": {
        "type": "object",
        "required": [
          "choice"
        ],
        "properties": {
          "choice": {
            "type": "string",
            "description": "One of the approval's `choices[].value`."
          },
          "comment": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "ResourceKey": {
        "type": "string",
        "description": "Resource key for rate limiting, e.g. \"mailbox:john@acme.com\""
      },
      "ResourcePool": {
        "type": "object",
        "description": "A pool of resources that can be assigned to instances.",
        "required": [
          "id",
          "tenant_id",
          "name",
          "strategy",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "round_robin_index": {
            "type": "integer",
            "format": "int32",
            "description": "Tracks the next index for round-robin rotation.",
            "minimum": 0
          },
          "strategy": {
            "$ref": "#/components/schemas/RotationStrategy"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ResourceRef": {
        "type": "object",
        "description": "A reference to the resource a finding is about, precise enough for the\ndashboard/CLI to deep-link to it.",
        "required": [
          "kind",
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The resource identifier (UUID or name, whichever is canonical for\nthe kind)."
          },
          "kind": {
            "type": "string",
            "description": "Resource kind, e.g. `sequence`, `instance`, `block`, `worker`,\n`credential`, `queue`, `plugin`, `webhook_endpoint`, `release`."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional human-readable name when the id alone is opaque."
          }
        }
      },
      "ResumeFromRequest": {
        "type": "object",
        "description": "Body for `POST /instances/{id}/resume-from/{block_id}`. The whole body is\noptional; when present, `context` must be a JSON object whose top-level\nkeys are shallow-merged into `context.data` (same per-key semantics as\n`StorageBackend::merge_context_data`) before the instance is re-scheduled.\n`signals` are enqueued before the wake transition — they are pending by\nthe time the instance can run again.",
        "properties": {
          "context": {},
          "signals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InjectedSignal"
            }
          }
        }
      },
      "RetargetTriggerRequest": {
        "type": "object",
        "required": [
          "sequence_id",
          "expected_updated_at"
        ],
        "properties": {
          "expected_updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          }
        },
        "additionalProperties": false
      },
      "RetryPolicy": {
        "type": "object",
        "required": [
          "max_attempts"
        ],
        "properties": {
          "backoff_multiplier": {
            "type": "number",
            "format": "double"
          },
          "initial_backoff": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "max_attempts": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "max_backoff": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "non_retryable_codes": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "retry_if": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RotationStrategy": {
        "type": "string",
        "description": "Rotation strategy for assigning resources from a pool.",
        "enum": [
          "round_robin",
          "weighted",
          "random"
        ]
      },
      "Route": {
        "type": "object",
        "required": [
          "condition",
          "blocks"
        ],
        "properties": {
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          },
          "condition": {
            "type": "string"
          }
        }
      },
      "RouterDef": {
        "type": "object",
        "required": [
          "id",
          "routes"
        ],
        "properties": {
          "default": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "routes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Route"
            }
          }
        }
      },
      "RunComparison": {
        "type": "object",
        "required": [
          "left",
          "right",
          "left_state",
          "right_state",
          "only_left",
          "only_right",
          "differing_outputs",
          "matching_blocks"
        ],
        "properties": {
          "differing_outputs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Common blocks whose (last-attempt) outputs differ."
          },
          "left": {
            "type": "string",
            "format": "uuid"
          },
          "left_state": {
            "type": "string"
          },
          "matching_blocks": {
            "type": "integer",
            "format": "int32",
            "description": "Common blocks with identical outputs.",
            "minimum": 0
          },
          "only_left": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blocks executed only by the left run, in execution order."
          },
          "only_right": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blocks executed only by the right run, in execution order."
          },
          "right": {
            "type": "string",
            "format": "uuid"
          },
          "right_state": {
            "type": "string"
          }
        }
      },
      "RuntimeCapabilities": {
        "type": "object",
        "description": "Bounded facts used by compatibility and placement decisions.",
        "required": [
          "runtime_id",
          "kind",
          "trust",
          "observed_at",
          "expires_at"
        ],
        "properties": {
          "battery_percent": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "capsule_signing_public_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Base64 Ed25519 key authorized to sign capsules emitted by this runtime."
          },
          "connectivity": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuntimeConnectivity",
                "description": "Current connectivity is deliberately distinct from offline capability:\na device may support offline execution while presently using Wi-Fi."
              },
              {
                "type": "null"
              }
            ]
          },
          "credentials": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tenant-local credential references available to this runtime. Values\nidentify configured bindings, never secret material."
          },
          "draining": {
            "type": "boolean",
            "description": "Draining runtimes remain discoverable for evidence but cannot receive\nnew work."
          },
          "estimated_cost_microunits": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "estimated_latency_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "hardware": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "kind": {
            "$ref": "#/components/schemas/RuntimeKind"
          },
          "labels": {
            "type": "object",
            "description": "Free-form capability labels (`gpu=a100`, `residency=eu`, ...) matched\nby step `placement.labels`, `placement.residency`, and tenant\nplacement policies. Bounded to 32 entries.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "observed_at": {
            "type": "string",
            "format": "date-time"
          },
          "offline_capable": {
            "type": "boolean"
          },
          "plugins": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "runtime_id": {
            "$ref": "#/components/schemas/RuntimeId"
          },
          "trust": {
            "$ref": "#/components/schemas/RuntimeTrustLevel"
          }
        }
      },
      "RuntimeConnectivity": {
        "type": "string",
        "description": "Current network path reported by a runtime for bounded locality decisions.",
        "enum": [
          "offline",
          "metered",
          "wifi",
          "ethernet"
        ]
      },
      "RuntimeContext": {
        "type": "object",
        "properties": {
          "attempt": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "current_step": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BlockId"
              },
              {
                "type": "null"
              }
            ]
          },
          "current_step_started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the current step began executing. Used as the baseline for\nper-step SLA deadlines and `wait_for_input` timeouts so earlier\nsteps do not eat into the timeout budget of later ones."
          },
          "dry_run": {
            "type": "boolean",
            "description": "Dry-run mode. When `true`, side-effecting step handlers (`tool_call`,\n`llm`, `mcp`, `agent`, `emit_event`, `send_signal`, `memory`,\n`self_modify`, external plugins) skip their real effect and return a\nstub output tagged `\"dry_run\": true`; control flow, templating and\nbranching still execute normally. Set once at instance creation and\npropagated to child instances (e.g. sub-sequences). Engine-managed and\nread-only to handlers — read it via `StepContext::is_dry_run`."
          },
          "dry_run_auto_approve": {
            "type": "boolean",
            "description": "When dry-run is active, auto-resolve `human_review` / `wait_for_input`\ngates with the default (first) choice instead of pausing, so the\nsimulation flows through human gates and exercises post-gate steps.\nIgnored outside dry-run. Engine-managed."
          },
          "instance_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "resource_key": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ResourceKey"
              },
              {
                "type": "null"
              }
            ]
          },
          "run_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Identifies one *run* of the instance (string UUID v7). Stamped on the\nfirst execution and regenerated by retry / resume-from-block /\nDLQ-retry — which also reset `total_steps_executed`, `current_step`\nand `started_at` — so a resurrected instance's webhooks are\ndistinguishable from the previous run's and the step counter does not\nphantom-re-fail against `max_steps_per_instance`."
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "total_steps_executed": {
            "type": "integer",
            "format": "int32",
            "description": "Total number of step executions for this instance (including retries).\nUsed by mobile SDK to enforce `max_steps_per_instance`.",
            "minimum": 0
          },
          "traceparent": {
            "type": [
              "string",
              "null"
            ],
            "description": "W3C `traceparent` of the dispatching engine span, set only on the\nper-step context handed to external workers so their spans join the\ncontrol-plane trace (see `docs/PLACEMENT.md#tracing`). Never persisted\non the instance."
          }
        }
      },
      "RuntimeId": {
        "type": "string",
        "format": "uuid"
      },
      "RuntimeKind": {
        "type": "string",
        "description": "Physical class of a runtime eligible to own or execute work.",
        "enum": [
          "server",
          "edge",
          "mobile",
          "desktop",
          "browser"
        ]
      },
      "RuntimeTrustLevel": {
        "type": "string",
        "description": "How strongly a runtime's identity and environment are verified.",
        "enum": [
          "unverified",
          "registered",
          "signed",
          "attested"
        ]
      },
      "SagaDef": {
        "type": "object",
        "description": "A saga: a sequence of steps that each carry an optional compensating\naction. If any step's action fails, the compensations for every\nalready-completed step run in reverse order (LIFO) — the classic saga\npattern for distributed transactions without two-phase commit.\n\nCompensation failures are recorded but do not stop the rollback: every\ncompleted step's compensation gets a chance to run, best-effort. The\nsaga node itself always fails once compensation finishes (whether or\nnot every compensation succeeded) — the original action failure is\nnever silently absorbed.",
        "required": [
          "id",
          "steps"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SagaStep"
            }
          }
        }
      },
      "SagaStep": {
        "type": "object",
        "required": [
          "id",
          "action"
        ],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/BlockDefinition",
            "description": "The forward action for this saga step."
          },
          "compensation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BlockDefinition",
                "description": "Compensating action run (in reverse order across all completed\nsteps) if a later step's action fails. `None` means this step has\nno compensation — it is skipped during rollback."
              },
              {
                "type": "null"
              }
            ]
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          }
        }
      },
      "SaveCheckpointRequest": {
        "type": "object",
        "required": [
          "checkpoint_data"
        ],
        "properties": {
          "checkpoint_data": {}
        }
      },
      "SemanticDiff": {
        "type": "object",
        "description": "The full semantic-diff report.",
        "required": [
          "entries"
        ],
        "properties": {
          "candidate_lint": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Lint findings on the candidate, included so the release report is\none artifact."
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DiffEntry"
            }
          },
          "max_severity": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DiffSeverity",
                "description": "Worst severity present (absent for an empty diff)."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "SendSignalRequest": {
        "type": "object",
        "required": [
          "signal_type"
        ],
        "properties": {
          "payload": {},
          "signal_type": {
            "$ref": "#/components/schemas/SignalType"
          }
        }
      },
      "SendWindow": {
        "type": "object",
        "description": "Time window during which a step is allowed to execute.\nHours are in 24h format relative to the instance's timezone.",
        "properties": {
          "days": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Days of week allowed (0=Mon .. 6=Sun). Empty means all days."
          },
          "end_hour": {
            "type": "integer",
            "format": "int32",
            "description": "End hour (0-23, exclusive). Defaults to 17.",
            "minimum": 0
          },
          "start_hour": {
            "type": "integer",
            "format": "int32",
            "description": "Start hour (0-23). Defaults to 9.",
            "minimum": 0
          }
        }
      },
      "SequenceDefinition": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "namespace",
          "name",
          "version",
          "blocks",
          "created_at"
        ],
        "properties": {
          "$schema": {
            "type": [
              "string",
              "null"
            ],
            "description": "Editor-facing JSON Schema link. It is metadata and does not affect execution."
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "deprecated": {
            "type": "boolean",
            "description": "If true, this version is deprecated. New instances should use a newer version.\nRunning instances bound to this version continue unaffected."
          },
          "embed": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SequenceEmbed",
                "description": "Embedding opt-ins (which step outputs embedded viewers may see)."
              },
              {
                "type": "null"
              }
            ]
          },
          "id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "input_schema": {
            "description": "Optional JSON Schema validated against `context.data` at instance\ncreate. When present, a create whose data fails validation is\nrejected (HTTP 422) before the instance is persisted. Doubles as the\ncontract the dashboard renders an input form from."
          },
          "interceptors": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InterceptorDef",
                "description": "Lifecycle interceptors (before/after step, on-signal, on-complete, on-failure)."
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "namespace": {
            "$ref": "#/components/schemas/Namespace"
          },
          "on_cancel": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            },
            "description": "Best-effort cleanup blocks run when the instance reaches terminal\n`Cancelled`. Same semantics as `on_failure`."
          },
          "on_failure": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            },
            "description": "Best-effort cleanup blocks run when the instance reaches terminal\n`Failed`. Each top-level step block is dispatched once; errors are\nswallowed (the instance is already failing). Use to release resources,\nsend a death notification, etc. — so a failed run doesn't \"just die\"."
          },
          "placement": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Placement",
                "description": "Sequence-level placement default (region, labels, residency,\naffinity, priority lane) applied to every worker-dispatched step;\nsee `docs/PLACEMENT.md`."
              },
              {
                "type": "null"
              }
            ]
          },
          "schema_version": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "sla": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SlaPolicy",
                "description": "Alert-only SLA policy. When set, an instance exceeding `max_runtime`\n(or a step exceeding `max_step_runtime`) emits an `instance.sla_breached`\nwebhook and increments `orch8_sla_breached_total` — the instance is NOT\nfailed or paused."
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "$ref": "#/components/schemas/SequenceStatus"
          },
          "sub_tenant": {
            "type": [
              "string",
              "null"
            ],
            "description": "Owning sub-tenant (embedded builder); `None` = tenant-level."
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "version": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "SequenceEmbed": {
        "type": "object",
        "description": "Per-sequence embedding settings. Nothing from a run's context or outputs\nis shown to embedded (end-customer) viewers unless the sequence lists the\nstep in `visible_outputs`.",
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display description."
          },
          "gallery": {
            "type": "boolean",
            "description": "Gallery template (tenant-level, namespace `embed-gallery`): listed\nto every sub-tenant, read-only, copyable by the embedded builder."
          },
          "template": {
            "description": "Gallery template descriptor (opaque to the engine)."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display title."
          },
          "visible_outputs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Step ids whose outputs embedded viewers may see."
          }
        }
      },
      "SequenceId": {
        "type": "string",
        "format": "uuid"
      },
      "SequenceStatus": {
        "type": "string",
        "description": "Lifecycle status for sequences: Draft → Staging → Production → Unpublished.",
        "enum": [
          "draft",
          "staging",
          "production",
          "unpublished"
        ]
      },
      "Session": {
        "type": "object",
        "description": "A session groups related instances and holds shared data across them.",
        "required": [
          "id",
          "tenant_id",
          "session_key",
          "state",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "Session-scoped shared data accessible by all instances in this session."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Optional TTL — session expires after this time."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "session_key": {
            "type": "string",
            "description": "Human-readable session key (e.g., \"user:123:onboarding\")."
          },
          "state": {
            "$ref": "#/components/schemas/SessionState"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SessionState": {
        "type": "string",
        "enum": [
          "active",
          "paused",
          "completed",
          "expired"
        ]
      },
      "SetDispatchRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "queue_name",
          "mode"
        ],
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/DispatchMode"
          },
          "push_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "queue_name": {
            "type": "string"
          },
          "secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional HMAC secret for signing pushed envelopes.\nOmission keeps the existing secret; explicit null clears it."
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "SetLabelRequest": {
        "type": "object",
        "required": [
          "version"
        ],
        "properties": {
          "canary_percent": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Percent (0–100) of executions routed to `canary_version`.",
            "minimum": 0
          },
          "canary_version": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Optional canary candidate version."
          },
          "tenant_id": {
            "type": "string"
          },
          "version": {
            "type": "integer",
            "format": "int32",
            "description": "Stable version the label points at."
          }
        }
      },
      "SetVersionPinRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "handler_name",
          "min_version"
        ],
        "properties": {
          "handler_name": {
            "type": "string"
          },
          "min_version": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          }
        }
      },
      "Signal": {
        "type": "object",
        "required": [
          "id",
          "instance_id",
          "signal_type",
          "payload",
          "delivered",
          "created_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "delivered": {
            "type": "boolean"
          },
          "delivered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "payload": {},
          "signal_type": {
            "$ref": "#/components/schemas/SignalType"
          }
        }
      },
      "SignalType": {
        "oneOf": [
          {
            "type": "string",
            "enum": [
              "pause"
            ]
          },
          {
            "type": "string",
            "enum": [
              "resume"
            ]
          },
          {
            "type": "string",
            "enum": [
              "cancel"
            ]
          },
          {
            "type": "string",
            "enum": [
              "update_context"
            ]
          },
          {
            "type": "object",
            "required": [
              "custom"
            ],
            "properties": {
              "custom": {
                "type": "string"
              }
            }
          }
        ]
      },
      "SignedFederationMessage": {
        "type": "object",
        "description": "HTTP body in both directions: an envelope plus the exact payload bytes.",
        "required": [
          "envelope",
          "payload_base64"
        ],
        "properties": {
          "envelope": {
            "$ref": "#/components/schemas/FederationEnvelope"
          },
          "payload_base64": {
            "type": "string"
          }
        }
      },
      "SigningKeyResponse": {
        "type": "object",
        "required": [
          "signing_key_id",
          "algorithm",
          "public_key"
        ],
        "properties": {
          "algorithm": {
            "type": "string",
            "description": "Always `ed25519`."
          },
          "public_key": {
            "type": "string",
            "description": "Base64 of the raw 32-byte Ed25519 public key. Pin it when verifying."
          },
          "signing_key_id": {
            "type": "string",
            "description": "Stable identifier of the engine's continuity signing key."
          }
        }
      },
      "SlaPolicy": {
        "type": "object",
        "description": "Alert-only service-level-agreement policy for a sequence. A breach is a\nsignal, not a state change: it fires one webhook + metric per breach kind\nand leaves the instance running. Both bounds are optional.",
        "properties": {
          "max_runtime": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum wall-clock lifetime of an instance, measured from `created_at`.\nOne `max_runtime` alert per instance.",
            "minimum": 0
          },
          "max_step_runtime": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Maximum wall-clock time the current step may stay running/waiting,\nmeasured from when it started. One alert per breaching step.",
            "minimum": 0
          }
        }
      },
      "StartRunRequest": {
        "type": "object",
        "required": [
          "sequence"
        ],
        "properties": {
          "idempotency_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional dedupe key (scoped to the tenant)."
          },
          "input": {
            "description": "Becomes the run's `context.data`."
          },
          "namespace": {
            "type": [
              "string",
              "null"
            ],
            "description": "Defaults to `default`."
          },
          "sequence": {
            "type": "string",
            "description": "Sequence name (latest version in `namespace`)."
          }
        },
        "additionalProperties": false
      },
      "StepCompensation": {
        "type": "object",
        "required": [
          "handler"
        ],
        "properties": {
          "depends_on": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockId"
            },
            "description": "Effect blocks that must be compensated after this block. The planner\nreverses these forward dependencies deterministically."
          },
          "handler": {
            "type": "string"
          },
          "params": {},
          "verification": {
            "$ref": "#/components/schemas/CompensationVerificationPolicy"
          }
        }
      },
      "StepDef": {
        "type": "object",
        "required": [
          "id",
          "handler"
        ],
        "properties": {
          "cache_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "If set, cache step output under this key in the instance KV state.\nOn subsequent executions, if a cached value exists for the resolved key,\nthe handler is skipped and the cached value is returned directly.\nThe key is template-resolved before lookup (e.g. `\"rate_{{ data.currency }}\"`)."
          },
          "cancellable": {
            "type": "boolean",
            "description": "If false, this step will not be cancelled when the instance receives a cancel signal.\nUsed for cleanup/finalization steps that must complete."
          },
          "compensation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StepCompensation",
                "description": "Receipt-backed recovery action for this externally visible step."
              },
              {
                "type": "null"
              }
            ]
          },
          "context_access": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ContextAccess",
                "description": "Restrict which context sections this step can access. If omitted, all sections visible."
              },
              {
                "type": "null"
              }
            ]
          },
          "deadline": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "SLA deadline: maximum wall-clock time from when this step starts running.\nIf breached, the escalation handler is invoked and the step is failed.",
            "minimum": 0
          },
          "delay": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DelaySpec"
              },
              {
                "type": "null"
              }
            ]
          },
          "fallback_handler": {
            "type": [
              "string",
              "null"
            ],
            "description": "Fallback handler to invoke when the primary handler's circuit breaker\nis `Open`. When set, step dispatch re-targets to this handler instead\nof deferring the instance for the cooldown window; when unset, the\nlegacy behaviour applies (defer to `now + remaining_cooldown_secs`).\nUses the same params + context as the primary handler; its own\nfailures are tracked under its own breaker key."
          },
          "handler": {
            "type": "string"
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "on_deadline_breach": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EscalationDef",
                "description": "Handler to invoke when the SLA deadline is breached.\nIf omitted but deadline is set, the step simply fails on breach."
              },
              {
                "type": "null"
              }
            ]
          },
          "output_schema": {
            "description": "Optional JSON Schema that the handler output must conform to.\nValidated after handler returns; schema violation is a permanent failure."
          },
          "params": {},
          "placement": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Placement",
                "description": "Step placement (region, labels, residency, affinity). Hard facts\nroute the step to the worker queue; see `docs/PLACEMENT.md`."
              },
              {
                "type": "null"
              }
            ]
          },
          "queue_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Named task queue for routing to dedicated worker pools.\nIf omitted, uses the default queue."
          },
          "rate_budget": {
            "type": [
              "string",
              "null"
            ],
            "description": "Global rate budget key (durable token bucket shared by every node,\nconfigured via `PUT /rate-budgets/{key}`). Over budget, the instance\nis deferred until a token refills — never failed."
          },
          "rate_limit_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "If set, this step consumes a rate limit token for the given resource key."
          },
          "retry": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RetryPolicy"
              },
              {
                "type": "null"
              }
            ]
          },
          "send_window": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SendWindow",
                "description": "If set, only execute during the specified time window (per instance timezone)."
              },
              {
                "type": "null"
              }
            ]
          },
          "timeout": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "wait_for_input": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/HumanInputDef",
                "description": "If set, this step pauses execution and waits for human input via a signal.\nThe signal name is `human_input:{block_id}`. Contains optional timeout."
              },
              {
                "type": "null"
              }
            ]
          },
          "when": {
            "type": [
              "string",
              "null"
            ],
            "description": "Conditional guard expression. When set, the step is only executed if the\nexpression evaluates to a truthy value; otherwise the step is skipped\n(marked `NodeState::Skipped`). Uses the same expression syntax as router\nconditions — `data.*`, `outputs.*`, comparisons, boolean ops."
          }
        }
      },
      "StepLog": {
        "type": "object",
        "description": "A stored step log line, annotated with the block it belongs to.",
        "required": [
          "block_id",
          "ts",
          "level",
          "message"
        ],
        "properties": {
          "block_id": {
            "type": "string"
          },
          "level": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "ts": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StepLogEntry": {
        "type": "object",
        "description": "One log line captured during (or reported for) a step's execution.",
        "required": [
          "ts",
          "level",
          "message"
        ],
        "properties": {
          "level": {
            "type": "string",
            "description": "`trace` | `debug` | `info` | `warn` | `error`."
          },
          "message": {
            "type": "string"
          },
          "ts": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SubSequenceDef": {
        "type": "object",
        "description": "Invoke another sequence as a child workflow.\nThe child instance is created and linked; the parent waits for completion.",
        "required": [
          "id",
          "sequence_name"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "input": {
            "description": "Input data to pass as the child instance's initial context data."
          },
          "sequence_name": {
            "type": "string",
            "description": "Name of the sequence to invoke (resolved by tenant + namespace + name)."
          },
          "version": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Optional specific version. If omitted, uses the latest non-deprecated version."
          }
        }
      },
      "SubTenantLimits": {
        "type": "object",
        "description": "Per-sub-tenant caps. `None` = uncapped (the tenant pool still applies).\n\nPersisted, so unknown fields are tolerated on read (binary rollback);\nthe API decodes request bodies with [`crate::strict`] instead.",
        "properties": {
          "max_concurrent": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Non-terminal instances the sub-tenant may hold at once.",
            "minimum": 0
          },
          "max_executions_per_month": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Executions (top-level instances) the sub-tenant may start per\ncalendar month (UTC).",
            "minimum": 0
          }
        }
      },
      "SubTenantLimitsResponse": {
        "type": "object",
        "description": "Limits as stored/returned. Absent fields are uncapped.",
        "required": [
          "sub_tenant"
        ],
        "properties": {
          "max_concurrent": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "max_executions_per_month": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "sub_tenant": {
            "type": "string"
          }
        }
      },
      "SubTenantUsage": {
        "type": "object",
        "description": "Metered activity of one sub-tenant over a window.",
        "required": [
          "sub_tenant",
          "executions_started",
          "executions_completed",
          "steps_executed"
        ],
        "properties": {
          "executions_completed": {
            "type": "integer",
            "format": "int64",
            "description": "Instances of the sub-tenant that completed in the window.",
            "minimum": 0
          },
          "executions_started": {
            "type": "integer",
            "format": "int64",
            "description": "Executions started in the window (durable counter; survives instance\nretention/pruning).",
            "minimum": 0
          },
          "last_active_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "steps_executed": {
            "type": "integer",
            "format": "int64",
            "description": "Steps (block outputs) recorded in the window for the sub-tenant.",
            "minimum": 0
          },
          "sub_tenant": {
            "type": "string"
          }
        }
      },
      "SubTenantUsageResponse": {
        "type": "object",
        "required": [
          "items",
          "active_sub_tenants",
          "from",
          "to"
        ],
        "properties": {
          "active_sub_tenants": {
            "type": "integer",
            "format": "int64",
            "description": "Sub-tenants that started at least one execution in the window.",
            "minimum": 0
          },
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubTenantUsage"
            }
          },
          "to": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TaskInstance": {
        "type": "object",
        "required": [
          "id",
          "sequence_id",
          "tenant_id",
          "namespace",
          "state",
          "priority",
          "timezone",
          "metadata",
          "context",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "budget": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Budget",
                "description": "Optional resource budget enforced by the scheduler (see [`Budget`])."
              },
              {
                "type": "null"
              }
            ]
          },
          "concurrency_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional concurrency key for limiting parallel executions."
          },
          "context": {
            "$ref": "#/components/schemas/ExecutionContext"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "idempotency_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional idempotency key for deduplication at creation time."
          },
          "max_concurrency": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Max concurrent running instances with the same concurrency key.",
            "minimum": 0
          },
          "metadata": {},
          "namespace": {
            "$ref": "#/components/schemas/Namespace"
          },
          "next_fire_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "parent_instance_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InstanceId",
                "description": "Parent instance ID (set when this instance is a sub-sequence child)."
              },
              {
                "type": "null"
              }
            ]
          },
          "priority": {
            "$ref": "#/components/schemas/Priority"
          },
          "sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "session_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Session ID for cross-instance shared state."
          },
          "state": {
            "$ref": "#/components/schemas/InstanceState"
          },
          "sub_tenant": {
            "type": [
              "string",
              "null"
            ],
            "description": "End customer (sub-tenant) inside `tenant_id`; `None` = tenant-level."
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "timezone": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TenantBudget": {
        "type": "object",
        "description": "A tenant spend budget over estimated LLM cost (the same list-price\nestimates `GET /usage` reports).",
        "required": [
          "id",
          "tenant_id",
          "period",
          "limit_usd",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "hard_cap": {
            "type": "boolean",
            "description": "When true, new `llm_call` dispatches fail closed once spend reaches\n`limit_usd` (cache hits are still served — they cost nothing)."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "limit_usd": {
            "type": "number",
            "format": "double",
            "description": "Spend limit in USD for one period."
          },
          "model": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional model filter: a prefix matched against the recorded model\n(`gpt-5` matches `gpt-5.4-mini`). `None` = all models."
          },
          "period": {
            "$ref": "#/components/schemas/BudgetPeriod"
          },
          "tenant_id": {
            "type": "string"
          },
          "thresholds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Soft thresholds in percent (each emits one alert per period)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TenantId": {
        "type": "string"
      },
      "ThemeResponse": {
        "type": "object",
        "description": "Theme as served to embed components.",
        "required": [
          "css_vars",
          "hide_badge"
        ],
        "properties": {
          "css_vars": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "hide_badge": {
            "type": "boolean",
            "description": "Effective: `true` only when requested *and* licensed for `white_label`."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "TimelineEntry": {
        "type": "object",
        "description": "One executed-block entry: the persisted snapshot of a single block\nexecution (first attempt, retry marker, loop iteration, ...).",
        "required": [
          "block_id",
          "attempt",
          "completed_at",
          "is_sentinel"
        ],
        "properties": {
          "attempt": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "block_id": {
            "type": "string"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "description": "When this row was persisted — i.e. when the block's execution (or the\nsentinel write) completed."
          },
          "is_sentinel": {
            "type": "boolean",
            "description": "`true` for internal bookkeeping rows (crash-recovery sentinels, retry\nmarkers, error markers) — flagged rather than hidden."
          },
          "output": {
            "description": "Inline output payload. Omitted when `include_outputs=false`. For\nartifact-backed (externalized) rows the stored reference marker is\nreturned as-is — resolve via `output_ref`."
          },
          "output_ref": {
            "type": [
              "string",
              "null"
            ],
            "description": "Externalized-payload reference, or a sentinel tag\n(`__in_progress__` / `__retry__` / `__error__`)."
          }
        }
      },
      "TimelineInstance": {
        "type": "object",
        "description": "Instance-level summary heading the timeline.",
        "required": [
          "id",
          "sequence_id",
          "state",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "context": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ExecutionContext",
                "description": "Current execution context. Omitted when `include_outputs=false`\n(contexts can be as large as outputs)."
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "state": {
            "$ref": "#/components/schemas/InstanceState"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TimelineResponse": {
        "type": "object",
        "required": [
          "instance",
          "state_transitions",
          "entries",
          "offset",
          "limit",
          "has_more"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimelineEntry"
            },
            "description": "Executed-block entries in execution order (`created_at ASC`),\npaginated by `offset` / `limit`."
          },
          "has_more": {
            "type": "boolean"
          },
          "instance": {
            "$ref": "#/components/schemas/TimelineInstance"
          },
          "limit": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "offset": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "state_transitions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimelineStateTransition"
            },
            "description": "State transitions recorded in the audit log (chronological, capped at\nthe most recent 200). Empty when audit logging is not enabled."
          }
        }
      },
      "TimelineStateTransition": {
        "type": "object",
        "description": "A recorded instance state transition (from the audit log).",
        "required": [
          "at"
        ],
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "from_state": {
            "type": [
              "string",
              "null"
            ]
          },
          "to_state": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "TriggerDef": {
        "type": "object",
        "description": "A persisted trigger definition that maps an event source to a sequence.",
        "required": [
          "slug",
          "sequence_name",
          "tenant_id",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "config": {
            "description": "Type-specific configuration (JSON)."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether this trigger is active."
          },
          "namespace": {
            "type": "string",
            "description": "Namespace for created instances."
          },
          "secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional secret for HMAC validation of incoming requests.\nRedacted in Debug/Serialize output — use `.secret.as_ref().map(|s| s.expose())` to access."
          },
          "sequence_name": {
            "type": "string",
            "description": "Sequence name to instantiate when fired."
          },
          "slug": {
            "type": "string",
            "description": "Unique slug used in the trigger URL / identifier."
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId",
            "description": "Tenant ID for created instances."
          },
          "trigger_type": {
            "$ref": "#/components/schemas/TriggerType",
            "description": "Trigger type: `webhook`, `nats`, `file_watch`, `event`, `activepieces_poll`,\n`kafka`, `sqs`, `pubsub`, `redis_streams`, `postgres_rows`."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Optional specific version. If omitted, uses latest."
          }
        }
      },
      "TriggerPollState": {
        "type": "object",
        "description": "Runtime state for a polling trigger (`TriggerType::ActivepiecesPoll`).\n\nStored separately from [`TriggerDef`] so the poll loop can persist its\ncursor and failure bookkeeping without rewriting the user-authored\ntrigger definition (avoiding lost-update races with API edits).",
        "required": [
          "slug",
          "updated_at"
        ],
        "properties": {
          "consecutive_failures": {
            "type": "integer",
            "format": "int32",
            "description": "Number of consecutive failed polls. Reset to 0 on success."
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Error message from the most recent failed poll. Cleared on success."
          },
          "last_poll_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the last poll attempt (success or failure) completed."
          },
          "slug": {
            "type": "string",
            "description": "Slug of the trigger this state belongs to."
          },
          "state": {
            "description": "Opaque cursor blob returned by the sidecar's last successful poll\n(`ActivePieces` store contents — `lastPoll` epoch, item ids, ...).\nSent back verbatim on the next poll for deduplication."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TriggerType": {
        "type": "string",
        "description": "The kind of event source that fires a trigger.",
        "enum": [
          "webhook",
          "nats",
          "file_watch",
          "event",
          "activepieces_poll",
          "kafka",
          "sqs",
          "pubsub",
          "redis_streams",
          "postgres_rows"
        ]
      },
      "TrustBoundaryProfile": {
        "type": "string",
        "description": "Opinionated profiles make the highest-value trust-boundary use cases\ndeployable without inventing policy from scratch.",
        "enum": [
          "private_rag",
          "biometric_approval",
          "data_residency",
          "bill_of_execution",
          "audit_evidence",
          "secret_safe_coding",
          "regulated_onboarding",
          "fraud_challenge",
          "executive_airlock",
          "personal_data_vault"
        ]
      },
      "TryCatchDef": {
        "type": "object",
        "required": [
          "id",
          "try_block",
          "catch_block"
        ],
        "properties": {
          "catch_block": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          },
          "finally_block": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          },
          "id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "try_block": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlockDefinition"
            }
          }
        }
      },
      "UpdateContextRequest": {
        "type": "object",
        "required": [
          "context"
        ],
        "properties": {
          "context": {
            "$ref": "#/components/schemas/ExecutionContext"
          }
        }
      },
      "UpdateCredentialRequest": {
        "type": "object",
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "kind": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CredentialKind"
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "refresh_token": {
            "type": [
              "string",
              "null"
            ]
          },
          "refresh_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "When set, replaces the stored secret. Write-only — never returned."
          }
        }
      },
      "UpdateCronRequest": {
        "type": "object",
        "properties": {
          "cron_expr": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "metadata": {},
          "overlap_policy": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OverlapPolicy"
              },
              {
                "type": "null"
              }
            ]
          },
          "timezone": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "UpdateResourceRequest": {
        "type": "object",
        "properties": {
          "daily_cap": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "enabled": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "warmup_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "warmup_start": {
            "type": [
              "string",
              "null"
            ]
          },
          "warmup_start_cap": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "weight": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "UpdateSessionDataRequest": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {}
        }
      },
      "UpdateSessionStateRequest": {
        "type": "object",
        "required": [
          "state"
        ],
        "properties": {
          "state": {
            "$ref": "#/components/schemas/SessionState"
          }
        }
      },
      "UpdateStateRequest": {
        "type": "object",
        "required": [
          "state"
        ],
        "properties": {
          "next_fire_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "state": {
            "$ref": "#/components/schemas/InstanceState"
          }
        }
      },
      "ValidateRequest": {
        "type": "object",
        "properties": {
          "sample": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "How many historical instances to replay (default 10, max 50).",
            "minimum": 0
          },
          "skip": {
            "type": "boolean",
            "description": "Skip replay entirely (draft → ready with an audit record)."
          }
        }
      },
      "ValidationReport": {
        "type": "object",
        "required": [
          "replayed",
          "matches",
          "divergences",
          "inconclusive",
          "release_state"
        ],
        "properties": {
          "divergences": {
            "type": "array",
            "items": {},
            "description": "Runs that diverged (details below, bounded)."
          },
          "inconclusive": {
            "type": "integer",
            "format": "int32",
            "description": "Runs that could not be judged because recorded outputs were\nmissing — never silently treated as success.",
            "minimum": 0
          },
          "matches": {
            "type": "integer",
            "format": "int32",
            "description": "Runs whose path and terminal state matched the recording.",
            "minimum": 0
          },
          "release_state": {
            "$ref": "#/components/schemas/ReleaseState"
          },
          "replayed": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "ValidationResponse": {
        "type": "object",
        "required": [
          "valid"
        ],
        "properties": {
          "valid": {
            "type": "boolean"
          }
        }
      },
      "VariantStats": {
        "type": "object",
        "description": "Aggregated terminal counts for one variant during canary.",
        "required": [
          "total",
          "completed",
          "failed",
          "cancelled"
        ],
        "properties": {
          "cancelled": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "completed": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "WaitStatus": {
        "type": "string",
        "description": "Wait registration lifecycle.",
        "enum": [
          "waiting",
          "satisfied",
          "cancelled"
        ]
      },
      "WebhookDeliveryAttempt": {
        "type": "object",
        "description": "One delivery attempt (bounded, redacted metadata only — never the\npayload or response body).",
        "required": [
          "id",
          "delivery_id",
          "url",
          "event_type",
          "attempt_number",
          "attempted_at",
          "duration_ms",
          "success",
          "signed"
        ],
        "properties": {
          "attempt_number": {
            "type": "integer",
            "format": "int32",
            "description": "1-based attempt number within the delivery."
          },
          "attempted_at": {
            "type": "string",
            "format": "date-time"
          },
          "delivery_id": {
            "type": "string",
            "format": "uuid",
            "description": "Groups the attempts of one delivery pass (initial emit or one\nredelivery)."
          },
          "duration_ms": {
            "type": "integer",
            "format": "int64"
          },
          "error_class": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DeliveryErrorClass"
              },
              {
                "type": "null"
              }
            ]
          },
          "error_excerpt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bounded, redacted excerpt of the transport error (never a response\nbody)."
          },
          "event_type": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "signed": {
            "type": "boolean",
            "description": "Whether the request was HMAC-signed."
          },
          "status_code": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32"
          },
          "success": {
            "type": "boolean"
          },
          "url": {
            "type": "string"
          }
        }
      },
      "WebhookDeliverySummary": {
        "type": "object",
        "description": "Aggregated view of one delivery (all attempts in a group).",
        "required": [
          "delivery_id",
          "url",
          "event_type",
          "attempts",
          "delivered",
          "first_attempt_at",
          "last_attempt_at"
        ],
        "properties": {
          "attempts": {
            "type": "integer",
            "format": "int64"
          },
          "delivered": {
            "type": "boolean"
          },
          "delivery_id": {
            "type": "string",
            "format": "uuid"
          },
          "event_type": {
            "type": "string"
          },
          "first_attempt_at": {
            "type": "string",
            "format": "date-time"
          },
          "instance_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "last_attempt_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_error_class": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DeliveryErrorClass",
                "description": "Error class of the final attempt when the delivery failed."
              },
              {
                "type": "null"
              }
            ]
          },
          "url": {
            "type": "string"
          }
        }
      },
      "WebhookOutboxEntry": {
        "type": "object",
        "description": "One outbound webhook delivery. `Pending`/`InFlight` rows are being worked\nby the engine; `Parked` rows failed after all retries and were kept for\nmanual inspection / redelivery.",
        "required": [
          "id",
          "url",
          "event_type",
          "payload",
          "attempts",
          "created_at"
        ],
        "properties": {
          "attempts": {
            "type": "integer",
            "format": "int32",
            "description": "How many delivery attempts were made so far."
          },
          "claimed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When an `InFlight` row was claimed; stale claims older than the\ndispatcher's worst-case retry pass are recovered back to `Pending`."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the delivery was first enqueued (or parked, for pre-drain rows)."
          },
          "delivery_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Links this entry to its attempt history (see\n`webhook_delivery::WebhookDeliveryAttempt`). `None` for rows parked\nbefore attempt tracking existed."
          },
          "event_type": {
            "type": "string",
            "description": "The event type (e.g. `instance.failed`)."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The related instance id, if the event carried one."
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "The last error (HTTP status or transport error) seen, if any."
          },
          "next_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When a `Pending` row becomes due for its next dispatch attempt.\n`None` means immediately due (fresh rows) or not scheduled (`Parked`)."
          },
          "payload": {
            "description": "The full serialized `WebhookEvent` payload, replayed verbatim on redelivery."
          },
          "status": {
            "$ref": "#/components/schemas/WebhookOutboxStatus",
            "description": "Delivery lifecycle state (see [`WebhookOutboxStatus`])."
          },
          "url": {
            "type": "string",
            "description": "The destination URL the delivery was targeting."
          }
        }
      },
      "WebhookOutboxStatus": {
        "type": "string",
        "description": "Delivery lifecycle of an outbox row.\n\n`Pending` rows are due for dispatch (the drain loop or the in-memory fast\npath claims them); `InFlight` rows are claimed by a dispatcher right now\n(a stale claim is reset to `Pending` if the dispatcher dies mid-dispatch);\n`Parked` rows exhausted their retries and await manual redelivery — the\ndrain loop never touches them.",
        "enum": [
          "pending",
          "in_flight",
          "parked"
        ]
      },
      "WorkbenchEvent": {
        "type": "object",
        "description": "One event on the unified timeline. Ordering contract: `(timestamp,\nkind, id)` — equal timestamps order by kind (state transitions before\noutputs before logs), then by id, so repeated queries render\nidentically.",
        "required": [
          "timestamp",
          "kind",
          "summary",
          "id"
        ],
        "properties": {
          "block_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string",
            "description": "Stable tiebreaker id."
          },
          "kind": {
            "type": "string",
            "description": "`state_transition` | `block_output` | `log` | `audit`."
          },
          "summary": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WorkerArtifactReceipt": {
        "type": "object",
        "required": [
          "artifact",
          "upload_id",
          "sha256",
          "size"
        ],
        "properties": {
          "artifact": {
            "$ref": "#/components/schemas/ArtifactRef"
          },
          "file_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "sha256": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "upload_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "WorkerAttemptEventKind": {
        "type": "string",
        "description": "Durable reason for a worker-task attempt transition.",
        "enum": [
          "claimed",
          "reclaimed",
          "completed",
          "failed",
          "timed_out",
          "cancelled",
          "stale_mutation_rejected"
        ]
      },
      "WorkerCommand": {
        "type": "object",
        "description": "A control command queued for a specific worker, delivered via the worker\ncontrol channel (`GET /workers/{id}/commands`). The worker acts on pending\ncommands and acks them (`DELETE /workers/commands/{id}`).",
        "required": [
          "id",
          "worker_id",
          "command",
          "created_at"
        ],
        "properties": {
          "command": {
            "$ref": "#/components/schemas/WorkerCommandKind",
            "description": "`drain` (stop claiming new tasks, finish in-flight), `reload`\n(re-read config / re-register handlers), `ping` (liveness probe), or\n`place` (accept a placement payload for runtime-local execution)."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "payload": {
            "description": "Optional command parameters (e.g. a drain deadline)."
          },
          "tenant_id": {
            "type": "string",
            "description": "Tenant that owns the target worker. A tenant-scoped worker session\nonly receives (and can only ack) commands of its own tenant, since\n`worker_id` is client-chosen. Empty = deliverable only to unscoped\n(root / insecure-mode) sessions."
          },
          "worker_id": {
            "type": "string",
            "description": "The worker this command targets."
          }
        }
      },
      "WorkerCommandKind": {
        "type": "string",
        "description": "The kind of a [`WorkerCommand`].",
        "enum": [
          "drain",
          "reload",
          "ping",
          "place"
        ]
      },
      "WorkerInfo": {
        "type": "object",
        "description": "Aggregated view of one worker on the fleet, grouped from its\nper-handler registrations.",
        "required": [
          "worker_id",
          "handlers",
          "queues",
          "last_seen_at",
          "alive",
          "in_flight"
        ],
        "properties": {
          "alive": {
            "type": "boolean",
            "description": "True when the worker polled within the liveness window."
          },
          "handlers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Handler names this worker has polled for."
          },
          "in_flight": {
            "type": "integer",
            "format": "int64",
            "description": "Number of tasks currently claimed by this worker."
          },
          "last_seen_at": {
            "type": "string",
            "format": "date-time"
          },
          "queues": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Named queues this worker has polled (empty when default queue only)."
          },
          "version": {
            "type": [
              "string",
              "null"
            ],
            "description": "Most recently reported version string, if any."
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "WorkerRegistration": {
        "type": "object",
        "description": "A worker's self-reported registration, refreshed on every poll.\n\nOne row per `(worker_id, handler_name)` pair — a worker that serves three\nhandlers appears three times. `last_seen_at` is bumped on every poll, so\nliveness is \"polled recently\", independent of whether tasks were claimed.",
        "required": [
          "worker_id",
          "handler_name",
          "last_seen_at"
        ],
        "properties": {
          "handler_name": {
            "type": "string"
          },
          "last_seen_at": {
            "type": "string",
            "format": "date-time"
          },
          "queue_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Named queue the worker polled, when using queue-scoped polling."
          },
          "tenant_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Tenant scope of the polling credential, when tenant-scoped."
          },
          "version": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional worker-reported build/deploy version string."
          },
          "worker_id": {
            "type": "string"
          }
        }
      },
      "WorkerTask": {
        "type": "object",
        "description": "A task dispatched to an external worker for execution.",
        "required": [
          "id",
          "instance_id",
          "block_id",
          "handler_name",
          "params",
          "context",
          "attempt",
          "state",
          "created_at"
        ],
        "properties": {
          "attempt": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "block_id": {
            "$ref": "#/components/schemas/BlockId"
          },
          "carries_credentials": {
            "type": "boolean",
            "description": "The step's params referenced `credentials://` material. Such a task is\nnever claimable by a `browser` runtime."
          },
          "checkpoint_seq": {
            "type": "integer",
            "format": "int64",
            "description": "Monotonic compare-and-swap version for `resume_checkpoint`.",
            "minimum": 0
          },
          "claim_epoch": {
            "type": "integer",
            "format": "int64",
            "description": "Monotonic ownership generation. Every successful claim increments this\nvalue. Workers must echo it on every lease mutation so a process from an\nolder claim cannot act after the task has been reclaimed, even when the\nsame stable `worker_id` is reused.",
            "minimum": 0
          },
          "claimed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "claimed_runtime_kind": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuntimeKind",
                "description": "Runtime kind of the current claimant (from its capability\nadvertisement), recorded for lease sizing, output bounds, and\nprovenance. `None` for legacy capability-less claims."
              },
              {
                "type": "null"
              }
            ]
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "context": {
            "description": "Serialized `ExecutionContext` — kept as raw JSON to avoid coupling workers to Rust types."
          },
          "continuity_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Continuity ownership epoch of the instance when the task was\ndispatched. Lease mutations are fenced on it: a task dispatched under\nan older owner cannot complete after a handoff. `None` = the instance\nwas not enrolled in continuity at dispatch.",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "effect_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EffectId",
                "description": "Deterministic idempotency key of this attempt's effect receipt, fixed\nat dispatch. Nodes pass it to handlers and downstream APIs as an\nidempotency key; the server settles the receipt by this stored id\n(never a recomputed one, which would miss after an ownership handoff)."
              },
              {
                "type": "null"
              }
            ]
          },
          "error_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "error_retryable": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "handler_name": {
            "type": "string"
          },
          "heartbeat_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "instance_id": {
            "$ref": "#/components/schemas/InstanceId"
          },
          "lease_secs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Lease (seconds between heartbeats) for the current claim, chosen from\nthe claimant's runtime kind. `None` = the server-wide default.",
            "minimum": 0
          },
          "output": {},
          "params": {},
          "queue_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Named task queue for routing to dedicated worker pools."
          },
          "requirements": {
            "$ref": "#/components/schemas/CapsuleRequirements",
            "description": "Capability, locality, and trust facts a runtime must satisfy before it\ncan atomically claim this task."
          },
          "resume_checkpoint": {
            "description": "Latest durable progress snapshot supplied by the activity worker.\nA replacement worker receives this value when it claims the task."
          },
          "state": {
            "$ref": "#/components/schemas/WorkerTaskState"
          },
          "timeout_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "worker_id": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WorkerTaskAttemptEvent": {
        "type": "object",
        "description": "Append-only evidence for one transition of one worker claim generation.",
        "required": [
          "id",
          "task_id",
          "claim_epoch",
          "event",
          "created_at"
        ],
        "properties": {
          "claim_epoch": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "event": {
            "$ref": "#/components/schemas/WorkerAttemptEventKind"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "task_id": {
            "type": "string",
            "format": "uuid"
          },
          "worker_id": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WorkerTaskState": {
        "type": "string",
        "description": "State of a worker task in its lifecycle.",
        "enum": [
          "pending",
          "claimed",
          "completed",
          "failed"
        ]
      },
      "WorkerTaskStats": {
        "type": "object",
        "required": [
          "by_state",
          "by_handler",
          "active_workers"
        ],
        "properties": {
          "active_workers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "by_handler": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "propertyNames": {
                "type": "string"
              }
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "by_state": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            },
            "propertyNames": {
              "type": "string"
            }
          }
        }
      },
      "WorkerVersionPin": {
        "type": "object",
        "description": "A minimum-worker-version pin for a `(tenant, handler)` pair. A worker\nreporting a version below `min_version` is not given tasks for that handler\nat poll time — used to roll a fixed worker build out before old workers can\npick up affected work.",
        "required": [
          "tenant_id",
          "handler_name",
          "min_version",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "handler_name": {
            "type": "string"
          },
          "min_version": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WorkflowRelease": {
        "type": "object",
        "description": "A release candidate under evaluation.",
        "required": [
          "id",
          "tenant_id",
          "namespace",
          "sequence_name",
          "baseline_sequence_id",
          "baseline_version",
          "candidate_sequence_id",
          "candidate_version",
          "state",
          "canary_percent",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "baseline_sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "baseline_version": {
            "type": "integer",
            "format": "int32"
          },
          "canary_percent": {
            "type": "integer",
            "format": "int32",
            "description": "Percentage of new instances routed to the candidate during\ncanary (0–100).",
            "minimum": 0
          },
          "canary_started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the canary started (observation window lower bound)."
          },
          "candidate_sequence_id": {
            "$ref": "#/components/schemas/SequenceId"
          },
          "candidate_version": {
            "type": "integer",
            "format": "int32"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "gates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReleaseGate"
            }
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "in_flight_policy": {
            "$ref": "#/components/schemas/InFlightPolicy"
          },
          "namespace": {
            "$ref": "#/components/schemas/Namespace"
          },
          "sequence_name": {
            "type": "string",
            "description": "Display name (the sequence name at creation) — informational\nonly; routing always uses the exact ids below."
          },
          "state": {
            "$ref": "#/components/schemas/ReleaseState"
          },
          "target": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReleaseTarget",
                "description": "Optional sub-tenant staged-rollout target. When set, sub-tenant\nscoped instances are routed by sub-tenant (list membership, then a\nstable per-sub-tenant percentage bucket) instead of per-instance\ncohorts, and unscoped instances follow the default (baseline until\npromotion)."
              },
              {
                "type": "null"
              }
            ]
          },
          "tenant_id": {
            "$ref": "#/components/schemas/TenantId"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "validation_summary": {
            "description": "Result summary of the last historical validation run, if any."
          }
        }
      }
    },
    "securitySchemes": {
      "embed_token": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "o8e1",
        "description": "Scoped embed token minted by POST /embed/tokens (tenant API key)"
      }
    }
  },
  "tags": [
    {
      "name": "health",
      "description": "Health check endpoints"
    },
    {
      "name": "sequences",
      "description": "Sequence definition management"
    },
    {
      "name": "instances",
      "description": "Task instance lifecycle"
    },
    {
      "name": "cron",
      "description": "Cron schedule management"
    },
    {
      "name": "workers",
      "description": "External worker task polling"
    },
    {
      "name": "sessions",
      "description": "Cross-instance session management"
    },
    {
      "name": "circuit_breakers",
      "description": "Circuit breaker inspection and reset"
    },
    {
      "name": "pools",
      "description": "Resource pool management"
    },
    {
      "name": "prompts",
      "description": "Versioned, tenant-scoped prompt registry with labels and canaries"
    },
    {
      "name": "budgets",
      "description": "Tenant LLM spend budgets: hard caps and threshold alerts"
    },
    {
      "name": "placement",
      "description": "Placement policies (residency, labels, affinity, lanes) and global rate budgets"
    },
    {
      "name": "federation",
      "description": "Opt-in federation transport: trust registry, outbound calls, and the signature-authenticated inbound endpoint"
    },
    {
      "name": "usage",
      "description": "LLM usage, estimated cost, cache savings and budget status"
    },
    {
      "name": "receipts",
      "description": "Signed effect-receipt bundles: at-most-once dispatch evidence (not an exactly-once claim)"
    },
    {
      "name": "migrations",
      "description": "Import sequences and in-flight instances from another engine (orch8 migrate --to)"
    },
    {
      "name": "cluster",
      "description": "Multi-node cluster management"
    },
    {
      "name": "credentials",
      "description": "Shared secrets referenced by step params via credentials://<id>"
    },
    {
      "name": "jobs",
      "description": "Background jobs: enqueue a handler invocation without authoring a sequence"
    },
    {
      "name": "triggers",
      "description": "Trigger definitions that convert inbound events into instance creations"
    },
    {
      "name": "webhooks",
      "description": "Public, unauthenticated webhook ingestion (HMAC-protected via trigger secret)"
    },
    {
      "name": "approvals",
      "description": "Human-in-the-loop approvals, including public Slack/Teams/email approval actions"
    },
    {
      "name": "alerts",
      "description": "Built-in alert rules (DLQ growth, circuit breakers, budget breaches, empty worker pools)"
    },
    {
      "name": "public",
      "description": "Unauthenticated, token-addressed public progress links"
    },
    {
      "name": "sub-tenants",
      "description": "End customers inside a tenant: X-Orch8-Sub-Tenant scoping, per-sub-tenant caps and metering"
    },
    {
      "name": "embed",
      "description": "Embedded surface: scoped o8e1 embed tokens, sub-tenant run/approval/sequence views, theme"
    },
    {
      "name": "license",
      "description": "Offline-verified license status (soft enforcement only)"
    },
    {
      "name": "continuity-product",
      "description": "Framework-neutral handoff protocol, profiles, receipts, conformance, and commercial deployment validation"
    }
  ]
}