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

# Verifier

> Run verification checks against the current session state

Run verification checks to validate agent actions. The verifier checks both database state (what changed) and interaction logs (what was done) to provide comprehensive verification.

## Request Body

<ParamField body="sessionId" type="string" required>
  Session identifier for the test
</ParamField>

<ParamField body="checks" type="array" required>
  Array of verification checks to perform

  <Expandable title="Check Object">
    <ParamField body="id" type="string" required>
      Unique identifier for the check
    </ParamField>

    <ParamField body="type" type="string" required>
      Check type: `state`, `log`, `rubric`, `sequential`, or `manual`
    </ParamField>

    <ParamField body="table" type="string">
      Database table to query (for `state` checks)
    </ParamField>

    <ParamField body="function" type="string">
      Custom function to execute (for `manual` checks)
    </ParamField>

    <ParamField body="function_args" type="array">
      Arguments for the function (for `manual` checks)
    </ParamField>

    <ParamField body="asserts" type="array" required>
      Array of assertion objects
    </ParamField>
  </Expandable>
</ParamField>

### Assertion Object

<ParamField body="comparator" type="string" required>
  Comparison operator: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `contains`, `regex`, `deep_equal`
</ParamField>

<ParamField body="function" type="string">
  Utility function to call (e.g., `object_contains`, `count`)
</ParamField>

<ParamField body="function_args" type="array">
  Arguments for the utility function. Use `_result[*]` to iterate through array results.
</ParamField>

<ParamField body="value" type="any" required>
  Expected value for comparison
</ParamField>

## Response

<ResponseField name="session_id" type="string">
  Session identifier
</ResponseField>

<ResponseField name="success" type="boolean | string">
  Overall result: `true` (all passed), `false` (at least one failed), or `'PENDING'` (rubric checks pending)
</ResponseField>

<ResponseField name="verifiers" type="array">
  Array of individual check results

  <Expandable title="properties">
    <ResponseField name="id" type="string">
      Check identifier
    </ResponseField>

    <ResponseField name="operator" type="string">
      Type of operation performed
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Whether this check passed
    </ResponseField>

    <ResponseField name="asserts" type="array">
      Detailed assertion results
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash State Check theme={null}
  curl -X POST http://localhost:3000/verifier \
    -H "Content-Type: application/json" \
    -d '{
      "sessionId": "test-session",
      "checks": [
        {
          "id": "check-event-created",
          "type": "state",
          "table": "events",
          "asserts": [
            {
              "comparator": "eq",
              "function": "object_contains",
              "function_args": ["_result[*]", {"title": "Team Meeting"}],
              "value": true
            }
          ]
        }
      ]
    }'
  ```

  ```bash Log Check theme={null}
  curl -X POST http://localhost:3000/verifier \
    -H "Content-Type: application/json" \
    -d '{
      "sessionId": "test-session",
      "checks": [
        {
          "id": "check-button-clicked",
          "type": "log",
          "asserts": [
            {
              "comparator": "eq",
              "function": "object_contains",
              "function_args": ["_result[*]", {
                "eventType": "click",
                "clickId": "submit-button"
              }],
              "value": true
            }
          ]
        }
      ]
    }'
  ```

  ```bash Manual Check theme={null}
  curl -X POST http://localhost:3000/verifier \
    -H "Content-Type: application/json" \
    -d '{
      "sessionId": "test-session",
      "checks": [
        {
          "id": "check-events-on-day",
          "type": "manual",
          "function": "find_events_on_day",
          "function_args": ["2024-11-20"],
          "asserts": [
            {
              "comparator": "gt",
              "function": "count",
              "function_args": ["_result"],
              "value": 0
            }
          ]
        }
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "session_id": "test-session",
    "success": true,
    "verifiers": [
      {
        "id": "check-event-created",
        "operator": "state_comparison",
        "success": true,
        "asserts": [
          {
            "actual_value": true,
            "expected_value": true,
            "comparator": "eq",
            "success": true,
            "matching_results": [
              {
                "id": 1,
                "title": "Team Meeting",
                "startTime": "2024-11-20T14:00:00Z"
              }
            ]
          }
        ]
      }
    ]
  }
  ```

  ```json Failure Response theme={null}
  {
    "session_id": "test-session",
    "success": false,
    "verifiers": [
      {
        "id": "check-event-created",
        "operator": "state_comparison",
        "success": false,
        "asserts": [
          {
            "actual_value": false,
            "expected_value": true,
            "comparator": "eq",
            "success": false
          }
        ],
        "all_results": []
      }
    ]
  }
  ```

  ```json Pending Response theme={null}
  {
    "session_id": "test-session",
    "success": "PENDING",
    "verifiers": [
      {
        "id": "rubric-check",
        "success": "PENDING"
      }
    ]
  }
  ```
</ResponseExample>
