agent-ssh 0.2.1

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

Status: implemented terminal consumer, managed producer under verification. Native discovery extraction and Marshal launch integration are not implemented by this change.

## 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 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. The current 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 managed CLI producer ---- versioned resolution JSON ---- terminal client
             |                                                 |
             +---- agent-attachment-protocol leaf crate --------+
                                                               |
                                                        layout library

Marshal launch service ---- external backend protocol ---- lifecycle provider
                                                              |
                                                        Pulse managed API
```

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. The terminal client depends on it by path. Pulse's CLI depends directly on the leaf through a Git dependency pinned to `02aebded107e79245fec0037b7b95d6d540a259b`. It 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. Pulse builds need read access to both existing private dependencies and this pinned source. Its build-token allowlist must name the repository explicitly. Local builds using operator credentials do not establish CI or release access.

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.

## Why the other designs were rejected

A broad `session-core` extraction would freeze unproven platform behavior and duplicate Pulse's private native handoff code. A direct Marshal-launch dependency would import lifecycle orchestration without solving existing-conversation attachment. A separate lifecycle implementation in the grid repo would create competing recovery authority.

The independent comparison preferred a provider-neutral JSON boundary. It retained the concrete Pulse managed exporter from the producer-owned alternative. Public library distribution waits for real reuse.

## 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).