Skip to content

Run literal argv through an owned application handle #89

Open

Description

@tony

Summary

Add an owned application handle that runs literal argv in a PTY, accepts interactive input, and returns the application's exit status or signal with a bounded final screen. LibTmux.Server.run/3 currently executes a tmux command; the implementation contract still lists the owned program runner as planned.

Motivation

An Elixir service can create a pane running an argv command and send input, but it must assemble application completion, output draining, cancellation and cleanup itself. A completed tmux operation does not establish that the application started, consumed input or exited.

Evidence

Current source and scope

Source inspection at 4d4b854e35e42d00afdaa3a95dfa294aeefd040b:

  • The implementation contract lists the runner as planned.
  • Server.run/3 accepts LibTmux.Command and returns one-shot command evidence.
  • Pane creation already distinguishes shell source from literal argv and has a packaged singleton-argv helper.

This is a source-backed proposal. No new Elixir runtime qualification was performed for this issue.

Proposal

Deliver a first core API around LibTmux.Program.start/3, an owning run-to-completion call, independent waits, literal input, screen capture and explicit stop. Use tagged results and a supervised OTP owner that retains application and cleanup results. Reuse the existing command encoder, native helper, daemon identity and control admission; keep blocking external I/O outside owner callbacks and bound admitted work and output delivery.

  • Copy and validate argv, working directory, environment, geometry and limits before effects. Preserve a lone executable, empty later arguments and shell metacharacters as data.
  • Add discoverable capability decisions for the program contract and each required primitive, bound to the connected daemon incarnation. Qualify the first implementation on released tmux 3.8; refuse older or unknown profiles before creating a pane, helper or temporary file unless an equivalent fallback is evidenced. Keep patch and prerelease parsing separate from exact profile qualification and generated-metadata drift checks.
  • Register completion and lifetime observation before releasing the application. Distinguish application exit from shell-command completion and visible readiness. Return normal status and signal separately, with final rendered screen bytes, merged PTY stdout/stderr, encoding rules and explicit history or byte loss.
  • A cancelled or timed-out wait leaves the program running. Cancellation of an owning run terminates and joins its accepted resources. Preserve both primary and cleanup failures and retain a recovery handle when cleanup is incomplete.
  • Bind writes and cleanup to the accepted daemon and application generation. Refuse external respawn, removed panes and reused identifiers. Define process-group termination, ignored TERM, caller/owner death, orphan recovery and the limit for descendants that daemonize; terminal ownership supplies no filesystem or network confinement.
  • Add critical native tests for fast exit and final writes, interactive input, cancellation during setup and wait, output pressure, replacement races and cleanup on owned private sockets. Include negative controls for subscription, final-drain, ownership and capability gates, plus installed-package examples and exact-head CI.
  • Ship runnable command and interactive examples with capability discovery and explicit cleanup, update native specs/reference exports and migration notes, and keep changelog-only commits separate. Raw replayable streams, borrowed-shell OSC 133 waits and layout work remain explicit follow-ups.

The existing MCP delivery issue #4 remains its own package task. Future MCP tools should reuse these core owners and capability decisions, expose structured status/loss/cleanup and retire only their accepted resources. #83 continues to own generic visible-text waiting; #18 concerns the control-supervision recipe rather than a Program runner.

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions