# Marshal and agent-ssh
Reviewed against [Marshal PR #180](https://github.com/ignition-is-go/marshal/pull/180), `feat/launch-core`. This API is still work in progress.
Marshal owns launch orchestration, launch IDs, backend recovery handles, roster binding, and first-task delivery. Its proposed `LaunchBackend` contract includes `check`, `recovery_handle`, `launch`, `recover`, `stop`, and `status`. The selected backend owns its execution resource. `Launched` includes an optional human-readable attach command.
The accepted dependency topology uses `libtmux` directly in Marshal, Pulse Agents, and `agent-ssh`. It does not introduce a shared generic tmux wrapper library. Pulse separately implements Marshal's `LaunchBackend` contract through Pulse's lifecycle API:
```text
Marshal
+-- native tmux LaunchBackend --> libtmux --> native agent
+-- Pulse LaunchBackend ------> Pulse Agents --> libtmux --> guest agent
agent-ssh --> libtmux for existing tmux attachment
--> Windows Terminal for pane layout
```
Pulse's backend integration and the other consumers' dependency migrations are separate work. This change implements `agent-ssh`'s Unix-side inspection and exact existing-session lookup. Its Windows SSH path invokes the installed Unix `agent-ssh` command. It neither requires Marshal's daemon nor imports its launch records.
agent-ssh owns the operator's terminal workspace: ordered pane commands, local working directories, Terminal profiles, panes per tab, restore, and moving existing panes between tabs. It does not implement another launch registry or claim to recover a running worker from its terminal title. Local sessions are supported alongside SSH sessions.
Explicit-command panes store argv. Version 2 provider-backed panes store references and resolve fresh attachment plans during restore. Existing Marshal-compatible SSH/tmux attach scripts and `marshal-shim codex-run resume THREAD_ID` commands can be used without linking an unreleased Marshal dependency. This is command-level compatibility, not a live integration with the launch API.
An attachment integration with Marshal must:
1. Save launch IDs as references to Marshal records, not copy backend handles as new authoritative records.
2. Query status/recover through Marshal before attaching. A restore must not silently issue another launch when attachment is unavailable.
3. Preserve the exact Codex thread binding and matching client/server version. A newer client can trigger an isolated server and ownership locks, as observed during recovery on this machine.
4. Use structured attach argv from the backend if available. The current optional `attach` string is human-readable and crosses two shells; do not split it on whitespace or execute it through an implicit local shell.
5. Leave launch orchestration and first-task delivery in Marshal. Leave Pulse-backed agent lifecycle, credentials, and guest provisioning in Pulse. Moving a pane must not imply stopping or relaunching its worker.
`agent-ssh` arranges terminal panes and attaches to existing executions. Pulse's `LaunchBackend` integration provides managed launch capability. These responsibilities remain separate even though both use `libtmux`.