Skip to content

Run an owned PTY application through Request #107

Open

Description

@tony

Summary

Add an owned application API that starts literal argv in a PTY, accepts interactive input, and returns the application's exit status or signal with a bounded final screen. The existing Request and control-watch machinery owns asynchronous work, but the public core has no Program owner combining application startup, completion and teardown.

Motivation

A Lua or Neovim caller can create a pane, send input and capture its screen, but must assemble application completion, final-output accounting and cleanup itself. Server:command completion and a visible-text match provide narrower evidence. The draft resource-lifecycle PR #27 overlaps ownership machinery and needs reconciliation before Program implementation proceeds.

Evidence

Current source and scope

Source inspection at 8c4def75911a9db561f27c5426a1befa3d02bff1:

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

Proposal

Deliver Server:start_program(argv, options) returning a Request for an owned Program, an owning run-to-completion call, and Request-returning wait, input, screen and stop operations. Preserve existing value/error settlement and expose status/signal, output loss and cleanup receipts. Reuse domain encoding, bound endpoints, runtime scopes and control watches; extend appropriate #27 machinery rather than adding a competing lifecycle engine.

  • Copy and validate argv, cwd, environment, geometry and limits before effects. Preserve singleton executables, empty later arguments and metacharacters as data. Reject invalid or unrepresentable requests before creation.
  • Extend the existing registry and generated manifest for the program contract and required event/drain primitives; use Expose the capability map through the public API #104 for public capability discovery. Bind decisions to the connected daemon evidence. Qualify the first path on released tmux 3.8, with pre-effect refusal below each requirement or for unknown profiles unless an equivalent fallback is evidenced. Test patch/prerelease policy, client/daemon mismatch, replacement and manifest drift.
  • Register lifetime and completion observation before release. Keep application exit, shell-command completion and visible readiness distinct. Return normal status versus signal and bounded final rendered bytes, with merged PTY stdout/stderr, encoding rules and explicit history/byte loss.
  • Separate waiter timeout/cancellation from owning-run cancellation. On owning cancellation, stop and join accepted resources while retaining primary and cleanup failures and a recoverable owner for incomplete cleanup.
  • Fence input and cleanup against external respawn, pane removal, daemon replacement and reused IDs. Establish process-group termination with ignored TERM, owner death and orphan recovery; state the limit for descendants that daemonize and for filesystem locality.
  • Keep both luv and Neovim event loops responsive with bounded callbacks, queues and retained bytes. Lua 5.1 requires explicit scopes; neither __gc nor Lua 5.4-only __close establishes the portable cleanup contract.
  • Add native tests for fast exit/final writes, interactive input, pressure, setup/wait/run cancellation, replacement and cleanup on owned sockets, with negative controls for critical gates. Run floor/current adapters, an installed rock consumer, complete command/interactive/cancellation examples, LuaLS/native docs checks and exact-head CI.
  • Document capability discovery, rendered screen versus terminal stream and cleanup recovery; keep changelog-only commits separate. Preserve Lifecycle(feat): Add owned tmux resource scopes #27's unresolved failures and Fix what the verification pass flagged #51's remaining qualification findings.

Raw replayable streams, borrowed-shell OSC 133 completion and layout work remain follow-ups. Existing visible-text waiting retains its own contract. No MCP server exists in this trunk; a future adapter should share core-owned program handles and capability/status/loss/cleanup data.

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