Skip to content

Define ownership and cancellation contracts for readers, PTYs, and output #355

Description

@stalep

Review of terminal-detect, terminal-api, and terminal-tty at 859020a6 on 2026-09-28.

Review item: Design 4
Priority: P2
Evidence: Design work motivated by reproduced leaks, hangs, and routing failures.

Problem / scope

Borrowed standard streams, owned device descriptors, daemon readers,
executors, native arenas, and renderer writes currently use inconsistent
lifecycle rules. Some paths cannot detect EOF; others free resources before
reads finish or skip cleanup after restore failure.

Document these contracts and identify the smallest shared implementation
boundaries. This is coordination/design work over the linked concrete bugs,
not another request to fix them in one large change.

Source at the reviewed commit

Acceptance criteria

  • Define owner, close/cancel behavior, EOF/error notification, repeat-open policy, and callback thread for each transport.
  • Keep borrowed System.in/out usable and make owned native resources releasable after cancellation.
  • Provide a common behavioral test matrix that each implementation can exercise, including output serialization and raw renderer access.

Tracking

Part of #300. Related: #335, #336, #337, #338, #341, #344, #311, #339.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions