Skip to content

feat(pty): add Unix spawn provider - #53

Open
passcod wants to merge 26 commits into
feat/spawn-providersfrom
feat/unix-pty-provider
Open

feat(pty): add Unix spawn provider#53
passcod wants to merge 26 commits into
feat/spawn-providersfrom
feat/unix-pty-provider

Conversation

@passcod

@passcod passcod commented Aug 25, 2026

Copy link
Copy Markdown
Member

🤖 Adds the Unix half of wrapper-native PTY transport to the 11.0 command/provider stack.

Summary

  • expose a stateful Tokio Pty spawn-provider wrapper through the ordinary .wrap(Pty::default()).spawn() lifecycle
  • return the ordinary boxed child contract and provide one-shot controller extraction through arbitrary transparent child layers
  • preserve merged terminal output, strong input/output ownership, weak resize ownership, VEOF policy, and independent child-wait/output-drain lifecycles
  • compose with process sessions, leader process groups, signal-mask reset, and direct-child kill-on-drop while rejecting incompatible group attachment and opaque command state
  • preserve Android, DragonFly BSD, FreeBSD, illumos, Linux, macOS, NetBSD 10+, OpenBSD, and Solaris support with atomic close-on-exec descriptor allocation
  • make provider rollback terminate the safely anchored PTY group and reap the direct child across later hook errors and panics
  • add portable-target, unsupported-target, lifecycle, ownership, cancellation, and package/documentation coverage

The non-default pty feature implies tokio1. This PR is stacked on #52.

passcod and others added 22 commits August 25, 2026 11:50
Port the low-level Unix PTY transport from e905958 behind the ordinary wrapper and provider lifecycle.

Co-Authored-By: Claude <noreply@anthropic.com>
Wait for the direct child through its native owner before draining the rest of the process group, keeping cached child state synchronized.

Co-Authored-By: Claude <noreply@anthropic.com>
Rewrite the frozen transport and supervision coverage around Command::wrap(Pty).spawn() and one-shot controller extraction.

Co-Authored-By: Claude <noreply@anthropic.com>
Cover one-shot controller traversal, portable post-spawn state, duplicate and conflicting providers, explicit-spawner rejection, rollback after hook failures, and provider reuse.

Co-Authored-By: Claude <noreply@anthropic.com>
Keep the migrated test helper distinct from the removed public PTY spawning API.

Co-Authored-By: Claude <noreply@anthropic.com>
Document controller ownership, merged output, draining and supervision lifecycles, complete Unix support, and the non-default Tokio feature without reviving the rejected builder API.

Co-Authored-By: Claude <noreply@anthropic.com>
Exercise the opt-in PTY feature in the frontend matrix and cross-check every supported Unix backend.

Co-Authored-By: Claude <noreply@anthropic.com>
Keep the portable unsupported API warning-free while compiling Unix-only child and native command internals solely for implemented backends.

Co-Authored-By: Claude <noreply@anthropic.com>
Verify platform availability wins over invalid size, native-only state, and pre-spawn hook side effects.

Co-Authored-By: Claude <noreply@anthropic.com>
Verify callers can end canonical input with the terminal control character while retaining both strong master owners.

Co-Authored-By: Claude <noreply@anthropic.com>
Verify native children and self-terminal custom chains terminate traversal with no PTY controller.

Co-Authored-By: Claude <noreply@anthropic.com>
Keep provider-only command mutations out of post-spawn attempt state and synchronize lifecycle rollback with the terminal child through the owned Tokio process.

Co-Authored-By: Claude <noreply@anthropic.com>
Wait through the direct child owner and stop using a numeric process-group ID once that child has been reaped. Retain the original PTY PID only for installing supervision around a provider child reaped by an earlier lifecycle hook.

Co-Authored-By: Claude <noreply@anthropic.com>
Exercise clean post-spawn native materialization, nested controller traversal and commitment, rollback after hook-driven reaping, and live process-group cleanup.

Co-Authored-By: Claude <noreply@anthropic.com>
Compile documentation examples, exercise the unsupported Unix backend, verify package contents, and keep target-specific provider internals warning-free.

Co-Authored-By: Claude <noreply@anthropic.com>
Clarify that process-group and session wrappers retain group-wide signalling only while the owned child is live, and cover descendant-held PTY output without unsafe post-reap group lookup.

Co-Authored-By: Claude <noreply@anthropic.com>
Update attach-to coverage for safe direct-child waiting without retaining or polling a foreign numeric process-group identity after exit.

Co-Authored-By: Claude <noreply@anthropic.com>
Create PTY endpoints with close-on-exec atomically where the native APIs permit it, reject pre-10 NetBSD before hooks, and use Solarish no-ctty STREAMS pushes so session-leader parents remain detached.

Co-Authored-By: Claude <noreply@anthropic.com>
Ensure the shared terminal child remains usable after its cancellation-safe wait future is dropped while pending.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
passcod and others added 4 commits August 26, 2026 00:42
Forward-integrate the provider-stack correction without rewriting the
published Unix PTY history.

Co-Authored-By: Claude <noreply@anthropic.com>
Forward-integrate the provider-stack lockfile correction without rewriting
the published Unix PTY history.

Co-Authored-By: Claude <noreply@anthropic.com>
Forward-integrate the provider-stack documentation correction without
rewriting the published Unix PTY history.

Co-Authored-By: Claude <noreply@anthropic.com>
Release automation owns the next package version, so the new PTY dependency
example continues to name the current release.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant