# 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 agent lifecycle: launch IDs, backend recovery handles, process status, stop, roster/session binding, and first-task delivery. Its `LaunchBackend` contract includes `check`, `recovery_handle`, `launch`, `recover`, `stop`, and `status`. The built-in tmux and external SSH backends implement that contract. `Launched` includes an optional human-readable attach command.
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.
The current workspace format stores explicit argv. 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.
When the launch API lands, a Marshal workspace adapter should:
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 stop, credentials, provisioning, and first-task delivery in Marshal. Moving a pane must not imply stopping or relaunching its worker.
This tool could later become a Marshal terminal client or a workspace-oriented subcommand. It should not itself become a `LaunchBackend` merely to arrange panes: terminal attachment and agent lifecycle are distinct responsibilities.