# `Tia.Map`
[🔗](https://github.com/devaction-labs/tia/blob/v0.1.0/lib/tia/map.ex#L1)

The recorded dependency map and the rules that keep it honest.

For each test file the map stores the source files it executed and one
fingerprint: the content hash of the test file and of every one of those
sources. A test file is stale when it has no entry or when its fingerprint
no longer matches the files on disk, so the map validates itself and needs
no help from `git`.

A separate `globals` fingerprint covers what a per-test map cannot see:
dependencies, configuration, migrations, `test_helper.exs` and any file that
defines macros. When it changes, every test file is stale.

# `selection`

```elixir
@type selection() :: {:run, [String.t()]} | {:all, String.t()}
```

# `t`

```elixir
@type t() :: %{required(String.t()) =&gt; term()}
```

# `affected`

```elixir
@spec affected(t(), [String.t()]) :: [String.t()]
```

Test files whose recorded sources include any of the changed paths.

# `delete`

```elixir
@spec delete(t(), String.t()) :: t()
```

Forgets a test file, which makes it stale until it is recorded again.

# `globals`

```elixir
@spec globals(Tia.Config.t()) :: String.t()
```

The fingerprint of everything the per-test map cannot see.

# `new`

```elixir
@spec new(Tia.Config.t()) :: t()
```

An empty map stamped with the current globals.

# `plan`

```elixir
@spec plan(t(), Tia.Config.t()) :: selection()
```

What a local run has to execute: `{:all, reason}` when the globals moved,
otherwise `{:run, stale_test_files}`.

# `prune`

```elixir
@spec prune(t(), Tia.Config.t()) :: t()
```

Drops the entries of test files that no longer exist on disk.

# `put`

```elixir
@spec put(t(), Tia.Config.t(), String.t(), [String.t()]) :: t()
```

Stores the sources a test file executed, fingerprinted against the disk.

# `read`

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

Reads a map, or `:error` when it is missing, unreadable or of another version.

# `select`

```elixir
@spec select(t(), [String.t()], Tia.Config.t()) :: selection()
```

What CI has to execute for a diff: the stale test files plus every test file
whose recorded sources include a changed path.

# `stale`

```elixir
@spec stale(t(), Tia.Config.t()) :: [String.t()]
```

Test files on disk that have no entry or whose fingerprint no longer matches.

# `test_files`

```elixir
@spec test_files(Tia.Config.t()) :: [String.t()]
```

Every test file on disk.

# `write`

```elixir
@spec write(t(), Path.t()) :: :ok
```

Writes the map with one test file per line, so concurrent edits merge cleanly.

---

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