# tmux_model

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** module
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_model.erl#L2
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_model/

Validated native domain records. Constructors perform no tmux I/O.

Missing optional observations remain not_loaded; required identity fields
must be supplied. Unavailable capabilities remain
unavailable. Neither state means an empty relation or known absence.
Rows created by `new/2` and the entity constructors are detached.
Entity constructors accept generated input-map types such as
`t:pane_input/0`. Use `new/2` to validate dynamic maps; Dialyzer checks
known constructor shapes but does not replace runtime validation.
Use `tmux_server:bind/2` to register a fresh observed row for actions;
use `m:tmux_snapshot` for captured graph relationships.

Observed rows carry a private `t:observation/0` value. Actions compare it
with the row's origin, snapshot identity and target fields, rejecting
mismatched observations before I/O. Valid-shaped binding mismatches return
observation_mismatch; detached and malformed rows keep their validation
errors. Retarget through
`tmux_server:bind/2`; it reads current values. This protects ordinary API
use, not authority against trusted code in the Erlang VM.

Native model version 2 adds this association. Discard version-1 rows and
snapshots on upgrade and freshly observe them. `to_map/1` extracts domain
fields for explicit schema validation; maps carry no actionable origin.

## Members

### Common operations

- [`#session{}`](/en/erlang/latest/reference/tmux_model-session/) (struct)
- [`#window{}`](/en/erlang/latest/reference/tmux_model-window/) (struct)
- [`#pane{}`](/en/erlang/latest/reference/tmux_model-pane/) (struct)
- [`new/2`](/en/erlang/latest/reference/tmux_model-new-2/) (function): Construct a detached row from validated observations.
- [`pane_input/0`](/en/erlang/latest/reference/t-tmux_model-pane_input-0/) (typealias): Trusted constructor fields for `pane/1`. Required keys use :=; optional observations may be not_loaded or unavailable. Integral floats are normalized to integers. Runtime validation still checks ranges, IDs, UTF-8 and derived values. Use `new/2` for dynamically validated maps.
- [`to_map/1`](/en/erlang/latest/reference/tmux_model-to_map-1/) (function): Return domain field values without origin or capture metadata. This is not the portable filter wire representation. Performs no I/O.

### Other members

- [`#window_link{}`](/en/erlang/latest/reference/tmux_model-window_link/) (struct)
- [`entity/1`](/en/erlang/latest/reference/tmux_model-entity-1/) (function): Return the built-in entity kind of a native row without I/O.
- [`get/2`](/en/erlang/latest/reference/tmux_model-get-2/) (function): Read a permitted domain field without I/O. Unknown fields raise unknown_field; unloaded and unavailable values remain distinct.
- [`model_version/1`](/en/erlang/latest/reference/tmux_model-model_version-1/) (function): Read the native model version. Unknown versions fail validation; record internals are not a persistence format.
- [`observation/0`](/en/erlang/latest/reference/t-tmux_model-observation-0/) (typealias): Private captured target association, created by observation. Retain with its row; construction and field access are internal. It is not an authorization or serialization format.
- [`origin/1`](/en/erlang/latest/reference/tmux_model-origin-1/) (function): Read the opaque origin token, or none for a detached row. This does not revalidate endpoint lifetime.
- [`pane_id/0`](/en/erlang/latest/reference/t-tmux_model-pane_id-0/) (typealias): A canonical pane ID binary in the percent namespace; nominal checking is by Dialyzer.
- [`pane/0`](/en/erlang/latest/reference/t-tmux_model-pane-0/) (typealias): A validated pane observation. Native records are experimental in OTP 29.
- [`pane/1`](/en/erlang/latest/reference/tmux_model-pane-1/) (function): Construct a detached pane row, validating required fields and scalar bounds without tmux I/O.
- [`row/0`](/en/erlang/latest/reference/t-tmux_model-row-0/) (typealias): One schema-defined native domain record, with separate origin and capture metadata.
- [`session_id/0`](/en/erlang/latest/reference/t-tmux_model-session_id-0/) (typealias): A canonical session ID binary in the dollar namespace.
- [`session_input/0`](/en/erlang/latest/reference/t-tmux_model-session_input-0/) (typealias): Trusted constructor fields for `session/1`. Required keys use :=; optional observations may be not_loaded or unavailable. Integral floats are normalized to integers. Runtime validation still checks ranges, IDs, UTF-8 and derived values. Use `new/2` for dynamically validated maps.
- [`session/0`](/en/erlang/latest/reference/t-tmux_model-session-0/) (typealias): A validated session observation. Native records are experimental in OTP 29.
- [`session/1`](/en/erlang/latest/reference/tmux_model-session-1/) (function): Construct a detached session row, validating required fields and scalar bounds without tmux I/O.
- [`snapshot_id/1`](/en/erlang/latest/reference/tmux_model-snapshot_id-1/) (function): Read the capture identity, or none when not associated with a snapshot. Performs no I/O.
- [`validate/1`](/en/erlang/latest/reference/tmux_model-validate-1/) (function): Validate native row shape, model version and normalized observations. Exported records do not enforce these invariants at construction. Performs no I/O.
- [`window_id/0`](/en/erlang/latest/reference/t-tmux_model-window_id-0/) (typealias): A canonical physical-window ID binary in the at-sign namespace.
- [`window_input/0`](/en/erlang/latest/reference/t-tmux_model-window_input-0/) (typealias): Trusted constructor fields for `window/1`. Required keys use :=; optional observations may be not_loaded or unavailable. Integral floats are normalized to integers. Runtime validation still checks ranges, IDs, UTF-8 and derived values. Use `new/2` for dynamically validated maps.
- [`window_link_input/0`](/en/erlang/latest/reference/t-tmux_model-window_link_input-0/) (typealias): Trusted constructor fields for `window_link/1`. Required keys use :=; optional observations may be not_loaded or unavailable. Integral floats are normalized to integers. Runtime validation still checks ranges, IDs, UTF-8 and derived values. Use `new/2` for dynamically validated maps.
- [`window_link/0`](/en/erlang/latest/reference/t-tmux_model-window_link-0/) (typealias): A validated window_link observation. Native records are experimental in OTP 29.
- [`window_link/1`](/en/erlang/latest/reference/tmux_model-window_link-1/) (function): Construct a detached window_link row, validating required fields and scalar bounds without tmux I/O.
- [`window/0`](/en/erlang/latest/reference/t-tmux_model-window-0/) (typealias): A validated window observation. Native records are experimental in OTP 29.
- [`window/1`](/en/erlang/latest/reference/tmux_model-window-1/) (function): Construct a detached window row, validating required fields and scalar bounds without tmux I/O.

## Guides

Pages that discuss `tmux_model`.

- [Native API documentation](/en/erlang/latest/guides/api-documentation/)
- [Installation](/en/erlang/latest/guides/installation/)
