{
  "openapi": "3.1.0",
  "info": {
    "title": "RunLater LOCAL prototype",
    "version": "0.6.0",
    "description": "No production service. At-least-once design; no ordering or exact-time guarantee. Active idempotency plus 30 days after termination. All numeric limits proposed. Arbitrary outbound HTTPS disabled."
  },
  "servers": [
    {
      "url": "http://127.0.0.1:8787",
      "description": "Local emulator only"
    }
  ],
  "security": [
    {
      "projectToken": []
    }
  ],
  "paths": {
    "/v1/tasks": {
      "post": {
        "operationId": "createTask",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "x-max-utf8-bytes": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Create"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Same canonical input and key returns original task",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Task"
                    },
                    {
                      "$ref": "#/components/schemas/TaskReceipt"
                    }
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Durably accepted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Task"
                    },
                    {
                      "$ref": "#/components/schemas/TaskReceipt"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "409": {
            "$ref": "#/components/responses/LocalError",
            "description": "Idempotency conflict or invalid transition"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "422": {
            "$ref": "#/components/responses/LocalError",
            "description": "Destination disabled"
          },
          "429": {
            "$ref": "#/components/responses/LocalThrottle",
            "description": "Admission deferred. Existing idempotent results still replay. Retained payload capacity may require retention expiry or config change."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "enqueue"
      },
      "get": {
        "operationId": "listTasks",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "At most 50 items with next_after cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read"
      }
    },
    "/v1/tasks/{id}": {
      "get": {
        "operationId": "getTask",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^task_[0-9a-f]{16}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant-owned task",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "404": {
            "$ref": "#/components/responses/LocalError",
            "description": "Not found in authenticated tenant"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read"
      }
    },
    "/v1/tasks/{id}/attempts": {
      "get": {
        "operationId": "getAttempts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^task_[0-9a-f]{16}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Redacted outcomes, no response bodies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Attempt"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "404": {
            "$ref": "#/components/responses/LocalError",
            "description": "Not found in authenticated tenant"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read"
      }
    },
    "/v1/tasks/{id}/cancel": {
      "post": {
        "operationId": "cancelTask",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^task_[0-9a-f]{16}$"
            }
          }
        ],
        "description": "Cancellation cannot undo a leased external effect; recorded success can win.",
        "responses": {
          "200": {
            "description": "Existing result",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Task"
                    },
                    {
                      "$ref": "#/components/schemas/TaskReceipt"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "404": {
            "$ref": "#/components/responses/LocalError",
            "description": "Not found in authenticated tenant"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "cancel"
      }
    },
    "/v1/tasks/{id}/redrive": {
      "post": {
        "operationId": "redriveTask",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^task_[0-9a-f]{16}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "x-max-utf8-bytes": 64
            }
          }
        ],
        "description": "Failed-only. New linked execution; original history and operation_key preserved.",
        "responses": {
          "200": {
            "description": "Existing result",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Task"
                    },
                    {
                      "$ref": "#/components/schemas/TaskReceipt"
                    }
                  ]
                }
              }
            }
          },
          "201": {
            "description": "New linked task",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Task"
                    },
                    {
                      "$ref": "#/components/schemas/TaskReceipt"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "404": {
            "$ref": "#/components/responses/LocalError",
            "description": "Not found in authenticated tenant"
          },
          "409": {
            "$ref": "#/components/responses/LocalError",
            "description": "Idempotency conflict or invalid transition"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "429": {
            "$ref": "#/components/responses/LocalThrottle",
            "description": "Admission deferred. Existing idempotent results still replay. Retained payload capacity may require retention expiry or config change."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "redrive"
      }
    },
    "/v1/queue": {
      "get": {
        "operationId": "getDefaultQueueLimits",
        "description": "Read-only committed configuration for authenticated tenant; no alarm/reconciliation/write.",
        "responses": {
          "200": {
            "description": "Tenant-wide default queue limits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueueLimits"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read"
      },
      "put": {
        "operationId": "configureDefaultQueueLimits",
        "description": "Configure the default tenant queue using a full object with explicit paused state. Pause/resume blocks new claims without undoing effects or resetting budgets. Same configuration does not refill tokens or append a configuration event. Read prior config before replacing; concurrent config writes are last committed writer wins.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueueLimits"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Durably committed limits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueueLimits"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "configure"
      }
    },
    "/v1/keys": {
      "get": {
        "operationId": "listProjectKeys",
        "x-required-permission": "manage_keys",
        "responses": {
          "200": {
            "description": "Existing/current redacted result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        }
      },
      "post": {
        "operationId": "issueLocalProjectKey",
        "x-required-permission": "manage_keys",
        "description": "Fixture-only. Same key ID and canonical spec replay without reactivating revoked/expired keys. Grants cannot exceed actor permissions.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewLocalKey"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing/current redacted result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyView"
                }
              }
            }
          },
          "201": {
            "description": "New key durably committed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "409": {
            "$ref": "#/components/responses/LocalError",
            "description": "Immutable key/rotation identity conflict"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "429": {
            "$ref": "#/components/responses/LocalThrottle",
            "description": "64 retained local keys maximum per project"
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        }
      }
    },
    "/v1/keys/audit": {
      "get": {
        "operationId": "getKeyAudit",
        "x-required-permission": "manage_keys",
        "responses": {
          "200": {
            "description": "Existing/current redacted result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyAudit"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        }
      }
    },
    "/v1/keys/{key_id}/revoke": {
      "post": {
        "operationId": "revokeProjectKey",
        "x-required-permission": "manage_keys",
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "description": "Immediate for subsequent API authorization. Does not cancel accepted work or undo a command that already committed. Target permissions must be a subset of actor permissions.",
        "responses": {
          "200": {
            "description": "Existing/current redacted result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "404": {
            "$ref": "#/components/responses/LocalError",
            "description": "Unknown project-owned key"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        }
      }
    },
    "/v1/keys/{key_id}/rotate": {
      "post": {
        "operationId": "rotateLocalProjectKey",
        "x-required-permission": "manage_keys",
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "description": "Atomically issue a new immutable key and schedule source revocation. Overlap <=24h; no validity gap permitted; replays are keyed by the new immutable key ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "new_key",
                  "revoke_old_at_ms"
                ],
                "properties": {
                  "new_key": {
                    "$ref": "#/components/schemas/NewLocalKey"
                  },
                  "revoke_old_at_ms": {
                    "type": "integer",
                    "format": "int64"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing/current redacted result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyView"
                }
              }
            }
          },
          "201": {
            "description": "New key durably committed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "404": {
            "$ref": "#/components/responses/LocalError",
            "description": "Unknown project-owned key"
          },
          "409": {
            "$ref": "#/components/responses/LocalError",
            "description": "Immutable key/rotation identity conflict"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "429": {
            "$ref": "#/components/responses/LocalThrottle",
            "description": "64 retained local keys maximum per project"
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        }
      }
    },
    "/v1/queue/health": {
      "get": {
        "operationId": "getQueueHealth",
        "responses": {
          "200": {
            "description": "Read-only tenant-local ledger health snapshot; not provider Queue depth. See OPERATIONS.md.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read"
      }
    },
    "/v1/queue/audit": {
      "get": {
        "operationId": "getQueueAudit",
        "responses": {
          "200": {
            "description": "Bounded payload-free tenant-local activity journal, latest 256 events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueueAudit"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read"
      }
    },
    "/v1/tasks/{id}/inspection": {
      "get": {
        "operationId": "inspectTask",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^task_[0-9a-f]{16}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payload-free task and attempt inspection; omits destination and operation key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Inspection"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "404": {
            "$ref": "#/components/responses/LocalError",
            "description": "Not found in authenticated tenant"
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read"
      }
    },
    "/v1/queue/maintenance": {
      "post": {
        "operationId": "maintainRetention",
        "description": "Trusted server time only. No query parameters accepted. Removes expired terminal rows, their idempotency records, and expired activity events; preserves active tasks and child redrive mappings.",
        "x-required-permission": "configure",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "maxProperties": 0
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Committed retention removal counts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RetentionReport"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getRuntimeHealth",
        "security": [],
        "description": "Default local build health only; no tenant data. Staging builds have an additional outer gate and are not described by this local-only contract.",
        "responses": {
          "200": {
            "description": "Local prototype health",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "status",
                    "outbound"
                  ],
                  "properties": {
                    "status": {
                      "const": "prototype"
                    },
                    "outbound": {
                      "const": "disabled"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/queue/metrics": {
      "get": {
        "operationId": "getQueueMetrics",
        "responses": {
          "200": {
            "description": "Bounded lifetime and 1/5/60 aligned minute-bucket observations; clock/saturation state explicit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueueMetrics"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read",
        "description": "Pure tenant-local fixed UTC minute buckets including current partial minute; server sampled. Transport/denial observations are separate from logical attempt outcomes. No provider, billing or business-operation error-rate claim."
      }
    },
    "/v1/queue/dead-letters": {
      "get": {
        "operationId": "listDeadLetters",
        "responses": {
          "200": {
            "description": "Diagnostic result; configure-only mutations return an opaque receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransportList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          }
        },
        "x-required-permission": "read",
        "description": "Tenant-local diagnostic references; never payload replay or a second task ledger. See docs/TRANSPORT-RECOVERY.md.",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^dlq_[0-9a-f]{64}$"
            }
          }
        ]
      },
      "post": {
        "operationId": "reportDeadLetter",
        "description": "Tenant-local diagnostic references; never payload replay or a second task ledger. See docs/TRANSPORT-RECOVERY.md.",
        "x-required-permission": "configure",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransportReference"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Diagnostic result; configure-only mutations return an opaque receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransportReceipt"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          },
          "201": {
            "description": "Diagnostic result; configure-only mutations return an opaque receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransportReceipt"
                }
              }
            }
          }
        }
      }
    },
    "/v1/queue/dead-letters/{record_id}": {
      "get": {
        "operationId": "getDeadLetter",
        "responses": {
          "200": {
            "description": "Diagnostic result; configure-only mutations return an opaque receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransportRecord"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          },
          "404": {
            "$ref": "#/components/responses/LocalError"
          }
        },
        "x-required-permission": "read",
        "description": "Tenant-local diagnostic references; never payload replay or a second task ledger. See docs/TRANSPORT-RECOVERY.md.",
        "parameters": [
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^dlq_[0-9a-f]{64}$"
            }
          }
        ]
      }
    },
    "/v1/queue/dead-letters/{record_id}/reconcile": {
      "post": {
        "operationId": "reconcileDeadLetter",
        "description": "Tenant-local diagnostic references; never payload replay or a second task ledger. See docs/TRANSPORT-RECOVERY.md.",
        "x-required-permission": "configure",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "maxProperties": 0
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Diagnostic result; configure-only mutations return an opaque receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransportReceipt"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/LocalError",
            "description": "Malformed JSON envelope or invalid operation input."
          },
          "401": {
            "$ref": "#/components/responses/LocalError",
            "description": "Missing, invalid, revoked or expired credential."
          },
          "403": {
            "$ref": "#/components/responses/LocalError",
            "description": "Credential lacks the required permission or authority."
          },
          "413": {
            "$ref": "#/components/responses/LocalError",
            "description": "Request body exceeds 24KiB at the shared envelope reader, before Durable Object dispatch. Applies to GET bodies too; normal GET clients send no body."
          },
          "415": {
            "$ref": "#/components/responses/LocalError",
            "description": "POST/PUT has a non-JSON Content-Type; root task/key/queue mutations also reject a missing Content-Type."
          },
          "503": {
            "$ref": "#/components/responses/LocalError",
            "description": "Default local prototype is disabled or authentication configuration is invalid; this outer gate runs before credentials, media or body processing."
          },
          "404": {
            "$ref": "#/components/responses/LocalError"
          }
        },
        "parameters": [
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^dlq_[0-9a-f]{64}$"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "projectToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Local fixtures only: legacy local-alpha/local-beta bootstrap tokens, or rl_local.<tenant>.<key_id>.<public_fixture_secret>. Production provisioning is gated."
      }
    },
    "schemas": {
      "Create": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "destination",
          "body",
          "operation_key"
        ],
        "properties": {
          "destination": {
            "type": "string",
            "enum": [
              "fixture://success",
              "fixture://retry",
              "fixture://fail"
            ]
          },
          "body": {
            "type": "string",
            "maxLength": 16384,
            "description": "UTF-8 byte bound is also enforced",
            "x-max-utf8-bytes": 16384
          },
          "operation_key": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$",
            "description": "Business operation identity, preserved on redrive"
          },
          "run_at_ms": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "default": 0,
            "description": "UTC Unix milliseconds; 0 or omitted means immediate; max 365 days ahead"
          }
        }
      },
      "Task": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^task_[0-9a-f]{16}$"
          },
          "input": {
            "$ref": "#/components/schemas/Create"
          },
          "status": {
            "type": "string",
            "enum": [
              "scheduled",
              "ready",
              "running",
              "retry_wait",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "due_ms": {
            "type": "integer"
          },
          "generation": {
            "type": "integer"
          },
          "fence": {
            "type": "integer"
          },
          "lease_until": {
            "type": [
              "integer",
              "null"
            ]
          },
          "cancel_requested": {
            "type": "boolean"
          },
          "terminal_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "attempts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attempt"
            }
          },
          "parent": {
            "type": [
              "string",
              "null"
            ]
          },
          "initial_due_ms": {
            "type": "integer",
            "description": "Persisted initial actual due time used for retry age, separate from canonical input"
          }
        },
        "required": [
          "id",
          "input",
          "status",
          "due_ms",
          "generation",
          "fence",
          "lease_until",
          "cancel_requested",
          "terminal_ms",
          "attempts",
          "parent",
          "initial_due_ms"
        ],
        "additionalProperties": false
      },
      "Attempt": {
        "type": "object",
        "required": [
          "fence",
          "started_ms",
          "finished_ms",
          "outcome"
        ],
        "properties": {
          "fence": {
            "type": "integer"
          },
          "started_ms": {
            "type": "integer"
          },
          "finished_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "outcome": {
            "type": [
              "string",
              "null"
            ]
          },
          "staging_diagnostic": {
            "$ref": "#/components/schemas/StageDiagnostic"
          }
        },
        "additionalProperties": false
      },
      "QueueLimits": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "max_active_tasks",
          "max_payload_bytes",
          "max_concurrent",
          "dispatch_per_second",
          "dispatch_burst",
          "paused"
        ],
        "properties": {
          "max_active_tasks": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "default": 1000
          },
          "max_payload_bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 131072,
            "default": 131072
          },
          "max_concurrent": {
            "type": "integer",
            "minimum": 1,
            "maximum": 64,
            "default": 4
          },
          "dispatch_per_second": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 20
          },
          "dispatch_burst": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 20
          },
          "paused": {
            "type": "boolean",
            "default": false,
            "description": "Durable dispatch gate; blocks new claims, preserves accepted work and in-flight effects. PUT must explicitly specify this field."
          }
        },
        "description": "All values proposed local prototype limits. One tenant-wide default logical queue per project; no multiple-queue sharding. Full replacement requires explicit paused; omitted paused is accepted only when migrating old stored snapshots, not API writes."
      },
      "NewLocalKey": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key_id",
          "token_sha256",
          "permissions",
          "expires_at_ms"
        ],
        "properties": {
          "key_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,80}$",
            "description": "Immutable local key ID; bootstrap_ prefix reserved"
          },
          "token_sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "SHA-256 of complete nonproduction rl_local.<tenant>.<key_id>.<secret> token. Server never receives raw secret in this body."
          },
          "permissions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "enqueue",
                "read",
                "cancel",
                "redrive",
                "configure",
                "manage_keys"
              ]
            },
            "description": "Input is normalized as a set; duplicate permissions are accepted and deduplicated."
          },
          "not_before_ms": {
            "type": "integer",
            "format": "int64",
            "default": 0,
            "minimum": 0
          },
          "expires_at_ms": {
            "type": "integer",
            "format": "int64",
            "description": "Exclusive UTC ms cutoff, future and no more than 30 days ahead; proposed local policy"
          }
        }
      },
      "KeyView": {
        "type": "object",
        "properties": {
          "key_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,80}$",
            "description": "Immutable local key ID; bootstrap_ prefix reserved"
          },
          "permissions": {
            "type": "array",
            "uniqueItems": true,
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "enqueue",
                "read",
                "cancel",
                "redrive",
                "configure",
                "manage_keys"
              ]
            }
          },
          "not_before_ms": {
            "type": "integer",
            "format": "int64",
            "default": 0,
            "minimum": 0
          },
          "expires_at_ms": {
            "type": "integer",
            "format": "int64",
            "description": "Exclusive UTC ms cutoff; legacy local bootstrap fixtures have an effectively unbounded cutoff."
          },
          "created_ms": {
            "type": "integer",
            "format": "int64"
          },
          "revoked_at_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "rotated_from": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "description": "No credential verifier or plaintext token is returned.",
        "required": [
          "key_id",
          "permissions",
          "not_before_ms",
          "expires_at_ms",
          "created_ms",
          "revoked_at_ms",
          "rotated_from"
        ],
        "additionalProperties": false
      },
      "TaskReceipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^task_[0-9a-f]{16}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "scheduled",
              "ready",
              "running",
              "retry_wait",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "generation": {
            "type": "integer"
          },
          "cancel_requested": {
            "type": "boolean"
          },
          "parent": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "description": "Returned for task mutation permissions without read; excludes payload, destination and attempts.",
        "required": [
          "id",
          "status",
          "generation",
          "cancel_requested",
          "parent"
        ],
        "additionalProperties": false
      },
      "StageDiagnostic": {
        "oneOf": [
          {
            "type": "string",
            "enum": [
              "policy_rejected",
              "redirect_rejected",
              "response_headers_too_large",
              "response_body_too_large",
              "receipt_rejected",
              "fetch_error",
              "timeout",
              "verified_receipt"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "receiver_status": {
                "type": "integer",
                "minimum": 100,
                "maximum": 599
              }
            },
            "required": [
              "receiver_status"
            ]
          }
        ]
      },
      "Inspection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^task_[0-9a-f]{16}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "scheduled",
              "ready",
              "running",
              "retry_wait",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "due_ms": {
            "type": "integer"
          },
          "generation": {
            "type": "integer"
          },
          "fence": {
            "type": "integer"
          },
          "lease_until": {
            "type": [
              "integer",
              "null"
            ]
          },
          "cancel_requested": {
            "type": "boolean"
          },
          "terminal_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "attempts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attempt"
            }
          },
          "parent": {
            "type": [
              "string",
              "null"
            ]
          },
          "initial_due_ms": {
            "type": "integer",
            "description": "Persisted initial actual due time used for retry age, separate from canonical input"
          }
        },
        "required": [
          "id",
          "status",
          "due_ms",
          "generation",
          "fence",
          "lease_until",
          "cancel_requested",
          "terminal_ms",
          "attempts",
          "parent",
          "initial_due_ms"
        ],
        "additionalProperties": false
      },
      "Health": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "sampled_at_ms": {
            "type": "integer"
          },
          "counts_by_state": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "scheduled": {
                "type": "integer",
                "minimum": 0
              },
              "ready": {
                "type": "integer",
                "minimum": 0
              },
              "running": {
                "type": "integer",
                "minimum": 0
              },
              "retry_wait": {
                "type": "integer",
                "minimum": 0
              },
              "succeeded": {
                "type": "integer",
                "minimum": 0
              },
              "failed": {
                "type": "integer",
                "minimum": 0
              },
              "cancelled": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "scheduled",
              "ready",
              "running",
              "retry_wait",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "eligible_backlog": {
            "type": "integer",
            "minimum": 0
          },
          "due_retry_backlog": {
            "type": "integer",
            "minimum": 0
          },
          "future_backlog": {
            "type": "integer",
            "minimum": 0
          },
          "oldest_eligible_due_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "oldest_eligible_age_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "active_leases": {
            "type": "integer",
            "minimum": 0
          },
          "expired_leases": {
            "type": "integer",
            "minimum": 0
          },
          "missing_leases": {
            "type": "integer",
            "minimum": 0
          },
          "retained_attempts": {
            "type": "integer",
            "minimum": 0
          },
          "finished_attempts": {
            "type": "integer",
            "minimum": 0
          },
          "attempt_failures_by_category": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "minimum": 0
            },
            "propertyNames": {
              "enum": [
                "timeout",
                "lease_expired_unknown",
                "retryable_http",
                "permanent_http",
                "unknown"
              ]
            }
          },
          "failed_tasks_without_attempts": {
            "type": "integer",
            "minimum": 0
          },
          "retained_tasks": {
            "type": "integer",
            "minimum": 0
          },
          "retained_audit_events": {
            "type": "integer",
            "minimum": 0
          },
          "paused": {
            "type": "boolean"
          }
        },
        "required": [
          "sampled_at_ms",
          "counts_by_state",
          "eligible_backlog",
          "due_retry_backlog",
          "future_backlog",
          "oldest_eligible_due_ms",
          "oldest_eligible_age_ms",
          "active_leases",
          "expired_leases",
          "missing_leases",
          "retained_attempts",
          "finished_attempts",
          "attempt_failures_by_category",
          "failed_tasks_without_attempts",
          "retained_tasks",
          "retained_audit_events",
          "paused"
        ]
      },
      "QueueEvent": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "sequence": {
            "type": "integer",
            "minimum": 0
          },
          "at_ms": {
            "type": "integer"
          },
          "kind": {
            "enum": [
              "accepted",
              "redriven",
              "cancel_requested",
              "claimed",
              "finished",
              "lease_expired",
              "age_expired",
              "configured",
              "retention",
              "transport_observed",
              "transport_reconciled",
              "attempt_budget_exhausted"
            ]
          },
          "task_id": {
            "type": "string",
            "pattern": "^task_[0-9a-f]{16}$"
          },
          "category": {
            "enum": [
              "timeout",
              "lease_expired_unknown",
              "retryable_http",
              "permanent_http",
              "unknown"
            ]
          }
        },
        "required": [
          "sequence",
          "at_ms",
          "kind"
        ]
      },
      "QueueAudit": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "events": {
            "type": "array",
            "maxItems": 256,
            "items": {
              "$ref": "#/components/schemas/QueueEvent"
            }
          },
          "capacity": {
            "const": 256
          },
          "last_sequence": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "events",
          "capacity",
          "last_sequence"
        ]
      },
      "RetentionReport": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "tasks_removed": {
            "type": "integer",
            "minimum": 0
          },
          "enqueue_keys_removed": {
            "type": "integer",
            "minimum": 0
          },
          "redrive_keys_removed": {
            "type": "integer",
            "minimum": 0
          },
          "audit_events_removed": {
            "type": "integer",
            "minimum": 0
          },
          "transport_records_removed": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "tasks_removed",
          "enqueue_keys_removed",
          "redrive_keys_removed",
          "audit_events_removed",
          "transport_records_removed"
        ]
      },
      "KeyAudit": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "events": {
            "type": "array",
            "maxItems": 256,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "actor_key_id": {
                  "type": "string"
                },
                "target_key_id": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                },
                "at_ms": {
                  "type": "integer"
                }
              },
              "required": [
                "actor_key_id",
                "target_key_id",
                "action",
                "at_ms"
              ]
            }
          }
        },
        "required": [
          "events"
        ]
      },
      "TaskList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "tasks": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/Task"
            }
          },
          "next_after": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "tasks",
          "next_after"
        ]
      },
      "KeyList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "keys": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/components/schemas/KeyView"
            }
          }
        },
        "required": [
          "keys"
        ]
      },
      "ApiError": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "error": {
            "enum": [
              "invalid_request",
              "forbidden",
              "destination_disabled",
              "idempotency_conflict",
              "not_found",
              "tenant_capacity",
              "stale_lease",
              "tenant_limited"
            ]
          },
          "reason": {
            "enum": [
              "active_tasks",
              "payload_bytes",
              "concurrency",
              "dispatch_rate"
            ]
          },
          "retry_after_ms": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "error"
        ]
      },
      "MetricCounts": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "admission_active_tasks_denied",
          "admission_payload_denied",
          "admission_retained_tasks_denied",
          "claim_references",
          "claim_ignored",
          "claim_missing",
          "claim_rate_denied",
          "claim_concurrency_denied",
          "claim_age_expired",
          "attempt_started",
          "attempt_succeeded",
          "attempt_timeout",
          "attempt_retryable_http",
          "attempt_permanent_http",
          "attempt_lease_expired_unknown",
          "attempt_unknown_failure",
          "stale_results_ignored",
          "clock_regressed_observations",
          "claim_paused",
          "paused_age_expired"
        ],
        "properties": {
          "admission_active_tasks_denied": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "admission_payload_denied": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "admission_retained_tasks_denied": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "claim_references": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "claim_ignored": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "claim_missing": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "claim_rate_denied": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "claim_concurrency_denied": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "claim_age_expired": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "attempt_started": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "attempt_succeeded": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "attempt_timeout": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "attempt_retryable_http": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "attempt_permanent_http": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "attempt_lease_expired_unknown": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "attempt_unknown_failure": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "stale_results_ignored": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "clock_regressed_observations": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "claim_paused": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "paused_age_expired": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          }
        }
      },
      "MetricSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "counts",
          "saturated",
          "attempt_completed",
          "attempt_errors_or_unknown",
          "attempt_error_ratio"
        ],
        "properties": {
          "counts": {
            "$ref": "#/components/schemas/MetricCounts"
          },
          "saturated": {
            "type": "boolean"
          },
          "attempt_completed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 6000000000000
          },
          "attempt_errors_or_unknown": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5000000000000
          },
          "attempt_error_ratio": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1
          }
        }
      },
      "MetricWindow": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "bucket_minutes",
          "start_inclusive_ms",
          "end_exclusive_ms",
          "observed_through_ms",
          "observations"
        ],
        "properties": {
          "bucket_minutes": {
            "type": "integer",
            "enum": [
              1,
              5,
              60
            ]
          },
          "start_inclusive_ms": {
            "type": "integer"
          },
          "end_exclusive_ms": {
            "type": "integer"
          },
          "observed_through_ms": {
            "type": "integer"
          },
          "observations": {
            "$ref": "#/components/schemas/MetricSummary"
          }
        }
      },
      "QueueMetrics": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sampled_at_ms",
          "effective_sample_ms",
          "last_observed_at_ms",
          "clock_regressed",
          "bucket_width_ms",
          "retained_bucket_capacity",
          "windows",
          "totals"
        ],
        "properties": {
          "sampled_at_ms": {
            "type": "integer"
          },
          "effective_sample_ms": {
            "type": "integer"
          },
          "last_observed_at_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "clock_regressed": {
            "type": "boolean"
          },
          "bucket_width_ms": {
            "const": 60000
          },
          "retained_bucket_capacity": {
            "const": 60
          },
          "windows": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": {
              "$ref": "#/components/schemas/MetricWindow"
            }
          },
          "totals": {
            "$ref": "#/components/schemas/MetricSummary"
          }
        }
      },
      "TransportReference": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "task_id": {
            "type": "string",
            "pattern": "^task_[0-9a-f]{16}$"
          },
          "generation": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "task_id",
          "generation"
        ]
      },
      "TransportReconciliation": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "at_ms": {
            "type": "integer"
          },
          "actor_label": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "classification": {
            "type": "string",
            "enum": [
              "missing",
              "stale_generation",
              "succeeded",
              "failed",
              "cancelled",
              "in_flight",
              "lease_awaiting_reconciliation",
              "waiting",
              "ready_outbox",
              "age_exhausted",
              "attempt_budget_exhausted"
            ]
          },
          "action": {
            "enum": [
              "outbox_confirmed",
              "lease_preserved",
              "schedule_preserved",
              "no_recovery",
              "budget_expired"
            ]
          }
        },
        "required": [
          "at_ms",
          "actor_label",
          "classification",
          "action"
        ]
      },
      "TransportRecord": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "record_id": {
            "type": "string",
            "pattern": "^dlq_[0-9a-f]{64}$"
          },
          "reference": {
            "$ref": "#/components/schemas/TransportReference"
          },
          "observed_at_ms": {
            "type": "integer"
          },
          "operator_reported": {
            "type": "boolean"
          },
          "transport_observed": {
            "type": "boolean"
          },
          "observed_classification": {
            "type": "string",
            "enum": [
              "missing",
              "stale_generation",
              "succeeded",
              "failed",
              "cancelled",
              "in_flight",
              "lease_awaiting_reconciliation",
              "waiting",
              "ready_outbox",
              "age_exhausted",
              "attempt_budget_exhausted"
            ]
          },
          "current_classification": {
            "type": "string",
            "enum": [
              "missing",
              "stale_generation",
              "succeeded",
              "failed",
              "cancelled",
              "in_flight",
              "lease_awaiting_reconciliation",
              "waiting",
              "ready_outbox",
              "age_exhausted",
              "attempt_budget_exhausted"
            ]
          },
          "current_status": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "scheduled",
              "ready",
              "running",
              "retry_wait",
              "succeeded",
              "failed",
              "cancelled",
              null
            ]
          },
          "current_generation": {
            "type": [
              "integer",
              "null"
            ]
          },
          "reconciliation": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TransportReconciliation"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "record_id",
          "reference",
          "observed_at_ms",
          "operator_reported",
          "transport_observed",
          "observed_classification",
          "current_classification",
          "current_status",
          "current_generation",
          "reconciliation"
        ]
      },
      "TransportReceipt": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "dead_letter": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TransportRecord"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "record_id": {
                    "type": "string",
                    "pattern": "^dlq_[0-9a-f]{64}$"
                  }
                },
                "required": [
                  "record_id"
                ]
              }
            ]
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "dead_letter",
          "replayed"
        ]
      },
      "TransportList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "records": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/TransportRecord"
            }
          },
          "next_after": {
            "type": [
              "string",
              "null"
            ]
          },
          "capacity": {
            "const": 128
          },
          "evicted_records": {
            "type": "integer",
            "minimum": 0
          },
          "sampled_at_ms": {
            "type": "integer"
          }
        },
        "required": [
          "records",
          "next_after",
          "capacity",
          "evicted_records",
          "sampled_at_ms"
        ]
      }
    },
    "responses": {
      "LocalError": {
        "description": "Local prototype error: plain UTF-8 text or structured JSON error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          },
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "LocalThrottle": {
        "description": "Tenant admission/capacity limit; suggested Retry-After does not guarantee admission.",
        "headers": {
          "Retry-After": {
            "description": "Integer seconds until a suggested retry; does not guarantee capacity",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          },
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema"
}
