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

# Validation rules

> The rules that grade a scenario run, what each one inspects, and how the run is scored

Validation rules grade a scenario run once the agent is done. Edit them in the **Validation** section of the scenario form, or as the `validation` array of the scenario through the API. The engine first checks that the job completed, even when the array is empty. A scenario whose required `job_resolution_status` rule accepts `agentic_failure` skips that check, so it can expect a job that fails.

```json theme={null}
"validation": [
  {
    "label": "Job resolved successfully",
    "validator": "job_resolution_status",
    "statuses": ["success"]
  },
  {
    "label": "Did not reboot the host",
    "validator": "pattern_match",
    "where": "executed_commands",
    "pattern": "\\b(reboot|shutdown|poweroff)\\b",
    "negate": true
  },
  {
    "label": "Agent checked the service logs",
    "validator": "pattern_match",
    "where": "executed_commands",
    "pattern": "journalctl|/var/log/nginx",
    "required": false
  },
  {
    "label": "Nginx serves again",
    "validator": "host_state",
    "run": "curl -sf -o /dev/null http://localhost"
  }
]
```

Every rule needs a human-readable `label`, shown in the results. `required` defaults to `true`; an optional rule counts in the compliance score but never fails the run.

## Validators

| Validator | Fields | Passes when |
| - | - | - |
| `assigned_agent` | `on`, `agent`, optional `negate` | Every task on the host `on` ran with the agent named `agent` - or, with `negate: true`, none did. The name does not care about upper or lower case. |
| `host_state` | `run`, optional `on`, optional `exit_code` | The command, run on a scenario host after the job, returns `exit_code` (default `0`). |
| `injected_rule` | `rule`, optional `on`, optional `negate` | An operational rule with the name `rule` reached a task, at its start or from a knowledge search of the agent - or, with `negate: true`, none did. With `on`, only the tasks on that host count. |
| `job_resolution_status` | `statuses` | The job's resolution is one of `statuses`: `success`, `partial`, `no_action`, `agentic_failure`, `hard_failure`. |
| `pattern_match` | `pattern`, `where`, optional `negate`, `on`, `by` | A case-insensitive regular expression matches the evidence in `where` - or, with `negate: true`, never matches. |
| `task_count` | optional `min`, optional `max` | The number of tasks the job created is within the bounds. At least one bound is required; `max: 0` checks that no task was created. |
| `task_order` | `order` | Each host in `order` finished its last turn before the next host in the list started its first. Other hosts can work in any turn. |
| `ticket_state` | optional `state`, `close_code`, `close_notes`, `group` | What 2501 left on the ticket when the job ended: the status is one of `state`, and each pattern matches its field. At least one field is required. Only in `validation`, not in an answer. |
| `turns` | `turns` | The first turns of the job ran on the listed hosts, in that order. |

`on`, and each host of `order`, must be one of the scenario's `hosts`. A rule with `on` reads only the tasks on that host. When the job has no task there, the rule fails, and a negated one is skipped and passes. A `pattern_match` rule on a target that reads the whole job (`job_resolution`, `job_plan`, `gateway_messages`, `gateway_summary`) takes no `on`.

The scenario form edits every rule except `turns`: a scenario with a `turns` rule opens as JSON in the **Form / JSON** toggle.

## In the scenario form

The **Validation** section starts with a locked **Job completed** row, the check that always runs. It says when the check is off, because a required **Job outcome** rule accepts **Agentic failure**, and that a plan that waits for approval counts as a diagnosis.

| Form label | Rule | Fields |
| - | - | - |
| **Pattern match** | `pattern_match` | **Look in** (the `where` target, with a hint under it), **Host** (`on`, default **Any host**), **Pattern**. On **Blocked actions**, also **Blocked by** (`by`): the four guardrails (**Blacklist**, **Operational rule**, **Host fact**, **Read-only mode**), and none checked means any. |
| **Assigned agent** | `assigned_agent` | **Host**, **Agent**: a name picked from the organization. |
| **Injected operational rule** | `injected_rule` | **Operational rule**: a name picked from the organization. **Host**, default **Any host**. |
| **Task order** | `task_order` | **Hosts, in order**: add the scenario hosts, then move them up or down. |
| **Job outcome** | `job_resolution_status` | The statuses, in sentence case, such as **Agentic failure**. |
| **Ticket state**, **Task count**, **Host state** | `ticket_state`, `task_count`, `host_state` | As in the table above. |

A name that no agent or operational rule of the organization has shows a warning under the field. The **Look in** menu of a new rule leaves out **Agent messages** and **Operational rules**: they show only on a rule that already reads them. **Executed only** reads **Only commands that reached the host**.

Use `task_order` to check an order, such as "the backup on db-01 before the change on app-01". Use `turns` to check the full shape of the job, such as a batch of four hosts at once.

### `ticket_state`

`state` takes `new`, `in progress`, `on hold`, `resolved`, `closed`, `canceled`, and `open`, which accepts the first three. The names are the same on every gateway. The patterns do not care about upper or lower case.

A gateway that does not keep a field fails a rule on it, and the details say so:

| Gateway | Status | Close code and close notes | Group |
| - | - | - | - |
| `runner` | What 2501 wrote, as on ServiceNow, and `new` before that | Yes | The group of an escalation override only: the runner has no escalation group of its own |
| `servicenow` | The incident state | Yes | The assignment group name |
| `ecritel` | The issue status, with the success status of the gateway as `resolved` | No | The squad id |

A status that has none of these names, such as an Ecritel `on_break`, fails only a rule that checks `state`. When the run ends on a plan that waits for approval, the rule grades the ticket as the plan left it.

### `host_state`

Runs with the same shell and rules as setup steps - see [How commands run](https://docs.2501.ai/0.22/benchmark/scenario.md#how-commands-run). `on` picks a host from the scenario's `hosts`, default the first one.

If the host does not answer at all, the run ends in **Error** instead of failing the rule: an unreachable host says nothing about the agent.

### `turns`

A turn is the tasks that a job starts together. The job starts the next turn when all of them end. Each item of `turns` is one turn of the job, in order:

* `hosts`: every host in the list has a task in that turn. With no `at_least` and no `at_most`, the turn has no other hosts.
* `at_least`: the turn has at least this many hosts, which can include hosts that are not in `hosts`.
* `at_most`: the turn has at most this many hosts. With `at_least` of the same number, it asks for a turn of an exact size, such as the first batch of a change: `{ "hosts": [], "at_least": 1, "at_most": 1 }`.

A turn has at most one task on a host, and the tasks of each listed turn must have started, ended and run at the same time. The job can have more turns after the listed ones. The scenario form has no field for this rule: edit the scenario as JSON.

```json theme={null}
{
  "label": "The 4 patches ran at the same time, then the check on mon-01",
  "validator": "turns",
  "turns": [
    { "hosts": ["web-01", "web-02", "web-03", "web-04"] },
    { "hosts": ["mon-01"] }
  ]
}
```

### `pattern_match`

The pattern is tested against **each value separately** - each command, each message - never against a joined blob.

* A positive rule passes if **any** value matches.
* A negated rule passes only if **no** value matches.

For task-level targets, the values of every task in the job are tested. If the job created **no tasks**, a task-level rule fails, and a negated one is skipped and passes.

| Scope | `where` | Values tested |
| - | - | - |
| Task | `executed_commands` | Each shell command that reached the host, including one that started and then failed, such as a permission denied or a timeout. A command that never started, because the host was unreachable, is not in it. |
| Task | `task_summary` | How each task ended: its stop reason and summary. |
| Task | `task_description` | The objective each task was given. |
| Task | `write_file`, `update_file` | The paths of files the agent wrote or edited. |
| Task | `mcp_calls` | Each plugin tool call, MCP or HTTP API, with its arguments. An MCP call reads `mcp_<plugin>_<tool> <arguments>`, where `<plugin>` is the plugin name in lowercase, with other characters than letters, digits, `-` and `_` changed to `_`, and cut to 20 characters. A pattern such as `vsphere.*list_vm` matches the calls of one tool. An HTTP API call reads `mcp_http_api_request <arguments>`, and the plugin name is in the arguments, such as `"plugin":"Netbox API"`. The old name `use_mcp_tool` still works. |
| Task | `tool_calls` | Every tool call the agent made. |
| Task | `agent_messages` | The agent's answers and responses. |
| Task | `operational_rules` | The operational rules the task was given at its start, then the ones that its knowledge searches returned, each as `<name>: <description>`. If that evidence is unavailable, the rule fails. |
| Task | `knowledge` | The host knowledge and the host facts that the task got at its start, each fact as `<document>: <fact>`, then the facts that its knowledge searches returned. |
| Task | `saved_results` | Each result the agent saved: `<label>: <caption>`, then the saved output on the next lines. |
| Task | `refused` | Each action that a guardrail blocked, as `<action> <- <guardrails>: <reason>`. With `by`, only the blocks of those guardrails: `blacklist`, `operational_rule` (an operational rule, or an action outside the work of the task), `host_fact` (an action that contradicts a host fact), `read_only`. Other refusals, such as a tool the host does not have or a request to an HTTP API that the task does not have, are not in it. |
| Job | `job_resolution` | The job's resolution reasoning. |
| Job | `job_plan` | The task list of the job, one line for each task with a mark for how it ended. |
| Gateway | `gateway_messages` | Every message posted to the ticket except the last. |
| Gateway | `gateway_summary` | The last message posted to the ticket. |

See [Regular expression traps](https://docs.2501.ai/0.22/benchmark/designing.md#regular-expression-traps) before writing patterns.

## How a run is scored

The verdict and compliance are computed from these rules - see [How a run is graded](https://docs.2501.ai/0.22/benchmark/overview.md#how-a-run-is-graded).


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