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

# Check structured output

> Check schemas, identifiers, and arithmetic with exact rules and record the result.

**Goal:** replace the invoice example with exact rules that your organization
owns.

**You are done when:** your customized check has a local `passed: true` report
for a pass, a rejection, and a technical failure with no verdict.

Use this recipe when a candidate must satisfy a schema, contain required
fields, match approved identifiers, or pass arithmetic and cross-field rules.

Do not use a semantic evaluator for arithmetic, schema validation, allowlists,
or another rule that ordinary code can decide exactly.

An invoice passes when its supplier is approved and its total equals the sum
of its integer minor-unit amounts. A mismatch or non-integer `amount_cents`
rejects; an unavailable policy source returns no verdict.

```mermaid theme={null}
flowchart LR
  C[Structured candidate] --> S[Schema and type checks]
  S --> P[Identifiers and exact policy]
  P --> A[Arithmetic and cross-field rules]
  A --> R[Pass, reject, or no verdict]
```

<Steps>
  <Step title="Create the example">
    ```bash theme={null}
    millwork verifier init invoice-check --recipe a --json
    ```

    **Expected result:** `selected_recipe` is `a`, `selected_check` ends in
    `recipe-a-structured-output.mjs`, `deployed_check` ends in
    `selected-check.mjs`, and `next_action` tests `selected-check.mjs`.
  </Step>

  <Step title="Run the local cases">
    Run the printed command:

    ```bash theme={null}
    cd invoice-check
    millwork verifier test --local \
      --check selected-check.mjs \
      --access authenticated \
      --json
    ```

    **Expected result:** `passed` is `true`. Check the labelled outcomes if a case fails.

    <Accordion title="See the four local case results">
      * `labelled.a-pass-reconciled-invoice` as a pass;
      * `labelled.a-reject-total-mismatch` as a rejection;
      * `labelled.a-reject-fractional-cents` as a rejection; and
      * `labelled.a-technical-policy-store` as HTTP 500 with no verdict.
    </Accordion>

    **Recovery:** if the CLI does not recognize `--recipe`, stop. Check the
    [install guide](/get-started/tenant-start#run-your-next-task) for a
    recipe-capable version; until it lists one, use its non-recipe path. If a
    labelled case fails, change the rule and its expected case together, then rerun
    the same local command.
  </Step>

  <Step title="Replace the example rules">
    Edit `recipe-a-structured-output.mjs`:

    1. replace the example supplier IDs with your approved values;
    2. define every required field and accepted type;
    3. require safe integer minor units in `amount_cents` and `total_cents`;
    4. keep optional completeness in `scoreQuality`;
    5. add representative pass, rejection, and unavailable-dependency cases.

    A high quality score must not override a failed identifier or total check.
    Rerun the Step 2 command against `selected-check.mjs` after your edits. Deploy
    only when your own pass, rejection, and technical-failure cases all pass.
  </Step>

  <Step title="Continue to deployment">
    Read the shared [endpoint contract](/cookbook/output-checks/build-the-dock#the-endpoint-contract)
    and [reserved-probe limits](/cookbook/output-checks/build-the-dock#reserved-probe-and-timing).
    Your next executable step is
    [Deploy and test HTTPS](/cookbook/output-checks/build-the-dock#deploy-and-test-https).
    Continue with Recipe 0 for connection, paid-run approval, receipt reading, and recovery.
    In the final receipt for a checked run, confirm `supplier_approved`,
    `line_amounts_valid`, and `total_reconciles` under named results.
  </Step>
</Steps>

<span id="keep-control-when-an-assistant-helps" />

<Accordion title="If an assistant helps with this recipe">
  Give the assistant only non-secret business rules and representative fixtures.
  Require it to show the three labelled outcomes before deployment. Enter keys
  yourself, approve endpoint test traffic, and approve any paid run separately.
</Accordion>
