BURROW // chapter 09
Chapter 09 Part 03 / Operator Experience

Interactive SSH shells

Shared shells use an existing authenticated connection. Humans and agents attach to the same Hovel-retained terminal, with one controller and independent observers.

Open and return

shell gateway
shells
resume 1

shell gateway creates a shell and controls it. shell gateway SESSION_ID observes an exact existing shell. Opening a workspace discovers recognized retained sessions as observer tabs; shells refreshes discovery.

Input / commandEffect
Ctrl+] / Alt+B / shell-detach IDReturn to management and release this attachment's claim. The shell remains.
Alt+T / shell-control IDExplicit generation-checked takeover; old controller tokens stop working.
resume ID / click tabSelect the view without claiming control.
shell-close IDEnd the selected shell for all attachments; preserve the master and siblings.
Alt+1–9 / Alt+Left/RightSelect or cycle shell tabs.

TUI numbers are workspace-local positions and can renumber. Opaque Hovel session IDs identify shells across frontends. A pane shows CONTROL or OBSERVE, controller label, geometry, synchronization and session ID.

Shared terminal control
flowchart TB
accTitle: One controller and independent observers
accDescr: Only the current controller can write input and resize the retained shell. Human and agent observers read its screen independently. Explicit takeover replaces controller authority.
Controller[Current controller] -->|Input and resize| Shell[Retained SSH shell]
Shell --> Human[Human observer]
Shell --> Agent[Agent observer]
Human -. Explicit takeover .-> Controller
Agent -. Explicit takeover .-> Controller

Switching tabs backgrounds a shell without releasing its claim. Detach releases control while preserving programs and working directory.

Create and inspect from the CLI

burrow --workspace /absolute/workspace session create gateway
# After approving its returned review:
burrow --workspace /absolute/workspace session create gateway --yes --review HASH
burrow --workspace /absolute/workspace session list gateway
burrow --workspace /absolute/workspace session inspect gateway SHELL_ID

Create defaults to 80×24; --columns N --rows N overrides geometry. The shell survives launcher exit. Reviews bind workspace, connection creation, manager generation and observed state.

A missing acknowledgement is uncertain: inspect the list before retrying. A leftover prepared session has not started SSH; close it explicitly. No automatic launch retry occurs.

Control without a TTY

Claim, takeover, input, resize and release require one JSON request on piped/file stdin and captured stdout. Tokens stay in memory or private mode-0600 files; never put them in arguments, history, logs or evidence.

import base64, json, subprocess
workspace, connection, session = "/absolute/workspace", "gateway", "SHELL_ID"
base = ["burrow", "--workspace", workspace, "session"]

def call(action, request=None):
    args = base + [action, connection, session]
    if request is not None:
        args += ["--request-stdin"]
    result = subprocess.run(args, input=json.dumps(request) if request is not None else None,
                            capture_output=True, text=True, check=True)
    return json.loads(result.stdout)

claim = call("claim", {"label": "maintenance", "columns": 100, "rows": 30})
try:
    accepted = call("input", {"token": claim["token"],
                             "data": base64.b64encode(b"pwd\n").decode()})
    # acceptedBytes is input acceptance, never command completion.
    screen = call("snapshot")  # Poll again for later output; do not infer exit status.
    call("resize", {"token": claim["token"], "columns": 120, "rows": 40})
finally:
    call("release", {"token": claim["token"]})

Takeover requires the controlGeneration from the latest inspect, as {"label":"operator","generation": observed["controlGeneration"]}. It replaces the old token. Claims have no automatic expiry; a disappeared controller requires explicit takeover.

Constraint / resultMeaning
Input1–4096 decoded bytes, supplied as base64. Ctrl+C is byte 0x03 (Aw==).
acceptedBytesThe accepted prefix, never proof of command execution. Backpressure leaves the remaining suffix unaccepted.
Geometry1–1000 per axis, at most 20,000 cells. Invalid dimensions retain the previous size.
Uncertain claim or writeInspect before continuing; never automatically replay bytes.
ReleaseInvalidates the token and retains shell, programs and geometry.

Observe and recover the screen

burrow --workspace /absolute/workspace session observe gateway SHELL_ID
burrow --workspace /absolute/workspace session observe gateway SHELL_ID NEXT_OFFSET
burrow --workspace /absolute/workspace session snapshot gateway SHELL_ID

Each observer owns its byte cursor. Observe returns base64 data and oldest/next positions without claiming control. Falling behind the 64 KiB retained suffix produces out-of-sync and no bytes. Recover with a complete snapshot, then continue at its returned byte position.

Only the controller changes remote geometry. Observers clip locally. Owner history holds at most 1,000 lines; Shift+Page keys scroll, Shift+Home/End choose oldest/live output. session snapshot CONNECTION ID HISTORY reads the same bounded history without resizing.

The emulator clips old output rather than reflowing it on resize. Shell screens are memory, not collected evidence. Use retained runs for command completion and exit results.

Exit, close and loss

burrow --workspace /absolute/workspace session close gateway SHELL_ID
# After approving its returned review:
burrow --workspace /absolute/workspace session close gateway SHELL_ID --yes --review HASH
StateInterpretation
runningThe local SSH process started; no individual command outcome is implied.
exitedThe channel exited; sshExit belongs to that client, not each terminal command.
lostSSH exit 255 or signal termination; remote outcome is uncertain.
unavailableThe owning module cannot be observed; remote cleanup is uncertain.
auditErrorEvidence persistence failed; inspect the accepted/cleanup result before retrying.

Selected close terminates and reaps one shell's SSH client. Connection close covers every admitted dependent shell; new shells invalidate an earlier review. Remote escaped processes are not guaranteed stopped.

Keep-running quit releases this frontend's claims and retains shells. Daemon or module loss cannot restore them. There is no fresh-login fallback, owner adoption or shell reconstruction. See resource lifetimes and recovery.

Public Hovel integration

Typed controls use the public RunSessionCommand route through the base module. Raw Hovel attach/send/read do not grant interactive access. Token-bearing commands use private request bodies. See the session API for input and result schemas.

Older managers without this shared-screen contract are refused. Review workspace restart before ending their resources; reconnect explicitly afterward. Cleaning build outputs cannot replace a retained owner.