H.Session.Tree (H v0.3.0)

Copy Markdown View Source

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.

Summary

Functions

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).

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).

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

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

Functions

build_archive(conversations, entries_index, decoded_entries, truncated?)

@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(conversations, entries, opts \\ [])

@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()

@spec max_nodes() :: pos_integer()

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

take_latest(list, max_nodes \\ 5000)

@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?}.