# `ExUnitJSON.Trace.Store`
[🔗](https://github.com/ZenHive/ex_unit_json/blob/main/lib/ex_unit_json/trace/store.ex#L1)

Cross-process handoff store for trace data captured by `ExUnitJSON.Trace.Recorder`.

Tracing happens inside the test process (and its tree); the JSON is emitted by
`ExUnitJSON.Formatter`, which runs in a *separate* process and only learns of a
test at `:test_finished` (when the test process is already dead). This module
bridges the two: a tiny registered owner process holds a named public ETS table
that recorders write to (keyed by the test's `{module, name}`) and the formatter
reads from.

A dedicated owner process (rather than letting the formatter own the table)
avoids an init-ordering race: a test's `setup` may run before the formatter's
`init/1`, and writing into a not-yet-created table would crash. `ensure_started/0`
is idempotent and safe to call from both the formatter and every traced test.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `clear`

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

Drops all stored entries. Called at suite finish to bound memory against any
entries left by tests that were written but never read.

# `ensure_started`

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

Starts the store if it is not already running. Idempotent and concurrency-safe.

# `put`

```elixir
@spec put(term(), term()) :: :ok
```

Stores `value` under `key`. Called by a recorder from the test process tree.

# `take`

```elixir
@spec take(term()) :: term() | nil
```

Removes and returns the value stored under `key`, or `nil` if absent.

---

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