# `Juggernaut.Store.Layout`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/store/layout.ex#L1)

The layout of `_build/juggernaut/` and its version (design notes §7).

`ensure/1` creates the directory and its `LAYOUT` file. A directory with another
layout version (or with content but no `LAYOUT`) is moved aside to a sibling
`juggernaut-old-<UTC timestamp>` and a fresh one is started; old data is never read
with the wrong layout and never deleted. A store moved aside within the same second as an
earlier one gets a numbered name (`-2`, ...). Failures are infrastructure errors (exit 3).

`ensure/2` comes first: a run calls it once, before anything else touches the store. The
writers (`Store.Lock.acquire/3`, `Store.History.append/2`, `Store.Runs.write/2`) call
`check/1` and refuse a root without the current `LAYOUT`, because a later `ensure/2`
would move such a store, and everything just written into it, aside.

# `cache_file`

```elixir
@spec cache_file(Path.t()) :: Path.t()
```

`cache/results/`: the per-mutant result cache, sharded by file (`Juggernaut.Cache.Shard`).

# `check`

```elixir
@spec check(Path.t()) :: :ok | {:error, Juggernaut.Error.t()}
```

`:ok` when `root` is a store of the current layout (`ensure/2` has run); otherwise an
infrastructure error. The store writers check this before writing.

# `coverage_index_file`

```elixir
@spec coverage_index_file(Path.t()) :: Path.t()
```

`coverage/index.etf`: the coverage index.

# `ensure`

```elixir
@spec ensure(Path.t(), DateTime.t()) ::
  {:ok, :created | :current | {:moved, Path.t()}}
  | {:error, Juggernaut.Error.t()}
```

Makes `root` a store of the current layout: `{:ok, :created}`, `{:ok, :current}`, or
`{:ok, {:moved, old_path}}` when an incompatible store was moved aside.

# `events_file`

```elixir
@spec events_file(Path.t(), String.t()) :: Path.t()
```

`runs/<run_id>/events.ndjson`: the NDJSON event stream.

# `harness_log`

```elixir
@spec harness_log(Path.t(), String.t()) :: Path.t()
```

`runs/<run_id>/harness.log`: worker stderr and diagnostics.

# `history_file`

```elixir
@spec history_file(Path.t()) :: Path.t()
```

`history/runs.ndjson`: one summary line per finished run.

# `layout_file`

```elixir
@spec layout_file(Path.t()) :: Path.t()
```

`LAYOUT`: the layout version.

# `lock_file`

```elixir
@spec lock_file(Path.t()) :: Path.t()
```

`lock`: the checkout lock.

# `mte_file`

```elixir
@spec mte_file(Path.t(), String.t()) :: Path.t()
```

`runs/<run_id>/mutation.json`: the mutation-testing-elements export.

# `mutants_file`

```elixir
@spec mutants_file(Path.t(), String.t()) :: Path.t()
```

`runs/<run_id>/mutants.ndjson`: one `{mutant, result}` per line.

# `report_file`

```elixir
@spec report_file(Path.t()) :: Path.t()
```

`report/index.html`: the last dashboard.

# `run_dir`

```elixir
@spec run_dir(Path.t(), String.t()) :: Path.t()
```

`runs/<run_id>/`.

# `run_file`

```elixir
@spec run_file(Path.t(), String.t()) :: Path.t()
```

`runs/<run_id>/run.json`: the run without mutants and results.

# `runs_dir`

```elixir
@spec runs_dir(Path.t()) :: Path.t()
```

`runs/`: one directory per run.

# `sandbox_dir`

```elixir
@spec sandbox_dir(Path.t()) :: Path.t()
```

`sandbox/`: the persistent project mirror.

# `server_dir`

```elixir
@spec server_dir(Path.t()) :: Path.t()
```

`server/`: the warm server's address and token.

# `version`

```elixir
@spec version() :: String.t()
```

The layout version this Juggernaut writes.

---

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