# `MingaAgent.EventLog.TouchedFiles`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/event_log/touched_files.ex#L1)

Projects the latest admitted file edit for each path in an agent session.

Durable event ids define recency. Replaying the same event or an older event
cannot replace a newer touch for the same path.

# `action`

```elixir
@type action() :: :created | :modified | :deleted
```

How the latest admitted edit changed a file.

# `rejection`

```elixir
@type rejection() ::
  {:invalid_file_edit, :event_id | :path | :before_content | :after_content}
```

Why a file-edit event cannot enter the projection.

# `t`

```elixir
@type t() :: %MingaAgent.EventLog.TouchedFiles{
  by_session: %{required(String.t()) =&gt; session_entries()}
}
```

# `touch`

```elixir
@type touch() :: %{path: String.t(), action: action(), timestamp: integer()}
```

Extension-facing summary of one touched file.

# `list`

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

Lists one session's latest file touches, most recent first.

# `new`

```elixir
@spec new() :: t()
```

Creates an empty touched-file projection.

# `rebuild`

```elixir
@spec rebuild([MingaAgent.EventLog.EventRecord.t()]) ::
  {:ok, t()} | {:error, rejection()}
```

Rebuilds the projection from persisted events in durable order.

# `record`

```elixir
@spec record(t(), MingaAgent.EventLog.EventRecord.t(), pos_integer()) ::
  {:ok, t()} | {:error, rejection()}
```

Applies one durably identified event to the projection.

# `validate`

```elixir
@spec validate(MingaAgent.EventLog.EventRecord.t()) :: :ok | {:error, rejection()}
```

Validates fields required to project a file-edit event.

---

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