agent-ssh 0.3.0

Arrange agent terminal layouts and reconnect through provider attachment plans
Documentation
# Agent attachment and terminal layout ownership

Status: the terminal consumer and managed Pulse producer are released. Pulse Agents 1.82.2 provides the managed attachment commands. This change adds existing-session tmux inspection and attachment using `libtmux`. Native harness discovery and Pulse's Marshal launch integration remain separate work.

## Decision

Keep agent lifecycle, native conversation identity, coordination, and terminal presentation separate. Restore resolves attachment intent. It does not create replacement agents.

| Object | Authority | Stored reference |
| --- | --- | --- |
| Native conversation and history | Native harness | Destination, harness, native state scope, conversation ID |
| Managed agent | Pulse Agents control plane | Authority, API origin, managed agent ID |
| Execution resource | Execution provider or harness backend | Provider-owned recovery handle |
| Launch operation | Marshal launch service or Pulse operation service | Owner-qualified operation ID |
| Coordination participant | Marshal | Marshal participant ID |
| Terminal pane and layout | Terminal client | Client-local view and placement |

A lost Marshal presence row does not prove process exit. A stopped execution does not imply a lost conversation. Closing a pane never means stopping its agent.

## Source evidence

The original attachment review used these source revisions:

- [Pulse Agents main 018787f](https://github.com/ignition-is-go/pulse-agents/tree/018787fbbaac72507dcd83629f46ffe6d63ba18b).
- [Marshal main 31a746b](https://github.com/ignition-is-go/marshal/tree/31a746b520bc5c7e7eba7f17882421a577749a90).
- [Marshal launch PR head 67c2d75](https://github.com/ignition-is-go/marshal/tree/67c2d7534e80674bff11460329c68ecb22ff0e1f).

Pulse's `AGENTS.md`, `GOAL.md`, product specification, and taxonomy govern its managed product. The `terminal-anywhere` document is a draft. At the reviewed base, the CLI has private `Destination` and `HandoffPlan` types. It does not export the draft's native session references. Its remote Codex path refuses non-Unix workstations.

Marshal main has no launch crate. Its reviewed PR introduces daemon-owned launch records and worker-owning `LaunchBackend` implementations. Its `StartLaunch` request describes fresh work, not an existing native conversation. Its `Launched.attach` field is a human-readable shell string. A terminal client must not split that string into argv or invoke `StartLaunch` as a reconnect fallback.

## Dependency topology

```text
Pulse Agents ----+
Marshal --------+---- libtmux ---- tmux
agent-ssh ------+

Pulse managed CLI producer ---- versioned resolution JSON ---- terminal client
             |                                                 |
             +---- agent-attachment-protocol leaf crate --------+
                                                               |
                                                        layout library

Marshal launch service ---- Pulse LaunchBackend ---- Pulse managed API
                                  (planned)
```

The accepted design has all three applications depend directly on the existing Rust `libtmux` crate. Each application retains its own integration and lifecycle policy. `agent-ssh` pins 0.1.2 for Unix-side session queries and exact-name lookup. Native Windows builds exclude that Unix-only dependency and execute the installed Unix application over SSH. Pulse and Marshal adoption must be verified in their own repositories; this diagram does not claim their migrations are complete.

Pulse separately implements Marshal's `LaunchBackend` contract. Marshal's native tmux route and its Pulse route use their respective `libtmux` integrations. Pulse keeps guest provisioning, authentication, harness selection, and durable agent identity. `agent-ssh` keeps Windows Terminal layout and attachment. No additional generic tmux wrapper crate is part of this design.

The JSON contract permits independent releases and avoids importing private service dependencies into the terminal tool. The experimental `agent-attachment-protocol` leaf crate contains the existing references, resolution states, attachment plans, and validation. Both terminal and Pulse CLI consumers use crates.io version 0.1.0. The terminal repository also uses a versioned path dependency for local development. Pulse does not depend on the terminal binary or layout library. The `agent-ssh` library keeps layout planning and re-exports the protocol under its existing `attachment` path. The JSON schema and validation behavior are unchanged.

The source repository is private. Published protocol packages and CLI installs use crates.io. Pulse's other private service dependencies retain their own build-token policy.

The terminal client's trusted resolver process is an adapter boundary. It must observe, not launch. The client verifies the returned target against the saved target. It discards failed or malformed replies rather than converting them into a fresh start.

Pulse's first producer uses its existing managed action catalog. A ready plan invokes the installed Pulse Agents CLI's explicit `attach` command. Authentication and tokenized terminal endpoints remain inside that command. Plan export never requests a terminal URL or changes runtime lifecycle.

No second session registry, transcript projection, credential store, universal harness protocol, or worker supervisor is added.

## Intent and observations

A version 2 terminal layout stores ordered pane intent and a per-tab pane count. A provider-backed pane stores an exact reference and a trusted resolver invocation. Every restore obtains a new observation. It does not write observations or executable plans back into the layout.

The initial resolution protocol supports local process handoff only. A command can invoke an existing provider's SSH attachment implementation. That does not establish native SSH support on every platform. Browser and tunnel plans remain unsupported until a caller proves their requirements.

`configured_command` preserves explicitly configured legacy local or SSH invocations. It is not an agent-health observation. Such a command can resume work because the operator configured it to do so. The terminal tool cannot prove that arbitrary local programs are read-only or credential-free.

## Recovery policy

| Observation | Restore behavior |
| --- | --- |
| Attachable | Compile the provider's attachment invocation |
| Saved conversation requiring resume | Report `resume_required`; no automatic resume |
| Unreachable destination | Retain intent and report `unreachable` |
| Ownership conflict | Report conflict; do not take over |
| Uncertain launch or attachment | Report `uncertain`; owner reconciles it |
| Deleted agent | Retain reference and report `deleted` |
| Unsupported platform or capability | Report `unsupported` |
| Otherwise unavailable | Report the provider's reason without executable actions |

Default restore opens no terminals if any resolved pane is non-ready. Explicit partial restore opens ready panes and reports skips. Partial grids compress remaining entries. This behavior does not alter saved placement intent.

A ready observation is not a lease. The provider's attach command rechecks availability. A race may make attachment fail, but that failure cannot trigger creation or task replay.

## Scope of shared code

The attachment JSON contract and tmux implementation reuse solve different problems. The contract communicates provider-owned attachment observations. `libtmux` supplies existing generic tmux mechanics. The earlier plan shared only the JSON contract and left custom tmux code in the consumers; that was incomplete.

The revised plan evaluates and reuses `libtmux` before adding custom backend code. A new generic `session-core` or tmux engine is not assumed. The managed provider remains behind its versioned attachment contract; sharing tmux mechanics does not transfer lifecycle authority to terminal restore.

## Naming and distribution

Use **terminal layout** for tabs and panes. Pulse reserves **workspace** for filesystem context. The repository is `ignition-is-go/agent-ssh`. Use the `agent-ssh` command. The shared protocol is published as an experimental 0.1 crate; it carries no stable API promise.

A future presentation-only binary may use a grid-oriented name. A future general session manager belongs with Pulse's native-session workflow. Naming and public release follow the acceptance gates in [the acceptance record](acceptance.md).