# Orca CLI contract recheck on 1.4.245

- Issue: #1090; hub task #643.
- Date: 2026-11-02, Asia/Seoul.
- Orca: `orca --version` printed `1.4.245`. The earlier observations in `src/cli/terminal-recovery.ts` were made on 1.4.223.
- Result: every command and error code agent-hub depends on for reading is **observed** on 1.4.245 and matches what the code expects. The commands that create, close or switch a pane are **unverified**, on purpose: this probe never creates, switches, closes or writes to a live pane.

## How this was checked

Read-only commands only, against the person's running Orca, from a script that printed field names, types, counts and error codes, never a value: `orca --version`, `orca terminal list --json`, `orca terminal show --terminal <handle> --json`, `orca terminal wait --terminal <handle> --for tui-idle --timeout-ms 1 --json`, `orca worktree current --json`, `orca worktree list --json`, and `--help` for the command groups. A `wait` returns at once when the terminal is already idle and otherwise times out after the 1 ms given, so it changes no pane. The error cases used a made-up handle that no terminal has, and a temporary directory Orca does not manage. No terminal handle, tab id, leaf id, worktree id, host name or path is recorded here, and nothing in this receipt can be used to find a pane.

## Commands the code reads, and what 1.4.245 does

| Command (as `terminal-recovery.ts` runs it) | Observed on 1.4.245 | What the code needs |
| --- | --- | --- |
| `terminal list --json` | exit 0, `ok: true`. `result` holds `terminals` (a list), `totalCount`, `truncated`, `hostScope` and `topologyRevisions`. A row holds `handle`, `incarnationId`, `worktreeId`, `worktreePath`, `agentIdentity`, `orphaned`, `writable`, `connected`, `title`, `preview`, `tabId`, `leafId`, `ptyId`, `branch`, `executionHostId` and `lastOutputAt`. `truncated` was `false` and `totalCount` equalled the row count. Every row had a non-empty `handle` and `incarnationId`, and both were unique across the list. | `listTerminals` reads `result.terminals` (or `result.items`). The complete-inventory check refuses a `truncated: true` list, a non-list, a row without a full identity, and a repeated handle or incarnation. |
| `terminal show --terminal <handle> --json` | exit 0, `ok: true`. `result.terminal` holds the same identity fields as a list row plus `agentWait`, `paneRuntimeId` and `rendererGraphEpoch`. Its `handle`, `incarnationId` and `worktreeId` equalled the list row's. | `terminalObject` unwraps `result.terminal`. `verifyBindingData` compares `handle`, `incarnationId`, `worktreeId` and the root. |
| `terminal wait --terminal <handle> --for tui-idle --timeout-ms <n> --json` | On a terminal that was already idle: exit 0 and `result.wait`. On one that was not idle within the timeout: exit 1 with `{"ok":false,"error":{"code":"timeout","message":...}}` (error keys `code` and `message`). Of 12 live terminals tried, 8 answered satisfied and 4 answered `timeout`. | `waitSatisfied` reads `satisfied` from `result` or `result.wait`, and takes exit 1 with code `timeout` as "not satisfied", not a failure. |
| `worktree current --json` | In a directory Orca manages: exit 0, `ok: true`, `result.worktree`. | Nothing in `terminal-recovery.ts` or the terminal opener runs it. It was observed because #1090 names it. The opener (#1089) uses `worktree list` instead. |
| `worktree list --json` | exit 0, `ok: true`. `result` holds `worktrees`, `totalCount`, `truncated` and `hostScope`. A row holds `id`, `path`, `isArchived`, `isMainWorktree` and others. | `resolveStartTerminalWorktree` (#1089) matches the one non-archived row whose `path` equals the project root, and refuses on a `truncated` list that lacks it. |

## Error codes the code depends on

| Code | How it was observed | Expected by the code |
| --- | --- | --- |
| `terminal_handle_stale` | `terminal show` and `terminal wait` with a made-up handle: exit 1, `ok: false`, `error` keys `code`, `data` and `message`, the code printed on stdout with nothing on stderr. | `run()` turns it into the `terminal-gone` blocker. It reads the code from stdout JSON, or from stderr JSON when stdout has none. |
| `timeout` | `terminal wait` with a 1 ms timeout on a terminal that was not idle: exit 1, `error` keys `code` and `message`. | `waitSatisfied` treats exit 1 with this code as `false`. Any other failure still throws. |
| `selector_not_found` | `worktree current` run in a temporary directory Orca does not manage: exit 1, `ok: false`. | Not read by the code. Recorded because it is the answer a start gets when the project is not in Orca, which `resolveStartTerminalWorktree` handles as "no match". |

## Observations that are not contract breaks

- `terminal list` rows carry `worktreePath` as a plain string. The code reads it with `nestedString(row, ["worktreePath", "projectRoot"])`, which is a list of alternative top-level names, not a path into a nested object. It returns the string, so the root comparison works on 1.4.245. The call reads like a nested lookup; it is not one.
- `agentIdentity` was a string on rows that had one and `null` on the rest (22 of 39 rows had one, with kinds `claude`, `codex`, `jcode`, `kimi` and `pi`). Rows have no `agent` or `session` field of their own. The code tries several names and takes the first that names a known adapter, so this is covered.
- `terminal list --json` returned all 39 terminals with `truncated: false`, so the complete-inventory path was the one exercised. What Orca does with more terminals than one page holds was not tried; the code treats `truncated: true` as an unknown inventory and refuses to act on it, and that path is covered by the fixture tests only.

## Unverified, with the reason

| Command or behaviour | Why it is unverified |
| --- | --- |
| `terminal create --worktree id:<id> --command ... --title ... --json` and the handle in its reply | It creates a live pane in the person's Orca. |
| `terminal close --terminal <handle> --json` | It closes a live pane. |
| `terminal switch --terminal <handle>` (named in a recovery next-step message) | It switches the person's active tab. |
| `terminal send`, `terminal read`, `terminal rename`, `terminal split`, `terminal set-pane-title` | The code does not call them. |
| The `orphaned: true` answer and a `connected: false` row | Every live row had `orphaned: false`. Forcing one needs a detached pane. |
| A `truncated: true` terminal or worktree list | The inventories were complete. |
| Remote servers (`--pairing-code`, `--environment`) | The code does not pass them. |
| The Linux binary (`orca-ide`) and `orca-dev` | The recheck ran the macOS `orca` only. |

## Version drift

Orca exposes `--version`, but agent-hub has no check for it, unlike the agent CLIs (`src/adapters/compat.ts`). This recheck is by hand. A later change could record `orca --version` next to a recovery plan and say when it differs from the version in the code comment. That is not done here and is not required by #1090's acceptance criteria.
