{
  "openapi": "3.1.0",
  "info": {
    "title": "Synthetic Archetype API",
    "version": "1.0.0",
    "summary": "Synthetic users that test your product and tell you what they found.",
    "description": "Synthetic Archetype lets a team test a product against synthetic customers. A persona pool describes a kind of customer; a run spins a persona off a pool, writes scenarios for a goal on a site, and hands an actor (for example Claude driving a browser) a brief to play that persona. The actor posts back its steps, verdict and findings, which the web portal turns into reports. The API also manages saved features, hosted validation tests and scripted user acceptance (UAT) tests.\n\nThis is the API behind the Archetype Claude Code plugin and the web portal at https://www.syntheticarchetype.com. It describes the public surface those clients use; internal and admin routes are left out.\n\nAuthentication: send an Auth0 access token as 'Authorization: Bearer <token>'. Outside the portal, get one with the device flow: POST /api/oauth/device/code, have the user open verification_uri_complete, then poll POST /api/oauth/device/token. When the server cannot check tokens at all (Auth0 unconfigured or unreachable), a guarded route and POST /api/oauth/validate-token answer 503 with error auth_unavailable: retry later, do not log in again.\n\nErrors: routes return their own JSON error bodies (ErrorMessage, PersonaError, OAuthError schemas). Errors raised by the framework (unknown path, wrong method, malformed JSON, unhandled exceptions) return an RFC 9457 problem document with Content-Type application/problem+json and the members type, title, status, detail, code, hint, docs, error (the code) and message (the detail) (see the Problem schema).",
    "contact": {
      "name": "Synthetic Archetype",
      "url": "https://www.syntheticarchetype.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://api.syntheticarchetype.com",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "API documentation",
    "url": "https://docs.syntheticarchetype.com/api"
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Meta",
      "description": "Health and API description."
    },
    {
      "name": "Auth",
      "description": "Device login flow and token checks."
    },
    {
      "name": "Features",
      "description": "Product features to validate, with optional test targets."
    },
    {
      "name": "Runs",
      "description": "Persona-driven validation runs acted out by the Claude Code plugin."
    },
    {
      "name": "Personas",
      "description": "Synthetic personas, presets and persona pools."
    },
    {
      "name": "Validation tests",
      "description": "Hosted validation tests (plugin runs are stored as validation tests too)."
    },
    {
      "name": "UAT",
      "description": "Scripted user acceptance tests run by a browser agent."
    },
    {
      "name": "Bootstrap",
      "description": "Conversational drafting of tests."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Check that the API is up",
        "description": "Liveness check. Returns {'status': 'ok'} with 200 when the server is running. Needs no token. Call it to tell a network or deployment problem apart from an authentication or request problem.",
        "tags": [
          "Meta"
        ],
        "responses": {
          "200": {
            "description": "The server is up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "summary": "Get the OpenAPI description",
        "description": "Returns this OpenAPI 3.1 document. Needs no token and may be read from any origin. Call it to discover the available operations and their request and response shapes.",
        "tags": [
          "Meta"
        ],
        "responses": {
          "200": {
            "description": "The OpenAPI document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpecUnderApi",
        "summary": "Get the OpenAPI description (under /api)",
        "description": "Returns this OpenAPI 3.1 document. Needs no token and may be read from any origin. Call it to discover the available operations and their request and response shapes. Same document as GET /openapi.json.",
        "tags": [
          "Meta"
        ],
        "responses": {
          "200": {
            "description": "The OpenAPI document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/oauth/device/code": {
      "post": {
        "operationId": "startDeviceAuthorization",
        "summary": "Start the device login flow",
        "description": "Starts the OAuth 2.0 device authorization flow with Auth0, the only way to get a token for this API outside the web portal. Call it when you have no valid token (or any call returned 401). It returns a device_code to poll with and a verification URL for the user to open and approve. Needs no token.",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": false,
          "description": "Optional. Defaults suit this API; send an empty object or no body.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceCodeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Device code issued. Show verification_uri_complete (or verification_uri and user_code) to the user, then poll POST /api/oauth/device/token every 'interval' seconds with device_code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceCodeResponse"
                }
              }
            }
          },
          "4XX": {
            "description": "Auth0 rejected the request (for example an unknown audience or scope); Auth0's status and body are passed through.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "500": {
            "description": "The backend has no Auth0 device client configured (error auth0_not_configured).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "502": {
            "description": "Auth0 could not be reached or answered with something other than JSON (auth0_unreachable, auth0_bad_response). Retry in a moment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        },
        "security": []
      },
      "get": {
        "operationId": "startDeviceAuthorizationViaGet",
        "summary": "Start the device login flow (GET form)",
        "description": "Starts the OAuth 2.0 device authorization flow with Auth0, the only way to get a token for this API outside the web portal. Call it when you have no valid token (or any call returned 401). It returns a device_code to poll with and a verification URL for the user to open and approve. Needs no token. Same as the POST form, with scope and audience as query parameters.",
        "tags": [
          "Auth"
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "Space-separated scopes. Default 'openid profile email offline_access'.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "audience",
            "in": "query",
            "required": false,
            "description": "Override the configured Auth0 API audience.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Device code issued. Show verification_uri_complete (or verification_uri and user_code) to the user, then poll POST /api/oauth/device/token every 'interval' seconds with device_code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceCodeResponse"
                }
              }
            }
          },
          "4XX": {
            "description": "Auth0 rejected the request (for example an unknown audience or scope); Auth0's status and body are passed through.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "500": {
            "description": "The backend has no Auth0 device client configured (error auth0_not_configured).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "502": {
            "description": "Auth0 could not be reached or answered with something other than JSON (auth0_unreachable, auth0_bad_response). Retry in a moment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/oauth/device/token": {
      "post": {
        "operationId": "pollDeviceToken",
        "summary": "Poll for the device login token",
        "description": "Exchanges a device_code from POST /api/oauth/device/code for tokens. Call it repeatedly, waiting 'interval' seconds between calls, until it returns 200. While the user has not approved yet, Auth0 answers 403 with error 'authorization_pending' (keep polling) or 'slow_down' (poll less often); 'expired_token' or 'access_denied' mean start over. On 200, send access_token as 'Authorization: Bearer <access_token>' to every other endpoint. Needs no token. device_code may also be sent as a form field.",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The user approved; tokens issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "device_code missing (error missing_device_code), or an error passed through from Auth0.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "403": {
            "description": "Not approved yet or no longer valid: authorization_pending, slow_down, expired_token, access_denied (passed through from Auth0).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "4XX": {
            "description": "Any other Auth0 error, passed through.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "500": {
            "description": "The backend has no Auth0 device client configured.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "502": {
            "description": "Auth0 could not be reached or did not answer with JSON. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/oauth/validate-token": {
      "post": {
        "operationId": "validateToken",
        "summary": "Check an access token",
        "description": "Checks whether an access token is accepted by this API (same signature, audience and issuer checks as every protected endpoint) and returns its decoded claims. Call it before a long task to find out whether you must log in again. The token goes in the Authorization header (preferred) or in the body field 'token'. Does not require a valid token: an invalid one is the answer, not an error.",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The token is valid for this API.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenValid"
                }
              }
            }
          },
          "400": {
            "description": "No token was sent (error missing_token).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenInvalid"
                }
              }
            }
          },
          "401": {
            "description": "The token is invalid or expired (error invalid_token); reason says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenInvalid"
                }
              }
            }
          },
          "503": {
            "description": "The server cannot check tokens right now: Auth0 is unconfigured or unreachable (error auth_unavailable). Retry later; logging in again does not help.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenInvalid"
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ]
      },
      "get": {
        "operationId": "validateTokenViaGet",
        "summary": "Check an access token (GET form)",
        "description": "Checks whether an access token is accepted by this API (same signature, audience and issuer checks as every protected endpoint) and returns its decoded claims. Call it before a long task to find out whether you must log in again. The token goes in the Authorization header (preferred) or in the body field 'token'. Does not require a valid token: an invalid one is the answer, not an error. The GET form also accepts the token as the 'token' query parameter; prefer the header, since URLs are logged.",
        "tags": [
          "Auth"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": false,
            "description": "Token to check, when it is not in the Authorization header.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The token is valid for this API.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenValid"
                }
              }
            }
          },
          "400": {
            "description": "No token was sent (error missing_token).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenInvalid"
                }
              }
            }
          },
          "401": {
            "description": "The token is invalid or expired (error invalid_token); reason says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenInvalid"
                }
              }
            }
          },
          "503": {
            "description": "The server cannot check tokens right now: Auth0 is unconfigured or unreachable (error auth_unavailable). Retry later; logging in again does not help.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenInvalid"
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/oauth/me": {
      "get": {
        "operationId": "getCurrentUserId",
        "summary": "Show who the token belongs to",
        "description": "Returns the user id (Auth0 subject) the bearer token resolves to. Call it to confirm a token works against a protected endpoint and to learn the caller's user id.",
        "tags": [
          "Auth"
        ],
        "responses": {
          "200": {
            "description": "The token was accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/features": {
      "get": {
        "operationId": "listFeatures",
        "summary": "List the user's features",
        "description": "Lists every live feature the caller has saved, newest first. Call it to find a feature id (to pass as featureId when starting a run) or to see what a feature's saved goal and url are.",
        "tags": [
          "Features"
        ],
        "responses": {
          "200": {
            "description": "The caller's features.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      },
      "post": {
        "operationId": "createFeature",
        "summary": "Save a new feature",
        "description": "Saves a product feature. Give it a title, a description in fields, and optionally a test target (url, startPath, goal, successMilestone) so later runs need nothing else. Every field is optional. Returns the stored feature.",
        "tags": [
          "Features"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeatureInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureEnvelope"
                }
              }
            }
          },
          "400": {
            "description": "A target field is malformed (error invalid_feature_target); message says which and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureFailure"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "description": "The write failed (FeatureFailure), or an unhandled server error (Problem).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureFailure"
                }
              },
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/features/{feature_id}": {
      "parameters": [
        {
          "name": "feature_id",
          "in": "path",
          "required": true,
          "description": "Feature id (the _id from GET /api/features, a 24-character hex ObjectId). A malformed id is treated as not found.",
          "schema": {
            "type": "string"
          },
          "example": "665f0a1b2c3d4e5f60718293"
        }
      ],
      "get": {
        "operationId": "getFeature",
        "summary": "Get one feature",
        "description": "Returns one of the caller's features by id, including its fields and test target.",
        "tags": [
          "Features"
        ],
        "responses": {
          "200": {
            "description": "The feature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureEnvelope"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No live feature with this id belongs to the caller (error not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      },
      "put": {
        "operationId": "updateFeature",
        "summary": "Update a feature",
        "description": "Changes the given keys of one of the caller's features (title, blocks, fields, associatedPersonaPoolIds, url, startPath, goal, successMilestone); other keys are ignored. Sending a target field as an empty string or null clears it. Returns the updated feature.",
        "tags": [
          "Features"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeatureInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureEnvelope"
                }
              }
            }
          },
          "400": {
            "description": "A target field is malformed (error invalid_feature_target); message says which and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureFailure"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No live feature with this id belongs to the caller (error not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "description": "The write failed (FeatureFailure), or an unhandled server error (Problem).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureFailure"
                }
              },
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteFeature",
        "summary": "Delete a feature",
        "description": "Soft-deletes one of the caller's features: it disappears from listings and lookups. Only call it when the user asked to delete the feature.",
        "tags": [
          "Features"
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "description": "The id is malformed or the write failed (error failed_to_delete), or an unhandled server error (Problem).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureFailure"
                }
              },
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/plugin/runs": {
      "post": {
        "operationId": "createRun",
        "summary": "Start a persona-driven validation run",
        "description": "Assembles a validation run: picks or generates a synthetic persona (from a persona pool when poolId is given, otherwise from the user's replay sessions), fits the persona's need to the goal, writes test scenarios, and returns a brief and instructions for an actor (for example Claude driving a browser) to play that persona on the target site. Call it when the user wants to see how a kind of customer experiences a site or feature. Needs a goal or a featureId, and a url unless the feature has one saved. This is synchronous and slow: allow up to about 90 seconds. After acting out the scenarios, post the results once to POST /api/plugin/runs/{run_id}/results.",
        "tags": [
          "Runs"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunCreateRequest"
              },
              "example": {
                "goal": "Sign up for the newsletter",
                "url": "https://example.com",
                "poolId": "a1b2c3d4"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Run assembled; act it out, then post results.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunCreated"
                }
              }
            }
          },
          "400": {
            "description": "Bad input (error bad_request: no goal or featureId, no usable url, or an unusable pool), or error plugin_outdated when personaId is sent. message says what to fix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "The featureId or poolId does not exist for this user (error run_not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "409": {
            "description": "Conflict (error conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error (error internal_error). Safe to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "502": {
            "description": "Persona generation failed upstream (error persona_generation_failed). No run was created; safe to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "504": {
            "description": "Assembly ran out of its time budget (error run_assembly_timeout). No run was created and no tester was added; retry in a moment, or retry without poolId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    },
    "/api/plugin/runs/{run_id}": {
      "parameters": [
        {
          "name": "run_id",
          "in": "path",
          "required": true,
          "description": "Run id (runId from POST /api/plugin/runs).",
          "schema": {
            "type": "string"
          },
          "example": "665f0a1b2c3d4e5f60718293"
        }
      ],
      "get": {
        "operationId": "getRun",
        "summary": "Get a run's status and feedback",
        "description": "Returns a run's status (running, completed, failed), progress, the feedback the actor posted, screenshot counts and whether analytics are ready. Call it to check on or read back a run started with POST /api/plugin/runs.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "200": {
            "description": "The run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunStatus"
                }
              }
            }
          },
          "400": {
            "description": "Bad request (error bad_request).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such run for this user (error run_not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "409": {
            "description": "Conflict (error conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error (error internal_error). Safe to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "502": {
            "description": "Upstream persona error (error persona_generation_failed). Safe to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    },
    "/api/plugin/runs/{run_id}/results": {
      "parameters": [
        {
          "name": "run_id",
          "in": "path",
          "required": true,
          "description": "Run id (runId from POST /api/plugin/runs).",
          "schema": {
            "type": "string"
          },
          "example": "665f0a1b2c3d4e5f60718293"
        }
      ],
      "post": {
        "operationId": "submitRunResults",
        "summary": "Submit the results of a run",
        "description": "Stores what the actor did and found during a run: the step log, a verdict and summary, per-scenario results and findings with optional evidence. Call it once, when the run is over, with the sessionId from POST /api/plugin/runs. The payload is validated before anything is written, so a 400 leaves the run untouched: fix the payload as the message says and post again. A run that already completed answers 409; a failed run may be posted again.",
        "tags": [
          "Runs"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunResultsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored. message describes what was kept.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunResultsAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Invalid payload or a sessionId that does not match the run (error bad_request); message names the field to fix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such run for this user (error run_not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "409": {
            "description": "The run is already completed (error conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error (error internal_error). Safe to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "502": {
            "description": "Upstream persona error (error persona_generation_failed); results were not stored. Safe to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    },
    "/api/persona": {
      "get": {
        "operationId": "listPersonas",
        "summary": "List the user's personas",
        "description": "Lists the synthetic personas saved for the caller, with demographics, traits and story. Call it to show the user their testers. Personas are grouped into pools for runs; to choose a tester for a run, list pools instead (GET /api/persona/pools).",
        "tags": [
          "Personas"
        ],
        "parameters": [
          {
            "name": "segment",
            "in": "query",
            "required": false,
            "description": "Only personas of this segment.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source_type",
            "in": "query",
            "required": false,
            "description": "Only personas of this source type.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size (default 100). Non-numeric values fall back to the default.",
            "schema": {
              "type": "integer",
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Items to skip (default 0).",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The caller's personas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaList"
                }
              }
            }
          },
          "400": {
            "description": "Validation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/persona/generate": {
      "post": {
        "operationId": "generatePersonas",
        "summary": "Generate personas from a distribution",
        "description": "Generates synthetic personas from a parsed demographic distribution and returns them without saving. Low level: the input must already be the parser's distribution structure. To create a tester from a plain description, use POST /api/persona/vibe; to create a pool, use POST /api/persona/custom then POST /api/persona/pool/create. Takes several seconds (one model call per persona).",
        "tags": [
          "Personas"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GeneratePersonaRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The generated personas.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "description": "Generated persona objects (meta, objective, subjective, descriptive sections and persona_need). Open ended."
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (invalid_request or validation_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "501": {
            "description": "Generator not available.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/persona/vibe": {
      "post": {
        "operationId": "createVibePersona",
        "summary": "Preview or save a persona from a description",
        "description": "Creates one synthetic persona from a plain-language description of the tester (vibePrompt) or from trait sliders (mode manual). With previewOnly true it returns 1 to 5 unsaved examples (200) so the user can pick a direction; otherwise it saves one persona into poolId or the user's default pool (201). Slow: one model call per example.",
        "tags": [
          "Personas"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VibePersonaRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preview only: unsaved examples.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaPreviewList"
                }
              }
            }
          },
          "201": {
            "description": "Saved persona.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Persona"
                }
              }
            }
          },
          "400": {
            "description": "vibePrompt missing in vibe mode (invalid_request), or validation_error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Referenced pool or preset not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/persona/custom": {
      "post": {
        "operationId": "createPersonaPreset",
        "summary": "Save a persona preset (pool spec)",
        "description": "Saves a customized persona preset, the spec a pool spins fresh testers off from, and generates one reference persona for it. This is step 1 of creating a pool: pass the returned persona.personaId in selectedPersonaIds to POST /api/persona/pool/create. Slow: one model call.",
        "tags": [
          "Personas"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomPersonaRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Preset and reference persona saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomPersonaCreated"
                }
              }
            }
          },
          "400": {
            "description": "Missing vibePrompt (vibe mode) or radarConfig (manual mode) (validation_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "501": {
            "description": "Not available on this server.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/persona/pool/create": {
      "post": {
        "operationId": "createPersonaPool",
        "summary": "Create a persona pool",
        "description": "Creates an empty persona pool. With selectedPersonaIds holding a preset's reference persona (from POST /api/persona/custom) the pool remembers that preset as its spec, and each run spins off a fresh tester from it. The new pool is named Pool_<hex>; rename it with PATCH /api/persona/pools/{pool_id}. Returns the pool id.",
        "tags": [
          "Personas"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolCreateRequest"
              },
              "example": {
                "selectedPersonaIds": [
                  "9f2c..."
                ],
                "archetypeName": "Busy parents",
                "description": "Parents shopping on their phone at night"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Pool created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolCreated"
                }
              }
            }
          },
          "400": {
            "description": "Backend form without pool_name and segment_name, or no user (invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "user_id in the body is not the signed in user (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/persona/pools": {
      "get": {
        "operationId": "listPersonaPools",
        "summary": "List the user's persona pools",
        "description": "Lists the caller's persona pools with member counts, specs and usage. Call it to find a pool id to pass as poolId to POST /api/plugin/runs, resolving the pool the user names.",
        "tags": [
          "Personas"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size (default 50).",
            "schema": {
              "type": "integer",
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Items to skip (default 0).",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The caller's pools.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolList"
                }
              }
            }
          },
          "400": {
            "description": "Validation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/persona/pools/{pool_id}": {
      "parameters": [
        {
          "name": "pool_id",
          "in": "path",
          "required": true,
          "description": "Pool id (poolId from GET /api/persona/pools, or personaPoolId from POST /api/persona/pool/create).",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getPersonaPool",
        "summary": "Get one persona pool with its members",
        "description": "Returns one of the caller's pools with every member persona and its specs.",
        "tags": [
          "Personas"
        ],
        "responses": {
          "200": {
            "description": "The pool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolDetail"
                }
              }
            }
          },
          "400": {
            "description": "Validation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such pool for this user (not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updatePersonaPool",
        "summary": "Update or rename a persona pool",
        "description": "Changes a pool's name, description, visibility, tags, metadata, active members or linked features. Send only the keys to change. Used to rename a pool right after creating it.",
        "tags": [
          "Personas"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated pool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolDetail"
                }
              }
            }
          },
          "400": {
            "description": "No supported field in the body, or the body is not a JSON object (invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such pool for this user (not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "updatePersonaPoolViaPost",
        "summary": "Update or rename a persona pool (POST alias)",
        "description": "Changes a pool's name, description, visibility, tags, metadata, active members or linked features. Send only the keys to change. Used to rename a pool right after creating it. Same as PATCH, for clients that cannot send PATCH.",
        "tags": [
          "Personas"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated pool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolDetail"
                }
              }
            }
          },
          "400": {
            "description": "No supported field in the body, or the body is not a JSON object (invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such pool for this user (not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deletePersonaPool",
        "summary": "Delete a persona pool",
        "description": "Soft-deletes one of the caller's pools. Only call it when the user asked to delete the pool.",
        "tags": [
          "Personas"
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolDeleted"
                }
              }
            }
          },
          "400": {
            "description": "Validation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such pool for this user (not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          },
          "500": {
            "description": "Server error (error internal_error). details.message is a generic sentence; quote request_id when reporting it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/validation-tests/{test_id}": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "Validation test id.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getValidationTest",
        "summary": "Get a validation test",
        "description": "Returns one of the caller's hosted validation tests (product, feature, goal or hypothesis, persona pool, status). Plugin runs are validation tests too: a runId works as test_id here.",
        "tags": [
          "Validation tests"
        ],
        "responses": {
          "200": {
            "description": "The test.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationTest"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      }
    },
    "/api/validation-tests/{test_id}/status": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "Validation test id.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getValidationTestStatus",
        "summary": "Poll a validation test's status",
        "description": "Returns the status of one of the caller's validation tests and a coarse progress number. Poll it every few seconds while a hosted test runs; stop at completed or failed.",
        "tags": [
          "Validation tests"
        ],
        "responses": {
          "200": {
            "description": "Current status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationTestStatus"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      }
    },
    "/api/validation-tests/{test_id}/results": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "Validation test id.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getValidationTestResults",
        "summary": "Get a hypothesis test's results (deprecated)",
        "description": "Returns the verdict of a hypothesis-mode validation test: supported, rejected or inconclusive, with confidence, evidence, per-persona votes and recommendations. Deprecated in favour of GET /api/analytics/tests/{test_id}/summary, which is not described here; still served.",
        "tags": [
          "Validation tests"
        ],
        "responses": {
          "200": {
            "description": "Results (fields are defaults when the test has not finished).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationTestResults"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        },
        "deprecated": true
      }
    },
    "/api/uat/tests": {
      "get": {
        "operationId": "listUatTests",
        "summary": "List the user's UAT tests",
        "description": "Lists the caller's user acceptance tests (scripted test cases run by a browser agent) with status and case counts.",
        "tags": [
          "UAT"
        ],
        "responses": {
          "200": {
            "description": "The caller's UAT tests.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatTestList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      },
      "post": {
        "operationId": "createUatTest",
        "summary": "Create a UAT test",
        "description": "Saves a draft user acceptance test: a prototype URL and test cases, each with a title, steps and an expected result. Nothing runs until POST /api/uat/tests/{test_id}/run. To draft the cases from a conversation, use POST /api/bootstrap/ with mode uat first.",
        "tags": [
          "UAT"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UatTestInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Draft created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatTestCreated"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed (error bad_request); message says what is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "description": "The write failed ({'error': 'Failed to create UAT test'}), or an unhandled server error (Problem).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              },
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/uat/tests/{test_id}": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "UAT test id (testId from POST /api/uat/tests).",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getUatTest",
        "summary": "Get a UAT test",
        "description": "Returns one of the caller's UAT tests with its cases, defects, progress and results.",
        "tags": [
          "UAT"
        ],
        "responses": {
          "200": {
            "description": "The test.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatTest"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      },
      "put": {
        "operationId": "updateUatTest",
        "summary": "Update a UAT test",
        "description": "Replaces the given parts of a UAT test (prototypeUrl, featureId, testCases, defects, storedCredentials). Not allowed while the test is running (409).",
        "tags": [
          "UAT"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UatTestInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated test.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatTest"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "409": {
            "description": "The test is running (error conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      },
      "delete": {
        "operationId": "deleteUatTest",
        "summary": "Delete a UAT test",
        "description": "Soft-deletes one of the caller's UAT tests. Only call it when the user asked to delete the test.",
        "tags": [
          "UAT"
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "const": true
                    },
                    "testId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "deleted",
                    "testId"
                  ],
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      }
    },
    "/api/uat/tests/{test_id}/run": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "UAT test id (testId from POST /api/uat/tests).",
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "runUatTest",
        "summary": "Run a UAT test",
        "description": "Starts running a draft, completed or failed UAT test in the background and returns at once (202). Follow it with GET /api/uat/tests/{test_id}/wait-status (long poll) or /status, then read /results.",
        "tags": [
          "UAT"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UatRunRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Started.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatRunStarted"
                }
              }
            }
          },
          "400": {
            "description": "The test has no cases (error bad_request).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "409": {
            "description": "Already running (error conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      }
    },
    "/api/uat/tests/{test_id}/status": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "UAT test id (testId from POST /api/uat/tests).",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getUatTestStatus",
        "summary": "Poll a UAT test's status",
        "description": "Returns a UAT test's status, progress, current step and case counts. Cheap; poll it every few seconds, or use /wait-status to wait for changes.",
        "tags": [
          "UAT"
        ],
        "responses": {
          "200": {
            "description": "Current status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatStatus"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      }
    },
    "/api/uat/tests/{test_id}/results": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "UAT test id (testId from POST /api/uat/tests).",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getUatTestResults",
        "summary": "Get a UAT test's results",
        "description": "Returns the full test with per-case results once a run has finished. Answers 202 while it is still running and 404 if it never ran.",
        "tags": [
          "UAT"
        ],
        "responses": {
          "200": {
            "description": "Finished (completed or failed). A failed run with no results has 'error' set and results null.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatTest"
                }
              }
            }
          },
          "202": {
            "description": "Still running; try again later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatRunning"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user, or it has not been run yet (error 'Test has not been run yet').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      }
    },
    "/api/uat/tests/{test_id}/wait-status": {
      "parameters": [
        {
          "name": "test_id",
          "in": "path",
          "required": true,
          "description": "UAT test id (testId from POST /api/uat/tests).",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "waitForUatTestStatus",
        "summary": "Wait for the next UAT status event (long poll)",
        "description": "Long poll: without cursor it returns the latest status event at once; with cursor it waits up to about 25 seconds for the next event and answers 204 if none came. Loop on it, passing back the cursor of the last event, until status is completed or failed.",
        "tags": [
          "UAT"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Cursor of the last event seen. Omit on the first call.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "runEpoch",
            "in": "query",
            "required": false,
            "description": "Run to follow (runEpoch from POST /run). Defaults to the test's latest run. Must be an integer.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A status event.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UatEvent"
                }
              }
            }
          },
          "204": {
            "description": "No new event within the wait; call again with the same cursor."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No such test for this user (error 'Test not found').",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "502": {
            "description": "The event stream failed (error event_stream_failure).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "503": {
            "description": "The event stream is not configured on this server (error event_stream_unavailable); poll /status instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerProblem"
          }
        }
      }
    },
    "/api/bootstrap/": {
      "post": {
        "operationId": "bootstrapTestDraft",
        "summary": "Draft a UAT or validation test from a conversation",
        "description": "Conversational helper: send the chat so far (and optionally a PDF or markdown spec) and get the assistant's next reply plus whatever it could draft: UAT test cases, prototype URL and credentials in mode uat, or a validation test configuration in mode validation. Nothing is saved; create the test with POST /api/uat/tests. Note the trailing slash: POST /api/bootstrap answers 308 to this path. Takes several seconds (one model call).",
        "tags": [
          "Bootstrap"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BootstrapRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The reply and any draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BootstrapResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid mode, empty or too many messages, or an unsupported file type (error is the message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "description": "A PDF is larger than 10 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "422": {
            "description": "A PDF's base64 content is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "description": "Drafting failed ({'error': 'Bootstrap failed. Please try again.'}). Safe to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Auth0 RS256 access token for this API's audience, validated against the tenant's JWKS (signature, audience, issuer; about 2 minutes of clock skew tolerated). Obtain one through the device flow (POST /api/oauth/device/code then POST /api/oauth/device/token) or by signing in to the web portal."
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "https://docs.syntheticarchetype.com/api#errors",
            "description": "Always the Errors section of the API docs; branch on code, not on type."
          },
          "title": {
            "type": "string",
            "description": "Short, human readable name of the HTTP status, for example 'Not Found'."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code, repeated from the response."
          },
          "detail": {
            "type": "string",
            "description": "What went wrong with this request, in one sentence. For a 500 this is a generic sentence: exception text is never exposed."
          },
          "instance": {
            "type": "string",
            "description": "Path of the request that failed."
          },
          "code": {
            "type": "string",
            "description": "Stable snake_case error code to branch on: the snake_case HTTP status name (not_found, method_not_allowed, bad_request, unsupported_media_type, too_many_requests, ...), except 500, which is internal_error."
          },
          "hint": {
            "type": "string",
            "description": "One sentence telling the caller how to recover."
          },
          "docs": {
            "type": "string",
            "format": "uri",
            "description": "Link to the API documentation."
          },
          "error": {
            "type": "string",
            "description": "Same value as code, in the {error, message} shape every route error uses: branch on it."
          },
          "message": {
            "type": "string",
            "description": "Same text as detail, for clients that show body.message."
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "detail",
          "code",
          "hint",
          "docs",
          "error",
          "message"
        ],
        "description": "RFC 9457 problem document (Content-Type application/problem+json). Returned for errors raised by the framework rather than by a route: an unknown path (404), a method the path does not accept (405, with an Allow header), a malformed JSON body on routes that parse strictly (400 or 415), and any unhandled server exception (500). Routes that build their own error bodies keep them; see ErrorMessage and PersonaError.",
        "additionalProperties": true
      },
      "ErrorMessage": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine slug or short phrase, for example 'run_not_found', 'not_found', 'Test not found', 'Invalid token'."
          },
          "message": {
            "type": "string",
            "description": "Plain-language explanation and, on plugin routes, what to do next. Not present on every route."
          }
        },
        "required": [
          "error"
        ],
        "description": "Error body built by a route itself (Content-Type application/json). The authentication guard returns this shape for every 401: {'error': 'Authorization header missing', 'message': 'No token provided'} or {'error': 'Invalid token', 'message': ...}.",
        "additionalProperties": true
      },
      "PersonaError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Error code: invalid_request, unauthorized, validation_error, not_found, conflict, not_implemented or internal_error."
          },
          "details": {
            "type": "object",
            "additionalProperties": true,
            "description": "Extra context, usually {'message': '<text>'}. On 500 the message is a generic sentence and never carries the exception text."
          },
          "request_id": {
            "type": "string",
            "description": "Random id for this request, for support."
          }
        },
        "required": [
          "error"
        ],
        "description": "Error body returned by the /api/persona routes (Content-Type application/json).",
        "additionalProperties": true
      },
      "OAuthError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Error code. Backend codes: auth0_not_configured, auth0_unreachable, auth0_bad_response, missing_device_code. Auth0 codes passed through verbatim: authorization_pending, slow_down, expired_token, access_denied, invalid_grant, and others."
          },
          "error_description": {
            "type": "string",
            "description": "Auth0's description, when the error came from Auth0."
          },
          "message": {
            "type": "string",
            "description": "Backend explanation, when the error came from the backend."
          }
        },
        "required": [
          "error"
        ],
        "description": "Error body of the device flow routes. Errors from Auth0 are passed through with Auth0's status code and body.",
        "additionalProperties": true
      },
      "Health": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "const": "ok"
          }
        },
        "required": [
          "status"
        ],
        "additionalProperties": true
      },
      "FeatureFields": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "strategic-goals": {
            "type": "string"
          },
          "expected-usage": {
            "type": "string"
          }
        },
        "description": "Free-text fields of a feature. The three keys shown are the defaults; other keys are stored as sent.",
        "additionalProperties": true
      },
      "FeatureInput": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Feature title. Defaults to 'New Feature' on create."
          },
          "blocks": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "Editor blocks, for example [{'id': 'block-1', 'type': 'text', 'content': ''}]."
          },
          "fields": {
            "$ref": "#/components/schemas/FeatureFields"
          },
          "associatedPersonaPoolIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Persona pool ids linked to this feature."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048,
            "description": "Full http or https address of the site a run should test. Empty string or null clears it on update."
          },
          "startPath": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512,
            "description": "Path to start on, beginning with '/', with no spaces, '?' or '#', for example /pages/thank-you. Empty string or null clears it on update."
          },
          "goal": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000,
            "description": "What a run should get done. No control characters. Empty string or null clears it on update."
          },
          "successMilestone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120,
            "description": "The event that proves the goal was reached. No control characters. Empty string or null clears it on update."
          }
        },
        "description": "Body for creating or updating a feature. Every key is optional. On update only title, blocks, fields, associatedPersonaPoolIds and the four target fields are applied.",
        "additionalProperties": true
      },
      "Feature": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Feature id (a 24-character MongoDB ObjectId). Use it as feature_id and as featureId when starting a run."
          },
          "userId": {
            "type": "string",
            "description": "Owner (Auth0 user id)."
          },
          "title": {
            "type": "string"
          },
          "blocks": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "fields": {
            "$ref": "#/components/schemas/FeatureFields"
          },
          "associatedPersonaPoolIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "url": {
            "type": "string"
          },
          "startPath": {
            "type": "string"
          },
          "goal": {
            "type": "string"
          },
          "successMilestone": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp."
          },
          "updatedAt": {
            "type": "string",
            "description": "ISO 8601 timestamp."
          },
          "deletedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null for live features."
          }
        },
        "required": [
          "_id",
          "title"
        ],
        "description": "A product feature saved by the user. The target fields (url, startPath, goal, successMilestone) are present only when set.",
        "additionalProperties": true
      },
      "FeatureEnvelope": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "feature": {
            "$ref": "#/components/schemas/Feature"
          }
        },
        "required": [
          "ok",
          "feature"
        ],
        "additionalProperties": true
      },
      "FeatureList": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Feature"
            }
          }
        },
        "required": [
          "ok",
          "features"
        ],
        "description": "Features owned by the caller, newest first.",
        "additionalProperties": true
      },
      "FeatureFailure": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string",
            "description": "invalid_feature_target, failed_to_create, failed_to_update or failed_to_delete."
          },
          "message": {
            "type": "string",
            "description": "Present for invalid_feature_target: which field is wrong and how to fix it."
          }
        },
        "required": [
          "ok",
          "error"
        ],
        "additionalProperties": true
      },
      "RunCreateRequest": {
        "type": "object",
        "properties": {
          "goal": {
            "type": "string",
            "description": "What the persona should try to do. Required unless featureId is given (the feature's goal or description is used)."
          },
          "featureId": {
            "type": "string",
            "description": "Id of a saved feature (GET /api/features). Supplies the goal, url and start path when they are not given."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Full http or https address of the site to test. Required unless the feature has a url saved."
          },
          "poolId": {
            "type": "string",
            "description": "Persona pool to draw the tester from (GET /api/persona/pools). A pool with a spec spins off one fresh tester for this run; a pool without one picks an existing member. Omit to run as the persona derived from the user's replay sessions. pool_id is accepted too."
          },
          "personaId": {
            "deprecated": true,
            "description": "Rejected: sending any non-null value returns 400 plugin_outdated. Personas are chosen through poolId."
          }
        },
        "description": "Either goal or featureId is required.",
        "additionalProperties": true
      },
      "Scenario": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Scenario id, SC-1, SC-2, ... Use it as scenarioId in steps, scenarioResults and findings."
          },
          "title": {
            "type": "string"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "expectedResult": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "title",
          "steps"
        ],
        "description": "One scenario of the run. Scenarios run in order in one browser session.",
        "additionalProperties": true
      },
      "RunPersona": {
        "type": "object",
        "properties": {
          "personaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "story": {
            "type": "string"
          },
          "personaCard": {
            "type": "string",
            "description": "Rendered seed card describing the persona, for the actor to role-play."
          },
          "traits": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            },
            "description": "Trait name to score."
          },
          "personaNeed": {
            "type": [
              "string",
              "null"
            ],
            "description": "What this persona needs from the product, fitted to this run's goal."
          },
          "needSource": {
            "type": [
              "string",
              "null"
            ],
            "description": "How personaNeed was produced."
          },
          "alignmentScore": {
            "type": [
              "number",
              "null"
            ],
            "description": "How well the persona fits the goal."
          }
        },
        "additionalProperties": true
      },
      "RunCreated": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "string",
            "description": "Run id. Use it for GET /api/plugin/runs/{run_id} and POST /api/plugin/runs/{run_id}/results."
          },
          "sessionId": {
            "type": "string",
            "description": "Session id (plugin-<hex>). Must be sent back as sessionId with the results."
          },
          "brief": {
            "type": "string",
            "description": "Natural-language brief for the actor."
          },
          "persona": {
            "$ref": "#/components/schemas/RunPersona"
          },
          "pool": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "poolId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "spunOff": {
                    "type": "boolean",
                    "description": "True when the tester was generated for this run, false when an existing member was chosen."
                  }
                },
                "additionalProperties": true
              },
              {
                "type": "null"
              }
            ],
            "description": "Pool provenance when poolId was given, otherwise null."
          },
          "instructions": {
            "type": "object",
            "properties": {
              "targetUrl": {
                "type": "string"
              },
              "goal": {
                "type": "string"
              },
              "scenarios": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Scenario"
                }
              },
              "conduct": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Rules the actor must follow."
              }
            },
            "additionalProperties": true
          },
          "reporting": {
            "type": "object",
            "properties": {
              "resultsEndpoint": {
                "type": "string",
                "description": "Path to POST the results to."
              },
              "requiredFields": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "['sessionId', 'status', 'steps', 'feedback']."
              }
            },
            "additionalProperties": true
          }
        },
        "required": [
          "runId",
          "sessionId",
          "brief",
          "persona",
          "pool",
          "instructions",
          "reporting"
        ],
        "additionalProperties": true
      },
      "RunStep": {
        "type": "object",
        "properties": {
          "seq": {
            "type": "integer",
            "description": "Step number, a whole number (1, 2, 3, ...)."
          },
          "actionText": {
            "type": "string",
            "description": "What the actor did."
          },
          "narration": {
            "type": "string",
            "description": "First-person narration in the persona's voice."
          },
          "observationPageType": {
            "type": "string",
            "description": "Kind of page observed, for example landing, form, checkout."
          },
          "success": {
            "type": "boolean",
            "description": "Whether the step worked."
          },
          "url": {
            "type": "string",
            "description": "Page URL at this step."
          },
          "error": {
            "type": "string",
            "description": "Error seen, if any."
          },
          "scenarioId": {
            "type": "string",
            "description": "Scenario this step belongs to (SC-1, ...)."
          },
          "screenshotB64": {
            "type": "string",
            "description": "Base64 screenshot. At most 6 per run, each at most 1 MB decoded; extras are dropped and counted, not rejected."
          }
        },
        "required": [
          "seq",
          "actionText",
          "narration",
          "observationPageType",
          "success"
        ],
        "additionalProperties": true
      },
      "FindingEvidence": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2048,
            "description": "Where the finding was seen."
          },
          "selector": {
            "type": "string",
            "maxLength": 512,
            "description": "Element involved."
          },
          "quote": {
            "type": "string",
            "maxLength": 1000,
            "description": "Exact on-screen text."
          }
        },
        "description": "Optional evidence. Non-string values and unknown keys are dropped, strings are trimmed to the limits; evidence is never a reason to reject the results.",
        "additionalProperties": true
      },
      "Finding": {
        "type": "object",
        "properties": {
          "scenarioId": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "description": "Conventionally bug, ux, content, performance or other. Not validated on ingest."
          },
          "severity": {
            "type": "string",
            "description": "Conventionally critical, high, medium or low. Not validated on ingest."
          },
          "description": {
            "type": "string"
          },
          "evidenceStepSeq": {
            "type": "integer",
            "description": "seq of the step that shows the finding."
          },
          "evidence": {
            "$ref": "#/components/schemas/FindingEvidence"
          }
        },
        "additionalProperties": true
      },
      "RunFeedback": {
        "type": "object",
        "properties": {
          "verdict": {
            "type": "string",
            "description": "Required. Conventionally pass, fail or mixed (reports show only these three)."
          },
          "summary": {
            "type": "string",
            "description": "Required. What happened, in a few sentences."
          },
          "scenarioResults": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "scenarioId": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "description": "pass, fail or blocked."
                },
                "actualResult": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          },
          "findings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Finding"
            }
          },
          "personaReaction": {
            "description": "Free-form reaction of the persona. Stored as sent."
          }
        },
        "required": [
          "verdict",
          "summary"
        ],
        "description": "The actor's feedback. Stored as sent apart from cleaning finding evidence; keys not listed here are kept.",
        "additionalProperties": true
      },
      "RunResultsRequest": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "The sessionId returned by POST /api/plugin/runs. Must match the run."
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "failed",
              "aborted"
            ],
            "description": "Final outcome of the run."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunStep"
            }
          },
          "feedback": {
            "$ref": "#/components/schemas/RunFeedback"
          },
          "durationSeconds": {
            "type": "number",
            "description": "Sent by the plugin; currently not stored."
          }
        },
        "required": [
          "sessionId",
          "status",
          "feedback"
        ],
        "additionalProperties": true
      },
      "RunResultsAccepted": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "runId": {
            "type": "string"
          },
          "testStatus": {
            "type": "string",
            "enum": [
              "completed",
              "failed"
            ]
          },
          "message": {
            "type": "string",
            "description": "Plain-language confirmation of what was stored."
          },
          "summary": {
            "type": "object",
            "properties": {
              "steps": {
                "type": "integer"
              },
              "findings": {
                "type": "integer"
              },
              "verdict": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "additionalProperties": true
          }
        },
        "required": [
          "ok",
          "runId",
          "testStatus",
          "message",
          "summary"
        ],
        "additionalProperties": true
      },
      "RunStatus": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "running, completed or failed."
          },
          "progress": {
            "type": "integer",
            "description": "0 while running, 100 once results are in."
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "feedback": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RunFeedback"
              },
              {
                "type": "null"
              }
            ],
            "description": "The feedback the actor posted, or null before results arrive."
          },
          "screenshots": {
            "type": "object",
            "properties": {
              "kept": {
                "type": "integer"
              },
              "dropped": {
                "type": "integer"
              }
            },
            "additionalProperties": true
          },
          "analyticsReady": {
            "type": "boolean",
            "description": "True once post-session analytics exist for the run."
          }
        },
        "required": [
          "runId",
          "status",
          "progress",
          "screenshots",
          "analyticsReady"
        ],
        "additionalProperties": true
      },
      "DeviceCodeRequest": {
        "type": "object",
        "properties": {
          "scope": {
            "type": "string",
            "description": "Space-separated scopes. Default 'openid profile email offline_access'."
          },
          "audience": {
            "type": "string",
            "description": "Override the configured Auth0 API audience. Leave unset to get a token this API accepts."
          }
        },
        "additionalProperties": true
      },
      "DeviceCodeResponse": {
        "type": "object",
        "properties": {
          "device_code": {
            "type": "string",
            "description": "Secret code to poll POST /api/oauth/device/token with. Do not show it to the user."
          },
          "user_code": {
            "type": "string",
            "description": "Short code the user confirms in the browser."
          },
          "verification_uri": {
            "type": "string",
            "description": "Page where the user enters user_code."
          },
          "verification_uri_complete": {
            "type": "string",
            "description": "Same page with user_code filled in. Show or open this for the user."
          },
          "expires_in": {
            "type": "integer",
            "description": "Seconds until device_code expires."
          },
          "interval": {
            "type": "integer",
            "description": "Minimum seconds between polls."
          }
        },
        "description": "Auth0's device authorization response, passed through. verification_uri and verification_uri_complete may be rewritten to the product's own domain.",
        "additionalProperties": true
      },
      "DeviceTokenRequest": {
        "type": "object",
        "properties": {
          "device_code": {
            "type": "string",
            "description": "device_code from POST /api/oauth/device/code."
          }
        },
        "required": [
          "device_code"
        ],
        "additionalProperties": true
      },
      "TokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "description": "Auth0 RS256 JWT. Send it as 'Authorization: Bearer <access_token>'."
          },
          "id_token": {
            "type": "string"
          },
          "refresh_token": {
            "type": "string",
            "description": "Present when offline_access was requested."
          },
          "token_type": {
            "type": "string"
          },
          "expires_in": {
            "type": "integer"
          },
          "scope": {
            "type": "string"
          }
        },
        "required": [
          "access_token"
        ],
        "description": "Auth0's token response, passed through.",
        "additionalProperties": true
      },
      "ValidateTokenRequest": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "Token to check, when it is not sent in the Authorization header."
          }
        },
        "additionalProperties": true
      },
      "TokenValid": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean",
            "const": true
          },
          "user_id": {
            "type": "string",
            "description": "Token subject (Auth0 user id)."
          },
          "audience": {
            "type": [
              "string",
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "issuer": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Unix time."
          },
          "issued_at": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Unix time."
          },
          "scope": {
            "type": [
              "string",
              "null"
            ]
          },
          "payload": {
            "type": "object",
            "additionalProperties": true,
            "description": "All decoded claims."
          }
        },
        "required": [
          "valid",
          "user_id",
          "payload"
        ],
        "additionalProperties": true
      },
      "TokenInvalid": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string",
            "description": "missing_token (400), invalid_token (401) or auth_unavailable (503)."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why validation failed, for example an ExpiredSignatureError message."
          }
        },
        "required": [
          "valid",
          "error"
        ],
        "additionalProperties": true
      },
      "Me": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "user_id"
        ],
        "additionalProperties": true
      },
      "PersonaControls": {
        "type": "object",
        "properties": {
          "ageRange": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[min, max] age."
          },
          "skillsRange": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[min, max] skill level."
          },
          "occupation": {
            "type": "string"
          },
          "education": {
            "type": "string"
          }
        },
        "description": "Demographic controls for generation. The keys shown are the ones the plugin sends; others are passed to the generator as sent.",
        "additionalProperties": true
      },
      "PersonaListItem": {
        "type": "object",
        "properties": {
          "personaId": {
            "type": "string"
          },
          "customPersonaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "customPersonaLabel": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "story": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "controls": {
            "type": "object",
            "additionalProperties": true
          },
          "preview": {
            "type": "object",
            "additionalProperties": true
          },
          "previewSnapshot": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "vibePromptSummary": {
            "type": [
              "string",
              "null"
            ]
          },
          "demographics": {
            "type": "object",
            "additionalProperties": true
          },
          "psychographics": {
            "type": "object",
            "additionalProperties": true
          },
          "behavioralTraits": {
            "type": "object",
            "additionalProperties": true
          },
          "goalsMotivations": {
            "type": "array",
            "items": {}
          },
          "painPoints": {
            "type": "array",
            "items": {}
          },
          "preferredChannels": {
            "type": "array",
            "items": {}
          },
          "presetMeta": {
            "type": "object",
            "additionalProperties": true
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "How the persona was made, for example vibe, manual, replay."
          }
        },
        "required": [
          "personaId",
          "name"
        ],
        "additionalProperties": true
      },
      "PersonaList": {
        "type": "object",
        "properties": {
          "personas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PersonaListItem"
            }
          }
        },
        "required": [
          "personas"
        ],
        "additionalProperties": true
      },
      "GeneratePersonaRequest": {
        "type": "object",
        "properties": {
          "demographic_input": {
            "type": "object",
            "additionalProperties": true,
            "description": "Parsed persona distribution structure. It must contain a 'segment' with 'distributions', as produced by the persona distribution parser; the shape is not validated by the route."
          },
          "segment": {
            "type": "string",
            "description": "Passed to the generator as the persona type (stage) to generate, for example 'subjective'. Defaults to the final stage."
          },
          "productDescription": {
            "type": "string",
            "description": "Product description used to give each persona a realistic need. product_description and product_desc are accepted too."
          }
        },
        "additionalProperties": true
      },
      "Persona": {
        "type": "object",
        "properties": {
          "personaId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "story": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "metas": {
            "type": "object",
            "additionalProperties": true
          },
          "behaviorProfile": {
            "type": "object",
            "additionalProperties": true
          },
          "personaNeed": {
            "type": [
              "string",
              "null"
            ]
          },
          "alignmentScore": {
            "type": [
              "number",
              "null"
            ]
          },
          "wouldConsider": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "considerReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "controls": {
            "type": "object",
            "additionalProperties": true
          },
          "preview": {
            "type": "object",
            "additionalProperties": true
          },
          "vibePrompt": {
            "type": [
              "string",
              "null"
            ]
          },
          "vibePromptSummary": {
            "type": [
              "string",
              "null"
            ]
          },
          "customPersonaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "presetMeta": {
            "type": "object",
            "additionalProperties": true
          },
          "poolId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pool the persona was added to."
          }
        },
        "required": [
          "personaId",
          "name"
        ],
        "description": "A persona saved for the user.",
        "additionalProperties": true
      },
      "VibePersonaRequest": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "vibe",
              "manual"
            ],
            "default": "vibe",
            "description": "vibe generates from vibePrompt; manual generates from radarConfig."
          },
          "vibePrompt": {
            "type": "string",
            "description": "Required in vibe mode: who the tester is and how they behave. 'prompt' is accepted too."
          },
          "radarConfig": {
            "type": "object",
            "additionalProperties": true,
            "description": "Manual mode: trait dimension name to configuration (see GET /api/persona/traits/radar)."
          },
          "controls": {
            "$ref": "#/components/schemas/PersonaControls"
          },
          "productDescription": {
            "type": "string",
            "description": "Gives the persona a need relative to this product. product_description and product_desc are accepted too."
          },
          "previewOnly": {
            "type": "boolean",
            "description": "True to return example personas without saving anything."
          },
          "previewCount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "default": 2,
            "description": "How many examples to preview (clamped to 1 to 5)."
          },
          "poolId": {
            "type": "string",
            "description": "Pool to add the saved persona to. Defaults to the user's default pool."
          }
        },
        "additionalProperties": true
      },
      "PersonaPreview": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "story": {
            "type": "string"
          },
          "personaNeed": {
            "type": [
              "string",
              "null"
            ]
          },
          "alignmentScore": {
            "type": [
              "number",
              "null"
            ]
          },
          "wouldConsider": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "preview": {
            "type": "object",
            "additionalProperties": true
          },
          "vibeSummary": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "description": "An example persona that was not saved.",
        "additionalProperties": true
      },
      "PersonaPreviewList": {
        "type": "object",
        "properties": {
          "examples": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PersonaPreview"
            }
          }
        },
        "required": [
          "examples"
        ],
        "additionalProperties": true
      },
      "CustomPersonaRequest": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "vibe",
              "manual"
            ],
            "default": "vibe"
          },
          "vibePrompt": {
            "type": "string",
            "description": "Required in vibe mode. 'prompt' is accepted too."
          },
          "radarConfig": {
            "type": "object",
            "additionalProperties": true,
            "description": "Required in manual mode."
          },
          "controls": {
            "$ref": "#/components/schemas/PersonaControls"
          },
          "archetypeName": {
            "type": "string",
            "description": "Display name of the preset and of its reference persona. Defaults to label."
          },
          "label": {
            "type": "string",
            "description": "Preset label. 'groupLabel' is accepted too. Default 'Custom Archetype'."
          },
          "vibePromptSummary": {
            "type": "string"
          },
          "previewSnapshot": {
            "type": "object",
            "additionalProperties": true
          },
          "productDescription": {
            "type": "string"
          },
          "poolId": {
            "type": "string",
            "description": "Pool to attach the reference persona to."
          },
          "customPersonaId": {
            "type": "string",
            "description": "Preset id to use. Generated when absent."
          },
          "meta": {
            "type": "object",
            "additionalProperties": true,
            "description": "Preset metadata. Derived from the generated persona when absent."
          }
        },
        "additionalProperties": true
      },
      "CustomPersonaCreated": {
        "type": "object",
        "properties": {
          "persona": {
            "$ref": "#/components/schemas/Persona"
          },
          "customPersonaId": {
            "type": "string",
            "description": "Id of the saved preset (the pool's spec)."
          },
          "preset": {
            "type": "object",
            "additionalProperties": true,
            "description": "The stored preset document."
          }
        },
        "required": [
          "persona",
          "customPersonaId",
          "preset"
        ],
        "additionalProperties": true
      },
      "PoolCreateRequest": {
        "type": "object",
        "properties": {
          "selectedPersonaIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Portal and plugin form. Ids of personas or preset segments. A persona that came from a preset (POST /api/persona/custom) is stored as the pool's spec and is NOT added as a member; other personas are attached as members. The pool gets an auto-generated name Pool_<hex>: rename it with PATCH /api/persona/pools/{pool_id}."
          },
          "customPersonaIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Preset ids to store as the pool's spec. custom_persona_ids is accepted too."
          },
          "archetypeName": {
            "type": "string",
            "description": "Name stored as metadata.primary_archetype_name. archetype_name is accepted too."
          },
          "description": {
            "type": "string"
          },
          "pool_name": {
            "type": "string",
            "description": "Backend form only (when selectedPersonaIds is absent): required pool name."
          },
          "segment_name": {
            "type": "string",
            "description": "Backend form only: required segment name."
          },
          "num_personas": {
            "type": "integer",
            "description": "Backend form only. Read but unused: pools are created empty."
          },
          "user_id": {
            "type": "string",
            "description": "Backend form only. Must be the token's user id; any other value answers 403."
          }
        },
        "description": "Two forms. With selectedPersonaIds (the plugin and portal form) the pool name is generated. Without it, pool_name and segment_name are required.",
        "additionalProperties": true
      },
      "PoolCreated": {
        "type": "object",
        "properties": {
          "personaPoolId": {
            "type": "string",
            "description": "Id of the new pool."
          },
          "selectedPersonaIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Personas attached as members (often empty)."
          },
          "customPersonaIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Preset ids stored as the pool's spec."
          },
          "archetypeName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "personaPoolId",
          "createdAt"
        ],
        "additionalProperties": true
      },
      "PoolPersona": {
        "type": "object",
        "properties": {
          "personaId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "story": {
            "type": "string"
          },
          "customPersonaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "customPersonaLabel": {
            "type": [
              "string",
              "null"
            ]
          },
          "vibePromptSummary": {
            "type": [
              "string",
              "null"
            ]
          },
          "previewSnapshot": {
            "type": "object",
            "additionalProperties": true
          },
          "preview": {
            "type": "object",
            "additionalProperties": true
          },
          "memoryPreviews": {
            "type": "array",
            "items": {}
          },
          "controls": {
            "type": "object",
            "additionalProperties": true
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": true
      },
      "PoolPreset": {
        "type": "object",
        "properties": {
          "customPersonaId": {
            "type": "string"
          },
          "archetypeName": {
            "type": [
              "string",
              "null"
            ]
          },
          "label": {
            "type": [
              "string",
              "null"
            ]
          },
          "previewSnapshot": {
            "type": "object",
            "additionalProperties": true
          },
          "vibePromptSummary": {
            "type": [
              "string",
              "null"
            ]
          },
          "controls": {
            "type": "object",
            "additionalProperties": true
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "description": "A spec (preset) the pool spins testers off from.",
        "additionalProperties": true
      },
      "Pool": {
        "type": "object",
        "properties": {
          "poolId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Pool name (Pool_<hex> until renamed)."
          },
          "description": {
            "type": "string"
          },
          "personaCount": {
            "type": "integer"
          },
          "activePersonaCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "visibility": {
            "type": "string",
            "description": "private by default."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Known keys: primary_archetype_name, selected_custom_persona_ids, selected_segments, primary_segment."
          },
          "stats": {
            "type": "object",
            "properties": {
              "testCount": {
                "type": "integer"
              },
              "lastUsedAt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "additionalProperties": true
          },
          "personasPreview": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PoolPersona"
            }
          },
          "customPresets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PoolPreset"
            }
          }
        },
        "required": [
          "poolId",
          "name"
        ],
        "additionalProperties": true
      },
      "PoolDetail": {
        "type": "object",
        "properties": {
          "poolId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Pool name (Pool_<hex> until renamed)."
          },
          "description": {
            "type": "string"
          },
          "personaCount": {
            "type": "integer"
          },
          "activePersonaCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "visibility": {
            "type": "string",
            "description": "private by default."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Known keys: primary_archetype_name, selected_custom_persona_ids, selected_segments, primary_segment."
          },
          "stats": {
            "type": "object",
            "properties": {
              "testCount": {
                "type": "integer"
              },
              "lastUsedAt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "additionalProperties": true
          },
          "personasPreview": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PoolPersona"
            }
          },
          "customPresets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PoolPreset"
            }
          },
          "personas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PoolPersona"
            },
            "description": "All members."
          }
        },
        "required": [
          "poolId",
          "name",
          "personas"
        ],
        "additionalProperties": true
      },
      "PoolList": {
        "type": "object",
        "properties": {
          "personaPools": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Pool"
            }
          },
          "totalCount": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        },
        "required": [
          "personaPools"
        ],
        "additionalProperties": true
      },
      "PoolUpdateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "visibility": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Replaces the pool's metadata."
          },
          "activePersonaIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Members to keep active. active_persona_ids is accepted too."
          },
          "associatedFeatureIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "description": "At least one supported key is required; others are ignored.",
        "additionalProperties": true
      },
      "PoolDeleted": {
        "type": "object",
        "properties": {
          "pool_id": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "pool_id",
          "deleted"
        ],
        "additionalProperties": true
      },
      "ValidationTest": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "testMode": {
            "type": "string",
            "description": "reaction-only, hypothesis-test, or other modes."
          },
          "status": {
            "type": "string",
            "description": "pending, running, analyzing, completed, failed or cancelled."
          },
          "productName": {
            "type": "string"
          },
          "productDescription": {
            "type": "string"
          },
          "productCategory": {
            "type": "string"
          },
          "targetAudience": {
            "type": "string"
          },
          "segmentName": {
            "type": [
              "string",
              "null"
            ]
          },
          "customPersonaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "customPersonaName": {
            "type": [
              "string",
              "null"
            ]
          },
          "featureName": {
            "type": "string"
          },
          "featureDescription": {
            "type": "string"
          },
          "featureCategory": {
            "type": "string"
          },
          "implementationEffort": {
            "type": "string"
          },
          "goal": {
            "type": [
              "string",
              "null"
            ]
          },
          "hypothesis": {
            "type": [
              "string",
              "null"
            ]
          },
          "successMetrics": {
            "type": "array",
            "items": {}
          },
          "createdAt": {
            "type": "string"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "personaPoolId": {
            "type": [
              "string",
              "null"
            ]
          },
          "selectedPersonaIds": {
            "type": "array",
            "items": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "required": [
          "testId",
          "status"
        ],
        "additionalProperties": true
      },
      "ValidationTestStatus": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "pending, running, analyzing, completed, failed (legacy 'finished' is reported as completed)."
          },
          "progress": {
            "type": "integer",
            "description": "Coarse progress from the status: pending 0, running 50, analyzing 95, completed 100, failed 0."
          },
          "currentStep": {
            "type": [
              "string",
              "null"
            ]
          },
          "estimatedTimeRemaining": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Seconds, when known."
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "testId",
          "status",
          "progress"
        ],
        "additionalProperties": true
      },
      "ValidationTestResults": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "testMode": {
            "type": "string",
            "const": "hypothesis-test"
          },
          "hypothesis": {
            "type": "string"
          },
          "result": {
            "type": "string",
            "description": "supported, rejected or inconclusive."
          },
          "confidence": {
            "type": "number"
          },
          "controlMetric": {
            "type": "number"
          },
          "experimentMetric": {
            "type": "number"
          },
          "improvement": {
            "type": "number"
          },
          "reasoning": {
            "type": "string"
          },
          "supportingEvidence": {
            "type": "array",
            "items": {}
          },
          "contradictingEvidence": {
            "type": "array",
            "items": {}
          },
          "personaResults": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "recommendations": {
            "type": "array",
            "items": {}
          },
          "nextSteps": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "testId",
          "testMode",
          "result"
        ],
        "additionalProperties": true
      },
      "UatCredentials": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "password": {
            "type": "string"
          },
          "rolePermissions": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "UatTestCase": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Case id, for example UAT-001."
          },
          "functionalArea": {
            "type": "string"
          },
          "title": {
            "type": "string",
            "description": "Required on create."
          },
          "priority": {
            "type": "string",
            "description": "Default medium."
          },
          "personaIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Required on create: at least one step."
          },
          "expectedResult": {
            "type": "string",
            "description": "Required on create."
          },
          "actualResult": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "not-started, pass, fail, and others set by the runner ('blocked' is reported as 'fail')."
          },
          "defectId": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "personaCredentials": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/UatCredentials"
            },
            "description": "Persona id to login credentials."
          }
        },
        "additionalProperties": true
      },
      "UatDefect": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "severity": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "uatCaseId": {
            "type": "string"
          },
          "needsRetest": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "UatTestInput": {
        "type": "object",
        "properties": {
          "prototypeUrl": {
            "type": "string",
            "description": "Required on create: address of the prototype to test."
          },
          "featureId": {
            "type": "string"
          },
          "testCases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UatTestCase"
            },
            "description": "Required and non-empty on create."
          },
          "defects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UatDefect"
            }
          },
          "storedCredentials": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "additionalProperties": true
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": true
      },
      "UatTestCreated": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "const": "draft"
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "testId",
          "status"
        ],
        "additionalProperties": true
      },
      "UatTestSummary": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "prototypeUrl": {
            "type": "string"
          },
          "totalCases": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "UatTestList": {
        "type": "object",
        "properties": {
          "tests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UatTestSummary"
            }
          }
        },
        "required": [
          "tests"
        ],
        "additionalProperties": true
      },
      "UatTest": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "draft, running, completed or failed."
          },
          "prototypeUrl": {
            "type": "string"
          },
          "featureId": {
            "type": [
              "string",
              "null"
            ]
          },
          "testCases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UatTestCase"
            }
          },
          "defects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UatDefect"
            }
          },
          "results": {
            "type": [
              "object",
              "array",
              "null"
            ],
            "description": "Per-case step logs once the test has run."
          },
          "progress": {
            "type": "number"
          },
          "currentStep": {
            "type": "string"
          },
          "totalCases": {
            "type": "integer"
          },
          "completedCases": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "storedCredentials": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "runEpoch": {
            "type": "integer"
          },
          "error": {
            "type": "string",
            "description": "Only on a failed run with no results."
          }
        },
        "required": [
          "testId",
          "status"
        ],
        "additionalProperties": true
      },
      "UatRunRequest": {
        "type": "object",
        "properties": {
          "credentials": {
            "type": "object",
            "additionalProperties": true,
            "description": "Login credentials passed to the runner."
          }
        },
        "additionalProperties": true
      },
      "UatRunStarted": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "const": "running"
          },
          "message": {
            "type": "string"
          },
          "runEpoch": {
            "type": "integer",
            "description": "Pass as runEpoch to the wait-status long poll."
          }
        },
        "required": [
          "testId",
          "status",
          "runEpoch"
        ],
        "additionalProperties": true
      },
      "UatStatus": {
        "type": "object",
        "properties": {
          "testId": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "progress": {
            "type": "number"
          },
          "currentStep": {
            "type": "string"
          },
          "totalCases": {
            "type": "integer"
          },
          "completedCases": {
            "type": "integer"
          }
        },
        "required": [
          "testId",
          "status"
        ],
        "additionalProperties": true
      },
      "UatRunning": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "const": "running"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "status"
        ],
        "additionalProperties": true
      },
      "UatEvent": {
        "type": "object",
        "properties": {
          "cursor": {
            "type": "string",
            "description": "Stream position. Send it back as cursor to wait for the next event."
          },
          "type": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "progress": {
            "type": "number"
          },
          "current_step": {
            "type": "string"
          },
          "viewerUrl": {
            "type": "string",
            "description": "Live browser view while the run is going, when available."
          }
        },
        "description": "Latest status event of a UAT run. Open ended: event keys vary by event type.",
        "additionalProperties": true
      },
      "BootstrapMessage": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "description": "'assistant' for model turns; any other value is treated as the user."
          },
          "content": {
            "type": "string"
          },
          "file": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "text/markdown",
                  "application/pdf"
                ]
              },
              "content_base64": {
                "type": "string",
                "description": "Base64 file content. PDFs are limited to 10 MB decoded."
              }
            },
            "description": "Optional attachment on a user turn.",
            "additionalProperties": true
          }
        },
        "required": [
          "role"
        ],
        "additionalProperties": true
      },
      "BootstrapRequest": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "uat",
              "validation"
            ]
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BootstrapMessage"
            },
            "minItems": 1,
            "maxItems": 50
          },
          "features": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            },
            "description": "uat mode only: the user's features, so the reply can name one."
          }
        },
        "required": [
          "mode",
          "messages"
        ],
        "additionalProperties": true
      },
      "BootstrapResponse": {
        "type": "object",
        "properties": {
          "reply": {
            "type": "string",
            "description": "The assistant's next message."
          },
          "suggestedPersonaPoolIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "featureId": {
            "type": "string"
          },
          "featureName": {
            "type": "string"
          },
          "test_cases": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/UatTestCase"
            },
            "description": "uat mode: drafted test cases, or null when none could be drafted yet."
          },
          "prototypeUrl": {
            "type": "string",
            "description": "uat mode."
          },
          "credentials": {
            "type": "object",
            "properties": {
              "email": {
                "type": "string"
              },
              "password": {
                "type": "string"
              }
            },
            "additionalProperties": true,
            "description": "uat mode."
          },
          "test_config": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "validation mode: drafted validation test configuration, or null."
          }
        },
        "required": [
          "reply",
          "suggestedPersonaPoolIds"
        ],
        "additionalProperties": true
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing, malformed, expired or otherwise invalid bearer token. Get a token through the device flow (POST /api/oauth/device/code, then POST /api/oauth/device/token) and retry.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorMessage"
            }
          }
        }
      },
      "ServerProblem": {
        "description": "Unhandled server error. The body never contains exception details. Safe to retry later.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    }
  }
}
