# `AgentWorkshop.Persistence`
[🔗](https://github.com/joshrotenberg/agent_workshop/blob/main/lib/agent_workshop/persistence.ex#L1)

Persist work board, store, and events to disk.

Subscribes to PubSub and writes state to JSON files on change. On startup,
loads saved state back into ETS tables so work survives IEx restarts.

## Files

- `work.json` -- full work board snapshot
- `store.json` -- full store snapshot
- `events.jsonl` -- append-only event log (one JSON object per line)

## Configuration

    configure(persistence: true)              # use .agent_workshop/ in cwd
    configure(persistence: "/path/to/dir")    # custom directory

Persistence is disabled by default. When disabled, this GenServer is idle.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `disable`

```elixir
@spec disable() :: :ok
```

Disable persistence. Closes open file handles.

# `enable`

```elixir
@spec enable(boolean() | String.t()) :: :ok
```

Enable persistence to the given directory.

Pass `true` to use the default `.agent_workshop/` in the current directory,
or a path string for a custom location.

# `enabled?`

```elixir
@spec enabled?() :: boolean()
```

Check if persistence is currently enabled.

# `flush`

```elixir
@spec flush() :: :ok
```

Force an immediate flush of all pending writes.

---

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