Display Architecture¶
This maintainer-facing page explains the internal display architecture built around DisplayContext.
If you only need to understand what appears in the terminal during a run, start with Transcript and Display Reference instead.
Overview¶
Every renderer receives a DisplayContext instead of constructing its own Console or reading environment variables directly. This keeps rendering testable, predictable, and easier to audit.
The DI invariant¶
The following rules are enforced by tests/display/test_di_invariants.py,
which scans every *.py under ralph/display/ and ralph/banner.py
at test time:
Console(may only appear inralph/display/theme.py.Theme(may only appear inralph/display/theme.py.os.environandos.getenvmay only appear inralph/display/context.pyandralph/display/content_condenser.py.
To opt a line out of the invariant scan, append # noqa: di-allow to it
and document why in the same commit.
Environment variables¶
The following environment variables influence display behaviour. All are
resolved once during make_display_context(); no renderer reads the
environment after that.
Width and mode
Variable |
Effect |
|---|---|
|
Any truthy value ( |
|
Positive integer overrides the console’s auto-detected width. |
Color
Variable |
Effect |
|---|---|
|
Any value disables color. Takes precedence over |
|
Any value forces color on non-TTY streams. |
Glyphs
Variable |
Effect |
|---|---|
|
Any truthy value disables Unicode glyphs; ASCII fallbacks are used
(e.g. |
|
Disables Unicode glyphs via the same fallback path as
|
Streaming
Variable |
Effect |
|---|---|
|
Set to |
|
Set to |
Long content
Variable |
Effect |
|---|---|
|
Set to |
|
Set to |
Mode thresholds¶
Mode |
Trigger |
|---|---|
|
Terminal width < 60 columns, or |
|
Terminal width 60–99 columns. |
|
Terminal width ≥ 100 columns. |
In compact mode, renderers suppress secondary table columns, extra blank
lines, and descriptive Rules to fit narrow terminals.
Iteration context labels¶
When the pipeline renders phase-start banners, [phase-close] lines, and the
final completion panel, it uses a set of canonical iteration labels that appear
consistently across all three display surfaces.
Label format |
Style |
Meaning |
|---|---|---|
|
Bold sky-blue ( |
Outer development cycle number (1-indexed). Shows |
|
Purple ( |
Inner analysis loop iteration. Shows |
|
Bold orange ( |
Remaining invocations allowed by the active budget counter. |
These labels are produced by helpers in ralph.display.phase_status
(format_dev_cycle, format_analysis_cycle) and consumed via
PhaseIterationContext when rendering [phase-close] lines.
Lifecycle view-model¶
The ralph.display.phase_lifecycle module defines the single source of
truth for data flowing through phase-start banners, phase-close after-banners,
and the final run summary. Three frozen dataclasses capture the lifecycle:
Class |
Used by |
|---|---|
Phase-start banners ( |
|
Phase-close after-banners ( |
|
Final run-completion panel and |
All three share the same canonical iteration fields
(outer_dev_iteration, outer_dev_cap, inner_analysis,
inner_analysis_cap) so every surface expresses iteration context in the
same vocabulary derived from ralph.display.phase_status.
Phase-close line format¶
After each phase ends, a structured [phase-close] line is written to the
transcript:
<ISO-TS> INFO META [phase-close] <glyph> phase=<name> [Dev N/cap] [Analysis N/cap] <produced> exit=<trigger> (elapsed=Ns, content_blocks=N, thinking_blocks=N, tool_calls=N, errors=N)
The
<glyph>prefix (◆Unicode,*ASCII) appears only for milestone-role phases (execution, review, fix).Canonical iteration labels (
[Dev N/cap]or[Dev #N],[Analysis N/cap]or[Analysis #N], etc.) appear between the phase name and the produced-artifact summary when aPhaseIterationContextis provided.exit=<trigger>(e.g.exit=produced) appears after the artifact summary when anexit_triggerstring is supplied toemit_phase_close. Runner code passesexit_trigger="produced"for all artifact-success paths.The trailing counter tuple always appears so every
[phase-close]line carries phase-level activity metrics.
See also¶
The full API reference for all display modules is available in the Python API Reference page, generated from docstrings.