docs/computer-use-tests.md

Computer-use checks

Use this guide when a manual or agent-driven terminal check is requested, or when a changed interaction needs visual verification. Select the affected case. These checks are not a coding completion gate and do not require replaying the whole Hub journey. Automated package and process tests remain separate.

Choose the interaction

Changed areaCheck through the shipped UI
Direct Hub pairingTwo administrators enter independently obtained identity checks, transfer a card through hidden input, approve both sides, and observe the pairing view reach Completion.
Client admission or Add agentEnter the correct role's identity checks, complete admission and endpoint approval, then open the intended remote application. Unapproved endpoints must remain behind Add agent.
Saved reconnect or remote CWDReconnect to the exact saved Hub/endpoint and verify the intended remote CWD and leaf. Don't substitute a new application for a recovery check.
/hub and terminal handoffOpen the client-local dashboard, return to the same TUI, then verify keyboard input and terminal restoration after quit/cancel.
Recovery feedbackWith the application ready, stop only the selected test relay and observe recovering/recovered or terminal failure for that case. Verify the same application where continuity is the assertion.
Authority decision UIInspect exact old/new identities, review without mutation, confirm once, and check the resulting approval or refusal.
Local port forwardingUse the model-free tunnel demo below, including decline, acceptance, repeated HTTP connections and stop.

A direct line is enough for a direct-only change. Add one/two relays or a separate diamond only when the requested behavior needs them. Host-specific systemd, firewall or container checks need their intended host, not a claimed pass from local tmux.

Preparation and safety

Use current build/ binaries. Reuse the integration owner's build when its inputs are unchanged. Never use the running orchestrator's $AGENTCLI as the test client, or invoke it with --stop.

Prefer the isolated process fixtures for setup and shutdown. For manual launches, create a short private run directory and separate config, state and runtime homes for every Hub, client and application daemon. For example, in Bash:

sh
1umask 077
2RUN=$(mktemp -d /tmp/ez-cu.XXXXXX)
3BIN=$PWD/build
4for owner in inviting joining client daemon; do
5 mkdir -p "$RUN/$owner/config" "$RUN/$owner/state" "$RUN/$owner/run"
6done
7h() {
8 local owner=$1; shift
9 env XDG_CONFIG_HOME="$RUN/$owner/config" \
10 XDG_STATE_HOME="$RUN/$owner/state" \
11 XDG_RUNTIME_DIR="$RUN/$owner/run" "$@"
12}

Resolve the exact registered AF_UNIX socket under the application daemon's homes. A Hub with different homes must not assume register local refers to that daemon. Use loopback listeners and unused ports for local checks.

Retain the exact PIDs of all launched services. Wait for typed service readiness, not just a socket file. Before a loss/recovery check, wait for its exact published, available endpoint and application-ready observation. Use observation barriers rather than a fixed setup sleep.

Never inspect auth files, copy real credentials, use broad kill commands, or run fault/pressure tests against the live orchestrator. Read-only checks against a live service require an explicit requested scope; do not send model prompts or mutate roots, sessions, configuration or authorization as an incidental probe.

Manual or agent-driven tmux

Use a dedicated test session and only its owned panes. Don't overwrite an existing orchestrator terminal. If the agent's computer-use tooling requires its agent session, reserve the test pane explicitly before sending input. Each new pane needs the explicit isolated environment; it does not inherit the shell function above.

For two-administrator pairing:

  1. Bootstrap two empty isolated Hubs and start their listeners. Open each built ez-agent-hub --config dashboard in its own terminal.
  2. Obtain each authority fingerprint independently from its local dashboard.
  3. On the inviting Hub, use invite pairing direct <joining-check>. On the joining Hub, use add hub direct <inviting-address> <inviting-check> and enter the card through hidden input.
  4. Confirm the displayed independent checks and make joining/inviting approvals using the commands displayed by fresh dashboard state. Keep the joining pairing view open until Completion.
  5. Check the requested restart, cancel, removal or refusal interaction only if it is part of this case. Pair eligibility alone is not proof of a live normal-peer link; use authenticated peer diagnostics for a link assertion.

For routed pairing, prepare the requested authenticated topology first, use invite pairing routed / add hub routed, and check address-free bilateral eligibility. The restricted carrier must not be mistaken for a new direct link. For application checks, use the actual CLI/TUI and independently verified admission/endpoint identities. Consult the Hub command guide and client guide for current commands.

Model-free local tunnel demo

Use a dedicated test terminal and the integration owner's current build/ distribution from the checkout under test. This fixture creates two chats with synthetic assistant links through the existing service API. It does not invoke a model. Run the following in a dedicated shell, not in the orchestrator's shell. Port 8080 must be unused. The helper waits for service readiness and prints both session IDs. Do not submit a prompt in either chat.

sh
1# Run from the checkout under test.
2umask 077
3RUN=$(mktemp -d /tmp/ez-tunnel-demo.XXXXXX)
4BIN="$PWD/build"
5REPO="$PWD"
6mkdir -p "$RUN/config/ez-agent" "$RUN/state" "$RUN/run" "$RUN/project" "$RUN/www"
7export XDG_CONFIG_HOME="$RUN/config" XDG_STATE_HOME="$RUN/state" XDG_RUNTIME_DIR="$RUN/run"
8cat > "$RUN/config/ez-agent/config.yaml" <<'EOF'
9providers:
10 offline:
11 type: ollama
12 base_url: http://127.0.0.1:1/v1
13 models:
14 - name: demo
15 max_context: 32768
16default_model: offline/demo
17EOF
18printf 'tunnel dashboard\n' > "$RUN/www/dashboard"
19printf 'tunnel other path\n' > "$RUN/www/other"
20python3 -m http.server 8080 --bind 127.0.0.1 --directory "$RUN/www" >"$RUN/http.log" 2>&1 &
21HTTP_PID=$!
22"$BIN/ez-agent-service" >"$RUN/service.log" 2>&1 &
23DAEMON_PID=$!
24python3 "$REPO/tests/testdata/tunnel_demo.py" "$RUN/run/ez-agent/ez-agent.sock" "$RUN/project"
25printf 'Run directory: %s\nHTTP fixture PID: %s\n' "$RUN" "$HTTP_PID"
26(cd "$RUN/project" && "$BIN/ez-agent" --no-autolaunch)

In the TUI, use /session and select Tunnel demo. Both assistant links must visibly expose their ez-agent://tunnel/localport/8080/... destinations. Click Open dashboard and verify that the confirmation identifies the connected local service, source localhost:8080, and /dashboard. Choose Decline. Compare ss -ltnp in another terminal before reviewing and after declining. Rendering, reviewing and declining must not add a client listener. The isolated HTTP access log should still be empty. The selected chat must still be Tunnel demo.

Now test keyboard activation without Ctrl+T. From the empty composer, press Tab until chat has focus, then Tab to highlight Open dashboard. Tab and Shift+Tab must move between the two links with a visible selection. Select the dashboard and press Enter. Choose Start with the confirmation's normal button navigation. The TUI must return directly to the same chat and restore chat focus, not open tunnel management. After setup, show Inbox using the sidebar selector or Ctrl+Left/Right. Its tunnel entry must show the assigned local URL. Enter on that entry opens its details without changing chat. Close the details.

Use /session to switch to Tunnel demo other chat. The existing forward must remain in Inbox and /tunnels. Close management and click Open other path in this chat, then choose Start. Acceptance must return to this second chat. There must now be two independent Inbox entries and two /tunnels rows with distinct IDs and local ports, even though they share source port 8080. Open each row to verify its path, service, status, local URL and Stop action. Starting entries show Cancel before setup completes. Setup can finish too quickly to capture manually; controlled TUI tests cover multiple pending entries and cancellation. Neither local port may be 8080. ss -ltnp must show each bound to 127.0.0.1, not a wildcard address. No browser is launched by the TUI.

In the second terminal, set both displayed ports below, then fetch both paths through each relay. Each request opens a fresh HTTP connection. Both rounds must succeed using the same relay ports, proving the listeners survive source EOF. The different path proves the link path is not a forwarding restriction.

sh
1DASHBOARD_PORT=49152 # Replace with the first forward's assigned client port.
2OTHER_PORT=49153 # Replace with the second forward's assigned client port.
3python3 - "$DASHBOARD_PORT" "$OTHER_PORT" <<'PY'
4import concurrent.futures
5import sys
6import urllib.request
7
8def fetch(request):
9 port, path = request
10 base = "http://localhost:" + port
11 with urllib.request.urlopen(base + path, timeout=5) as response:
12 body = response.read().decode().strip()
13 assert body == "tunnel " + ("dashboard" if path == "/dashboard" else "other path"), body
14 print(port, path, body)
15requests = [(port, path) for port in sys.argv[1:] for path in ["/dashboard", "/other"]]
16for _ in range(2):
17 for request in requests:
18 fetch(request)
19with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool:
20 list(pool.map(fetch, requests))
21PY

To check failed-stream recovery, stop only the printed HTTP fixture PID from the second terminal, then request the relay with a five-second timeout. That request must fail while the TUI keeps the same URL. Restart the exact HTTP fixture command above from the second terminal using the printed run directory, and record its new PID. A new request through the unchanged relay must succeed. Inspect the HTTP log before that new request to check that the failed request was not replayed after restart. Clean up the replacement HTTP process from its own terminal at the end. This checks source loss without waiting for a protocol timeout; deterministic adapter tests separately cover macro timeouts.

Stop only the dashboard forward in /tunnels. Its relay must become unreachable and disappear from Inbox and the live list; the other relay must still serve /other. Switch back to Tunnel demo and verify that Inbox and /tunnels still show the remaining forward. Activate its Inbox entry and stop it there. Its relay must now be unreachable too, without changing the selected chat.

Start both links again, open a raw connection through one without sending a request, and quit the TUI with Ctrl+C. The raw connection must close and both new relay URLs must no longer be reachable. Use python3 -c 'import socket; s=socket.create_connection(("localhost", PORT)); s.settimeout(30); print(repr(s.recv(1)))' with one new port substituted; quitting should print b''. Keep this check in a separate terminal so it does not block the TUI.

After the TUI exits, in the same isolated shell, stop and join only these test processes. If the helper or TUI failed, perform the same cleanup before removing the run directory.

sh
1"$BIN/ez-agent" --no-autolaunch --stop
2wait "$DAEMON_PID"
3# Kill the original fixture only if it is still a running job of this shell.
4if jobs -pr | grep -Fxq "$HTTP_PID"; then kill "$HTTP_PID"; fi
5wait "$HTTP_PID" 2>/dev/null || true
6rm -rf "$RUN"

Pause captures during invitation display and transfer. Never retain JOIN words, proofs, private state dumps or credential-bearing terminal transcripts. Clear secret-bearing scrollback before capturing. Keep any redacted screenshots and logs in an external directory selected for this check, not in the repository.

Optional scripted status captures

The shipped pairing process test can mirror redacted dashboard status into tmux. This is automated process evidence, not a substitute for driving the actual interactive dashboards above. Use an explicitly owned session with windows 1 and 2 and a private external evidence directory:

sh
1AGENTHUB_TMUX_ACCEPTANCE=1 \
2AGENTHUB_TMUX_SESSION="$CU_SESSION" \
3AGENTHUB_TMUX_EVIDENCE="$EVIDENCE" \
4 python3 -m pytest -q -s tests/suites/test_agenthub_process.py \
5 -k two_hub --tb=no

The process fixture creates its own isolated homes and owns child shutdown. Its terminal mirrors are selected by AGENTHUB_TMUX_SESSION; they never default to the orchestrator's agent panes. The test submits decisions itself, so report its result as scripted rather than manual operator acceptance.

Finish the selected check

Stop and reap only the exact test processes. Use the built client under the application daemon's isolated homes for --stop; signal an exact test Hub PID for Hub shutdown. Remove stale sockets only after their owner has joined. Close only the owned test panes/session and remove the private run state after cleanup.

Report the interaction tested, source/binaries, topology if relevant, outcome, and any skipped part of the request. A successful screenshot is not evidence of an unobserved protocol boundary or maximum-capacity behavior.