# path_checks

Entity-path checks: rules on the blocks each entity visits (order, never, at most N times, always), checked by `naga check` on one traced replication.

In the model file this key holds a list of entries.

## Typical uses

These sections guard and present a model. `assertions` check that a KPI stays on the right side of a bound. `path_checks` check which blocks entities visit. A `dashboard` defines the tiles, gauges and charts that a viewer sees, and the inputs a viewer may change. Use the first two as tests of a model, and the third for people who did not build it.

## Behaviour and rules

An assertion names a KPI key, an operator and a value. It passes only when the whole confidence interval over its `replications` clears the bound, at the given `confidence`. The operator `==` means inside the value plus or minus `tolerance`. `naga check` runs the assertions, and assertions with the same replication count run together.

A path check has one of four rules. `order` needs an entity to reach a first block before a later one. `never` forbids a block. `at_most` limits the visits. `always` requires that every entity that left through a DISPOSE visited the block. A path check is judged on one traced replication.

A dashboard widget is an expression sampled at the same instants as the time series. Without `pages`, the dashboard that Present mode shows is generated from the model. The `limits` cap what a run started by a viewer may cost.

## Fields

| Field | Type | Required | Default | Unit | Description |
|---|---|---|---|---|---|
| `name` | string | yes |  |  | The rule's name, as the check lists it. |
| `description` | string |  |  |  | What the rule guards; the run does not read it. |
| `rule` | choice | yes |  |  | "order": an entity that visits both blocks reaches "first" before "then" (first visits). "never": no entity visits "block". "at_most": none visits it more than "count" times. "always": every entity that left through a DISPOSE visited it; one still in the system at the end is not judged by this rule. One of `order`, `never`, `at_most`, `always`. |
| `block` | string |  |  |  | The block of a never, at_most or always rule. |
| `first` | string |  |  |  | An order rule's earlier block. |
| `then` | string |  |  |  | An order rule's later block. |
| `count` | integer |  |  |  | An at_most rule's most visits per entity. |
| `e_type` | string |  |  |  | Judge entities of this type only: the type an entity had when last seen. |

A field of a nested object is described in the JSON Schema (`naga schema`).

## Example

```json
{"path_checks": [{"name": "Everything leaves", "rule": "always", "block": "dispose_1"}]}
```

In the Python builder the section is a keyword of `Model`:

```python
from nagasim import build as nb
m = nb.Model(path_checks=[{'name': 'Everything leaves', 'rule': 'always', 'block': 'dispose_1'}])
```

## Used in

Guides: [Model assertions and CI](../../model-assertions.md).

## See also

- [All sections](index.md), [Model file keys](../schema.md), [Model file format](../../model-file-format.md)
