ADR-0307:
Hierarchical Sub-App Mounting (app_compose)
- Status: Accepted
- Date: 2026-11-28
- Related: ADR-0291 (Freeze Rust, Grow in Tenon), ADR-0292
(Application Actions API & State Deltas), ADR-0300
(
app.actions/v1.2), ADR-0301 (Semantic TUI Accessibility Tree)
Context
Tenon provides composable pure TUI primitives
(tui, tui_layout,
tui_shell) and a pure control-plane contract
(app_actions, state_delta), but
composing multiple independent App /
ActionApp panes into one unified multi-pane workspace
(such as an IDE or operator console with file browser, editor,
terminal, and log panes) still required manual wiring for:
- Pane focus & layout management: focus
ring cycling (
ws.focus_next/ws.focus_prev), direct and directional focus (ws.focus,ws.focus_dir), zoom toggling (ws.zoom), per-paneRectclipping,Caps.clusterpropagation, and namespaceda11y_nodes. - Action & state namespacing: merging child
ActionSpecs under<prefix>.*, isolating per-panestate_rev, projecting composite state under/<id>for accurate RFC-6901state_deltapatches, and routing CLI subcommands (<bin> <id> ...). - Fault isolation: preventing a trapping or faulty child pane from crashing or freezing healthy sibling panes, while rendering a clear recovery error card.
- Decoupled cross-pane communication: allowing one pane (e.g., a file tree) to notify another (e.g., an editor) without direct coupling or infinite feedback loops.
Decision
We introduce a pure (capabilities = []) library
plugin plugins/app_compose/ and extend
plugins/tui_shell/plugin.tn with cluster-aware error
card rendering, strictly in pure Tenon with zero Rust
compiler/runtime changes (ADR-0291):
1.
Hierarchical Workspace Composition
(app_compose.workspace)
- Defines the
PaneAppinterface unifying TUI (pane_update,pane_view),ActionApp(pane_project_state,pane_state_summary,pane_actions,pane_apply), cross-pane topics (pane_on_topic), recovery (pane_recover), and pure fault probing (pane_fault_probe). Workspace<P>mounts independent child panes viamount_pane(ws, id, action_prefix, layout, app)usingtui_layout.flex(fill_pane,fixed_pane,percent_pane,clamped_pane), tracking per-panestate_rev, cached canonicallast_projected,last_rect, and optionalPaneFault.- Built-in workspace actions:
ws.focus,ws.focus_next,ws.focus_prev,ws.focus_dir(left|right|up|down),ws.zoom,ws.recover, andws.emit_topic. - Child actions are automatically merged under
<action_prefix>.<action>. When a pane is faulted, its actions are markedenabled: false(pane_faulted) fail-closed while sibling actions remain active. - Composite
project_stateplaces each pane under/<id>alongside/_workspacemetadata (rev,focused_pane,zoomed_pane,pane_revs,faults,topic_stats). Because Tenon does not support genericimpl<P>blocks (E0657), concrete workspace wrappers delegateAppandActionApptoworkspace_update,workspace_view,build_composite_state,workspace_summary,workspace_actions, andworkspace_apply, plugging directly intoapp_actions.session.ActionSession. workspace_viewclips each pane to its computedRectviatui.compose.compose, threadsCaps.cluster, rebases hit targets, and translates/namespaces childa11y_nodesunder<pane_id>.*.route_cli_argsmaps<pane-id|prefix> <action> [args...]to<action_prefix>.<action>andws <subcmd> [args...]tows.<subcmd>.
2.
Fault Isolation & Error Cards (app_compose.fault
+ tui_shell.plugin)
tui_shell.pluginaddserror_card(slot, trap, recovery_hint, size, cluster) -> Blockandview_or_error_card(...), rendering a sanitized, bounded, cluster-aware bordered fault card (safe on zero/tiny sizes) displaying fault kind, source site, and recovery action hint.app_compose.faultprovidesPaneFault,FaultStage,fault_card_block,fault_card_screen(with anA11yRole.Statusnode), and hostTraps.containhooks (isolate_render,isolate_step,isolate_action, plusapply_contained_render,apply_contained_step,apply_contained_actiononWorkspace<P>).- On a trap, the faulty pane preserves its last good state,
records a
PaneFault, and renders its error card while all sibling panes remain interactive.ws.recoverclears the fault and invokespane_recover.
3. Pure Typed
TopicBus (app_compose.topic)
TopicEvent { topic, source_pane, payload_json, depth },EmitTopic, andemit_topic_effect(ActionEffect.kind == "emit_topic") enable decoupled pub/sub across mounted panes.- Subscriptions support exact matches,
"*", and"prefix.*"patterns, excluding self-echo (sub.pane_id != ev.source_pane). publishanddrain_workspace_topics/drain_and_dispatchenforce bounded delivery depth (max_depth, default8) and queue capacity (max_queue, default128), incrementingdropped_cycle_count/dropped_overflow_countinstead of looping infinitely.
Consequences
- Zero Rust changes;
app_composeandtui_shellremaincapabilities = []with identical behavior on native C (tenon test) andtenon interp. - Multi-pane Tenon apps gain fault-isolated composition,
namespaced
ActionApp/state_deltaintegration, and cycle-safe cross-pane pub/sub out of the box. - Ready for Wave 3 Barrier bundling into
edition = "2026"(crates/tenon-compiler/src/editions.rsandcrates/tenon-assets/build.rs).