# `Pixir.Fork`
[🔗](https://github.com/Ranvier-Technologies/pixir/blob/main/lib/pixir/fork.ex#L1)

Inter-Session fork planning and execution (ADR 0024).

A fork creates a new child Session Log by replaying a prefix of a parent Session's
canonical History. The parent Log is never mutated.

# `dry_run`

```elixir
@spec dry_run(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, map()}
```

Plan a fork without writing the child Log.

# `fork`

```elixir
@spec fork(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, map()}
```

Create a child Session Log from a parent prefix.

# `fork_root_session_id`

```elixir
@spec fork_root_session_id([Pixir.Event.t()], String.t()) :: String.t()
```

Resolve the fork-tree root Session id for Provider cache-family routing (ADR 0020).

Returns the root from the first `session_fork` Event when present; otherwise
`session_id` (a non-fork Session is its own root).

# `plan`

```elixir
@spec plan(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, map()}
```

Build a fork plan for CLI dry-run and execution.

# `replay_types`

```elixir
@spec replay_types() :: [atom()]
```

Canonical event types copied into a child fork Log.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
