<!-- https://tinyactors.dev/cli/commands/path/ -->
# tinyactors path

Kind: reference. For: [Workflow developer who tests](https://tinyactors.dev/audiences/workflow-tester.xml), [Agent-platform engineer](https://tinyactors.dev/audiences/agent-platform.xml).
Voice: [Reference](https://tinyactors.dev/voices/reference.xml).

> Find the shortest path to a state: events, conditions and transitions.

Find the shortest path to a state: events, conditions and transitions.

<a id="usage"></a>

## Usage

```shell
tinyactors path [options] INPUT...
```

Searches a chart's configurations breadth first for one holding the `--to` state. It starts from the initial configuration, or from the `--from` state. Any transition whose source is active may be taken: events come in any order and conditions may hold. So each step lists the events that take it and the condition it needs. The chart is the first one, or the one `--chart` names.

<a id="options"></a>

## Options

- **`-W, --warnings-as-errors`**: Refuse a chart that compiles with a warning.
- **`-I, --include DIR`**: Search `DIR` for a src that is not beside the file naming it, in the order given. Repeatable.
- **`-c, --chart NAME`**: Look at the chart named `NAME` only. Repeatable.
- **`-s, --segment N`**: Read the image that segment N of a snapshot runs. Default: the newest live segment.
- **`-t, --to STATE`**: Search for a configuration that holds `STATE`.
- **`--from STATE`**: Start in `STATE`, entered with its defaults. Default: the initial configuration.
- **`-u, --unreachable`**: Succeed only when no path exists, and exit with 1 otherwise.

Configure output formats like `-f json` using the [shared options on the command reference](https://tinyactors.dev/cli/commands/index.md#program-options).

<a id="examples"></a>

## Examples

```shell
tinyactors path order.scxml --to shipped
```

```text title="output"
# Path

- **Chart**: order
- **From**: 
- **To**: shipped
- **Result**: found
- **Meaning**: the steps below reach it, if their events come and their conditions hold
- **Transitions**: 3
- **Explored**: 5
- **Start**: open

## Steps

| Step | Events | Eventless | Condition | Source | Targets | Active |
| --- | --- | --- | --- | --- | --- | --- |
| 1 | checkout | no | total > 0 | open | paying | paying |
| 2 | charge.ok | no |  | paying | paid | paid |
| 3 | shipped | no |  | paid | shipped | shipped |
```

Find the shortest path to shipped.

```shell
tinyactors path order.scxml --from cancelled --to paid --unreachable
```

```text title="output"
# Path

- **Chart**: order
- **From**: cancelled
- **To**: paid
- **Result**: unreachable
- **Meaning**: no sequence of transitions reaches it, whatever events come and conditions hold
- **Transitions**: 0
- **Explored**: 1
- **Start**: cancelled

## Steps

_none_
```

Fail if paid can be reached from cancelled.

```shell
tinyactors path -f json --chart payment shop.tai --to settled
```

```text title="output"
{
  "chart": "payment",
  "from": "",
  "to": "settled",
  "result": "found",
  "meaning": "the steps below reach it, if their events come and their conditions hold",
  "transitions": 2,
  "explored": 4,
  "start": "pending",
  "steps": [
    {
      "step": 1,
      "events": "authorize",
      "eventless": false,
      "condition": "",
      "source": "pending",
      "targets": "authorized",
      "active": "authorized"
    },
    {
      "step": 2,
      "events": "capture",
      "eventless": false,
      "condition": "",
      "source": "authorized",
      "targets": "settled",
      "active": "settled"
    }
  ]
}
```

Find a path in one chart of an image as JSON.

<a id="exit-status"></a>

## Exit status

- **`1`**: An input is refused: it does not compile or verify, or it is damaged or of an unknown format.
- **`1`**: Without `--unreachable`, no path exists or the search stops at its limit.
- **`1`**: With `--unreachable`, a path exists, or the search stops at its limit.
- **`3`**: A file cannot be read or written, or memory runs out.

<a id="see"></a>

## Related pages

- **[`tinyactors states`](https://tinyactors.dev/cli/commands/states/index.md)**: List each chart's states as a tree in document order.
- **[`tinyactors transitions`](https://tinyactors.dev/cli/commands/transitions/index.md)**: List each chart's transitions with events, conditions and targets.
- **[`tinyactors events`](https://tinyactors.dev/cli/commands/events/index.md)**: List every event name and the transitions, raises and sends using it.
- **[`tinyactors data`](https://tinyactors.dev/cli/commands/data/index.md)**: List each chart's data declarations.
- **[`tinyactors expressions`](https://tinyactors.dev/cli/commands/expressions/index.md)**: List each chart's expressions and scripts with where they are.
- **[`tinyactors graph`](https://tinyactors.dev/cli/commands/graph/index.md)**: Draw each chart, or list its boxes and edges.
- **[`tinyactors disassemble`](https://tinyactors.dev/cli/commands/disassemble/index.md)**: List each chart's executable content instruction by instruction.
- **[`tinyactors inspect`](https://tinyactors.dev/cli/commands/inspect/index.md)**: Show what an image, a snapshot or a blob holds.

## Commands

- [tinyactors compile](https://tinyactors.dev/cli/commands/compile/)
- [tinyactors check](https://tinyactors.dev/cli/commands/check/)
- [tinyactors inspect](https://tinyactors.dev/cli/commands/inspect/)
- [tinyactors states](https://tinyactors.dev/cli/commands/states/)
- [tinyactors transitions](https://tinyactors.dev/cli/commands/transitions/)
- [tinyactors events](https://tinyactors.dev/cli/commands/events/)
- [tinyactors data](https://tinyactors.dev/cli/commands/data/)
- [tinyactors expressions](https://tinyactors.dev/cli/commands/expressions/)
- [tinyactors disassemble](https://tinyactors.dev/cli/commands/disassemble/)
- [tinyactors graph](https://tinyactors.dev/cli/commands/graph/)
- [tinyactors diff](https://tinyactors.dev/cli/commands/diff/)
- [tinyactors lint](https://tinyactors.dev/cli/commands/lint/)
- [tinyactors path](https://tinyactors.dev/cli/commands/path/)
- [tinyactors fmt](https://tinyactors.dev/cli/commands/fmt/)
- [tinyactors actors](https://tinyactors.dev/cli/commands/actors/)
- [tinyactors run](https://tinyactors.dev/cli/commands/run/)
- [tinyactors help](https://tinyactors.dev/cli/commands/help/)
- [tinyactors version](https://tinyactors.dev/cli/commands/version/)
