> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moonbounce.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Judge results under a decision's objective

> Judges one version's labeled results under the decision's objective and, with a `base`, compares the two on the same items: the loss report a preview returns. Each mistake's loss is its severity under the objective (every mistake `normal` when none is set), weighted so each expected outcome counts equally however many items it has; `loss_per_case` is their mean. `accepted` (lower loss per case, no new severe mistake on a human-labeled case) and `reasons` say whether the candidate is better. Each side is runs by `run_ids` (from evaluate with `items`, one structure per side) or `results` passed inline with their `structure` or `structure_hash`. Items match by `item_id`; the candidate's labels are used; unlabeled items, outcomes neither version can produce, items the base lacks and retryable failures on either side are left out and counted in `excluded`; a permanent failure counts as a mistake. List a resend's run beside the original: an item's result that didn't fail replaces its failed one. The report lists the worst mistakes, with example ids on every roll-up row. Send `cases` to page through each item's loss: `filter.kind` is `all`, `wrong` (default), `right`, `failed`, `severe`, `changed`, `cell`, `question`, `near_cut` or `missing_criterion`. Runs no engine and spends nothing; the word is loss, not money. An unknown or expired run is 404 RUN_UNKNOWN. A version whose result is a value, not outcomes, is 400 OUTCOMES_INVALID.



## OpenAPI

````yaml /openapi.json post /v1/decisions/{decision_id}/loss-reports
openapi: 3.1.0
info:
  title: Moonbounce Decisions API
  version: 0.0.0
  description: >-
    Moonbounce decisions: evaluate an item's state against a decision structure
    (System One questions, attributes you supply and aggregations over both),
    record feedback and import labeled examples, review a ranked queue, and
    improve the structure through suggestions that ship as code diffs, each with
    a preview (backtest) and an evidence label.


    **Authentication.** Send an API key as `Authorization: Bearer <key>` on
    every operation except `GET /health` and `POST /v1/structures/hash`. Call
    the API from a server, never a browser: a key must not reach one, and the
    API sends no CORS headers. A key belongs to one organization and one
    environment: production, or test for a key with the `env:test` permission.
    Test traffic never counts as production traffic.


    **Requests.** JSON bodies (`Content-Type: application/json`) of at most 1
    MB, parsed strictly: duplicate keys, lone surrogates, integers outside
    ±(2^53 - 1), `__proto__` keys, U+0000 and nesting deeper than 64 are a 400.


    **Retries.** Send an `Idempotency-Key` on every POST under /v1 that takes
    one (all but `POST /v1/structures/hash` and `POST /v1/review/items/fill`,
    whose retry is another fill within the day's budget). Keep it for the
    request's retries. The same key with the same request returns the first
    stored result, marked `Idempotent-Replayed: true`, for 24 hours (410 if that
    result was since deleted); with another request it is 422
    IDEMPOTENCY_KEY_REUSED. Keys are scoped to the organization and environment
    across every operation, so use a fresh key per request. A request that
    failed before its result was stored runs again when retried. 429 and 503
    under /v1 may carry `Retry-After` (seconds); a daily QUOTA_EXCEEDED cap
    instead names its reset time.


    **Errors.** Every error under /v1 is `{"error": {"type", "message",
    "reason"?, "param"?, "details"?}}` (ErrorBody); `GET /health` answers its
    own shape. Every response carries a `Request-Id` header. Rate limits apply
    per key, and per client IP for requests without a valid key; a 429
    RATE_LIMITED carries `Retry-After`.
servers:
  - url: https://api.moonbounce.ai
    description: Production
security: []
paths:
  /v1/decisions/{decision_id}/loss-reports:
    post:
      tags:
        - objective
      summary: Judge results under a decision's objective
      description: >-
        Judges one version's labeled results under the decision's objective and,
        with a `base`, compares the two on the same items: the loss report a
        preview returns. Each mistake's loss is its severity under the objective
        (every mistake `normal` when none is set), weighted so each expected
        outcome counts equally however many items it has; `loss_per_case` is
        their mean. `accepted` (lower loss per case, no new severe mistake on a
        human-labeled case) and `reasons` say whether the candidate is better.
        Each side is runs by `run_ids` (from evaluate with `items`, one
        structure per side) or `results` passed inline with their `structure` or
        `structure_hash`. Items match by `item_id`; the candidate's labels are
        used; unlabeled items, outcomes neither version can produce, items the
        base lacks and retryable failures on either side are left out and
        counted in `excluded`; a permanent failure counts as a mistake. List a
        resend's run beside the original: an item's result that didn't fail
        replaces its failed one. The report lists the worst mistakes, with
        example ids on every roll-up row. Send `cases` to page through each
        item's loss: `filter.kind` is `all`, `wrong` (default), `right`,
        `failed`, `severe`, `changed`, `cell`, `question`, `near_cut` or
        `missing_criterion`. Runs no engine and spends nothing; the word is
        loss, not money. An unknown or expired run is 404 RUN_UNKNOWN. A version
        whose result is a value, not outcomes, is 400 OUTCOMES_INVALID.
      operationId: lossReport
      parameters:
        - schema:
            $ref: '#/components/schemas/DecisionId'
          required: true
          name: decision_id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LossReportRequest'
      responses:
        '200':
          description: The loss report
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LossReportResponse'
        '400':
          description: 'Invalid request: `param` names the field at fault when one applies'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: Missing or invalid API key (reason KEY_INVALID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '403':
          description: The key may not do this
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: Not found, or not in this key's organization and environment
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '429':
          description: >-
            RATE_LIMITED: retry after Retry-After seconds; QUOTA_EXCEEDED:
            details.reset_at gives the daily reset time (no Retry-After)
          headers:
            Retry-After:
              schema:
                type: string
                description: Seconds to wait before retrying, when waiting helps.
              required: false
              description: Seconds to wait before retrying, when waiting helps.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '503':
          description: >-
            Temporarily unavailable, with Retry-After (for example reason
            AUTH_UNAVAILABLE, ENGINE_UNAVAILABLE or STORE_UNAVAILABLE): retry
            with the same Idempotency-Key
          headers:
            Retry-After:
              schema:
                type: string
                description: Seconds to wait before retrying, when waiting helps.
              required: true
              description: Seconds to wait before retrying, when waiting helps.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
        - bearerAuth:
            - decisions:develop
components:
  schemas:
    DecisionId:
      type: string
      pattern: ^[a-z][a-z0-9_.-]{0,127}$
    LossReportRequest:
      type: object
      properties:
        candidate:
          $ref: '#/components/schemas/ReportSide'
        base:
          anyOf:
            - type: object
              properties:
                run_ids:
                  type: array
                  items:
                    $ref: '#/components/schemas/EvrId'
                  minItems: 1
                  maxItems: 50
                  description: >-
                    Runs of one structure, from evaluate with `items`; their
                    labeled items are judged.
              required:
                - run_ids
              additionalProperties: false
            - type: object
              properties:
                structure:
                  $ref: '#/components/schemas/DecisionStructure'
                results:
                  type: array
                  items:
                    $ref: '#/components/schemas/InlineResult'
                  minItems: 1
                  maxItems: 10000
              required:
                - structure
                - results
              additionalProperties: false
            - type: object
              properties:
                structure_hash:
                  $ref: '#/components/schemas/StructureHash'
                results:
                  type: array
                  items:
                    $ref: '#/components/schemas/InlineResult'
                  minItems: 1
                  maxItems: 10000
              required:
                - structure_hash
                - results
              additionalProperties: false
          description: 'The version to compare with: same items, by item_id.'
        cases:
          type: object
          properties:
            filter:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - all
                    - wrong
                    - right
                    - failed
                    - severe
                    - changed
                    - cell
                    - question
                    - near_cut
                    - missing_criterion
                  description: >-
                    Which rows: `all`, `wrong`, `right`, `failed`, `severe`,
                    `changed` (base and candidate differ), `cell` (`expected`
                    and `got`), `question` (a suspect question), `near_cut`
                    (`at`), `missing_criterion`. The last three read the
                    candidate's attributed mistakes.
                expected:
                  $ref: '#/components/schemas/Outcome'
                got:
                  anyOf:
                    - $ref: '#/components/schemas/Outcome'
                    - type: 'null'
                question:
                  type: string
                at:
                  type: number
              required:
                - kind
              additionalProperties: false
              description: 'Default: `wrong`.'
            limit:
              type: integer
              minimum: 1
              maximum: 200
              description: Rows per page. Default 50.
            cursor:
              type: string
              description: '`next_cursor` from the previous page.'
          additionalProperties: false
          description: Page through each item's loss. Without it the report has no rows.
      required:
        - candidate
      additionalProperties: false
    LossReportResponse:
      type: object
      properties:
        objective:
          type: object
          properties:
            source:
              type: string
              enum:
                - stored
                - balanced
              description: >-
                `stored`: the decision's stored objective. `balanced`: none is
                set, so each outcome's mistakes weigh the same in total.
            revision:
              type:
                - integer
                - 'null'
              minimum: 1
            objective_hash:
              type:
                - string
                - 'null'
              description: The stored objective as written (null when balanced).
            effective_hash:
              type: string
              description: >-
                The hash of the severities and target scored by (each run weighs
                outcomes by its own cases). Never compare reports under
                different ones.
            unknown_outcomes:
              type: array
              items:
                type: string
          required:
            - source
            - revision
            - objective_hash
            - effective_hash
            - unknown_outcomes
          additionalProperties: true
          description: What this run scored with.
          x-moonbounce-sdk-known-fields: true
        base:
          anyOf:
            - $ref: '#/components/schemas/LossReport'
            - type: 'null'
          description: The base's report; null when there is no base.
        candidate:
          $ref: '#/components/schemas/LossReport'
        accepted:
          type: boolean
          description: >-
            The candidate lowers loss per case and adds no new severe mistake on
            a human-labeled case. False without a base.
        reasons:
          type: array
          items:
            type: string
          description: Why it is not accepted; empty when it is.
        new_severe_human:
          type: array
          items:
            type: string
          description: >-
            Human-labeled cases the candidate gets severely wrong that the base
            did not.
        environment:
          $ref: '#/components/schemas/Environment'
        decision_id:
          $ref: '#/components/schemas/DecisionIdOutput'
        excluded:
          type: object
          properties:
            unlabeled:
              type: integer
              minimum: 0
              description: Candidate items without `expected`.
            failed_transient:
              type: integer
              minimum: 0
              description: >-
                Items that failed on either side for a reason that may pass (an
                outage, not starting in time): not evidence either way.
            base_only:
              type: integer
              minimum: 0
              description: Base items the candidate doesn't have.
            outcome_not_in_result:
              type: integer
              minimum: 0
              description: >-
                Labeled items whose expected outcome neither version can
                produce.
            no_base:
              type: integer
              minimum: 0
              description: Labeled items the base doesn't have, with a base given.
          required:
            - unlabeled
            - failed_transient
            - base_only
            - outcome_not_in_result
            - no_base
          additionalProperties: true
          description: Items left out of the report, by why.
          x-moonbounce-sdk-known-fields: true
        cases:
          type: object
          properties:
            filter:
              $ref: '#/components/schemas/CaseFilter'
            total:
              type: integer
              minimum: 0
              description: Rows matching the filter.
            rows:
              type: array
              items:
                $ref: '#/components/schemas/LossRow'
            next_cursor:
              anyOf:
                - type: string
                - type: 'null'
          required:
            - filter
            - total
            - rows
            - next_cursor
          additionalProperties: true
          description: 'With `cases` in the request: one page of rows.'
          x-moonbounce-sdk-known-fields: true
      required:
        - objective
        - base
        - candidate
        - accepted
        - reasons
        - new_severe_human
        - environment
        - decision_id
        - excluded
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    ErrorBody:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              $ref: '#/components/schemas/ErrorType'
            reason:
              type: string
              pattern: ^[A-Z][A-Z0-9_]+$
              description: >-
                Set where a caller can act on it, one of the reasons in the
                ErrorReason schema. New reasons may be added: treat an unknown
                one by the status and `type`.
            message:
              type: string
              description: For people; don't parse it.
            param:
              type: string
              description: >-
                The request field at fault, as a dotted path
                (`attribute_values.region`, `claims.1.value`).
            details:
              type: object
              properties:
                issues:
                  type: array
                  items:
                    $ref: '#/components/schemas/ErrorIssue'
              additionalProperties: {}
          required:
            - type
            - message
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
      required:
        - error
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    ReportSide:
      anyOf:
        - type: object
          properties:
            run_ids:
              type: array
              items:
                $ref: '#/components/schemas/EvrId'
              minItems: 1
              maxItems: 50
              description: >-
                Runs of one structure, from evaluate with `items`; their labeled
                items are judged.
          required:
            - run_ids
          additionalProperties: false
        - type: object
          properties:
            structure:
              $ref: '#/components/schemas/DecisionStructure'
            results:
              type: array
              items:
                $ref: '#/components/schemas/InlineResult'
              minItems: 1
              maxItems: 10000
          required:
            - structure
            - results
          additionalProperties: false
        - type: object
          properties:
            structure_hash:
              $ref: '#/components/schemas/StructureHash'
            results:
              type: array
              items:
                $ref: '#/components/schemas/InlineResult'
              minItems: 1
              maxItems: 10000
          required:
            - structure_hash
            - results
          additionalProperties: false
      description: >-
        One version's results: runs by id, or results inline with the structure
        they ran on.
    EvrId:
      type: string
      pattern: >-
        ^evr_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
    DecisionStructure:
      type: object
      properties:
        questions:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Question'
          description: System One questions, keyed by name.
        attributes:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Attribute'
          description: >-
            Values your app supplies with each call in `attribute_values`. The
            model never sees them.
        aggregations:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Aggregation'
        result:
          type: string
          minLength: 1
          maxLength: 80
          description: The final feature's path, such as `aggregations.band`.
          examples:
            - questions.asks_for_refund
            - aggregations.band
      required:
        - questions
        - result
      additionalProperties: false
      description: >-
        Everything that defines a decision: questions, attribute declarations,
        aggregations and the result. Names are unique across all three maps.
    InlineResult:
      type: object
      properties:
        item_id:
          type: string
          minLength: 1
          maxLength: 256
        expected:
          type: string
          minLength: 1
          maxLength: 200
          description: Needed on the candidate side; a base's labels are ignored.
        label_source:
          $ref: '#/components/schemas/LabelSource'
        status:
          $ref: '#/components/schemas/RunItemStatus'
        outcome:
          $ref: '#/components/schemas/Outcome'
        value:
          type: number
        answers:
          type: object
          additionalProperties:
            type:
              - number
              - 'null'
        attributes:
          $ref: '#/components/schemas/AttributeValues'
        error:
          type: object
          properties:
            code:
              type: string
            retryable:
              type: boolean
            message:
              type: string
          required:
            - code
            - retryable
          additionalProperties: false
          description: >-
            A failed result's error, as evaluate gave it: a retryable one is
            left out, not judged.
      required:
        - item_id
        - status
      additionalProperties: false
      description: One result, as an evaluate run returns it, with its label.
    StructureHash:
      type: string
      pattern: ^sha256:[0-9a-f]{64}$
    Outcome:
      type: string
      minLength: 1
      maxLength: 200
      description: >-
        An outcome name, or the exact enum label when a string attribute is the
        result.
    LossReport:
      type: object
      properties:
        'n':
          type: integer
          minimum: 0
          description: Cases scored.
        loss:
          type: number
          minimum: 0
          description: Total loss of the mistakes.
        loss_per_case:
          type: number
          minimum: 0
        target_met:
          type:
            - boolean
            - 'null'
          description: >-
            Whether loss per case is at or below the objective's target; null
            without one.
        macro_f1:
          type:
            - number
            - 'null'
          minimum: 0
          maximum: 1
          description: >-
            Mean F1 over the outcomes expected or given: the headline. Not the
            loss.
        outcomes:
          type: array
          items:
            type: object
            properties:
              outcome:
                $ref: '#/components/schemas/OutcomeOutput'
              expected:
                type: integer
                minimum: 0
              given:
                type: integer
                minimum: 0
              precision:
                type:
                  - number
                  - 'null'
                minimum: 0
                maximum: 1
              recall:
                type:
                  - number
                  - 'null'
                minimum: 0
                maximum: 1
              f1:
                type:
                  - number
                  - 'null'
                minimum: 0
                maximum: 1
            required:
              - outcome
              - expected
              - given
              - precision
              - recall
              - f1
            additionalProperties: true
            x-moonbounce-sdk-known-fields: true
        by_mistake:
          type: array
          items:
            type: object
            properties:
              expected:
                $ref: '#/components/schemas/OutcomeOutput'
              got:
                anyOf:
                  - $ref: '#/components/schemas/OutcomeOutput'
                  - type: 'null'
              'n':
                type: integer
                minimum: 1
              loss:
                type: number
                minimum: 0
              examples:
                type: array
                items:
                  type: string
                description: A few of its cases, worst first, by the id each case carries.
            required:
              - expected
              - got
              - 'n'
              - loss
              - examples
            additionalProperties: true
            x-moonbounce-sdk-known-fields: true
          description: >-
            Loss by mistake cell, worst first: the loss-weighted confusion
            matrix. A response lists the worst 50.
        by_mistake_total:
          type: integer
          minimum: 0
          description: How many mistake cells there are.
        by_question:
          type: array
          items:
            type: object
            properties:
              question:
                type: string
              loss:
                type: number
                minimum: 0
              share:
                type: number
                minimum: 0
                maximum: 1
              examples:
                type: array
                items:
                  type: string
                description: A few of its cases, worst first, by the id each case carries.
            required:
              - question
              - loss
              - share
              - examples
            additionalProperties: true
            x-moonbounce-sdk-known-fields: true
          description: >-
            Loss by suspect question, worst first: each wrong case's loss spread
            over the questions a reviewer corrected, else those whose flip alone
            fixes it. A large share points at rewriting that question.
        missing_criterion:
          type: object
          properties:
            'n':
              type: integer
              minimum: 0
            loss:
              type: number
              minimum: 0
            examples:
              type: array
              items:
                type: string
              description: A few of its cases, worst first, by the id each case carries.
          required:
            - 'n'
            - loss
            - examples
          additionalProperties: true
          description: >-
            Wrong cases with no suspect: no reviewer correction, and no single
            unconfirmed answer whose flip fixes it. A criterion the structure
            lacks; clustered on one theme, it points at adding a question.
          x-moonbounce-sdk-known-fields: true
        failed:
          type: object
          properties:
            'n':
              type: integer
              minimum: 0
            loss:
              type: number
              minimum: 0
          required:
            - 'n'
            - loss
          additionalProperties: true
          description: >-
            Cases the version failed permanently, counted as its dearest
            mistake: an input or engine problem.
          x-moonbounce-sdk-known-fields: true
        near_cuts:
          type: array
          items:
            type: object
            properties:
              aggregation:
                type: string
              at:
                type: number
              lower_it:
                type: object
                properties:
                  'n':
                    type: integer
                    minimum: 0
                  loss:
                    type: number
                    minimum: 0
                required:
                  - 'n'
                  - loss
                additionalProperties: true
                description: >-
                  Wrong cases just below the cut that belong in the band above
                  it.
                x-moonbounce-sdk-known-fields: true
              raise_it:
                type: object
                properties:
                  'n':
                    type: integer
                    minimum: 0
                  loss:
                    type: number
                    minimum: 0
                required:
                  - 'n'
                  - loss
                additionalProperties: true
                description: >-
                  Wrong cases just above the cut that belong in the band below
                  it.
                x-moonbounce-sdk-known-fields: true
              examples:
                type: array
                items:
                  type: string
                description: A few of its cases, worst first, by the id each case carries.
            required:
              - aggregation
              - at
              - lower_it
              - raise_it
              - examples
            additionalProperties: true
            x-moonbounce-sdk-known-fields: true
          description: >-
            Wrong cases within 0.1 of a cut of the result's bands whose expected
            band is the adjacent one, by the direction that would fix them.
        severe:
          type: object
          properties:
            'n':
              type: integer
              minimum: 0
            human:
              type: integer
              minimum: 0
          required:
            - 'n'
            - human
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
        cases:
          type: array
          items:
            $ref: '#/components/schemas/LossCase'
          description: >-
            The worst mistakes, at most 25, with the answers behind them. The
            roll-ups cover every case.
        cases_total:
          type: integer
          minimum: 0
          description: How many mistakes there are; `cases` lists the worst.
        attributed:
          type: integer
          minimum: 0
          description: >-
            How many mistakes, worst first and permanent failures aside,
            `by_question`, `missing_criterion` and `fixing_flips` cover (at most
            100). The other roll-ups cover every case.
      required:
        - 'n'
        - loss
        - loss_per_case
        - target_met
        - macro_f1
        - outcomes
        - by_mistake
        - by_mistake_total
        - by_question
        - missing_criterion
        - failed
        - near_cuts
        - severe
        - cases
        - cases_total
        - attributed
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    Environment:
      type: string
      enum:
        - production
        - test
      description: >-
        The environment of the key that made the call: `production` or `test`.
        Evaluations, feedback, reviews and suggestions are separate per
        environment; registered structures are shared.
    DecisionIdOutput:
      type: string
      pattern: ^[a-z][a-z0-9_.-]{0,127}$
    CaseFilter:
      type: object
      properties:
        kind:
          type: string
          enum:
            - all
            - wrong
            - right
            - failed
            - severe
            - changed
            - cell
            - question
            - near_cut
            - missing_criterion
          description: >-
            Which rows: `all`, `wrong`, `right`, `failed`, `severe`, `changed`
            (base and candidate differ), `cell` (`expected` and `got`),
            `question` (a suspect question), `near_cut` (`at`),
            `missing_criterion`. The last three read the candidate's attributed
            mistakes.
        expected:
          $ref: '#/components/schemas/OutcomeOutput'
        got:
          anyOf:
            - $ref: '#/components/schemas/OutcomeOutput'
            - type: 'null'
        question:
          type: string
        at:
          type: number
      required:
        - kind
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    LossRow:
      type: object
      properties:
        item_id:
          type: string
          minLength: 1
          maxLength: 256
        expected:
          $ref: '#/components/schemas/OutcomeOutput'
        got:
          anyOf:
            - $ref: '#/components/schemas/OutcomeOutput'
            - type: 'null'
        loss:
          type: number
          minimum: 0
        severe:
          type: boolean
        base:
          type: object
          properties:
            got:
              anyOf:
                - $ref: '#/components/schemas/OutcomeOutput'
                - type: 'null'
            loss:
              type: number
              minimum: 0
            severe:
              type: boolean
          required:
            - got
            - loss
            - severe
          additionalProperties: true
          description: The same item under the base, when there is one.
          x-moonbounce-sdk-known-fields: true
      required:
        - item_id
        - expected
        - got
        - loss
        - severe
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    ErrorType:
      type: string
      enum:
        - invalid_request
        - authentication
        - permission_denied
        - not_found
        - conflict
        - rate_limited
        - engine_failed
        - unavailable
        - internal
    ErrorIssue:
      type: object
      properties:
        param:
          type: string
        code:
          type: string
          pattern: ^[A-Z][A-Z0-9_]+$
          description: >-
            Stable, extensible issue code; unknown codes still have a parameter
            and human-readable message.
        message:
          type: string
      required:
        - param
        - code
        - message
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    Question:
      oneOf:
        - $ref: '#/components/schemas/NoulQuestion'
      discriminator:
        propertyName: type
        mapping:
          noul: '#/components/schemas/NoulQuestion'
    Attribute:
      oneOf:
        - $ref: '#/components/schemas/StringAttribute'
        - $ref: '#/components/schemas/NumberAttribute'
        - $ref: '#/components/schemas/BooleanAttribute'
      discriminator:
        propertyName: type
        mapping:
          string: '#/components/schemas/StringAttribute'
          number: '#/components/schemas/NumberAttribute'
          boolean: '#/components/schemas/BooleanAttribute'
    Aggregation:
      oneOf:
        - $ref: '#/components/schemas/WeightedMean'
        - $ref: '#/components/schemas/Logistic'
        - $ref: '#/components/schemas/Min'
        - $ref: '#/components/schemas/Max'
        - $ref: '#/components/schemas/Product'
        - $ref: '#/components/schemas/NoisyOr'
        - $ref: '#/components/schemas/All'
        - $ref: '#/components/schemas/Any'
        - $ref: '#/components/schemas/Bands'
        - $ref: '#/components/schemas/Rules'
        - $ref: '#/components/schemas/Match'
      discriminator:
        propertyName: type
        mapping:
          weighted_mean: '#/components/schemas/WeightedMean'
          logistic: '#/components/schemas/Logistic'
          min: '#/components/schemas/Min'
          max: '#/components/schemas/Max'
          product: '#/components/schemas/Product'
          noisy_or: '#/components/schemas/NoisyOr'
          all: '#/components/schemas/All'
          any: '#/components/schemas/Any'
          bands: '#/components/schemas/Bands'
          rules: '#/components/schemas/Rules'
          match: '#/components/schemas/Match'
    LabelSource:
      type: string
      enum:
        - human
        - synthetic
        - unknown
      description: >-
        Where the label came from: `human`, `synthetic` (an agent made it) or
        `unknown`. Only `human` counts toward the no-new-severe-mistake rule.
    RunItemStatus:
      type: string
      enum:
        - decided
        - computed
        - abstained
        - failed
    AttributeValues:
      type: object
      additionalProperties:
        anyOf:
          - type: string
            maxLength: 200
          - type: number
          - type: boolean
    OutcomeOutput:
      type: string
      minLength: 1
      maxLength: 200
      description: >-
        An outcome name, or the exact enum label when a string attribute is the
        result.
    LossCase:
      type: object
      properties:
        evaluation_id:
          type: string
          pattern: >-
            ^evl_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: A stored case's evaluation; absent for a dataset item.
        item_id:
          type: string
          description: >-
            A dataset item's id, as an evaluate run was given it; absent for a
            stored case.
        expected:
          $ref: '#/components/schemas/OutcomeOutput'
        got:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 200
          description: >-
            The outcome given; null when there is none: a permanent failure
            (`failed`), or an abstention whose result names no abstain outcome.
        failed:
          type: boolean
          description: >-
            The version failed this case permanently: an input or engine
            problem, not a missing criterion.
        loss:
          type: number
          minimum: 0
        severe:
          type: boolean
          description: >-
            The objective's severity for this mistake, before weighting by
            outcome, is at least `severe` (10). Always false without a stored
            objective.
        human:
          type: boolean
          description: >-
            Labeled by a person, so it counts toward the no-new-severe-mistake
            rule.
        margin:
          anyOf:
            - type: object
              properties:
                value:
                  type: number
                cut:
                  type: number
                  description: The cut to cross to reach the expected outcome's band.
                distance:
                  type: number
                  minimum: 0
                adjacent:
                  type: boolean
                  description: >-
                    The expected band is next to the value's, so moving this one
                    cut alone fixes it.
              required:
                - value
                - cut
                - distance
                - adjacent
              additionalProperties: true
              x-moonbounce-sdk-known-fields: true
            - type: 'null'
          description: >-
            For a bands result: the boundary of the nearest band holding the
            expected outcome, and how far the value is from it. Null otherwise.
        attributed:
          type: boolean
          description: >-
            Its fixing flips and suspects were worked out: one of the worst
            mistakes (see `attributed` on the report).
        fixing_flips:
          type: array
          items:
            type: string
          description: >-
            Questions whose opposite answer (0 or 1) alone gives the expected
            outcome. Empty: a missing criterion.
        flips_total:
          type: integer
          minimum: 0
          description: How many fixing flips there are; a response lists at most 10.
        answer_conflicts:
          type: array
          items:
            type: string
          description: >-
            Questions whose answer disagrees with a reviewer's `expected_answer`
            for this case.
        suspects:
          type: array
          items:
            type: string
          description: >-
            The questions blamed, as `by_question` counts them: the conflicts,
            else the fixing flips no reviewer confirmed. Empty on an attributed
            mistake: a missing criterion.
        answers:
          type: object
          additionalProperties:
            type:
              - number
              - 'null'
          description: >-
            The answers of its fixing flips and conflicting questions (a stored
            run keeps every answer).
      required:
        - expected
        - got
        - failed
        - loss
        - severe
        - human
        - margin
        - attributed
        - fixing_flips
        - flips_total
        - answer_conflicts
        - suspects
        - answers
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    NoulQuestion:
      type: object
      properties:
        type:
          type: string
          enum:
            - noul
        instructions:
          $ref: '#/components/schemas/Instructions'
        criteria:
          type: object
          properties:
            'true':
              type: string
              minLength: 1
              maxLength: 4000
            'false':
              type: string
              minLength: 1
              maxLength: 4000
          additionalProperties: false
        reads:
          type: array
          items:
            $ref: '#/components/schemas/StatePath'
          minItems: 1
          maxItems: 64
          description: >-
            Paths into an object `state` this question reads, such as
            `state.message` or `state.order.customer.tier`. The question sees
            just those values, nested as in the state. Without it the question
            sees the whole state, as in System One. Every path must exist in the
            call's `state`; no entry may repeat or contain another.
      required:
        - type
        - instructions
      additionalProperties: false
      description: P(true) for a statement about the state.
    StringAttribute:
      type: object
      properties:
        type:
          type: string
          enum:
            - string
        enum:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 200
          minItems: 1
          maxItems: 255
        default:
          type: string
        source:
          type: string
          minLength: 1
          maxLength: 200
          description: >-
            The model and version behind this attribute, such as
            `toxicity-classifier-v3`. Hashed.
      required:
        - type
        - enum
      additionalProperties: false
    NumberAttribute:
      type: object
      properties:
        type:
          type: string
          enum:
            - number
        minimum:
          type: number
        maximum:
          type: number
        default:
          type: number
        source:
          type: string
          minLength: 1
          maxLength: 200
          description: >-
            The model and version behind this attribute, such as
            `toxicity-classifier-v3`. Hashed.
      required:
        - type
      additionalProperties: false
    BooleanAttribute:
      type: object
      properties:
        type:
          type: string
          enum:
            - boolean
        default:
          type: boolean
        source:
          type: string
          minLength: 1
          maxLength: 200
          description: >-
            The model and version behind this attribute, such as
            `toxicity-classifier-v3`. Hashed.
      required:
        - type
      additionalProperties: false
    WeightedMean:
      type: object
      properties:
        type:
          type: string
          enum:
            - weighted_mean
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              weight:
                type: number
                exclusiveMinimum: 0
              invert:
                type: boolean
            required:
              - name
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - inputs
      additionalProperties: false
      description: 'Σ wᵢ·xᵢ / Σ wᵢ: a weighted average from 0 to 1, not a probability.'
    Logistic:
      type: object
      properties:
        type:
          type: string
          enum:
            - logistic
        bias:
          type: number
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              weight:
                type: number
            required:
              - name
              - weight
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - bias
        - inputs
      additionalProperties: false
      description: σ(bias + Σ wᵢ·xᵢ), with signed weights on raw input values.
    Min:
      type: object
      properties:
        type:
          type: string
          enum:
            - min
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              invert:
                type: boolean
            required:
              - name
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - inputs
      additionalProperties: false
      description: 'min xᵢ: all of these, when they overlap.'
    Max:
      type: object
      properties:
        type:
          type: string
          enum:
            - max
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              invert:
                type: boolean
            required:
              - name
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - inputs
      additionalProperties: false
      description: 'max xᵢ: any of these, when they overlap.'
    Product:
      type: object
      properties:
        type:
          type: string
          enum:
            - product
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              invert:
                type: boolean
            required:
              - name
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - inputs
      additionalProperties: false
      description: 'Π xᵢ: all of these, when they are independent.'
    NoisyOr:
      type: object
      properties:
        type:
          type: string
          enum:
            - noisy_or
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              invert:
                type: boolean
            required:
              - name
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - inputs
      additionalProperties: false
      description: '1 − Π(1 − xᵢ): any of these, when they are independent.'
    All:
      type: object
      properties:
        type:
          type: string
          enum:
            - all
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              gte:
                type: number
              gt:
                type: number
              lte:
                type: number
              lt:
                type: number
            required:
              - name
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - inputs
      additionalProperties: false
      description: 1 when every input passes its threshold (default ≥ 0.5), else 0.
    Any:
      type: object
      properties:
        type:
          type: string
          enum:
            - any
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                $ref: '#/components/schemas/FeatureRef'
              gte:
                type: number
              gt:
                type: number
              lte:
                type: number
              lt:
                type: number
            required:
              - name
            additionalProperties: false
          minItems: 1
          maxItems: 64
      required:
        - type
        - inputs
      additionalProperties: false
      description: 1 when any input passes its threshold (default ≥ 0.5), else 0.
    Bands:
      type: object
      properties:
        type:
          type: string
          enum:
            - bands
        input:
          $ref: '#/components/schemas/FeatureRef'
        below:
          $ref: '#/components/schemas/Name'
        cuts:
          type: array
          items:
            type: object
            properties:
              at:
                type: number
              outcome:
                $ref: '#/components/schemas/Name'
            required:
              - at
              - outcome
            additionalProperties: false
          minItems: 1
          maxItems: 9
        abstain:
          $ref: '#/components/schemas/Name'
      required:
        - type
        - input
        - below
        - cuts
      additionalProperties: false
      description: >-
        Names an outcome for each range of one feature's value. `at` means ≥;
        `below` is under the first cut.
    Rules:
      type: object
      properties:
        type:
          type: string
          enum:
            - rules
        rules:
          type: array
          items:
            type: object
            properties:
              when:
                $ref: '#/components/schemas/Condition'
              outcome:
                $ref: '#/components/schemas/Name'
            required:
              - when
              - outcome
            additionalProperties: false
          minItems: 1
          maxItems: 64
        else:
          $ref: '#/components/schemas/Name'
      required:
        - type
        - rules
        - else
      additionalProperties: false
      description: >-
        The first rule whose condition is true names its `outcome`; otherwise
        `else`.
    Match:
      type: object
      properties:
        type:
          type: string
          enum:
            - match
        input:
          $ref: '#/components/schemas/FeatureRef'
        cases:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Name'
          description: >-
            Maps labels to outcomes. "__proto__" is not supported as a case key;
            use a rules is-condition for that label.
        else:
          $ref: '#/components/schemas/Name'
        abstain:
          $ref: '#/components/schemas/Name'
      required:
        - type
        - input
        - cases
      additionalProperties: false
      description: Maps a label straight to an outcome.
    Instructions:
      anyOf:
        - type: string
          minLength: 1
          maxLength: 4000
        - type: object
          additionalProperties: {}
        - type: array
          items: {}
          minItems: 1
    StatePath:
      type: string
      minLength: 1
      maxLength: 256
      description: >-
        `state.<key>` or a nested object path such as
        `state.order.customer.tier`: keys of an object `state`. A key has no
        `.`, `[` or `]`. Array indexes are not supported yet.
      examples:
        - state.message
        - state.order.order_total_usd
    FeatureRef:
      type: string
      minLength: 1
      maxLength: 80
      description: >-
        A feature's path: `questions.<name>`, `attributes.<name>` or
        `aggregations.<name>`.
      examples:
        - questions.asks_for_refund
        - aggregations.band
    Name:
      type: string
      pattern: ^[a-z][a-z0-9_]{0,63}$
    Condition:
      anyOf:
        - type: object
          properties:
            name:
              $ref: '#/components/schemas/FeatureRef'
            gte:
              type: number
            gt:
              type: number
            lte:
              type: number
            lt:
              type: number
            is:
              type: string
              minLength: 1
              maxLength: 200
            in:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 200
              minItems: 1
              maxItems: 255
            abstained:
              type: boolean
              enum:
                - true
          required:
            - name
          additionalProperties: false
        - type: object
          properties:
            all:
              type: array
              items:
                $ref: '#/components/schemas/Condition'
              minItems: 1
              maxItems: 64
          required:
            - all
          additionalProperties: false
        - type: object
          properties:
            any:
              type: array
              items:
                $ref: '#/components/schemas/Condition'
              minItems: 1
              maxItems: 64
          required:
            - any
          additionalProperties: false
        - type: object
          properties:
            not:
              $ref: '#/components/schemas/Condition'
          required:
            - not
          additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API key, sent as `Authorization: Bearer <key>`. Each operation lists
        the scope its key needs: `decisions:evaluate` (evaluate and read
        evaluations), `decisions:feedback` (your app's feedback) or
        `decisions:develop` (everything else, including owner feedback and the
        review queue). An operation listing no scope takes any scoped key. A key
        with no scope, or without the operation's, gets 403 INSUFFICIENT_SCOPE.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.