ADR-0306:
Universal Live App Discovery & Attachment Bus
(tenon app)
- Status: Accepted
- Date: 2026-11-28
- Related: ADR-0291 (Freeze Rust, Grow in Tenon),
ADR-0292/0293/0300 (
app.actionsv1-v1.2), ADR-0225 (presented approvals), ADR-0301 (tui_a11y), ADR-0296 (test_caps)
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.
- 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 created0700and must be owned by the euid.scanremoves 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-sockorTENON_APP_SOCK=0disables publication. - Wire v1 (
app_bus.proto). One JSON object per LF line over a Unix socket:ping,state,actions,act,screen(textora11y),approvals,mcp. Replies carryrev. Lines are capped at 1 MiB, args at 64 KiB.acthonoursexpected_rev(stale calls getstale_rev). - Server (
app_bus.server,app_bus.host).BusServer<A: ActionApp>is a pure state machine overActionSession<A>(the same engine MCP uses, so policy, redaction, undo andstate_revapply).host.pumpis nonblocking and is called from the app's tick;host.refreshrepublishesstate_revandstate_summary. Sockets are0600andproc.acceptverifies the peer uid. - Approval gate.
actandmcp(tools/call app_act, single or batch) onDestructiveorrequires_approvalactions queue a pending prompt and returnapproval_pending+approval_id; they never execute. The host app renderspending_prompts, marks them shown and feedsEvents toon_event:Event.Presentedmakes shown prompts presented, keyyapproves only a presented prompt (otherwise ignored),ndenies. The retry must carryapproval_token; it must match the action and exact args, is single use, and is passed to the session aspresented_approval_id, so the existing ADR-0225 gate re-checks it. No wire op can approve.dry_runpreviews need no approval. tenon app.ls,state,actions,act,screen,mcp-bridge, each with--json. Targets resolve as<pid>,<app>or<app>@<pid>; ambiguity is an error.actwaits for the human by pollingapprovals(--approval-timeout-ms,--no-wait); exit 3 means approval pending, denied or timed out (never auto-approved).tenon-dev-mcp.app.ls,app.state,app.actions,app.screen(read) andapp.act(write) shell out totenon 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
- Any app that embeds
app_bus.hostbecomes attachable;app_host(Wave 3) can callstart_unless_disabledandpumpfor every app. - Agents see the same
state_revas the human, so concurrent edits surface asstale_revinstead of silent overwrites. - A hostile local process of another uid cannot attach (0700
dir, 0600 socket, peer uid check). A process of the same
uid can; that is the intended trust boundary, same as
procmanandagentd. - The liveness probe connects to each socket, so a live app sees
short empty connections during
ls;host.pumptolerates them. tenon-dev-mcpruns children sandboxed to--rootwith a cleared env, soapp.*needs the runtime directory and sockets reachable (an exec-profile or sandbox exception); that is a deployment decision, not made here.
Limits and follow-ups
- Endpoints are
unix:<path>only; the lease field is an opaqueendpointso loopback TCP can be added without a format change. started_msis supplied by the host.state_summarycomes fromActionApp.state_summary.- TUIs that block in
tty.waitmust callpumpon every wake orTick;proc.waitis for headless daemons (one wait per process). scancannot delete orphan sockets that have no lease.
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).