On this page

ADR-0304: One Action Catalog, Six Surfaces (derive AppSurface)

Context

Tenon applications routinely need to expose the same domain actions across multiple user and agent surfaces:

  1. A human-ergonomic CLI (subcommands, positional args, short flags, --help, shell completions, TTY-adaptive tables).
  2. A direct automation CLI (state, actions, act with --expected-rev, --approval-token, --dry-run).
  3. A dual-era MCP server (2026-07-28 + 2025-11-25) supporting both the flat-token 3+1 surface (app_state, app_actions, app_act, app_wait) and --mcp-direct per-action tool export.
  4. An interactive TUI Command Palette (Ctrl-P fuzzy search via tui_complete, inline argument prompt specs, and Ctrl-K Co-Pilot compact catalog).
  5. A loopback HTTP/JSON & SSE control plane (GET /state, GET /actions, POST /act, GET /events delta frames).
  6. A compile-time type-checked Tenon client for inter-app orchestration and unit tests.

Previously, wiring all six surfaces required duplicating action metadata, CLI flags, schemas, palette entries, HTTP routes, and typed builders by hand.

Decision

Introduce a pure (capabilities = []) GEN_ABI 2 generator and runtime adapter plugin plugins/app_surface/:

  1. derive AppSurface (app_surface.lib):
    • Consumes a single annotated Action catalog struct supporting @prefix, @name, @doc/@action_doc, @risk, @approval, @key, @positional, @short, @min, @max, and @choices.
    • Emits <Catalog>Cmd, <catalog>_specs(), <catalog>_decode(name, args_json), <catalog>_compact_catalog(), <catalog>_surface_catalog(), per-action typed client builders (<catalog>_call_<action>(...) -> ActionCall), and <catalog>_client_encode(cmd) -> ActionCall.
    • Fails closed (E0966) on unsupported field types, invalid or duplicate @short flags, duplicate action names or CLI subcommands, invalid @risk, inverted bounds, empty @choices, or schemas rejected by mcp.wire.schema_supported.
  2. Six Pure Runtime Adapters (capabilities = []):
    • app_surface.cli: Human CLI + Direct Actions CLI (dispatch_cli, render_help, render_subcommand_help, emit_completions for bash/zsh/fish, cli_ui-compatible format_actions_table and format_kv_output).
    • app_surface.mcp_surface: Dual-era MCP server (SurfaceMcpMode.Flat delegating to app_actions_mcp.bridge, and SurfaceMcpMode.Direct exporting per-action tools via mcp_server.lib).
    • app_surface.tui_palette: Ctrl-P tui_complete.palette.Palette builder, fuzzy filter (filter_palette), inline arg_prompt_spec, and Ctrl-K copilot_catalog.
    • app_surface.http_router: web.route + web.api-compatible pure loopback router for GET /state, GET /actions, POST /act, and GET /events (SSE state_delta frames), rejecting non-loopback Host/Origin headers with 403.
    • app_surface.client: Typed Tenon client (ActionClient<A>, client_call, client_dry_run, call_typed) executing generated compile-time checked ActionCall builders through ActionSession<A>.

Consequences