Raxol.Terminal.Capabilities.Ladder (Raxol Terminal v2.6.1)

Copy Markdown View Source

Degradation ladder: pure tier selection over the capability record (roadmap T3 seam, 04 design §1c / §7).

Modes:

  • :inline_log -- the inline hybrid (scroll-region history + pinned footer). Requires a real terminal, no multiplexer, and either a Modern/Rich tier or Core with verified sync-output.
  • :tmux_conservative -- inside tmux/screen: clamped caps, no OSC marks assumed consumed.
  • :flat -- append-only + plain prompt, zero regions/cursor jumps. The screen-reader answer, the CI/pipe answer. Always safe.

Env overrides: RAXOL_FORCE_FLAT=1 forces :flat (downgrade is always safe; a forced downgrade on a capable terminal emits the [:raxol, :degradation, :forced_downgrade] telemetry so it is at least observable). RAXOL_FORCE_MODE=inline_log on an incapable record is REFUSED -- select/2 returns {:error, :incapable} and assert_capable!/2 raises IncapableModeError. Fail loud, never emit inline sequences to a terminal that cannot host them (LAD-N-01).

Summary

Functions

Fail-loud guard: raises IncapableModeError when the mode cannot be hosted (LAD-N-01). Never proceed and corrupt.

Can this record host the given mode? Downgrades are always safe; :inline_log needs the scroll-region floor (proxy until T0's verdict: tier + sync_output -- 04 §10 Q5) and no multiplexer.

Non-raising guard: :ok or {:error, :incapable}.

The three ladder modes.

Selects the rendering mode for a capability record. Total: always {:ok, mode} or {:error, reason}, never raises (LAD-P-02).

Types

mode()

@type mode() :: :inline_log | :tmux_conservative | :flat

Functions

assert_capable!(mode, caps)

@spec assert_capable!(mode(), Raxol.Terminal.Capabilities.t()) :: :ok

Fail-loud guard: raises IncapableModeError when the mode cannot be hosted (LAD-N-01). Never proceed and corrupt.

capable?(atom, caps)

@spec capable?(mode(), Raxol.Terminal.Capabilities.t()) :: boolean()

Can this record host the given mode? Downgrades are always safe; :inline_log needs the scroll-region floor (proxy until T0's verdict: tier + sync_output -- 04 §10 Q5) and no multiplexer.

guard(mode, caps)

@spec guard(mode(), Raxol.Terminal.Capabilities.t()) :: :ok | {:error, :incapable}

Non-raising guard: :ok or {:error, :incapable}.

modes()

@spec modes() :: [mode()]

The three ladder modes.

select(caps, env \\ %{})

@spec select(Raxol.Terminal.Capabilities.t(), map()) ::
  {:ok, mode()} | {:error, term()}

Selects the rendering mode for a capability record. Total: always {:ok, mode} or {:error, reason}, never raises (LAD-P-02).