On this page

ADR-0306: Universal Live App Discovery & Attachment Bus (tenon app)

Context

app_actions and app_actions_mcp let an app expose typed state and actions, but only to the process that owns the session (--mcp-actions stdio, a co-pilot overlay, a test). A coding agent cannot find the TUI the human is already using, read what is on its screen, or act on it without launching a second copy. app_actions_tui.wire has a DiscoveryRecord codec but nothing publishes or consumes it.

Decision

A new pure-.tn plugin plugins/app_bus/ and a bundled CLI examples/tools/tenon-app/ (tenon app), with no Rust changes.

  1. Leases (app_bus.lease). A live app writes <pid>.lease.json (pid, app, cwd, endpoint, socket_path, state_rev, state_summary, started_ms) to $XDG_RUNTIME_DIR/tenon/apps, else ~/.cache/tenon/apps. Publication is write-temp, chmod 0600, rename (atomic). The directory is created 0700 and must be owned by the euid. scan removes leases whose PID is gone or whose socket refuses a connection, and rejects without trusting any lease with a wrong owner or mode. --no-app-sock or TENON_APP_SOCK=0 disables publication.
  2. Wire v1 (app_bus.proto). One JSON object per LF line over a Unix socket: ping, state, actions, act, screen (text or a11y), approvals, mcp. Replies carry rev. Lines are capped at 1 MiB, args at 64 KiB. act honours expected_rev (stale calls get stale_rev).
  3. Server (app_bus.server, app_bus.host). BusServer<A: ActionApp> is a pure state machine over ActionSession<A> (the same engine MCP uses, so policy, redaction, undo and state_rev apply). host.pump is nonblocking and is called from the app's tick; host.refresh republishes state_rev and state_summary. Sockets are 0600 and proc.accept verifies the peer uid.
  4. Approval gate. act and mcp (tools/call app_act, single or batch) on Destructive or requires_approval actions queue a pending prompt and return approval_pending + approval_id; they never execute. The host app renders pending_prompts, marks them shown and feeds Events to on_event: Event.Presented makes shown prompts presented, key y approves only a presented prompt (otherwise ignored), n denies. The retry must carry approval_token; it must match the action and exact args, is single use, and is passed to the session as presented_approval_id, so the existing ADR-0225 gate re-checks it. No wire op can approve. dry_run previews need no approval.
  5. tenon app. ls, state, actions, act, screen, mcp-bridge, each with --json. Targets resolve as <pid>, <app> or <app>@<pid>; ambiguity is an error. act waits for the human by polling approvals (--approval-timeout-ms, --no-wait); exit 3 means approval pending, denied or timed out (never auto-approved).
  6. tenon-dev-mcp. app.ls, app.state, app.actions, app.screen (read) and app.act (write) shell out to tenon app ... --json.

Native shim

Fs has no rename, unlink, chmod, rmdir or owner query, and Tenon has no PID liveness call. plugins/app_bus/native/tz_app_bus.h (about 100 lines of C, [ffi] shim in the same style as proc and wallclock) provides exactly those six primitives; all policy stays in .tn.

Consequences

Limits and follow-ups

Registration (Coordinator, Wave 3 barrier)

app_bus must be registered as a bundled edition plugin (library, capabilities ffi, fs, native header native/tz_app_bus.h) in crates/tenon-assets/build.rs and crates/tenon-compiler/src/editions.rs, and tenon app wired through BundledAppSpec in crates/tenon/src/main.rs / app_launcher.rs (snippet in the Wave 3 completion post).