Skip to content

chore: reproduction harness and probes for #13 and #14 - #15

Merged
Alorse merged 9 commits into
mainfrom
chore/repro-harness
Sep 29, 2026
Merged

Alorse merged 9 commits into
mainfrom
chore/repro-harness

Conversation

@Alorse

@Alorse Alorse commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Phase 1 of the stability review: tooling to reproduce and measure the problems in #13 (two voices at once, then a freeze) and #14 (asks the learner to repeat phrases they never said). No app code changes. public/ is untouched, so no cache bump is needed.

What's in it

Offline, deterministic (runs in npm test)

  • test/harness/fake-gemini.mjs: a scriptable fake Gemini Live upstream. It supports real-time or burst replies (burst is what gemini-3.8-live actually does), drops with close code 1011, setups that are slow or never complete, and a swallowed turnComplete. Each session's audio carries its own sample value, so any chunk can be traced back to the session that produced it.
  • test/harness/redirect-upstream.mjs + server.mjs: run the real, unmodified server against the fake, with review/translate answered locally. The helper runs on a free port and stops the child by PID only.
  • test/live-harness.test.js: 2 baseline tests (pass), plus 14 todo tests that pin each confirmed bug. They show up as TODO and don't fail the suite. When a fix lands, remove its todo so it becomes a regression test.

Browser (manual, like browser-check)

  • scripts/repro-browser.mjs: runs headless Chrome with the fake mic against the real server and the fake upstream. It instruments playback buffers, sockets, mic streams, and how much tutor audio is still queued when the mic reopens. Scenarios: double-tap, server-restart, end-restart, echo-window, upstream-drop-twice, two-tabs, idle-cpu.
  • scripts/perf-server.mjs: server CPU and RSS per live session (offline).

Real API (spends quota, so keep runs small)

  • scripts/live-probe.mjs: turn timing, plus which setup fields the model accepts.
  • scripts/speech-probe.mjs: what the tutor hears and says back for clean, doubled-mic, quiet, accented, and echo-only learner audio. Flags try a language hint, a system instruction, or a revised prompt without editing code. test/fixtures/speech-accented.pcm (153 KB) is generated once with Gemini TTS.
  • scripts/perf-api.mjs: /live time to first audio, review and translate latency, shell weight. It defaults to scratch port 8399.

Verified

🤖 Generated with Claude Code

Alorse and others added 8 commits September 28, 2026 23:41
A scriptable stand-in for the Gemini Live WebSocket plus a preload that
points the real, unmodified server at it (and answers review/translate
fetches locally), so session lifecycle bugs can be reproduced offline and
deterministically. Replies stream at real-time pace with a per-session
sample value, which lets a listener tell which upstream session any audio
chunk came from. The server helper runs on a free port and stops the child
by PID only.

Co-authored-by: Claude Code <noreply@anthropic.com>
Runs the real server against the fake upstream and asserts the correct
behaviour for each confirmed bug: reconnect starts a new conversation
instead of resuming, mic audio leaks into the reconnecting session, queued
audio is not flushed on a drop, a second drop leaves a zombie session that
holds a slot, no setup timeout, no turn watchdog, an upstream leak when the
client leaves during setup, a repeated start opening a second upstream, a
'thinking' state that never fires, the silence nudge sent as the learner,
a persona with no "didn't catch that" rule, and ACCESS_TOKENS never being
enforced. They are marked todo so the suite stays green; each flips to a
passing regression test when its fix lands.

Co-authored-by: Claude Code <noreply@anthropic.com>
Measures one tutor turn against the real Gemini Live API (connect, setup,
time to first audio, audio delivery, where turnComplete lands relative to
the end of playback, chunk sizes, base64/JSON wire overhead) and checks
which optional setup fields the model accepts (systemInstruction,
transcription language hints, session resumption, context window
compression). Spends one short greeting plus one setup-only connection per
variant.

Co-authored-by: Claude Code <noreply@anthropic.com>
Replays one learner turn through the real Live API with Parley's exact
setup frame and persona prompt, for a clean control and degraded variants
(two mic pipelines interleaved, a quiet noisy mic, a strong Spanish accent,
and only a faint tail of the tutor's own voice), and records the input
transcript and the tutor's reply. Flags try an English language hint, the
persona as a systemInstruction, or a revised prompt from a file. The
accented fixture is generated once with Gemini TTS and committed so later
runs only spend the Live sessions.

Co-authored-by: Claude Code <noreply@anthropic.com>
Drives the real page in headless Chrome with a fake microphone against the
real server and the fake upstream, and instruments the page before any app
code runs: scheduled playback buffers (tagged with the upstream session
that produced them), /live sockets and mic frames sent, getUserMedia
streams still live, and how much tutor audio is still queued when the
server re-opens the mic. Scenarios: double-tap, server-restart,
end-restart, echo-window, upstream-drop-twice, two-tabs, idle-cpu.

The fake upstream gains a burst mode that matches what gemini-3.8-live
does: the reply's audio arrives at once and turnComplete is held until
real-time playback would end.

Co-authored-by: Claude Code <noreply@anthropic.com>
Runs the real server against the fake upstream with N simulated browsers
streaming mic frames exactly like the page (31.25 base64/JSON frames per
second) and samples the server process from /proc, so the cost of each
live session can be measured before and after a change.

Co-authored-by: Claude Code <noreply@anthropic.com>
Measures what a device sees from a running Parley: /live socket open ->
ready -> first greeting audio -> greeting done, /api/review and
/api/translate round trips, and the app shell's bytes, caching and
compression. Defaults to a scratch port so it is never pointed at
production by accident.

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
The server joins DATA_DIR onto the project root, so the absolute temp path
the harness passed was written under the repo's tmp/ while cleanup removed
a different directory, leaving one profile dir behind per run. Create it
under tmp/ and pass it as a relative path.

Co-authored-by: Claude Code <noreply@anthropic.com>
@Alorse
Alorse merged commit 642b41a into main Sep 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant