# `MingaEditor.Shell.Runtime`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/shell/runtime.ex#L1)

Immutable owner of the editor's active shell runtime value.

A runtime contains one resolved registry entry, the state produced by that shell, and stashed states tied to exact registry identities. Registry lookup and every effectful policy decision stay outside this module. Callers resolve entries and initialize replacement states before invoking a transition.

# `persistence_change`

```elixir
@type persistence_change() ::
  {MingaEditor.Shell.Entry.t(), shell_state(), shell_state()}
```

# `shell_state`

```elixir
@type shell_state() :: MingaEditor.Shell.shell_state()
```

# `stash`

```elixir
@type stash() :: %{
  required(MingaEditor.Shell.Identity.t()) =&gt; MingaEditor.Shell.StateStash.t()
}
```

# `t`

```elixir
@type t() :: %MingaEditor.Shell.Runtime{
  entry: MingaEditor.Shell.Entry.t(),
  stash: stash(),
  state: shell_state()
}
```

# `accept_persisted_state`

```elixir
@spec accept_persisted_state(t(), MingaEditor.Shell.Entry.t(), shell_state()) :: t()
```

Installs state returned by persistence for the exact active or stashed registration.

# `accept_rendered_state`

```elixir
@spec accept_rendered_state(
  t(),
  atom(),
  MingaEditor.Shell.Identity.t(),
  shell_state()
) :: t()
```

Installs shell state returned by a render for the exact active identity.

# `activate`

```elixir
@spec activate(t(), MingaEditor.Shell.Entry.t(), shell_state()) :: t()
```

Activates a resolved entry, stashing the outgoing state and restoring only an exact identity match.

# `active_entry?`

```elixir
@spec active_entry?(t(), MingaEditor.Shell.Entry.t()) :: boolean()
```

Returns true when a resolved entry is exactly the active registration.

# `active_session`

```elixir
@spec active_session(t()) :: pid() | nil
```

Returns the active session through the active shell contract.

# `active_tab`

```elixir
@spec active_tab(t()) :: MingaEditor.State.Tab.t() | nil
```

Returns the active tab through the active shell contract.

# `active_tab_kind`

```elixir
@spec active_tab_kind(t()) :: atom()
```

Returns the active tab kind through the active shell contract.

# `blur_bottom_panel`

```elixir
@spec blur_bottom_panel(t()) :: t()
```

Routes bottom-panel blur through the active shell contract.

# `default_entry`

```elixir
@spec default_entry() :: MingaEditor.Shell.Entry.t()
```

Returns the deterministic built-in entry used by raw Editor state construction.

# `drop_extension_feature_state_sources`

```elixir
@spec drop_extension_feature_state_sources(t(), [MingaEditor.Shell.Entry.t()]) :: t()
```

Drops extension feature state through active and exact-identity stashed shell callbacks.

# `drop_feature_state_source`

```elixir
@spec drop_feature_state_source(
  t(),
  [MingaEditor.Shell.Entry.t()],
  MingaEditor.FeatureState.source()
) ::
  t()
```

Drops one feature-state source through active and exact-identity stashed callbacks.

# `entry`

```elixir
@spec entry(t()) :: MingaEditor.Shell.Entry.t()
```

Returns the resolved active entry.

# `fallback_from_removed`

```elixir
@spec fallback_from_removed(t(), MingaEditor.Shell.Entry.t(), shell_state()) :: t()
```

Falls back from a removed active registration without stashing its now-unresolvable value.

# `find_tab_by_buffer`

```elixir
@spec find_tab_by_buffer(t(), pid()) :: MingaEditor.State.Tab.t() | nil
```

Finds a tab through the active shell contract.

# `id`

```elixir
@spec id(t()) :: atom()
```

Returns the active shell id.

# `identity`

```elixir
@spec identity(t()) :: MingaEditor.Shell.Identity.t()
```

Returns the exact identity of the active resolved entry.

# `install_traditional_state`

```elixir
@spec install_traditional_state(t(), MingaEditor.Shell.Traditional.State.t()) :: t()
```

Installs a value produced by a named Traditional.State transition when Traditional is active.

# `matches_identity?`

```elixir
@spec matches_identity?(t(), MingaEditor.Shell.Identity.t()) :: boolean()
```

Returns true when an asynchronous identity belongs to the active entry.

# `module`

```elixir
@spec module(t()) :: module()
```

Returns the active shell contract module.

# `new`

```elixir
@spec new(MingaEditor.Shell.Entry.t(), shell_state()) :: t()
```

Builds a runtime from an already-resolved entry and initialized shell state.

# `owns_agent_session?`

```elixir
@spec owns_agent_session?(t(), [MingaEditor.Shell.Entry.t()], pid()) :: boolean()
```

Returns whether the active or an exact-identity stashed entry owns a session.

# `restorable?`

```elixir
@spec restorable?(t(), MingaEditor.Shell.Entry.t()) :: boolean()
```

Returns whether an exact-identity stashed value can restore the resolved entry.

# `retire_buffer`

```elixir
@spec retire_buffer(t(), pid()) :: t()
```

Retires a dead buffer from active and exact-identity stashed Traditional values.

# `route_agent_event`

```elixir
@spec route_agent_event(t(), MingaEditor.Shell.workspace(), pid(), term()) ::
  {t(), MingaEditor.Shell.workspace(), persistence_change() | nil}
```

Routes an agent event through the active entry.

# `route_buffer_added`

```elixir
@spec route_buffer_added(
  t(),
  MingaEditor.Shell.workspace(),
  MingaEditor.Shell.workspace(),
  MingaEditor.Shell.BufferMetadata.t()
) :: {t(), MingaEditor.Shell.workspace()}
```

Routes workflow-prepared buffer metadata through the active shell outside root transitions.

# `route_buffer_died`

```elixir
@spec route_buffer_died(t(), MingaEditor.Shell.workspace(), pid()) ::
  {t(), MingaEditor.Shell.workspace()}
```

Routes buffer-removal lifecycle through the active shell.

# `route_buffer_switched`

```elixir
@spec route_buffer_switched(t(), MingaEditor.Shell.workspace()) ::
  {t(), MingaEditor.Shell.workspace()}
```

Routes buffer-switch lifecycle through the active shell.

# `route_event`

```elixir
@spec route_event(t(), MingaEditor.Shell.workspace(), term()) ::
  {t(), MingaEditor.Shell.workspace()}
```

Routes a shell event through the active entry's contract.

# `route_gui_action`

```elixir
@spec route_gui_action(t(), MingaEditor.Shell.workspace(), term()) ::
  {t(), MingaEditor.Shell.workspace()}
```

Routes a shell GUI action through the active entry's contract.

# `route_remote_session_disconnected`

```elixir
@spec route_remote_session_disconnected(t(), pid()) ::
  {t(), boolean(), persistence_change() | nil}
```

Routes a remote disconnect through the active entry.

# `route_session_down`

```elixir
@spec route_session_down(t(), pid(), term()) ::
  {t(), boolean(), persistence_change() | nil}
```

Routes an optional active session-down transition through the active entry.

# `route_session_restarted`

```elixir
@spec route_session_restarted(
  t(),
  [MingaEditor.Shell.Entry.t()],
  pid(),
  pid(),
  term()
) ::
  {t(), boolean(), [persistence_change()]}
```

Routes a session restart through the active and exact-identity stashed entries.

# `route_stashed_agent_event`

```elixir
@spec route_stashed_agent_event(
  t(),
  [MingaEditor.Shell.Entry.t()],
  MingaEditor.Shell.workspace(),
  pid(),
  term()
) :: {t(), MingaEditor.Shell.workspace(), [persistence_change()]}
```

Routes an agent event through exact-identity stashes using caller-resolved entries.

# `route_stashed_remote_session_disconnected`

```elixir
@spec route_stashed_remote_session_disconnected(
  t(),
  [MingaEditor.Shell.Entry.t()],
  pid()
) ::
  {t(), boolean(), [persistence_change()]}
```

Routes a remote disconnect through the first exact-identity stash that owns it.

# `route_stashed_session_down`

```elixir
@spec route_stashed_session_down(t(), [MingaEditor.Shell.Entry.t()], pid(), term()) ::
  {t(), boolean(), [persistence_change()]}
```

Routes session-down through the first exact-identity stash that owns it.

# `set_tab_session`

```elixir
@spec set_tab_session(t(), term(), pid() | nil) :: t()
```

Associates a session with a shell tab through the active contract.

# `stash`

```elixir
@spec stash(t()) :: stash()
```

Returns the identity-keyed shell-state stash.

# `state`

```elixir
@spec state(t()) :: shell_state()
```

Returns the active shell state.

# `sync_agent_status`

```elixir
@spec sync_agent_status(t(), [MingaEditor.Shell.Entry.t()], pid(), term()) :: t()
```

Routes an optional agent status update through active and stashed entries.

# `track_agent_file`

```elixir
@spec track_agent_file(t(), [MingaEditor.Shell.Entry.t()], pid(), String.t()) :: t()
```

Routes optional agent-file tracking through active and stashed entries.

# `validate_registration`

```elixir
@spec validate_registration(t(), MingaEditor.Shell.Entry.t(), shell_state()) ::
  {t(), :current | :reset}
```

Accepts the currently resolved active entry or resets state when its registry identity changed.

---

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