Skip to content

Add an authenticated cross-process recorder control channel #77

Description

@abrichr

Problem

openadapt-capture exposes Recorder.stop() and internal stop events inside the recorder process. It does not expose a cross-process control contract. The launcher therefore cannot stop a recorder that another terminal started.

The launcher formerly printed a success-shaped message for openadapt capture stop even though it did not stop anything. The launcher fix now returns non-success and directs the operator to Ctrl+C in the recorder terminal. This is a truthful interim result, not the target product behavior.

Target contract

Add a local, authenticated, owner-only control channel for an active Capture session.

  • Create the channel before the recorder reports ready.
  • Bind each request to the exact session identifier and recorder instance. Prevent PID-reuse and stale-descriptor confusion.
  • Authenticate the local operating-system user. Keep any capability token out of command-line arguments, process listings, logs, and recording artifacts.
  • Use local IPC, such as a protected Unix-domain socket on macOS/Linux and a protected named pipe on Windows. Do not expose an unauthenticated TCP listener or a writable global stop file.
  • Make stop idempotent. A repeated request for the same terminal session must not corrupt or duplicate finalization.
  • On a graceful stop, flush the event stream and media, write complete terminal metadata atomically, and return success only after the saved session passes its integrity checks.
  • If finalization times out or the recorder disconnects, return non-success and retain explicit incomplete-session metadata. Do not report a complete recording.
  • Remove the control endpoint on normal exit. Detect and remove a stale endpoint only after proving that its bound recorder instance is no longer live.
  • Expose a small public client API so the launcher does not read private Capture database or process state.

Acceptance

  • Subprocess tests prove ready -> status -> stop -> complete session on macOS, Windows, and Linux.
  • Tests prove wrong-user or wrong-token requests, stale endpoints, repeated stop, recorder crash, and finalization timeout fail closed.
  • openadapt capture stop calls the public client API and returns success only for a confirmed, complete stop.
  • Flow and Desktop can reuse the same control contract without implementing a second native recorder.

Current workaround

Use Ctrl+C in the terminal that owns the active raw Capture session. Use openadapt flow record for a compile-ready recording.

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