The Fake User: How Phosphor Tests Itself Through the Wire

November 15, 2026

Every UI change on a BBS has a tempting failure mode: you run the unit tests, they’re green, you ship — and someone’s screen is mangled, because the unit tests never looked at a screen. Headless law suites prove logic. They can’t prove what bytes land on a 24-row terminal.

So Phosphor has an actor: the fake user.

What the fake user is

The fake user is a standalone Java wire client — TelnetWireClient, ScreenDecoder, and CellGrid — living in the test tree under net.phosphorbbs.wire. It connects to a running server over a real TCP socket and behaves the way a real terminal does:

  • One-packet negotiation. It answers the server’s telnet handshake the way MuffinTerm-class clients do: window size (NAWS 80×24) plus terminal type (TTYPE IS “ansi”) all in a single packet, and it never acknowledges the server’s WILL ECHO offer — the same volunteer-gated option burst a real client rides.
  • A per-cell ANSI emulator. ScreenDecoder turns the byte stream into a cursor-tracked 80×24 grid, one cell each for glyph, color, and attributes — full SGR (16-color, 256-color, 24-bit truecolor), bold/inverse/underline, and the CP437 glyph law that makes box-drawing corners and card suits arrive as single bytes on the wire.
  • Screen-aware reading. The wire is a diff stream — unchanged cells never re-arrive. So the client doesn’t read “bytes since last step”; it reads screens until they settle (expect/expectChange), with a watchdog per scenario: every step has a hard deadline, and a stuck step gets its worker thread cancelled and a ruler-dump of the last screen attached to the failure. No blind sleeps, no wedged CI.

The independence law

Here’s the part we’re proudest of. The wire package imports nothing from Phosphor’s own code — net.phosphorbbs.* — except itself. One law test (WireIndependenceLawTest) greps the package at build time and fails the build naming any offender. The only white-list is the boot helpers directory, and that’s spelled out in the law itself.

Why? A test client that imports the server’s classes is a mirror: it breaks exactly when the code it’s checking breaks. The fake user has to be an outsider — a 1994-era dialup guest with a modem and excellent manners. JDK stdlib, a socket, JUnit, and nothing else. The day the client starts “helping” itself to the server’s table model is the day it stops being proof.

It boots the real server as a black box

A fake user needs a board. Rather than stubbing one, each suite forks a separate JVM that runs the real Main — the actual entry point — against a fresh scratch H2 database, listening on wire ports pulled from seeded settings rows.

Getting a fresh boot to match production is where the honesty lives. The seeder converges the scratch board to the deployed calibration: the reviewer’s menu is the deployed shape (including the plugin-provided stock-market row, which only appears for the right group membership), labels converge to what the wire actually shows, and federation is dialed down to its inert default so a test boot never phones a peer. Every convergence is documented in code — and the boot law (WireDevBootLawTest) proves boot → teardown → boot is idempotent.

The lesson we stamped into the seeder early: scenario assertions calibrated from database rows alone went wrong once, because the wire showed a row a query didn’t — the plugin menu row. So the standing rule is now calibrate against a live capture, then harden the honest markers. (Two dialects, one schema is why an H2 scratch board is even possible.)

Thirteen scenarios, inside the regular build

The scenarios run inside the normal Maven build now — not a side pipeline. Each is a JUnit test:

  1. login_menu — the menu paints the deployed calibration exactly: title, the aligned box border (columns checked cell-by-cell), the inverse counts bar, zero mojibake glyphs.
  2. blackjack_layout — deal a blackjack hand and repaint with suit glyphs; corner-aligned dealer/hand boxes; Q returns cleanly.
  3. instant_update — our favorite. A bare TCP connection — zero keystrokes — bumps the WHO’S ONLINE count from N to N+1 within six seconds, and closing the connection drops it back. “It updates live” is now a provable law, not a plan.
  4. dialog_keys — prompts and dialogs route keys the way users expect.
  5. news — the news board reads correctly, including the exit pops.
  6. file_areas / chat_render / mail_inbox / sysop_panels / doors_landing / menu_navigation — each surface walked with the same discipline.
  7. geometry_lint — the self-checking one, below.

The full gate is at the ~9,985-test mark, and sixty-odd of those are wire laws. If the fake user can’t log in and read the menu, whatever the change was, it doesn’t ship.

The geometry lint: a critic that never sleeps

Screens are drawn — box tops paired with box bottoms, borders aligned on shared rows, nothing leaking past the right edge. WireLinter enforces that on every frame every scenario observes. Three rules, each with its own law test: box_square (every top border pairs with a bottom; verticals consistent; a missing right corner names the row), off_right (a box opener with no closer, or content touching the final column), and overlap (distinct boxes intersecting on shared rows).

Two exemptions are themselves laws, because they’re the design: row 0 is a title row (long titles clip legally), and the last row is the status bar (full width by design). And because a paint can be caught mid-repaint, a violation only counts after it survives a settled re-capture — lint can’t fail on a transitional frame.

Scene diff: “changed exactly this region, nothing else”

Scenario suites capture baselines — the exact ruler-formatted screen for login_menu, a story thread, the mail inbox, the SysOp dashboard — and every run compares live frames byte-for-cell against them. The interesting law isn’t the equality check; it’s the deliberate-change law: seed a change, and assert the diff is exactly the bounding box the change implies — nothing else moved. That catches the bugs that feel invisible: an update that repaints one region and blanks another. Baselines only regenerate with an explicit -Dwire.updateBaselines=true, so a fixture change is always a conscious update, never a silent rewrite.

The Python pack: retired with honors

The wire client started life as a small Python harness — and that was deliberate: an outsider language, real-wire by construction, zero build coupling (the story lives here alongside other 2026 decisions). Once all 13 scenarios were ported green inside the Maven gate, the Python pack retired in its own commit. git history keeps every line; the tree keeps nothing. (The standalone daily prod-smoke stays — it watches the deployed board hour by hour, which is a different job from testing code. That’s the next post.)

The cheat sheet

  • Law: the wire package imports no server code; a law test fails the build otherwise.
  • Law: every UI-facing change ships with its own scenario — headless suites are necessary but not wire-truth.
  • Law: a violation only counts after it survives a settled re-capture.
  • Law: baselines regen only by explicit flag.
  • Habit: calibrate against a live capture, then harden the markers.

Where to go next: the cursor-anchor law is the sibling story — a subtle wire bug root-caused with the same cell-level forensics the fake user now automates.