# `Gralkor.CaptureBuffer`
[🔗](https://github.com/elimydlarz/gralkor/blob/main/lib/gralkor/capture_buffer.ex#L1)

In-flight conversation buffer keyed by `session_id`.

Holds turns until an explicit flush — session lifetime is owned by the
consumer; there is no idle-flush policy. On `flush/1` (or shutdown via
`flush_all/0` from `terminate/2`), the buffered turns are handed to the
configured `flush_callback` with retry: server-internal failures get the
configured backoff (default 1s/2s/4s); contract errors (4xx) and
upstream-LLM errors drop without retry.

See `ex-capture-buffer` in `gralkor/TEST_TREES.md`.

# `append`

Append one turn (a list of `Gralkor.Message`) to the session's buffer.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `flush`

Schedule a retry-backed flush of the session's turns. Returns `:ok` immediately.

# `flush_all`

Flush every buffered session and await each. Used at shutdown.

# `start_link`

# `turns_for`

Return the buffered turns for `session_id`, or `[]` if none.

---

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