# Real-client verification

This runbook covers the automated client checks under `tests/clients/` (open mode, `servers.dat` NBT writer, and closed-mode release-binary end-to-end) and the manual checks that still need a human with real external credentials, a real browser, or a real Minecraft Java Edition / Prism Launcher client.

## 1. Automated checks (offline, no Mojang or Discord account)

Install the pinned `minecraft-protocol` (`1.68.0`) / `prismarine-nbt` harness and run all five suites against compiled `sculkworm`, `sculkworm-agent`, and `sculkworm-connect` binaries:

```sh
cargo build --locked --bins
npm --prefix tests/clients ci --no-audit --no-fund
node tests/clients/run-all.mjs
```

Pass `SCULKWORM_BIN_DIR=/path/to/bin-dir` to test release or musl binaries instead of `target/debug/` (every suite resolves binaries through the shared helper in `tests/clients/harness.mjs`: `SCULKWORM_BIN_DIR` first, then explicit per-binary overrides `SCULKWORM_BIN` / `SCULKWORM_AGENT_BIN` / `SCULKWORM_CONNECT_BIN` or the directory of `SCULKWORM_BIN`, then `target/debug/`). CI runs `cargo build --release --locked --bins --target x86_64-unknown-linux-musl` and executes all five suites against those static musl binaries via `SCULKWORM_BIN_DIR`.

| Suite | What it proves | What it does not prove |
| --- | --- | --- |
| `tests/clients/offline-play.mjs` | Real `minecraft-protocol` (`1.68.0`) 1.21.4 (protocol `769`) status pings to two backends, unknown-host zero-byte close, and offline-mode Login → Configuration → Play (`system_chat` + 3 keepalive roundtrips + clean disconnect) through the relay. | Real vanilla Java client binary. |
| `tests/clients/online-encrypted.mjs` | Online-mode RSA-1024 Encryption Request/Response, `POST /session/minecraft/join` and `GET /session/minecraft/hasJoined` against `dev/mock-mojang`, AES-128-CFB8 stream activation in both directions, and encrypted Configuration + Play (`system_chat` + 3 keepalive roundtrips) through the relay. | Real `sessionserver.mojang.com`, Microsoft OAuth tokens, Mojang-signed chat keys, or real vanilla launcher. |
| `tests/clients/handshake-26.4-srv.mjs` | Wire-level Minecraft 26.4 `_o` (origin, both `%3A` and literal `:`), `_id`, `\0FML\0`, Transfer intent (`3`), 1024-character host strings, verbatim Handshake replay, and pre-26.4 SRV target rejection against the real relay binary. | Real Minecraft 26.4 or pre-26.4 vanilla client DNS/SRV behavior. |
| `tests/clients/servers-dat.mjs` | Real `sculkworm-connect play --add-server` writing uncompressed NBT `servers.dat` parsed back by `prismarine-nbt`: missing nested directory creation, empty file handling, appending alongside existing entries/extra root tags, byte-identical idempotent re-runs, in-place `ip` update preserving extra server fields (`icon`, `acceptTextures`, `hidden`), and default `.minecraft` directory discovery. | Rendering in a real Minecraft / Prism Launcher Multiplayer list. |
| `tests/clients/closed-e2e.mjs` | Full end-to-end closed mode across the compiled `sculkworm`, `sculkworm-agent`, and `sculkworm-connect` binaries with a loopback HTTPS mock OIDC IdP: OIDC discovery on `PUT /v1/routes/{host}`, `POST .../agent-token`, `sculkworm-agent` with `--ca-file` + SPKI `--pin`, `GET /v1/agents`, vanilla closed-route status ping on port 25565, `sculkworm-connect login --device` (CSRF cookie, `Sec-Fetch-Site`, `confirm=1`, `__Host-swdevcb`, `prompt=consent`), loopback browser redirect login, `sculkworm-connect play --add-server`, real `minecraft-protocol` status ping + Play session through the tunnel, and `logout`. | Real Discord OAuth2 app, real browser UI rendering, Java sync-jar agent, or real Prism/Minecraft 26.4 client. |

## 2. Closed-mode end-to-end run against release binaries

Executed locally on 2026-11-27 against optimized release binaries (`cargo build --release --locked --bins`):

```sh
cargo build --release --locked --bins
SCULKWORM_BIN_DIR="$PWD/target/release" node tests/clients/run-all.mjs
```

Real output from the release binaries (`closed-e2e.mjs` and the full client suite):

```text
[step1] PUT /v1/routes/friends.play.example -> 201 {"active":true,"agent_connected":false,"agent_token":null,"authorizer":{"allow":{"any_of":["minecraft"],"claim":"groups"},"client":"mock-oidc","scopes":["openid","profile"],"type":"oidc"},"authorizer_id":"a36e0b5c286c1fd2","host":"friends.play.example","mode":"closed","tenant":"sculk"}
[step2] POST agent-token -> 201 token_id=0d35c60dc471b165 prefix=swa_0d35c60d...
[step3] GET /v1/agents -> {"agents":[{"connected_at":"2026-11-27T09:06:26Z","host":"friends.play.example","peer":"127.0.0.1:41278","session":"e8ddcfbf3c6af4e2","software":"sculkworm-agent/0.1","streams":0,"token_id":"0d35c60dc471b165"}]}
[step4] vanilla MC status ping -> {"version":{"name":"sculkworm","protocol":769},"players":{"max":0,"online":0},"description":{"text":"Closed server: join it with sculkworm-connect\nsculkworm-connect play friends.play.example"},"sculkworm":{"relay":"https://127.0.0.1:44267","route":"friends.play.example"}}
[step5a] connect --device prompt: Open https://127.0.0.1:44267/login/device on any device, sign in and type the code KCXB-SMXC.
[step5b] connect --device finished: Logged in to friends.play.example as alex (subject user-alex-42, expires 2026-12-27T09:06:30Z)
[step6a] connect loopback start URL captured (route=friends.play.example)
[step6b] connect loopback finished: Logged in to friends.play.example as alex (subject user-alex-42, expires 2026-12-27T09:06:35Z)
[step7a] servers.dat -> {"servers":[{"ip":"127.0.0.1:35817","name":"friends.play.example"}]}
[step7b] tunneled MC status ping -> {"version":{"name":"1.21.4","protocol":769},"players":{"max":20,"online":0,"sample":[]},"description":{"text":"Closed tunnel backend"},"latency":2}
[step7c] tunneled MC play -> player=AlexClosed chat="Welcome AlexClosed to Closed tunnel backend" keepalives=3
[step8] logout -> ok (logins remaining: 0)
[closed-e2e] OK
[offline-play] OK version=1.21.4 protocol=769 host=survival.play.example motd="Survival offline backend" player=SculkPlayer chat="Welcome SculkPlayer to Survival offline backend" keepalives_client=3 keepalives_server=3
[online-encrypted] OK version=1.21.4 protocol=769 host=online.play.example player=Notch uuid=069a79f4-44e9-4726-a5be-fca90e38aaf5 encrypted=true session_calls="POST /session/minecraft/join 204, GET /session/minecraft/hasJoined 200" keepalives_client=3 keepalives_server=3
[handshake-26.4-srv] OK cases=6 version=1.21.4+wire-778 origin=play.origin.example direct=alpha.play.example pre264_srv_target_rejected=relay.edge.example
[servers-dat] OK cases=6 route=friends.play.example fresh=127.0.0.1:39321 appended=127.0.0.1:38235 updated=127.0.0.1:37165 idempotent_bytes=198
```

## 3. What still needs a human operator

Automated suites use a loopback mock OIDC IdP, recorded Discord API fixtures, synthetic HTTP requests in place of a browser, `dev/mock-mojang`, and `minecraft-protocol`. The following items are **not** verified automatically and still require a human with real accounts and UIs (do not invent credentials):

1. **Real Discord application login.** Register a real Discord application at `https://discord.com/developers/applications` with redirect URI `https://<relay-public-host>/login/callback` (see [tunnel.md section 12](https://docs.sculk.network/nightly/sculkworm/tunnel.md#12-open-items-that-need-the-operator)), put its `client_id` and `client_secret` in `secrets.json`, configure a closed route with `preset: "discord"` (and optional `allow.discord_guild`), and run `sculkworm-connect play <route>` end to end against `discord.com`.
2. **Real browser rendering of the device and confirmation pages.** Open `https://<relay-public-host>/login/device` in a real desktop/mobile browser, type the `XXXX-XXXX` user code, verify the visual layout and phishing warning on the confirmation screen, check that `SameSite=Strict` (`__Host-swdev`) and `SameSite=Lax` (`__Host-swdevcb`) cookies work across the IdP redirect back to `/login/callback`, and verify the final completion and denial HTML pages.
3. **Java sync-jar tunnel agent against a real browser login.** Run the Java `clients/sync` pre-launch tunnel client against a live relay with a real browser OAuth/OIDC/Discord login and confirm it carries Minecraft traffic cleanly through Prism Launcher.
4. **Real Prism Launcher / Minecraft 1.21.x and 26.4 runs.** Verify online-mode Mojang login, the Multiplayer server list reading `servers.dat` written by `--add-server`, Minecraft 26.4 `_o` / `_id` Handshake host parameters, and pre-26.4 DNS `SRV` behavior using the manual runbook below.

## 4. Manual Prism Launcher runbook

Run these checks when you want real-client proof for **online-mode login with Mojang**, **Minecraft 26.4 `_o` / `_id`**, and **pre-26.4 DNS `SRV` behavior**.

### Prerequisites

- Prism Launcher signed in with a real Microsoft/Minecraft account.
- Two Prism instances: **1.21.4** (or latest **1.21.x**) and **26.4** (or a **26.4 Snapshot 1+** build).
- One online-mode Minecraft backend (Vanilla, Paper, or Fabric) matching each version you test, listening on e.g. `127.0.0.1:25581` (1.21.x) and `127.0.0.1:25582` (26.4).
- A running `sculkworm` relay pointing at those backends:

```sh
cat > /tmp/verify-routes.json <<'EOF'
{
  "routes": {
    "v121.play.example": "127.0.0.1:25581",
    "v264.play.example": "127.0.0.1:25582",
    "srv.play.example": "127.0.0.1:25582"
  }
}
EOF
SCULKWORM_LISTEN=0.0.0.0:25565 \
SCULKWORM_ROUTES_FILE=/tmp/verify-routes.json \
  ./target/release/sculkworm 2>&1 | tee /tmp/sculkworm-verify.log
```

In a second terminal, tail the relay log and highlight `host=` so you can read the exact route key on every ping and join:

```sh
tail -f /tmp/sculkworm-verify.log | grep --line-buffered -E 'event=(route|unknown_host|handshake_rejected|closed)' | grep --line-buffered --color=always -E 'host=[^ ]+|$'
```

### DNS / hosts setup

- **Direct hostname checks (A / `/etc/hosts`)**: add `127.0.0.1 v121.play.example v264.play.example` to `/etc/hosts` (or publish a wildcard `A` record `*.play.example -> <relay IP>`).
- **SRV record checks (real DNS required — `/etc/hosts` cannot serve `SRV`)**: publish two records in a zone you control, replacing `play.example` with your domain:
  1. `relay.play.example` `A` → `<relay IP>`
  2. `_minecraft._tcp.srv.play.example` `SRV` `0 5 25565 relay.play.example.` (target must differ from `srv.play.example` so the client exercises SRV redirection). Add `srv.play.example` to `routes.json`, and do **not** add `relay.play.example`.

### Test cases in Prism

In each Prism instance, open **Multiplayer → Add Server**, enter the address below, refresh the server list (Status ping), then click **Join Server** (Login + Play) and check the highlighted `host=` in the log tail.

| Case | Prism instance | Server Address | Expected relay log line |
| --- | --- | --- | --- |
| 1. Online-mode 1.21.x | 1.21.4 / 1.21.x | `v121.play.example` | `event=route host=v121.play.example target=... intent=status` then `intent=login` (player enters world with Mojang auth) |
| 2. 26.4 `_id` parameter | 26.4 | `test123@v264.play.example` | `event=route host=v264.play.example target=... intent=status` then `intent=login` (backend sees `?_id=test123` if `allowed-connection-ids=test123`) |
| 3. 26.4 SRV `_o` origin | 26.4 | `srv.play.example` (via SRV → `relay.play.example`) | `event=route host=srv.play.example target=... intent=status` and `intent=login` (`_o` overrides `relay.play.example`) |
| 4. Pre-26.4 SRV behavior | 1.21.4 / 1.21.x | `srv.play.example` (via SRV → `relay.play.example`) | Record what `host=` actually shows for **both** Status ping and Login (expected per MC-278651: `host=srv.play.example` on Status, `event=unknown_host host=relay.play.example` on Login) |

### Operator results table

Fill in one row per test run and attach or commit the results when updating [protocol.md](https://docs.sculk.network/nightly/sculkworm/protocol.md#verification-status):

| Date | Client version & launcher | Case | Route key seen (`host=`) | Status / Login OK | Notes |
| --- | --- | --- | --- | --- | --- |
| YYYY-MM-DD | Prism / Vanilla 1.21.x | 1. Online-mode direct | | | |
| YYYY-MM-DD | Prism / Vanilla 26.4 | 2. `_id` (`id@host`) | | | |
| YYYY-MM-DD | Prism / Vanilla 26.4 | 3. SRV `_o` | | | |
| YYYY-MM-DD | Prism / Vanilla 1.21.x | 4. Pre-26.4 SRV | | | |
