# AUTO-GENERATED tier-A mirror spec — do not edit.
# Source: openapi/runtime/exceptions.yaml (runtime 0.71.2)
#  + policy: openapi/mirror-policies/exceptions.json
# Regenerate: node scripts/generate-mirror-specs.mjs
openapi: 3.0.3
info:
  title: naturali.ai — Exceptions API
  version: 1.0.0
  description: >-
    Exceptions: what went wrong and what was done about it — the record a failed run leaves behind,
    acknowledged when someone takes it and resolved when it is dealt with. A fully runtime-backed
    module — this spec is generated verbatim from the runtime's own, re-rooted under
    /v1/projects/{project_id}. The project in the path is authorized by naturali and enforced
    upstream by the project's scoped credential.


    This module mirrors the upstream runtime verbatim (tier A, #304): paths are the runtime's own
    re-rooted under /v1/projects/{project_id}, and every field, method, status code and error shape
    passes through unchanged. Errors raised by the runtime arrive in its envelope; errors raised by
    naturali itself (authentication, project resolution, an unreachable runtime) use naturali's.
  contact:
    name: naturali.ai
    url: https://naturali.ai
servers:
  - url: "{baseUrl}"
    description: Host of your naturali.ai deployment; every path carries the /v1 prefix.
    variables:
      baseUrl:
        description: Base host URL.
        default: https://api.naturali.ai
tags:
  - name: Exceptions
    description: Triage the failure/anomaly exception queue
security:
  - bearerAuth: []
  - oauth2:
      - mcp:access
paths:
  /v1/projects/{project_id}/exceptions:
    get:
      tags:
        - Exceptions
      summary: List exception items
      description: Returns exception items for a project, filterable by status, severity, and kind.
      operationId: listExceptions
      parameters:
        - name: status
          in: query
          description: Filter by triage status
          schema:
            type: string
            enum:
              - open
              - acknowledged
              - resolved
        - name: severity
          in: query
          description: Filter by severity
          schema:
            type: string
            enum:
              - info
              - warning
              - critical
        - name: kind
          in: query
          description: Filter by how the exception was filed
          schema:
            type: string
            enum:
              - run_failed
              - guardrail_tripwire
              - approval_expired
              - quota_unpriced
              - event_trigger_loop
              - chain_limit
              - manual
        - name: limit
          in: query
          required: false
          description: Maximum number of results to return
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: offset
          in: query
          required: false
          description: Number of results to skip
          schema:
            type: integer
            default: 0
      responses:
        "200":
          description: List of exception items
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - total
                  - limit
                  - offset
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ExceptionItem"
                  total:
                    type: integer
                  limit:
                    type: integer
                  offset:
                    type: integer
        "401":
          description: Unauthorized
        "403":
          description: Forbidden
        "500":
          description: Internal server error
    parameters:
      - $ref: "#/components/parameters/ProjectId"
  /v1/projects/{project_id}/exceptions/{exception_id}:
    get:
      tags:
        - Exceptions
      summary: Get an exception item
      description: Returns a single exception item with its full detail.
      operationId: getException
      parameters:
        - $ref: "#/components/parameters/exception_id"
      responses:
        "200":
          description: Exception item
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExceptionItem"
        "401":
          description: Unauthorized
        "403":
          description: Forbidden
        "404":
          description: Exception item not found
    parameters:
      - $ref: "#/components/parameters/ProjectId"
  /v1/projects/{project_id}/exceptions/{exception_id}/acknowledge:
    post:
      tags:
        - Exceptions
      summary: Acknowledge an exception item
      description: Moves the item to `acknowledged` ("someone is on it"), recording who. A no-op that
        returns the item unchanged when already acknowledged; rejected when already resolved.
      operationId: acknowledgeException
      parameters:
        - $ref: "#/components/parameters/exception_id"
      responses:
        "200":
          description: Exception item acknowledged
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExceptionItem"
        "401":
          description: Unauthorized
        "403":
          description: Forbidden
        "404":
          description: Exception item not found
        "409":
          description: Item already resolved
    parameters:
      - $ref: "#/components/parameters/ProjectId"
  /v1/projects/{project_id}/exceptions/{exception_id}/resolve:
    post:
      tags:
        - Exceptions
      summary: Resolve an exception item
      description: Moves the item to `resolved` ("fixed"), recording who and an optional note.
      operationId: resolveException
      parameters:
        - $ref: "#/components/parameters/exception_id"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                note:
                  type: string
                  description: Optional resolution note
                  example: Root cause fixed; retried the run successfully.
      responses:
        "200":
          description: Exception item resolved
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExceptionItem"
        "401":
          description: Unauthorized
        "403":
          description: Forbidden
        "404":
          description: Exception item not found
        "409":
          description: Item already resolved
    parameters:
      - $ref: "#/components/parameters/ProjectId"
components:
  schemas:
    ExceptionItem:
      type: object
      properties:
        id:
          type: string
          example: exc_V1StGXR8Z5jdHi6B
        project_id:
          x-naturali-ref: projects
          type: string
        status:
          type: string
          enum:
            - open
            - acknowledged
            - resolved
        severity:
          type: string
          enum:
            - info
            - warning
            - critical
        kind:
          type: string
          enum:
            - run_failed
            - guardrail_tripwire
            - approval_expired
            - quota_unpriced
            - event_trigger_loop
            - chain_limit
            - manual
          description: How the exception was filed
        title:
          type: string
          description: Human-readable one-line summary
        detail:
          type: object
          nullable: true
          description: Structured context (tool, args digest, error message, guardrail version)
        occurrence_count:
          type: integer
          description: How many times this exact failure has been observed while open
        last_seen_at:
          type: string
          format: date-time
          description: Timestamp of the most recent occurrence
        orchestration_run_id:
          type: string
          nullable: true
          description: Originating orchestration run
        node_id:
          type: string
          nullable: true
          description: Originating node id within the run's graph
        agent_id:
          type: string
          nullable: true
          description: Associated agent
        guardrail_version:
          type: string
          nullable: true
          description: "`<guardrailId>@<version>` for a guardrail_tripwire exception"
        acknowledged_by:
          type: string
          nullable: true
          description: Acknowledging user's public ID
        resolved_by:
          type: string
          nullable: true
          description: Resolving user's public ID
        resolution_note:
          type: string
          nullable: true
          description: Optional note recorded at resolution
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
  parameters:
    ProjectId:
      name: project_id
      in: path
      required: true
      description: Project public ID (proj_ prefix).
      schema:
        type: string
        example: proj_V1StGXR8Z5jdHi6B
    exception_id:
      name: exception_id
      in: path
      required: true
      description: Exception item ID
      schema:
        type: string
        example: exc_V1StGXR8Z5jdHi6B
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A naturali API key (nat_sk_…) or a session JWT.
    oauth2:
      type: oauth2
      description: "A connected app's OAuth access token, issued by this API's authorization server
        (discovery: /.well-known/oauth-authorization-server). Its one scope carries every operation,
        confined to the projects the user chose when approving the app."
      flows:
        authorizationCode:
          authorizationUrl: https://api.naturali.ai/authorize
          tokenUrl: https://api.naturali.ai/token
          refreshUrl: https://api.naturali.ai/token
          scopes:
            mcp:access: Every operation this API serves, on the projects the grant covers.
