# `H.Session.Tree`
[🔗](https://github.com/parlant/harness/blob/v0.3.0/lib/h/session/tree.ex#L1)

Read-only session-wide entry tree builder for live, cold native, and imported
archived sessions.

Projects raw session entries into bounded, single-line sanitized summary nodes
with explicit `parent_id` links and per-conversation `leaf_entry_id` pointers
without ever leaking raw base64 payloads or unbounded tool outputs.

# `build_archive`

```elixir
@spec build_archive(map(), map(), [map()], boolean()) :: {[map()], [map()], boolean()}
```

Builds `{conversations_wire, nodes_wire, truncated?}` from an imported
`H.Archive` (`conversations` map `%{cid => %{parent: nil | {pcid, at}, head: id | nil}}`,
`entries_index` map `%{id => {cid, parent_id, offset, size}}`, and decoded
selected entries in ascending ID order).

# `build_native`

```elixir
@spec build_native(map(), [map()], keyword()) :: {[map()], [map()], boolean()}
```

Builds `{conversations_wire, nodes_wire, truncated?}` from a native
`conversations` map (`%{cid => %{id, parent, owner, entry_ids}}`) and a list
of entries (in any order).

# `max_nodes`

```elixir
@spec max_nodes() :: pos_integer()
```

Maximum number of entry nodes included in a single tree response.

# `take_latest`

```elixir
@spec take_latest([term()], pos_integer()) :: {[term()], boolean()}
```

Selects up to `max_nodes` latest IDs from an ascending list of IDs, returning
`{selected_ids_asc, truncated?}`.

---

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